diff --git a/examples/integration-scripts/credentials.ts b/examples/integration-scripts/credentials.ts index fe067de5..772aea7f 100644 --- a/examples/integration-scripts/credentials.ts +++ b/examples/integration-scripts/credentials.ts @@ -41,13 +41,14 @@ async function run() { // Create two identifiers, one for each client - let op1 = await client1.identifiers().create('issuer', { + let icpResult1 = client1.identifiers().create('issuer', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op1 = await icpResult1.op() while (!op1["done"] ) { op1 = await client1.operations().get(op1.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -56,13 +57,14 @@ async function run() { await client1.identifiers().addEndRole("issuer", 'agent', client1!.agent!.pre) console.log("Issuer's AID:", aid1.prefix) - let op2 = await client2.identifiers().create('recipient', { + let icpResult2 = await client2.identifiers().create('recipient', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op2 = await icpResult2.op() while (!op2["done"] ) { op2 = await client2.operations().get(op2.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -71,13 +73,14 @@ async function run() { await client2.identifiers().addEndRole("recipient", 'agent', client2!.agent!.pre) console.log("Recipient's AID:", aid2.prefix) - let op3 = await client3.identifiers().create('verifier', { + let icpResult3 = await client3.identifiers().create('verifier', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op3 = await icpResult3.op() while (!op3["done"] ) { op3 = await client3.operations().get(op3.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -179,11 +182,25 @@ async function run() { console.log("Credential issued") // Recipient check issued credential - let creds2 = await client2.credentials().list('recipient') - assert.equal(creds2.length, 1) - assert.equal(creds2[0].sad.s, schemaSAID) - assert.equal(creds2[0].sad.i, aid1.prefix) - assert.equal(creds2[0].status.s, "0") // 0 = issued + let credentialReceived = false + while (!credentialReceived) { + let notifications = await client2.notifications().list() + for (let notif of notifications.notes){ + if (notif.a.r == '/exn//credential/issue') { + credentialReceived = true + await client2.notifications().mark(notif.i) + } + } + await new Promise(resolve => setTimeout(resolve, 1000)); + } + + // Credetials are no longer accepted by default + // pending implementation in KERI to accept them + // let creds2 = await client2.credentials().list('recipient') + // assert.equal(creds2.length, 1) + // assert.equal(creds2[0].sad.s, schemaSAID) + // assert.equal(creds2[0].sad.i, aid1.prefix) + // assert.equal(creds2[0].status.s, "0") // 0 = issued console.log("Credential received by recipient") // Present credential @@ -210,19 +227,20 @@ async function run() { console.log("Credential revoked") // Recipient check revoked credential - let revoked = false - while (!revoked) { - let cred2 = await client2.credentials().get('recipient', creds1[0].sad.d) - if (cred2.status.s == "1") { - revoked = true - } - } - creds2 = await client2.credentials().list('recipient') - assert.equal(creds2.length, 1) - assert.equal(creds2[0].sad.s, schemaSAID) - assert.equal(creds2[0].sad.i, aid1.prefix) - assert.equal(creds2[0].status.s, "1") // 1 = revoked - console.log("Revocation received by recipient") + // credentialReceived = false + // let revoked = false + // while (!revoked) { + // let cred2 = await client2.credentials().get('recipient', creds1[0].sad.d) + // if (cred2.status.s == "1") { + // revoked = true + // } + // } + // let creds2 = await client2.credentials().list('recipient') + // assert.equal(creds2.length, 1) + // assert.equal(creds2[0].sad.s, schemaSAID) + // assert.equal(creds2[0].sad.i, aid1.prefix) + // assert.equal(creds2[0].status.s, "1") // 1 = revoked + // console.log("Revocation received by recipient") // Present revoked credential await client1.credentials().present('issuer', creds1[0].sad.d, 'verifier', true) diff --git a/examples/integration-scripts/delegation.ts b/examples/integration-scripts/delegation.ts index d9921ccf..8563fde1 100644 --- a/examples/integration-scripts/delegation.ts +++ b/examples/integration-scripts/delegation.ts @@ -34,13 +34,14 @@ async function run() { console.log("Client 2 connected. Client AID:",state2.controller.state.i,"Agent AID: ", state2.agent.i) // Client 1 create delegator AID - let op1 = await client1.identifiers().create('delegator',{ + let icpResult1 = await client1.identifiers().create('delegator',{ toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op1 = await icpResult1.op() while (!op1["done"] ) { op1 = await client1.operations().get(op1.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -60,7 +61,8 @@ async function run() { console.log("OOBI resolved") // Client 2 creates delegate AID - op2 = await client2.identifiers().create('delegate',{delpre: aid1.prefix}) + let icpResult2 = await client2.identifiers().create('delegate',{delpre: aid1.prefix}) + op2 = await icpResult2.op() let delegatePrefix = op2.name.split(".")[1] console.log("Delegate's prefix:", delegatePrefix) console.log("Delegate waiting for approval...") diff --git a/examples/integration-scripts/multisig.ts b/examples/integration-scripts/multisig.ts index ea59b32a..9f185cd1 100644 --- a/examples/integration-scripts/multisig.ts +++ b/examples/integration-scripts/multisig.ts @@ -41,13 +41,14 @@ async function run() { // Create two identifiers, one for each client - let op1 = await client1.identifiers().create('multisig1', { + let icpResult1 = client1.identifiers().create('multisig1', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op1 = await icpResult1.op() while (!op1["done"] ) { op1 = await client1.operations().get(op1.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -56,13 +57,14 @@ async function run() { await client1.identifiers().addEndRole("multisig1", 'agent', client1!.agent!.pre) console.log("Multisig1's AID:", aid1.prefix) - let op2 = await client2.identifiers().create('multisig2', { + let icpResult2 = client2.identifiers().create('multisig2', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op2 = await icpResult2.op() while (!op2["done"] ) { op2 = await client2.operations().get(op2.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -71,13 +73,14 @@ async function run() { await client2.identifiers().addEndRole("multisig2", 'agent', client2!.agent!.pre) console.log("Multisig2's AID:", aid2.prefix) - let op3 = await client3.identifiers().create('multisig3', { + let icpResult3 = client3.identifiers().create('multisig3', { toad: 3, wits: [ "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"] }) + let op3 = await icpResult3.op() while (!op3["done"] ) { op3 = await client3.operations().get(op3.name); await new Promise(resolve => setTimeout(resolve, 1000)); @@ -131,7 +134,7 @@ async function run() { // Create a multisig identifier let rstates = [aid1["state"], aid2["state"], aid3["state"]] let states = rstates - op1 = await client1.identifiers().create("multisig",{ + icpResult1 = client1.identifiers().create("multisig",{ algo: signify.Algos.group, mhab: aid1, isith: 3, @@ -144,9 +147,25 @@ async function run() { states: states, rstates: rstates }) + op1 = await icpResult1.op() + let serder = icpResult1.serder + let sigs = icpResult1.sigs + let sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})) + + let ims = signify.d(signify.messagize(serder, sigers)) + let atc = ims.substring(serder.size) + let embeds = { + icp: [serder, atc], + } + + let smids = states.map((state) => state['i']) + let recp = [aid2["state"], aid3["state"]].map((state) => state['i']) + + await client1.exchanges().send("multisig1", "multisig", aid1, "/multisig/icp", + {'gid': serder.pre, smids: smids, rmids: smids}, embeds, recp) console.log("Multisig1 joined multisig waiting for others...") - op2 = await client2.identifiers().create("multisig",{ + icpResult2 = client2.identifiers().create("multisig",{ algo: signify.Algos.group, mhab: aid2, isith: 3, @@ -159,9 +178,25 @@ async function run() { states: states, rstates: rstates }) + op2 = await icpResult2.op() + serder = icpResult2.serder + sigs = icpResult2.sigs + sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})) + + ims = signify.d(signify.messagize(serder, sigers)) + atc = ims.substring(serder.size) + embeds = { + icp: [serder, atc], + } + + smids = states.map((state) => state['i']) + recp = [aid1["state"], aid3["state"]].map((state) => state['i']) + + await client2.exchanges().send("multisig2", "multisig", aid2, "/multisig/icp", + {'gid': serder.pre, smids: smids, rmids: smids}, embeds, recp) console.log("Multisig2 joined multisig waiting for others...") - op3 = await client3.identifiers().create("multisig",{ + icpResult3 = client3.identifiers().create("multisig",{ algo: signify.Algos.group, mhab: aid3, isith: 3, @@ -174,6 +209,22 @@ async function run() { states: states, rstates: rstates }) + op3 = await icpResult3.op() + serder = icpResult3.serder + sigs = icpResult3.sigs + sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})) + + ims = signify.d(signify.messagize(serder, sigers)) + atc = ims.substring(serder.size) + embeds = { + icp: [serder, atc], + } + + smids = states.map((state) => state['i']) + recp = [aid1["state"], aid2["state"]].map((state) => state['i']) + + await client3.exchanges().send("multisig3", "multisig", aid3, "/multisig/icp", + {'gid': serder.pre, smids: smids, rmids: smids}, embeds, recp) console.log("Multisig3 joined multisig waiting for others...") while (!op1["done"]) { diff --git a/examples/integration-scripts/randy.ts b/examples/integration-scripts/randy.ts index bb5a20ac..0ed53017 100644 --- a/examples/integration-scripts/randy.ts +++ b/examples/integration-scripts/randy.ts @@ -27,7 +27,8 @@ async function run() { const state1 = await client1.state() console.log("Client 1 connected. Client AID:",state1.controller.state.i,"Agent AID: ", state1.agent.i) - let op = await client1.identifiers().create('aid1', {algo: signify.Algos.randy}) + let icpResult = client1.identifiers().create('aid1', {algo: signify.Algos.randy}) + let op = await icpResult.op() assert.equal(op['done'], true) let aid = op['response'] const icp = new signify.Serder(aid) diff --git a/examples/integration-scripts/salty.ts b/examples/integration-scripts/salty.ts index 35291b49..4e1082cd 100644 --- a/examples/integration-scripts/salty.ts +++ b/examples/integration-scripts/salty.ts @@ -27,7 +27,8 @@ async function run() { const state1 = await client1.state() console.log("Client 1 connected. Client AID:",state1.controller.state.i,"Agent AID: ", state1.agent.i) - let op = await client1.identifiers().create('aid1', {bran: '0123456789abcdefghijk'}) + let icpResult = client1.identifiers().create('aid1', {bran: '0123456789abcdefghijk'}) + let op = await icpResult.op() assert.equal(op['done'], true) const aid1 = op['response'] const icp = new signify.Serder(aid1) @@ -47,7 +48,8 @@ async function run() { assert.equal(salt.stem, 'signify:aid') assert.equal(aid.prefix, icp.pre) - op = await client1.identifiers().create('aid2', {count:3, ncount:3, isith:"2", nsith:"2", bran:"0123456789lmnopqrstuv"}) + icpResult = client1.identifiers().create('aid2', {count:3, ncount:3, isith:"2", nsith:"2", bran:"0123456789lmnopqrstuv"}) + op = await icpResult.op() assert.equal(op['done'], true) const aid2 = op['response'] const icp2 = new signify.Serder(aid2) diff --git a/examples/integration-scripts/witness.ts b/examples/integration-scripts/witness.ts index 5889be22..c91dfeec 100644 --- a/examples/integration-scripts/witness.ts +++ b/examples/integration-scripts/witness.ts @@ -39,10 +39,11 @@ async function run() { console.log("Witness OOBI resolved") // Client 1 creates AID with 1 witness - op1 = await client1.identifiers().create('aid1',{ + let icpResult1 = await client1.identifiers().create('aid1',{ toad: 1, wits: ["BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha"] }) + op1 = await icpResult1.op() while (!op1["done"] ) { op1 = await client1.operations().get(op1.name); await new Promise(resolve => setTimeout(resolve, 1000)); diff --git a/src/keri/app/signify.ts b/src/keri/app/signify.ts index 9421c4fc..b7243434 100644 --- a/src/keri/app/signify.ts +++ b/src/keri/app/signify.ts @@ -562,7 +562,7 @@ export class Identifier { * @async * @param {string} name Name or alias of the identifier * @param {CreateIdentiferArgs} [kargs] Optional parameters to create the identifier - * @returns {Promise} A promise to the long-running operation + * @returns {InceptionResult} The inception result */ create(name: string, kargs:CreateIdentiferArgs={}): InceptionResult { @@ -1515,8 +1515,6 @@ export class Registries { let keeper = this.client!.manager!.get(hab) data[keeper.algo] = keeper.params() - console.log(data) - let res = await this.client.fetch(path, method, data) return await res.json() } @@ -1921,7 +1919,7 @@ export class Exchanges { } /** - * Send exn messaget to list of recipients + * Create exn message * @async * @returns {Promise} A promise to the list of replay messages * @param sender