From d354555d86819c75cc99b59b85bc9577e3f0171c Mon Sep 17 00:00:00 2001 From: Rodolfo Miranda Date: Wed, 18 Oct 2023 14:53:37 -0300 Subject: [PATCH] prettyfied --- .../integration-scripts/externalModule.ts | 12 +- examples/integration-scripts/multisig.ts | 138 +++++++++++------- examples/integration-scripts/salty.ts | 16 +- src/keri/app/aiding.ts | 4 +- src/keri/app/exchanging.ts | 5 +- 5 files changed, 102 insertions(+), 73 deletions(-) diff --git a/examples/integration-scripts/externalModule.ts b/examples/integration-scripts/externalModule.ts index 4329e6b0..9765c2a9 100644 --- a/examples/integration-scripts/externalModule.ts +++ b/examples/integration-scripts/externalModule.ts @@ -32,13 +32,11 @@ async function run() { state1.agent.i ); let words = new BIP39Shim(0, {}).generateMnemonic(256); - let icpResult = await client1 - .identifiers() - .create('aid1', { - algo: signify.Algos.extern, - extern_type: 'bip39_shim', - extern: { mnemonics: words }, - }); + let icpResult = await client1.identifiers().create('aid1', { + algo: signify.Algos.extern, + extern_type: 'bip39_shim', + extern: { mnemonics: words }, + }); let op = await icpResult.op(); assert.equal(op['done'], true); } diff --git a/examples/integration-scripts/multisig.ts b/examples/integration-scripts/multisig.ts index 3a096c05..252e6c57 100644 --- a/examples/integration-scripts/multisig.ts +++ b/examples/integration-scripts/multisig.ts @@ -405,7 +405,6 @@ async function run() { let multisig = identifiers3.aids[1].prefix; - // Multisig end role // for brevity, this script authorize only the agent of member 1 // a full implementation should repeat the process to authorize all agents @@ -424,29 +423,40 @@ async function run() { // to the other members let stamp = new Date().toISOString().replace('Z', '000+00:00'); - let endRoleRes = await client1.identifiers().addEndRole('multisig','agent',eid1,stamp); + let endRoleRes = await client1 + .identifiers() + .addEndRole('multisig', 'agent', eid1, stamp); op1 = await endRoleRes.op(); let rpy = endRoleRes.serder; sigs = endRoleRes.sigs; - let mstate = hab["state"]; - let seal = ['SealEvent', {i: hab['prefix'], s: mstate["ee"]["s"], d: mstate["ee"]["d"]}]; - sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})); - let roleims = signify.d(signify.messagize(rpy, sigers, seal, undefined, undefined, false)); + let mstate = hab['state']; + let seal = [ + 'SealEvent', + { i: hab['prefix'], s: mstate['ee']['s'], d: mstate['ee']['d'] }, + ]; + sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig })); + let roleims = signify.d( + signify.messagize(rpy, sigers, seal, undefined, undefined, false) + ); atc = roleims.substring(rpy.size); let roleembeds: any = { - rpy: [rpy, atc] - } + rpy: [rpy, atc], + }; recp = [aid2['state'], aid3['state']].map((state) => state['i']); - res = await client1.exchanges().send( - 'member1', - 'multisig', - aid1, - '/multisig/rpy', - {gid: aid}, - roleembeds, - recp + res = await client1 + .exchanges() + .send( + 'member1', + 'multisig', + aid1, + '/multisig/rpy', + { gid: aid }, + roleembeds, + recp + ); + console.log( + `Member1 authorized agent role to ${eid1}, waiting for others to authorize...` ); - console.log(`Member1 authorized agent role to ${eid1}, waiting for others to authorize...`); //Member2 check for notifications and join the authorization msgSaid = ''; @@ -469,31 +479,42 @@ async function run() { let rpystamp = exn.e.rpy.dt; let rpyrole = exn.e.rpy.a.role; let rpyeid = exn.e.rpy.a.eid; - endRoleRes = await client2.identifiers().addEndRole('multisig',rpyrole,rpyeid,rpystamp); - op2 = await endRoleRes.op() + endRoleRes = await client2 + .identifiers() + .addEndRole('multisig', rpyrole, rpyeid, rpystamp); + op2 = await endRoleRes.op(); rpy = endRoleRes.serder; sigs = endRoleRes.sigs; hab = await client2.identifiers().get('multisig'); - mstate = hab["state"] - seal = ['SealEvent', {i: hab['prefix'], s: mstate["ee"]["s"], d: mstate["ee"]["d"]}]; - sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})); - roleims = signify.d(signify.messagize(rpy, sigers, seal, undefined, undefined, false)); + mstate = hab['state']; + seal = [ + 'SealEvent', + { i: hab['prefix'], s: mstate['ee']['s'], d: mstate['ee']['d'] }, + ]; + sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig })); + roleims = signify.d( + signify.messagize(rpy, sigers, seal, undefined, undefined, false) + ); atc = roleims.substring(rpy.size); roleembeds = { - rpy: [rpy, atc] - } + rpy: [rpy, atc], + }; recp = [aid1['state'], aid3['state']].map((state) => state['i']); - res = await client2.exchanges().send( - 'member2', - 'multisig', - aid2, - '/multisig/rpy', - {gid: aid}, - roleembeds, - recp + res = await client2 + .exchanges() + .send( + 'member2', + 'multisig', + aid2, + '/multisig/rpy', + { gid: aid }, + roleembeds, + recp + ); + console.log( + `Member2 authorized agent role to ${eid1}, waiting for others to authorize...` ); - console.log(`Member2 authorized agent role to ${eid1}, waiting for others to authorize...`); //Member3 check for notifications and join the authorization msgSaid = ''; @@ -515,32 +536,42 @@ async function run() { rpystamp = exn.e.rpy.dt; rpyrole = exn.e.rpy.a.role; rpyeid = exn.e.rpy.a.eid; - endRoleRes = await client3.identifiers().addEndRole('multisig',rpyrole,rpyeid,rpystamp); + endRoleRes = await client3 + .identifiers() + .addEndRole('multisig', rpyrole, rpyeid, rpystamp); - op3 = await endRoleRes.op() + op3 = await endRoleRes.op(); rpy = endRoleRes.serder; sigs = endRoleRes.sigs; hab = await client3.identifiers().get('multisig'); - mstate = hab["state"] - seal = ['SealEvent', {i: hab['prefix'], s: mstate["ee"]["s"], d: mstate["ee"]["d"]}]; - sigers = sigs.map((sig: any) => new signify.Siger({qb64: sig})); - roleims = signify.d(signify.messagize(rpy, sigers, seal, undefined, undefined, false)); + mstate = hab['state']; + seal = [ + 'SealEvent', + { i: hab['prefix'], s: mstate['ee']['s'], d: mstate['ee']['d'] }, + ]; + sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig })); + roleims = signify.d( + signify.messagize(rpy, sigers, seal, undefined, undefined, false) + ); atc = roleims.substring(rpy.size); roleembeds = { - rpy: [rpy, atc] - } + rpy: [rpy, atc], + }; recp = [aid1['state'], aid2['state']].map((state) => state['i']); - res = await client3.exchanges().send( - 'member3', - 'multisig', - aid3, - '/multisig/rpy', - {gid: aid}, - roleembeds, - recp + res = await client3 + .exchanges() + .send( + 'member3', + 'multisig', + aid3, + '/multisig/rpy', + { gid: aid }, + roleembeds, + recp + ); + console.log( + `Member3 authorized agent role to ${eid1}, waiting for others to authorize...` ); - console.log(`Member3 authorized agent role to ${eid1}, waiting for others to authorize...`); - // Check for completion while (!op1['done']) { @@ -1078,6 +1109,5 @@ async function run() { op3 = await client3.operations().get(op3.name); await new Promise((resolve) => setTimeout(resolve, 1000)); } - console.log("Multisig create registry completed!"); - + console.log('Multisig create registry completed!'); } diff --git a/examples/integration-scripts/salty.ts b/examples/integration-scripts/salty.ts index e25bb563..281881e3 100644 --- a/examples/integration-scripts/salty.ts +++ b/examples/integration-scripts/salty.ts @@ -55,15 +55,13 @@ async function run() { assert.equal(salt.stem, 'signify:aid'); assert.equal(aid.prefix, icp.pre); - icpResult = await client1 - .identifiers() - .create('aid2', { - count: 3, - ncount: 3, - isith: '2', - nsith: '2', - bran: '0123456789lmnopqrstuv', - }); + icpResult = await 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']; diff --git a/src/keri/app/aiding.ts b/src/keri/app/aiding.ts index 4797479d..594ca7cc 100644 --- a/src/keri/app/aiding.ts +++ b/src/keri/app/aiding.ts @@ -361,7 +361,7 @@ export class Identifier { return new EventResult(serder, sigs, res); } - /** + /** * Authorize an endpoint provider in a given role for a managed identifier * @remarks * Typically used to authorize the agent to be the endpoint provider for the identifier in the role of `agent` @@ -395,7 +395,7 @@ export class Identifier { 'POST', jsondata ); - return new EventResult(rpy,sigs, res); + return new EventResult(rpy, sigs, res); } /** diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index a9d5e1c3..fdea31cb 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -134,7 +134,10 @@ export function exchange( ): [Serder, Uint8Array] { const vs = versify(Ident.KERI, undefined, Serials.JSON, 0); const ilk = Ilks.exn; - const dt = date !== undefined ? date : nowUTC().toISOString().replace('Z', '000+00:00'); + const dt = + date !== undefined + ? date + : nowUTC().toISOString().replace('Z', '000+00:00'); const p = dig !== undefined ? dig : ''; const q = modifiers !== undefined ? modifiers : {}; const ems = embeds != undefined ? embeds : {};