Skip to content

Commit

Permalink
prettyfied
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolfo Miranda committed Oct 18, 2023
1 parent d5964f7 commit d354555
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 73 deletions.
12 changes: 5 additions & 7 deletions examples/integration-scripts/externalModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
138 changes: 84 additions & 54 deletions examples/integration-scripts/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = '';
Expand All @@ -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 = '';
Expand All @@ -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']) {
Expand Down Expand Up @@ -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!');
}
16 changes: 7 additions & 9 deletions examples/integration-scripts/salty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -395,7 +395,7 @@ export class Identifier {
'POST',
jsondata
);
return new EventResult(rpy,sigs, res);
return new EventResult(rpy, sigs, res);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/keri/app/exchanging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 : {};
Expand Down

0 comments on commit d354555

Please sign in to comment.