Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W3c demo poc #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
10 changes: 3 additions & 7 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
"license": "Apache-2.0",
"scripts": {
"alice": "ts-node src/AliceInquirer.ts",
"faber": "ts-node src/FaberInquirer.ts",
"faber": "ts-node --logError src/FaberInquirer.ts",
"refresh": "rm -rf ./node_modules ./yarn.lock && yarn"
},
"dependencies": {
"@hyperledger/indy-vdr-nodejs": "^0.2.0-dev.5",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/anoncreds-nodejs": "file:/Users/artem/anoncreds-rs/wrappers/javascript/packages/anoncreds-nodejs/build",
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.1",
"inquirer": "^8.2.5"
},
"devDependencies": {
"@aries-framework/anoncreds": "*",
"@aries-framework/anoncreds-rs": "*",
"@aries-framework/askar": "*",
"@aries-framework/core": "*",
"@aries-framework/indy-sdk": "*",
"@aries-framework/indy-vdr": "*",
"@aries-framework/cheqd": "*",

"@aries-framework/node": "*",
"@types/figlet": "^1.5.4",
"@types/indy-sdk": "^1.16.26",
Expand Down
2 changes: 1 addition & 1 deletion demo/src/Alice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Alice extends BaseAgent {
}

public static async build(): Promise<Alice> {
const alice = new Alice(9000, 'alice')
const alice = new Alice(9000, 'alice1')
await alice.initializeAgent()
return alice
}
Expand Down
1 change: 1 addition & 0 deletions demo/src/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class BaseAgent {
key: name,
},
endpoints: [`http://localhost:${this.port}`],
// logger: new ConsoleLogger(LogLevel.trace),
} satisfies InitConfig

this.config = config
Expand Down
8 changes: 5 additions & 3 deletions demo/src/Faber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Faber extends BaseAgent {
}

public static async build(): Promise<Faber> {
const faber = new Faber(9001, 'faber')
const faber = new Faber(9001, 'faber1')
await faber.initializeAgent()
return faber
}
Expand Down Expand Up @@ -195,7 +195,7 @@ export class Faber extends BaseAgent {
return this.credentialDefinition
}

public async issueCredential() {
public async issueCredential(isW3C?: boolean) {
const schema = await this.registerSchema()
const credentialDefinition = await this.registerCredentialDefinition(schema.schemaId)
const connectionRecord = await this.getConnectionRecord()
Expand Down Expand Up @@ -224,6 +224,7 @@ export class Faber extends BaseAgent {
credentialDefinitionId: credentialDefinition.credentialDefinitionId,
},
},
isW3C,
})
this.ui.updateBottomBar(
`\nCredential offer sent!\n\nGo to the Alice agent to accept the credential offer\n\n${Color.Reset}`
Expand Down Expand Up @@ -251,7 +252,7 @@ export class Faber extends BaseAgent {
return proofAttribute
}

public async sendProofRequest() {
public async sendProofRequest(isW3C?: boolean) {
const connectionRecord = await this.getConnectionRecord()
const proofAttribute = await this.newProofAttribute()
await this.printProofFlow(greenText('\nRequesting proof...\n', false))
Expand All @@ -266,6 +267,7 @@ export class Faber extends BaseAgent {
requested_attributes: proofAttribute,
},
},
isW3C: isW3C,
})
this.ui.updateBottomBar(
`\nProof request sent!\n\nGo to the Alice agent to accept the proof request\n\n${Color.Reset}`
Expand Down
11 changes: 9 additions & 2 deletions demo/src/FaberInquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ export class FaberInquirer extends BaseInquirer {
public async credential() {
const registry = await prompt([this.inquireOptions([RegistryOptions.indy, RegistryOptions.cheqd])])
await this.faber.importDid(registry.options)
await this.faber.issueCredential()
const confirm = await prompt([this.inquireConfirmation('Do you want to issue credential in W3C format')])

await this.faber.issueCredential(confirm.options == ConfirmOptions.Yes)
const title = 'Is the credential offer accepted?'
await this.listener.newAcceptedPrompt(title, this)
}

public async proof() {
await this.faber.sendProofRequest()
let isW3C = true
const confirm = await prompt([this.inquireConfirmation('Should be the proof in W3C format?')])
if (confirm.options === ConfirmOptions.No) {
isW3C = false
}
await this.faber.sendProofRequest(isW3C)
const title = 'Is the proof request accepted?'
await this.listener.newAcceptedPrompt(title, this)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/anoncreds-rs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"tsyringe": "^4.8.0"
},
"devDependencies": {
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/anoncreds-shared": "^0.2.0-dev.4",
"@hyperledger/anoncreds-nodejs": "file:/Users/artem/anoncreds-rs/wrappers/javascript/packages/anoncreds-nodejs/build",
"@hyperledger/anoncreds-shared": "file:/Users/artem/anoncreds-rs/wrappers/javascript/packages/anoncreds-shared/build",
"@types/ref-array-di": "^1.2.6",
"@types/ref-struct-di": "^1.1.10",
"reflect-metadata": "^0.1.13",
Expand Down
Loading