diff --git a/.eslintrc b/.eslintrc index b4245e37..bb7a5e07 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,6 @@ "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-namespace": "warn", "@typescript-eslint/ban-types": "warn", - "@typescript-eslint/no-unused-vars": "warn", - "@typescript-eslint/ban-ts-comment": "warn" + "@typescript-eslint/no-unused-vars": "warn" } } diff --git a/examples/integration-scripts/challenge.ts b/examples/integration-scripts/challenge.ts index d67ad5bd..be815fa5 100644 --- a/examples/integration-scripts/challenge.ts +++ b/examples/integration-scripts/challenge.ts @@ -49,7 +49,7 @@ async function run() { assert.equal(challenge1_big.words.length, 24); // Create two identifiers, one for each client - let icpResult1 = await client1.identifiers().create('alice', { + const icpResult1 = await client1.identifiers().create('alice', { toad: 3, wits: [ 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', @@ -68,7 +68,7 @@ async function run() { .addEndRole('alice', 'agent', client1!.agent!.pre); console.log("Alice's AID:", aid1.i); - let icpResult2 = await client2.identifiers().create('bob', { + const icpResult2 = await client2.identifiers().create('bob', { toad: 3, wits: [ 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', @@ -86,8 +86,8 @@ async function run() { console.log("Bob's AID:", aid2.i); // Exchenge OOBIs - let oobi1 = await client1.oobis().get('alice', 'agent'); - let oobi2 = await client2.oobis().get('bob', 'agent'); + const oobi1 = await client1.oobis().get('alice', 'agent'); + const oobi2 = await client2.oobis().get('bob', 'agent'); op1 = await client1.oobis().resolve(oobi2.oobis[0], 'bob'); while (!op1['done']) { @@ -121,7 +121,7 @@ async function run() { console.log('Alice verified challenge response'); //Alice mark response as accepted - let exn = new Serder(op1.response.exn); + const exn = new Serder(op1.response.exn); op1 = await client1.challenges().responded('alice', aid2.i, exn.ked.d); console.log('Alice marked challenge response as accepted'); diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index 64c03c44..d49db9ae 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -57,8 +57,8 @@ async function waitForNotifications( ): Promise { const awaitedNotifications = []; while (true) { - let notifications = await client.notifications().list(); - for (let note of notifications.notes) { + const notifications = await client.notifications().list(); + for (const note of notifications.notes) { if (note.a.r === route) { awaitedNotifications.push(note); } @@ -115,7 +115,7 @@ test('credentials', async () => { const verifierAidName = 'verifier'; // Create two identifiers, one for each client - let issuerIcpRes = await issuerClient.identifiers().create(issuerAidName, { + const issuerIcpRes = await issuerClient.identifiers().create(issuerAidName, { toad: 3, wits: [...KLI_WITNESS_DEMO_PREFIXES], }); @@ -131,7 +131,7 @@ test('credentials', async () => { .addEndRole(issuerAidName, 'agent', issuerClient!.agent!.pre); console.log("Issuer's AID:", issuerAID); - let holderIcpRes = await holderClient.identifiers().create(holderAidName, { + const holderIcpRes = await holderClient.identifiers().create(holderAidName, { toad: 3, wits: [...KLI_WITNESS_DEMO_PREFIXES], }); @@ -147,7 +147,7 @@ test('credentials', async () => { .addEndRole(holderAidName, 'agent', holderClient!.agent!.pre); console.log("Recipient's AID:", holderAID); - let verifierIcpRes = await verifierClient + const verifierIcpRes = await verifierClient .identifiers() .create(verifierAidName, { toad: 3, @@ -187,18 +187,18 @@ test('credentials', async () => { await new Promise((resolve) => setTimeout(resolve, 250)); } - let issSchema = await issuerClient.schemas().get(schemaSAID); + const issSchema = await issuerClient.schemas().get(schemaSAID); assert.equal(issSchema.$id, schemaSAID); - let hldSchemas = await holderClient.schemas().list(); + const hldSchemas = await holderClient.schemas().list(); assert.equal(hldSchemas.length, 1); assert.equal(hldSchemas[0].$id, schemaSAID); console.log('Resolved QVI Schema OOBI for issuer, holder, and verifier'); // Agent discovery through OOBI exchange between issuer, holder, and verifier console.log('Getting Agent OOBIs for issuer, holder, and verifier'); - let issAgentOOBI = await issuerClient.oobis().get(issuerAidName, 'agent'); - let hldAgentOOBI = await holderClient.oobis().get(holderAidName, 'agent'); - let vfyAgentOOBI = await verifierClient + const issAgentOOBI = await issuerClient.oobis().get(issuerAidName, 'agent'); + const hldAgentOOBI = await holderClient.oobis().get(holderAidName, 'agent'); + const vfyAgentOOBI = await verifierClient .oobis() .get(verifierAidName, 'agent'); @@ -263,7 +263,7 @@ test('credentials', async () => { issOp = await issuerClient.operations().get(issOp.name); await new Promise((resolve) => setTimeout(resolve, 250)); } - let registries = await issuerClient.registries().list(issuerAidName); + const registries = await issuerClient.registries().list(issuerAidName); const registry = registries[0]; assert.equal(registries.length, 1); assert.equal(registry.name, registryName); @@ -373,7 +373,7 @@ test('credentials', async () => { verifierClient, '/exn/ipex/grant' ); - let verifierGrantNote = verifierNotifications[0]; + const verifierGrantNote = verifierNotifications[0]; const [admit3, sigs3, aend3] = await verifierClient .ipex() diff --git a/examples/integration-scripts/delegation.ts b/examples/integration-scripts/delegation.ts index 66005721..797f43f5 100644 --- a/examples/integration-scripts/delegation.ts +++ b/examples/integration-scripts/delegation.ts @@ -43,7 +43,7 @@ async function run() { ); // Client 1 create delegator AID - let icpResult1 = await client1.identifiers().create('delegator', { + const icpResult1 = await client1.identifiers().create('delegator', { toad: 3, wits: [ 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', @@ -64,7 +64,7 @@ async function run() { // Client 2 resolves delegator OOBI console.log('Client 2 resolving delegator OOBI'); - let oobi1 = await client1.oobis().get('delegator', 'agent'); + const oobi1 = await client1.oobis().get('delegator', 'agent'); let op2 = await client2.oobis().resolve(oobi1.oobis[0], 'delegator'); while (!op2['done']) { op2 = await client2.operations().get(op2.name); @@ -73,11 +73,11 @@ async function run() { console.log('OOBI resolved'); // Client 2 creates delegate AID - let icpResult2 = await client2 + const icpResult2 = await client2 .identifiers() .create('delegate', { delpre: aid1.prefix }); op2 = await icpResult2.op(); - let delegatePrefix = op2.name.split('.')[1]; + const delegatePrefix = op2.name.split('.')[1]; console.log("Delegate's prefix:", delegatePrefix); console.log('Delegate waiting for approval...'); diff --git a/examples/integration-scripts/externalModule.test.ts b/examples/integration-scripts/externalModule.test.ts index aa4c13c2..8729ec02 100644 --- a/examples/integration-scripts/externalModule.test.ts +++ b/examples/integration-scripts/externalModule.test.ts @@ -29,12 +29,12 @@ test('bip39_shim', async () => { 'Agent AID: ', state1.agent.i ); - let words = new BIP39Shim(0, {}).generateMnemonic(256); - let icpResult = await client1.identifiers().create('aid1', { + const words = new BIP39Shim(0, {}).generateMnemonic(256); + const icpResult = await client1.identifiers().create('aid1', { algo: signify.Algos.extern, extern_type: 'bip39_shim', extern: { mnemonics: words }, }); - let op = await icpResult.op(); + const op = await icpResult.op(); assert.equal(op['done'], true); }, 30000); diff --git a/examples/integration-scripts/modules/bip39_shim.ts b/examples/integration-scripts/modules/bip39_shim.ts index c8a624ff..355297f8 100644 --- a/examples/integration-scripts/modules/bip39_shim.ts +++ b/examples/integration-scripts/modules/bip39_shim.ts @@ -33,11 +33,11 @@ export class BIP39Shim { } keys(count: number, kidx: number, transferable: boolean) { - let keys = []; + const keys = []; for (let idx = 0; idx < count; idx++) { - let keyId = `${this.stem}-${this.pidx}-${kidx + idx}`; - let seed = mnemonicToSeedSync(this.mnemonics, keyId); - let signer = new Signer({ + const keyId = `${this.stem}-${this.pidx}-${kidx + idx}`; + const seed = mnemonicToSeedSync(this.mnemonics, keyId); + const signer = new Signer({ raw: new Uint8Array(seed), code: MtrDex.Ed25519_Seed, transferable: transferable, @@ -48,15 +48,15 @@ export class BIP39Shim { } incept(transferable: boolean) { - let signers = this.keys(this.icount, this.kidx, transferable); - let verfers = signers.map((signer) => signer.verfer.qb64); + const signers = this.keys(this.icount, this.kidx, transferable); + const verfers = signers.map((signer) => signer.verfer.qb64); - let nsigners = this.keys( + const nsigners = this.keys( this.ncount, this.kidx + this.icount, transferable ); - let digers = nsigners.map( + const digers = nsigners.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -64,23 +64,23 @@ export class BIP39Shim { } rotate(ncount: number, transferable: boolean) { - let signers = this.keys( + const signers = this.keys( this.ncount, this.kidx + this.icount, transferable ); - let verfers = signers.map((signer) => signer.verfer.qb64); + const verfers = signers.map((signer) => signer.verfer.qb64); this.kidx = this.kidx + this.icount; this.icount = this.ncount; this.ncount = ncount; - let nsigners = this.keys( + const nsigners = this.keys( this.ncount, this.kidx + this.icount, this.transferable ); - let digers = nsigners.map( + const digers = nsigners.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -94,10 +94,10 @@ export class BIP39Shim { indices: number[] | undefined = undefined, ondices: number[] | undefined = undefined ) { - let signers = this.keys(this.icount, this.kidx, this.transferable); + const signers = this.keys(this.icount, this.kidx, this.transferable); if (indexed) { - let sigers = []; + const sigers = []; let i = 0; for (const [j, signer] of signers.entries()) { if (indices != undefined) { @@ -132,7 +132,7 @@ export class BIP39Shim { } return sigers.map((siger) => siger.qb64); } else { - let cigars = []; + const cigars = []; for (const [_, signer] of signers.entries()) { cigars.push(signer.sign(ser)); } diff --git a/examples/integration-scripts/multisig.test.ts b/examples/integration-scripts/multisig.test.ts index 12b94632..3ab15bfe 100644 --- a/examples/integration-scripts/multisig.test.ts +++ b/examples/integration-scripts/multisig.test.ts @@ -289,17 +289,17 @@ test('multisig', async function run() { `[${identifiers3.aids[1].prefix}]` ); - let multisig = identifiers3.aids[1].prefix; + const 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 - let members = await client1.identifiers().members('multisig'); + const members = await client1.identifiers().members('multisig'); let hab = await client1.identifiers().get('multisig'); let aid = hab['prefix']; - let signing = members['signing']; - let eid1 = Object.keys(signing[0].ends.agent)[0]; //agent of member 1 + const signing = members['signing']; + const eid1 = Object.keys(signing[0].ends.agent)[0]; //agent of member 1 // other agent eids can be obtained with // let eid2 = Object.keys(signing[1].ends.agent)[0]; // let eid3 = Object.keys(signing[2].ends.agent)[0]; @@ -446,7 +446,7 @@ test('multisig', async function run() { console.log(`End role authorization for agent ${eid1}completed!`); // Holder resolve multisig OOBI - let oobimultisig = await client1.oobis().get('multisig', 'agent'); + const oobimultisig = await client1.oobis().get('multisig', 'agent'); op4 = await client4.oobis().resolve(oobimultisig.oobis[0], 'multisig'); op4 = await waitForOp(client4, op4); console.log(`Holder resolved multisig OOBI`); @@ -593,16 +593,16 @@ test('multisig', async function run() { // Update new key states op1 = await client1.keyStates().query(aid2.prefix, 1); op1 = await waitForOp(client1, op1); - let aid2State = op1['response']; + const aid2State = op1['response']; op1 = await client1.keyStates().query(aid3.prefix, 1); op1 = await waitForOp(client1, op1); - let aid3State = op1['response']; + const aid3State = op1['response']; op2 = await client2.keyStates().query(aid3.prefix, 1); op2 = await waitForOp(client2, op2); op2 = await client2.keyStates().query(aid1.prefix, 1); op2 = await waitForOp(client2, op2); - let aid1State = op2['response']; + const aid1State = op2['response']; op3 = await client3.keyStates().query(aid1.prefix, 1); op3 = await waitForOp(client3, op3); @@ -744,14 +744,14 @@ test('multisig', async function run() { console.log('Starting multisig registry creation'); - let vcpRes1 = await client1.registries().create({ + const vcpRes1 = await client1.registries().create({ name: 'multisig', registryName: 'vLEI Registry', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', }); op1 = await vcpRes1.op(); serder = vcpRes1.regser; - let regk = serder.pre; + const regk = serder.pre; let anc = vcpRes1.serder; sigs = vcpRes1.sigs; @@ -787,14 +787,14 @@ test('multisig', async function run() { res = await client2.groups().getRequest(msgSaid); exn = res[0].exn; - let vcpRes2 = await client2.registries().create({ + const vcpRes2 = await client2.registries().create({ name: 'multisig', registryName: 'vLEI Registry', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', }); op2 = await vcpRes2.op(); serder = vcpRes2.regser; - let regk2 = serder.pre; + const regk2 = serder.pre; anc = vcpRes2.serder; sigs = vcpRes2.sigs; @@ -830,14 +830,14 @@ test('multisig', async function run() { res = await client3.groups().getRequest(msgSaid); exn = res[0].exn; - let vcpRes3 = await client3.registries().create({ + const vcpRes3 = await client3.registries().create({ name: 'multisig', registryName: 'vLEI Registry', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', }); op3 = await vcpRes3.op(); serder = vcpRes3.regser; - let regk3 = serder.pre; + const regk3 = serder.pre; anc = vcpRes3.serder; sigs = vcpRes3.sigs; @@ -875,10 +875,10 @@ test('multisig', async function run() { const vcdata = { LEI: '5493001KJTIIGC8Y1R17', }; - let holder = aid4.prefix; + const holder = aid4.prefix; - let TIME = new Date().toISOString().replace('Z', '000+00:00'); - let credRes = await client1.credentials().issue({ + const TIME = new Date().toISOString().replace('Z', '000+00:00'); + const credRes = await client1.credentials().issue({ issuerName: 'multisig', registryId: regk, schemaId: SCHEMA_SAID, @@ -922,7 +922,7 @@ test('multisig', async function run() { res = await client3.groups().getRequest(msgSaid); exn = res[0].exn; - let credRes3 = await client3.credentials().issue({ + const credRes3 = await client3.credentials().issue({ issuerName: 'multisig', registryId: regk3, schemaId: SCHEMA_SAID, @@ -941,7 +941,7 @@ test('multisig', async function run() { op3 = await waitForOp(client3, op3); console.log('Multisig create credential completed!'); - let m = await client1.identifiers().get('multisig'); + const m = await client1.identifiers().get('multisig'); // Update states op1 = await client1.keyStates().query(m.prefix, 4); @@ -957,7 +957,7 @@ test('multisig', async function run() { console.log('Starting grant message'); stamp = new Date().toISOString().replace('Z', '000+00:00'); - let [grant, gsigs, end] = await client1.ipex().grant({ + const [grant, gsigs, end] = await client1.ipex().grant({ senderName: 'multisig', acdc: credRes.acdc, anc: credRes.anc, @@ -1005,7 +1005,7 @@ test('multisig', async function run() { res = await client2.groups().getRequest(msgSaid); exn = res[0].exn; - let [grant2, gsigs2, end2] = await client2.ipex().grant({ + const [grant2, gsigs2, end2] = await client2.ipex().grant({ senderName: 'multisig', recipient: holder, acdc: credRes2.acdc, @@ -1049,7 +1049,7 @@ test('multisig', async function run() { res = await client3.groups().getRequest(msgSaid); exn = res[0].exn; - let [grant3, gsigs3, end3] = await client3.ipex().grant({ + const [grant3, gsigs3, end3] = await client3.ipex().grant({ senderName: 'multisig', recipient: holder, acdc: credRes3.acdc, @@ -1092,7 +1092,7 @@ test('multisig', async function run() { console.log('Holder received exchange message with the grant message'); res = await client4.exchanges().get(msgSaid); - let [admit, asigs, aend] = await client4 + const [admit, asigs, aend] = await client4 .ipex() .admit('holder', '', res.exn.d); @@ -1104,7 +1104,7 @@ test('multisig', async function run() { msgSaid = await waitForMessage(client1, '/exn/ipex/admit'); console.log('Member1 received exchange message with the admit response'); - let creds = await client4.credentials().list(); + const creds = await client4.credentials().list(); console.log(`Holder holds ${creds.length} credential`); }, 240000); @@ -1119,8 +1119,8 @@ async function waitForOp(client: SignifyClient, op: any) { async function waitForMessage(client: SignifyClient, route: string) { let msgSaid = ''; while (msgSaid == '') { - let notifications = await client.notifications().list(); - for (let notif of notifications.notes) { + const notifications = await client.notifications().list(); + for (const notif of notifications.notes) { if (notif.a.r == route) { msgSaid = notif.a.d; await client.notifications().mark(notif.i); @@ -1132,11 +1132,11 @@ async function waitForMessage(client: SignifyClient, route: string) { } async function bootClient(): Promise { - let bran = signify.randomPasscode(); - let client = new SignifyClient(url, bran, signify.Tier.low, bootUrl); + const bran = signify.randomPasscode(); + const client = new SignifyClient(url, bran, signify.Tier.low, bootUrl); await client.boot(); await client.connect(); - let state = await client.state(); + const state = await client.state(); console.log( 'Client AID:', state.controller.state.i, @@ -1149,13 +1149,13 @@ async function bootClient(): Promise { } async function createAID(client: SignifyClient, name: string, wits: string[]) { - let icpResult1 = await client.identifiers().create(name, { + const icpResult1 = await client.identifiers().create(name, { toad: wits.length, wits: wits, }); let op = await icpResult1.op(); op = await waitForOp(client, op); - let aid = await client.identifiers().get(name); + const aid = await client.identifiers().get(name); await client.identifiers().addEndRole(name, 'agent', client!.agent!.pre); console.log(name, 'AID:', aid.prefix); return aid; diff --git a/examples/integration-scripts/randy.test.ts b/examples/integration-scripts/randy.test.ts index 0a6d823f..f8f396ca 100644 --- a/examples/integration-scripts/randy.test.ts +++ b/examples/integration-scripts/randy.test.ts @@ -40,7 +40,7 @@ test('randy', async () => { op = await icpResult.op(); assert.equal(op['done'], true); let ked = op['response']; - let ixn = new signify.Serder(ked); + const ixn = new signify.Serder(ked); assert.equal(ixn.ked['s'], '1'); assert.deepEqual([...ixn.ked['a']], [icp.pre]); @@ -56,13 +56,13 @@ test('randy', async () => { op = await icpResult.op(); assert.equal(op['done'], true); ked = op['response']; - let rot = new signify.Serder(ked); + const rot = new signify.Serder(ked); assert.equal(rot.ked['s'], '2'); assert.equal(rot.verfers.length, 1); assert.equal(rot.digers.length, 1); assert.notEqual(rot.verfers[0].qb64, icp.verfers[0].qb64); assert.notEqual(rot.digers[0].qb64, icp.digers[0].qb64); - let dig = new signify.Diger( + const dig = new signify.Diger( { code: signify.MtrDex.Blake3_256 }, rot.verfers[0].qb64b ); diff --git a/examples/integration-scripts/request-present.ts b/examples/integration-scripts/request-present.ts index bbb88667..da00f5b2 100644 --- a/examples/integration-scripts/request-present.ts +++ b/examples/integration-scripts/request-present.ts @@ -117,10 +117,10 @@ async function run() { // Exchenge OOBIs console.log('Resolving OOBIs...'); - let oobi1 = await client1.oobis().get('issuer', 'agent'); - let oobi2 = await client2.oobis().get('recipient', 'agent'); - let oobi3 = await client3.oobis().get('verifier', 'agent'); - let schemaOobi = 'http://127.0.0.1:7723/oobi/' + schemaSAID; + const oobi1 = await client1.oobis().get('issuer', 'agent'); + const oobi2 = await client2.oobis().get('recipient', 'agent'); + const oobi3 = await client3.oobis().get('verifier', 'agent'); + const schemaOobi = 'http://127.0.0.1:7723/oobi/' + schemaSAID; op1 = await client1.oobis().resolve(oobi2.oobis[0], 'recipient'); while (!op1['done']) { @@ -179,12 +179,12 @@ async function run() { op1 = await client1.operations().get(op1.name); await new Promise((resolve) => setTimeout(resolve, 1000)); } - let registries = await client1.registries().list('issuer'); + const registries = await client1.registries().list('issuer'); assert.equal(registries.length, 1); assert.equal(registries[0].name, 'vLEI'); - let schema = await client1.schemas().get(schemaSAID); + const schema = await client1.schemas().get(schemaSAID); assert.equal(schema.$id, schemaSAID); - let schemas = await client2.schemas().list(); + const schemas = await client2.schemas().list(); assert.equal(schemas.length, 1); assert.equal(schemas[0].$id, schemaSAID); console.log('Registry created'); @@ -200,7 +200,7 @@ async function run() { op1 = await client1.operations().get(op1.name); await new Promise((resolve) => setTimeout(resolve, 1000)); } - let creds1 = await client1.credentials().list('issuer'); + const creds1 = await client1.credentials().list('issuer'); assert.equal(creds1.length, 1); assert.equal(creds1[0].sad.s, schemaSAID); assert.equal(creds1[0].sad.i, aid1.prefix); @@ -208,7 +208,7 @@ async function run() { console.log('Credential issued'); // Recipient check issued credential - let creds2 = await client2.credentials().list('recipient'); + const 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); @@ -221,8 +221,8 @@ async function run() { // Recipient checks for a presentation request notification let requestReceived = false; while (!requestReceived) { - let notifications = await client2.notifications().list(); - for (let notif of notifications) { + const notifications = await client2.notifications().list(); + for (const notif of notifications) { if (notif.a.r == '/presentation/request') { assert.equal(notif.a.schema.n, schemaSAID); requestReceived = true; @@ -240,8 +240,8 @@ async function run() { // Verifier checks for a presentation notification requestReceived = false; while (!requestReceived) { - let notifications = await client3.notifications().list(); - for (let notif of notifications) { + const notifications = await client3.notifications().list(); + for (const notif of notifications) { if (notif.a.r == '/presentation') { assert.equal(notif.a.schema.n, schemaSAID); requestReceived = true; @@ -251,7 +251,7 @@ async function run() { await new Promise((resolve) => setTimeout(resolve, 1000)); } - let creds3 = await client3 + const creds3 = await client3 .credentials() .list('verifier', { filter: { '-i': { $eq: aid1.prefix } } }); // filter by issuer assert.equal(creds3.length, 1); diff --git a/examples/integration-scripts/salty.test.ts b/examples/integration-scripts/salty.test.ts index 9d1da56b..c0b78d80 100644 --- a/examples/integration-scripts/salty.test.ts +++ b/examples/integration-scripts/salty.test.ts @@ -122,7 +122,7 @@ test('salty', async () => { op = await icpResult.op(); assert.equal(op['done'], true); let ked = op['response']; - let rot = new signify.Serder(ked); + const rot = new signify.Serder(ked); assert.equal(rot.ked['d'], 'EBQABdRgaxJONrSLcgrdtbASflkvLxJkiDO0H-XmuhGg'); assert.equal(rot.ked['s'], '1'); assert.equal(rot.verfers.length, 1); @@ -140,7 +140,7 @@ test('salty', async () => { op = await icpResult.op(); assert.equal(op['done'], true); ked = op['response']; - let ixn = new signify.Serder(ked); + const ixn = new signify.Serder(ked); assert.equal(ixn.ked['d'], 'ENsmRAg_oM7Hl1S-GTRMA7s4y760lQMjzl0aqOQ2iTce'); assert.equal(ixn.ked['s'], '2'); assert.deepEqual([...ixn.ked['a']], [icp.pre]); diff --git a/examples/integration-scripts/singlesig-ixn.test.ts b/examples/integration-scripts/singlesig-ixn.test.ts index 0393daf1..20df9484 100644 --- a/examples/integration-scripts/singlesig-ixn.test.ts +++ b/examples/integration-scripts/singlesig-ixn.test.ts @@ -26,10 +26,10 @@ describe("singlesig-ixn", () => { test("step1", async () => { expect(name1_id).toEqual(contact1_id); - let keystate1 = await client1.keyStates().get(name1_id); + const keystate1 = await client1.keyStates().get(name1_id); expect(keystate1).toHaveLength(1); - let keystate2 = await client2.keyStates().get(contact1_id); + const keystate2 = await client2.keyStates().get(contact1_id); expect(keystate2).toHaveLength(1); // local and remote keystate sequence match @@ -37,28 +37,28 @@ describe("singlesig-ixn", () => { }); test("ixn1", async () => { // local keystate before ixn - let keystate0: KeyState = (await client1.keyStates().get(name1_id)).at(0); + const keystate0: KeyState = (await client1.keyStates().get(name1_id)).at(0); expect(keystate0).not.toBeNull(); // ixn - let result: EventResult = await client1.identifiers().interact("name1", {}); + const result: EventResult = await client1.identifiers().interact("name1", {}); await waitOperation(client1, await result.op()); // local keystate after ixn - let keystate1: KeyState = (await client1.keyStates().get(name1_id)).at(0); + const keystate1: KeyState = (await client1.keyStates().get(name1_id)).at(0); expect(parseInt(keystate1.s)).toBeGreaterThan(0); // sequence has incremented expect(parseInt(keystate1.s)).toEqual(parseInt(keystate0.s) + 1); // remote keystate after ixn - let keystate2: KeyState = (await client2.keyStates().get(contact1_id)).at(0); + const keystate2: KeyState = (await client2.keyStates().get(contact1_id)).at(0); // remote keystate is one behind expect(parseInt(keystate2.s)).toEqual(parseInt(keystate1.s) - 1); // refresh remote keystate let op = await client2.keyStates().query(contact1_id, parseInt(keystate1.s), undefined); op = await waitOperation(client2, op); - let keystate3: KeyState = op.response; + const keystate3: KeyState = op.response; // local and remote keystate match expect(keystate3.s).toEqual(keystate1.s); }); diff --git a/examples/integration-scripts/singlesig-rot.test.ts b/examples/integration-scripts/singlesig-rot.test.ts index a45be5d7..3f88fb92 100644 --- a/examples/integration-scripts/singlesig-rot.test.ts +++ b/examples/integration-scripts/singlesig-rot.test.ts @@ -28,10 +28,10 @@ describe("singlesig-rot", () => { test("step1", async () => { expect(name1_id).toEqual(contact1_id); - let keystate1 = await client1.keyStates().get(name1_id); + const keystate1 = await client1.keyStates().get(name1_id); expect(keystate1).toHaveLength(1); - let keystate2 = await client2.keyStates().get(contact1_id); + const keystate2 = await client2.keyStates().get(contact1_id); expect(keystate2).toHaveLength(1); // local and remote keystate sequence match @@ -39,18 +39,18 @@ describe("singlesig-rot", () => { }); test("rot1", async () => { // local keystate before rot - let keystate0: KeyState = (await client1.keyStates().get(name1_id)).at(0); + const keystate0: KeyState = (await client1.keyStates().get(name1_id)).at(0); expect(keystate0).not.toBeNull(); expect(keystate0.k).toHaveLength(1); expect(keystate0.n).toHaveLength(1); // rot - let args: RotateIdentifierArgs = {}; - let result: EventResult = await client1.identifiers().rotate("name1", args); + const args: RotateIdentifierArgs = {}; + const result: EventResult = await client1.identifiers().rotate("name1", args); await waitOperation(client1, await result.op()); // local keystate after rot - let keystate1: KeyState = (await client1.keyStates().get(name1_id)).at(0); + const keystate1: KeyState = (await client1.keyStates().get(name1_id)).at(0); expect(parseInt(keystate1.s)).toBeGreaterThan(0); // sequence has incremented expect(parseInt(keystate1.s)).toEqual(parseInt(keystate0.s) + 1); @@ -60,14 +60,14 @@ describe("singlesig-rot", () => { expect(keystate1.n[0]).not.toEqual(keystate0.n[0]); // remote keystate after rot - let keystate2: KeyState = (await client2.keyStates().get(contact1_id)).at(0); + const keystate2: KeyState = (await client2.keyStates().get(contact1_id)).at(0); // remote keystate is one behind expect(parseInt(keystate2.s)).toEqual(parseInt(keystate1.s) - 1); // refresh remote keystate let op = await client2.keyStates().query(contact1_id, parseInt(keystate1.s), undefined); op = await waitOperation(client2, op); - let keystate3: KeyState = op.response; + const keystate3: KeyState = op.response; // local and remote keystate match expect(keystate3.s).toEqual(keystate1.s); expect(keystate3.k[0]).toEqual(keystate1.k[0]); diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index 6123c8e2..f8be928f 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -19,8 +19,8 @@ describe("test-setup-single-client", () => { expect(client.controller?.pre).toEqual("EB3UGWwIMq7ppzcQ697ImQIuXlBG5jzh-baSx-YG3-tY"); }); test("step2", async () => { - let env = resolveEnvironment(); - let oobi = await client.oobis().get("name1", "witness"); + const env = resolveEnvironment(); + const oobi = await client.oobis().get("name1", "witness"); expect(oobi.oobis).toHaveLength(3); switch (env.preset) { case "local": diff --git a/examples/integration-scripts/utils/test-setup.ts b/examples/integration-scripts/utils/test-setup.ts index 6053dd58..0dc253f6 100644 --- a/examples/integration-scripts/utils/test-setup.ts +++ b/examples/integration-scripts/utils/test-setup.ts @@ -15,12 +15,12 @@ import { waitOperation } from "./test-util"; * $ SIGNIFY_SECRETS="0ACqshJKkJ7DDXcaDuwnmI8s,0ABqicvyicXGvIVg6Ih-dngE" npx jest ./tests */ export async function getOrCreateClients(count: number, brans: string[] | undefined = undefined): Promise { - let tasks: Promise[] = []; - let secrets = process.env["SIGNIFY_SECRETS"]?.split(","); + const tasks: Promise[] = []; + const secrets = process.env["SIGNIFY_SECRETS"]?.split(","); for (let i = 0; i < count; i++) { tasks.push(getOrCreateClient(brans?.at(i) ?? secrets?.at(i) ?? undefined)); } - let clients: SignifyClient[] = await Promise.all(tasks); + const clients: SignifyClient[] = await Promise.all(tasks); console.log(`SIGNIFY_SECRETS="${clients.map(i => i.bran).join(",")}"`); return clients; } @@ -29,15 +29,15 @@ export async function getOrCreateClients(count: number, brans: string[] | undefi * Connect or boot a SignifyClient instance */ export async function getOrCreateClient(bran: string | undefined = undefined): Promise { - let env = resolveEnvironment(); + const env = resolveEnvironment(); await ready(); bran ??= randomPasscode(); bran = bran.padEnd(21, "_"); - let client = new SignifyClient(env.url, bran, Tier.low, env.bootUrl); + const client = new SignifyClient(env.url, bran, Tier.low, env.bootUrl); try { await client.connect(); } catch { - let res = await client.boot(); + const res = await client.boot(); if (!res.ok) throw new Error(); await client.connect(); } @@ -58,30 +58,30 @@ export async function getOrCreateClient(bran: string | undefined = undefined): P export async function getOrCreateIdentifier(client: SignifyClient, name: string, kargs: CreateIdentiferArgs | undefined = undefined): Promise<[string, string]> { let id: any = undefined; try { - let identfier = await client.identifiers().get(name); + const identfier = await client.identifiers().get(name); // console.log("identifiers.get", identfier); id = identfier.prefix; } catch { - let env = resolveEnvironment(); + const env = resolveEnvironment(); kargs ??= { toad: env.witnessIds.length, wits: env.witnessIds }; - let result: EventResult = await client.identifiers().create(name, kargs); + const result: EventResult = await client.identifiers().create(name, kargs); let op = await result.op(); op = await waitOperation(client, op); // console.log("identifiers.create", op); id = op.response.i; } - let eid = client.agent?.pre!; + const eid = client.agent?.pre!; if (!await hasEndRole(client, name, "agent", eid)) { - let result: EventResult = await client.identifiers().addEndRole(name, "agent", eid); + const result: EventResult = await client.identifiers().addEndRole(name, "agent", eid); let op = await result.op(); op = await waitOperation(client, op); // console.log("identifiers.addEndRole", op); } - let oobi = await client.oobis().get(name, "agent"); - let result: [string, string] = [id, oobi.oobis[0]]; + const oobi = await client.oobis().get(name, "agent"); + const result: [string, string] = [id, oobi.oobis[0]]; console.log(name, result); return result; } @@ -90,10 +90,10 @@ export async function getOrCreateIdentifier(client: SignifyClient, name: string, * Get list of end role authorizations for a Keri idenfitier */ export async function getEndRoles(client: SignifyClient, alias: string, role?: string): Promise { - let path = (role !== undefined) ? `/identifiers/${alias}/endroles/${role}` : `/identifiers/${alias}/endroles`; - let response: Response = await client.fetch(path, "GET", null); + const path = (role !== undefined) ? `/identifiers/${alias}/endroles/${role}` : `/identifiers/${alias}/endroles`; + const response: Response = await client.fetch(path, "GET", null); if (!response.ok) throw new Error(await response.text()); - let result = await response.json(); + const result = await response.json(); // console.log("getEndRoles", result); return result; } @@ -102,8 +102,8 @@ export async function getEndRoles(client: SignifyClient, alias: string, role?: s * Test if end role is authorized for a Keri identifier */ export async function hasEndRole(client: SignifyClient, alias: string, role: string, eid: string): Promise { - let list = await getEndRoles(client, alias, role); - for (let i of list) { + const list = await getEndRoles(client, alias, role); + for (const i of list) { if (i.role === role && i.eid === eid) { return true; } @@ -121,10 +121,10 @@ export async function hasEndRole(client: SignifyClient, alias: string, role: str * }); */ export async function getOrCreateContact(client: SignifyClient, name: string, oobi: string): Promise { - let list = await client.contacts().list(undefined, "alias", `^${name}$`); + const list = await client.contacts().list(undefined, "alias", `^${name}$`); // console.log("contacts.list", list); if (list.length > 0) { - let contact = list[0]; + const contact = list[0]; if (contact.oobi === oobi) { // console.log("contacts.id", contact.id); return contact.id; diff --git a/examples/scripts/client.ts b/examples/scripts/client.ts index dc06fd28..11e8d4c3 100644 --- a/examples/scripts/client.ts +++ b/examples/scripts/client.ts @@ -3,8 +3,8 @@ import signify from 'signify-ts'; await connect(); async function connect() { - let url = 'http://127.0.0.1:3901'; - let bran = '0123456789abcdefghijk'; + const url = 'http://127.0.0.1:3901'; + const bran = '0123456789abcdefghijk'; await signify.ready(); const client = new signify.SignifyClient(url, bran); @@ -27,17 +27,17 @@ async function connect() { }); await client.connect(); - let d = await client.state(); + const d = await client.state(); console.log('Connected: '); console.log(' Agent: ', d.agent.i, ' Controller: ', d.controller.state.i); - let identifiers = client.identifiers(); + const identifiers = client.identifiers(); const oobis = client.oobis(); const operations = client.operations(); const exchanges = client.exchanges(); - let salt = 'abcdefghijk0123456789'; - let res = await identifiers.create('multisig-ts', { bran: salt }); + const salt = 'abcdefghijk0123456789'; + const res = await identifiers.create('multisig-ts', { bran: salt }); let op = await res.op(); let aid = op['response']; @@ -68,7 +68,7 @@ async function connect() { await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second } console.log('done.'); - let kli = op['response']; + const kli = op['response']; console.log('Resolving multisig-sigpy...'); op = await oobis.resolve( @@ -80,13 +80,13 @@ async function connect() { await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second } console.log('done.'); - let sigPy = op['response']; + const sigPy = op['response']; aid = await identifiers.get('multisig-ts'); - let sigTs = aid['state']; + const sigTs = aid['state']; - let states = [sigPy, kli, sigTs]; - let ires = await identifiers.create('multisig', { + const states = [sigPy, kli, sigTs]; + const ires = await identifiers.create('multisig', { algo: signify.Algos.group, mhab: aid, delpre: 'EHpD0-CDWOdu5RJ8jHBSUkOqBZ3cXeDVHWNb_Ul89VI7', @@ -102,18 +102,18 @@ async function connect() { rstates: states, }); - let serder = ires.serder; - let sigs = ires.sigs; - let sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig })); + const serder = ires.serder; + const sigs = ires.sigs; + const 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 = { + const ims = signify.d(signify.messagize(serder, sigers)); + const atc = ims.substring(serder.size); + const embeds = { icp: [serder, atc], }; - let smids = states.map((state) => state['i']); - let recp = [sigPy, kli].map((state) => state['i']); + const smids = states.map((state) => state['i']); + const recp = [sigPy, kli].map((state) => state['i']); await exchanges.send( 'multisig-ts', diff --git a/examples/scripts/list_notifications.ts b/examples/scripts/list_notifications.ts index f7e3ea9d..3001897e 100644 --- a/examples/scripts/list_notifications.ts +++ b/examples/scripts/list_notifications.ts @@ -6,68 +6,68 @@ const prmpt = promptSync({ sigint: true }); await list_notifications(); async function list_notifications() { - let url = 'http://127.0.0.1:3901'; - let bran = '0123456789abcdefghijk'; + const url = 'http://127.0.0.1:3901'; + const bran = '0123456789abcdefghijk'; await signify.ready(); const client = new signify.SignifyClient(url, bran); await client.connect(); - let d = await client.state(); + const d = await client.state(); console.log('Connected: '); console.log(' Agent: ', d.agent.i, ' Controller: ', d.controller.state.i); - let identifiers = client.identifiers(); - let notifications = client.notifications(); - let groups = client.groups(); - let registries = client.registries(); + const identifiers = client.identifiers(); + const notifications = client.notifications(); + const groups = client.groups(); + const registries = client.registries(); - let res = await notifications.list(); - let notes = res.notes; + const res = await notifications.list(); + const notes = res.notes; for (const note of notes) { - let payload = note.a; - let route = payload.r; + const payload = note.a; + const route = payload.r; if (route === '/multisig/vcp') { - let res = await groups.getRequest(payload.d); + const res = await groups.getRequest(payload.d); if (res.length == 0) { console.log( 'error extracting exns matching nre for ' + payload.data ); } - let msg = res[0]; + const msg = res[0]; let sender = msg['sender']; - let group = msg['groupName']; + const group = msg['groupName']; - let exn = msg['exn']; - let usage = exn['a']['usage']; + const exn = msg['exn']; + const usage = exn['a']['usage']; console.log( 'Credential registry inception request for group AID :' + group ); console.log('\tReceived from: ' + sender); console.log('\tPurpose: ' + usage); console.log('\nAuto-creating new registry...'); - let yes = prmpt('Approve [Y|n]? '); + const yes = prmpt('Approve [Y|n]? '); if (yes === 'y' || yes === 'Y' || yes === '') { try { - let registryName = prmpt( + const registryName = prmpt( 'Enter new local name for registry: ' ); let embeds = exn['e']; - let vcp = embeds['vcp']; - let ixn = embeds['ixn']; - let serder = new signify.Serder(ixn); - let ghab = await identifiers.get(group); + const vcp = embeds['vcp']; + const ixn = embeds['ixn']; + const serder = new signify.Serder(ixn); + const ghab = await identifiers.get(group); let keeper = client.manager!.get(ghab); - let sigs = keeper.sign(signify.b(serder.raw)); - let sigers = sigs.map( + const sigs = keeper.sign(signify.b(serder.raw)); + const sigers = sigs.map( (sig: any) => new signify.Siger({ qb64: sig }) ); - let ims = signify.d(signify.messagize(serder, sigers)); - let atc = ims.substring(serder.size); + const ims = signify.d(signify.messagize(serder, sigers)); + const atc = ims.substring(serder.size); embeds = { vcp: [new signify.Serder(vcp), undefined], ixn: [serder, atc], @@ -75,7 +75,7 @@ async function list_notifications() { sender = ghab['group']['mhab']; keeper = client.manager!.get(sender); - let [nexn, end] = signify.exchange( + const [nexn, end] = signify.exchange( '/multisig/vcp', { gid: ghab['prefix'], usage: 'test' }, sender['prefix'], @@ -87,7 +87,7 @@ async function list_notifications() { ); console.log(nexn.pretty()); - let esigs = keeper.sign(signify.b(nexn.raw)); + const esigs = keeper.sign(signify.b(nexn.raw)); await groups.sendRequest( group, nexn.ked, diff --git a/examples/scripts/make_endroles.ts b/examples/scripts/make_endroles.ts index 6a3f8a91..16f48dda 100644 --- a/examples/scripts/make_endroles.ts +++ b/examples/scripts/make_endroles.ts @@ -3,48 +3,48 @@ import signify from 'signify-ts'; await makeends(); async function makeends() { - let url = 'http://127.0.0.1:3901'; - let bran = '0123456789abcdefghijk'; + const url = 'http://127.0.0.1:3901'; + const bran = '0123456789abcdefghijk'; await signify.ready(); const client = new signify.SignifyClient(url, bran); await client.connect(); - let d = await client.state(); + const d = await client.state(); console.log('Connected: '); console.log(' Agent: ', d.agent.i, ' Controller: ', d.controller.state.i); - let identifiers = client.identifiers(); - let escrows = client.escrows(); + const identifiers = client.identifiers(); + const escrows = client.escrows(); - let members = await identifiers.members('multisig'); - let hab = await identifiers.get('multisig'); - let aid = hab['prefix']; - let signing = members['signing']; + const members = await identifiers.members('multisig'); + const hab = await identifiers.get('multisig'); + const aid = hab['prefix']; + const signing = members['signing']; - let auths = new Map(); - let stamp = new Date(); + const auths = new Map(); + const stamp = new Date(); signing.forEach((end: any) => { - let ends = end['ends']; - let roles = ['agent', 'mailbox']; + const ends = end['ends']; + const roles = ['agent', 'mailbox']; roles.forEach((role) => { if (role in ends) { Object.keys(ends[role]).forEach((k: any) => { - let key = [aid, role, k].join('.'); + const key = [aid, role, k].join('.'); auths.set(key, stamp); }); } }); }); - let rpys = await escrows.listReply('/end/role'); + const rpys = await escrows.listReply('/end/role'); rpys.forEach((rpy: object) => { - let serder = new signify.Serder(rpy); - let payload = serder.ked['a']; + const serder = new signify.Serder(rpy); + const payload = serder.ked['a']; - let key = Object.values(payload).join('.'); - let then = new Date(Date.parse(serder.ked['dt'])); + const key = Object.values(payload).join('.'); + const then = new Date(Date.parse(serder.ked['dt'])); if (auths.has(key) && then < stamp) { identifiers.addEndRole( 'multisig', diff --git a/examples/scripts/multisig-create-credential.ts b/examples/scripts/multisig-create-credential.ts index 1d4b9b90..78174123 100644 --- a/examples/scripts/multisig-create-credential.ts +++ b/examples/scripts/multisig-create-credential.ts @@ -3,8 +3,8 @@ import signify from 'signify-ts'; await connect(); async function connect() { - let url = 'http://127.0.0.1:3901'; - let bran = '0123456789abcdefghijk'; + const url = 'http://127.0.0.1:3901'; + const bran = '0123456789abcdefghijk'; await signify.ready(); const client = new signify.SignifyClient(url, bran); @@ -27,17 +27,17 @@ async function connect() { }); await client.connect(); - let d = await client.state(); + const d = await client.state(); console.log('Connected: '); console.log(' Agent: ', d.agent.i, ' Controller: ', d.controller.state.i); - let identifiers = client.identifiers(); + const identifiers = client.identifiers(); const oobis = client.oobis(); const operations = client.operations(); const exchanges = client.exchanges(); - let salt = '0123456789lmnopqrstuv'; - let res = await identifiers.create('agent0', { bran: salt }); + const salt = '0123456789lmnopqrstuv'; + const res = await identifiers.create('agent0', { bran: salt }); let op = await res.op(); let aid = op['response']; @@ -55,7 +55,7 @@ async function connect() { await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second } console.log('done.'); - let multisig1 = op['response']; + const multisig1 = op['response']; console.log('Resolving multisig2...'); op = await oobis.resolve( @@ -67,13 +67,13 @@ async function connect() { await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second } console.log('done.'); - let multisig2 = op['response']; + const multisig2 = op['response']; aid = await identifiers.get('agent0'); - let agent0 = aid['state']; + const agent0 = aid['state']; - let states = [multisig2, multisig1, agent0]; - let ires = await identifiers.create('multisig', { + const states = [multisig2, multisig1, agent0]; + const ires = await identifiers.create('multisig', { algo: signify.Algos.group, mhab: aid, toad: 3, @@ -94,11 +94,11 @@ async function connect() { let ims = signify.d(signify.messagize(serder, sigers)); let atc = ims.substring(serder.size); - let embeds = { + const embeds = { icp: [serder, atc], }; - let smids = states.map((state) => state['i']); + const smids = states.map((state) => state['i']); let recp = [multisig2, multisig1].map((state) => state['i']); await exchanges.send( @@ -111,7 +111,7 @@ async function connect() { recp ); - let multisigAID = serder.pre; + const multisigAID = serder.pre; console.log('Waiting for multisig AID to be created'); op = await ires.op(); @@ -131,10 +131,10 @@ async function connect() { await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second } console.log('done.'); - let schemaSAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; + const schemaSAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; console.log('Creating registry...'); - let vcpRes1 = await client.registries().create({ + const vcpRes1 = await client.registries().create({ name: 'multisig', registryName: 'vLEI Registry', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', @@ -142,15 +142,15 @@ async function connect() { let op1 = await vcpRes1.op(); serder = vcpRes1.regser; - let regk = serder.pre; - let anc = vcpRes1.serder; + const regk = serder.pre; + const anc = vcpRes1.serder; sigs = vcpRes1.sigs; sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig })); ims = signify.d(signify.messagize(anc, sigers)); atc = ims.substring(anc.size); - let regbeds = { + const regbeds = { vcp: [serder, ''], anc: [anc, atc], }; @@ -182,10 +182,10 @@ async function connect() { const vcdata = { LEI: '5493001KJTIIGC8Y1R17', }; - let holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k'; + const holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k'; - let TIME = '2023-09-25T16:01:37.000000+00:00'; - let credRes = await client + const TIME = '2023-09-25T16:01:37.000000+00:00'; + const credRes = await client .credentials() .issue( 'multisig', @@ -199,16 +199,16 @@ async function connect() { ); op1 = await credRes.op(); - let acdc = new signify.Serder(credRes.acdc); - let iss = credRes.iserder; - let ianc = credRes.anc; - let isigs = credRes.sigs; + const acdc = new signify.Serder(credRes.acdc); + const iss = credRes.iserder; + const ianc = credRes.anc; + const isigs = credRes.sigs; sigers = isigs.map((sig: any) => new signify.Siger({ qb64: sig })); ims = signify.d(signify.messagize(ianc, sigers)); atc = ims.substring(anc.size); - let vcembeds = { + const vcembeds = { acdc: [acdc, ''], iss: [iss, ''], anc: [ianc, atc], @@ -233,25 +233,25 @@ async function connect() { console.log('Creating IPEX grant message to send...'); - let [grant, gsigs, end] = await client + const [grant, gsigs, end] = await client .ipex() .grant('multisig', holder, '', acdc, iss, ianc, atc, undefined, TIME); - let m = await client.identifiers().get('multisig'); + const m = await client.identifiers().get('multisig'); - let mstate = m['state']; - let seal = [ + const mstate = m['state']; + const seal = [ 'SealEvent', { i: m['prefix'], s: mstate['ee']['s'], d: mstate['ee']['d'] }, ]; sigers = gsigs.map((sig: any) => new signify.Siger({ qb64: sig })); - let gims = signify.d( + const gims = signify.d( signify.messagize(grant, sigers, seal, undefined, undefined, true) ); atc = gims.substring(grant.size); atc += end; - let gembeds: any = { + const gembeds: any = { exn: [grant, atc], }; diff --git a/src/keri/app/aiding.ts b/src/keri/app/aiding.ts index 594ca7cc..aca4ac24 100644 --- a/src/keri/app/aiding.ts +++ b/src/keri/app/aiding.ts @@ -70,17 +70,17 @@ export class Identifier { * @returns {Promise} A promise to the list of managed identifiers */ async list(start: number = 0, end: number = 24): Promise { - let extraHeaders = new Headers(); + const extraHeaders = new Headers(); extraHeaders.append('Range', `aids=${start}-${end}`); - let path = `/identifiers`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data, extraHeaders); + const path = `/identifiers`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data, extraHeaders); - let cr = res.headers.get('content-range'); - let range = parseRangeHeaders(cr, 'aids'); - let aids = await res.json(); + const cr = res.headers.get('content-range'); + const range = parseRangeHeaders(cr, 'aids'); + const aids = await res.json(); return { start: range.start, @@ -97,10 +97,10 @@ export class Identifier { * @returns {Promise} A promise to the identifier information */ async get(name: string): Promise { - let path = `/identifiers/${name}`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data); + const path = `/identifiers/${name}`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -117,31 +117,31 @@ export class Identifier { ): Promise { const algo = kargs.algo == undefined ? Algos.salty : kargs.algo; - let transferable = kargs.transferable ?? true; - let isith = kargs.isith ?? '1'; - let nsith = kargs.nsith ?? '1'; + const transferable = kargs.transferable ?? true; + const isith = kargs.isith ?? '1'; + const nsith = kargs.nsith ?? '1'; let wits = kargs.wits ?? []; - let toad = kargs.toad ?? 0; - let dcode = kargs.dcode ?? MtrDex.Blake3_256; - let proxy = kargs.proxy; - let delpre = kargs.delpre; - let data = kargs.data != undefined ? [kargs.data] : []; - let pre = kargs.pre; - let states = kargs.states; - let rstates = kargs.rstates; - let prxs = kargs.prxs; - let nxts = kargs.nxts; - let mhab = kargs.mhab; - let _keys = kargs.keys; - let _ndigs = kargs.ndigs; - let bran = kargs.bran; - let count = kargs.count; - let ncount = kargs.ncount; - let tier = kargs.tier; - let extern_type = kargs.extern_type; - let extern = kargs.extern; - - let xargs = { + const toad = kargs.toad ?? 0; + const dcode = kargs.dcode ?? MtrDex.Blake3_256; + const proxy = kargs.proxy; + const delpre = kargs.delpre; + const data = kargs.data != undefined ? [kargs.data] : []; + const pre = kargs.pre; + const states = kargs.states; + const rstates = kargs.rstates; + const prxs = kargs.prxs; + const nxts = kargs.nxts; + const mhab = kargs.mhab; + const _keys = kargs.keys; + const _ndigs = kargs.ndigs; + const bran = kargs.bran; + const count = kargs.count; + const ncount = kargs.ncount; + const tier = kargs.tier; + const extern_type = kargs.extern_type; + const extern = kargs.extern; + + const xargs = { transferable: transferable, isith: isith, nsith: nsith, @@ -168,8 +168,8 @@ export class Identifier { extern: extern, }; - let keeper = this.client.manager!.new(algo, this.client.pidx, xargs); - let [keys, ndigs] = await keeper!.incept(transferable); + const keeper = this.client.manager!.new(algo, this.client.pidx, xargs); + const [keys, ndigs] = await keeper!.incept(transferable); wits = wits !== undefined ? wits : []; let serder: Serder | undefined = undefined; if (delpre == undefined) { @@ -205,8 +205,8 @@ export class Identifier { }); } - let sigs = await keeper!.sign(b(serder.raw)); - var jsondata: any = { + const sigs = await keeper!.sign(b(serder.raw)); + const jsondata: any = { name: name, icp: serder.ked, sigs: sigs, @@ -223,7 +223,7 @@ export class Identifier { jsondata[algo] = keeper.params(); this.client.pidx = this.client.pidx + 1; - let res = this.client.fetch('/identifiers', 'POST', jsondata); + const res = this.client.fetch('/identifiers', 'POST', jsondata); return new EventResult(serder, sigs, res); } @@ -235,18 +235,18 @@ export class Identifier { * @returns {Promise} A promise to the interaction event result */ async interact(name: string, data?: any): Promise { - let hab = await this.get(name); - let pre: string = hab.prefix; + const hab = await this.get(name); + const pre: string = hab.prefix; - let state = hab.state; - let sn = Number(state.s); - let dig = state.d; + const state = hab.state; + const sn = Number(state.s); + const dig = state.d; data = Array.isArray(data) ? data : [data]; data = Array.isArray(data) ? data : [data]; - let serder = interact({ + const serder = interact({ pre: pre, sn: sn + 1, data: data, @@ -254,16 +254,16 @@ export class Identifier { version: undefined, kind: undefined, }); - let keeper = this.client!.manager!.get(hab); - let sigs = await keeper.sign(b(serder.raw)); + const keeper = this.client!.manager!.get(hab); + const sigs = await keeper.sign(b(serder.raw)); - let jsondata: any = { + const jsondata: any = { ixn: serder.ked, sigs: sigs, }; jsondata[keeper.algo] = keeper.params(); - let res = this.client.fetch( + const res = this.client.fetch( '/identifiers/' + name + '?type=ixn', 'PUT', jsondata @@ -281,18 +281,18 @@ export class Identifier { name: string, kargs: RotateIdentifierArgs = {} ): Promise { - let transferable = kargs.transferable ?? true; - let ncode = kargs.ncode ?? MtrDex.Ed25519_Seed; - let ncount = kargs.ncount ?? 1; - - let hab = await this.get(name); - let pre = hab.prefix; - - let state = hab.state; - let count = state.k.length; - let dig = state.d; - let ridx = Number(state.s) + 1; - let wits = state.b; + const transferable = kargs.transferable ?? true; + const ncode = kargs.ncode ?? MtrDex.Ed25519_Seed; + const ncount = kargs.ncount ?? 1; + + const hab = await this.get(name); + const pre = hab.prefix; + + const state = hab.state; + const count = state.k.length; + const dig = state.d; + const ridx = Number(state.s) + 1; + const wits = state.b; let isith = state.kt; let nsith = kargs.nsith ?? isith; @@ -305,28 +305,28 @@ export class Identifier { if (nsith == undefined) nsith = `${Math.max(1, Math.ceil(ncount / 2)).toString(16)}`; - let cst = new Tholder({ sith: isith }).sith; // current signing threshold - let nst = new Tholder({ sith: nsith }).sith; // next signing threshold + const cst = new Tholder({ sith: isith }).sith; // current signing threshold + const nst = new Tholder({ sith: nsith }).sith; // next signing threshold // Regenerate next keys to sign rotation event - let keeper = this.client.manager!.get(hab); + const keeper = this.client.manager!.get(hab); // Create new keys for next digests - let ncodes = kargs.ncodes ?? new Array(ncount).fill(ncode); + const ncodes = kargs.ncodes ?? new Array(ncount).fill(ncode); - let states = kargs.states == undefined ? [] : kargs.states; - let rstates = kargs.rstates == undefined ? [] : kargs.rstates; - let [keys, ndigs] = await keeper!.rotate( + const states = kargs.states == undefined ? [] : kargs.states; + const rstates = kargs.rstates == undefined ? [] : kargs.rstates; + const [keys, ndigs] = await keeper!.rotate( ncodes, transferable, states, rstates ); - let cuts = kargs.cuts ?? []; - let adds = kargs.adds ?? []; - let data = kargs.data != undefined ? [kargs.data] : []; - let toad = kargs.toad; - let serder = rotate({ + const cuts = kargs.cuts ?? []; + const adds = kargs.adds ?? []; + const data = kargs.data != undefined ? [kargs.data] : []; + const toad = kargs.toad; + const serder = rotate({ pre: pre, keys: keys, dig: dig, @@ -341,9 +341,9 @@ export class Identifier { data: data, }); - let sigs = await keeper.sign(b(serder.raw)); + const sigs = await keeper.sign(b(serder.raw)); - var jsondata: any = { + const jsondata: any = { rot: serder.ked, sigs: sigs, smids: @@ -357,7 +357,7 @@ export class Identifier { }; jsondata[keeper.algo] = keeper.params(); - let res = this.client.fetch('/identifiers/' + name, 'PUT', jsondata); + const res = this.client.fetch('/identifiers/' + name, 'PUT', jsondata); return new EventResult(serder, sigs, res); } @@ -390,7 +390,7 @@ export class Identifier { sigs: sigs, }; - let res = this.client.fetch( + const res = this.client.fetch( '/identifiers/' + name + '/endroles', 'POST', jsondata @@ -430,7 +430,7 @@ export class Identifier { * @returns {Promise} - A promise to the list of members */ async members(name: string): Promise { - let res = await this.client.fetch( + const res = await this.client.fetch( '/identifiers/' + name + '/members', 'GET', undefined @@ -460,7 +460,7 @@ export class EventResult { } async op(): Promise { - let res = await this.promise; + const res = await this.promise; return await res.json(); } } diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 10790592..1e3a6e69 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -107,13 +107,13 @@ export class SignifyClient { async state(): Promise { const caid = this.controller?.pre; - let res = await fetch(this.url + `/agent/${caid}`); + const res = await fetch(this.url + `/agent/${caid}`); if (res.status == 404) { throw new Error(`agent does not exist for controller ${caid}`); } const data = await res.json(); - let state = new State(); + const state = new State(); state.agent = data.agent ?? {}; state.controller = data.controller ?? {}; state.ridx = data.ridx ?? 0; @@ -170,9 +170,9 @@ export class SignifyClient { data: any, extraHeaders?: Headers ): Promise { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); - let final_headers = new Headers(); + const final_headers = new Headers(); headers.set('Signify-Resource', this.controller.pre); headers.set( @@ -181,7 +181,7 @@ export class SignifyClient { ); headers.set('Content-Type', 'application/json'); - let _body = method == 'GET' ? null : JSON.stringify(data); + const _body = method == 'GET' ? null : JSON.stringify(data); if (_body !== null) { headers.set('Content-Length', String(_body.length)); } @@ -203,7 +203,7 @@ export class SignifyClient { final_headers.append(key, value); }); } - let res = await fetch(this.url + path, { + const res = await fetch(this.url + path, { method: method, body: _body, headers: final_headers, @@ -255,7 +255,7 @@ export class SignifyClient { keeper.signers[0].verfer ); - let headers = new Headers(); + const headers = new Headers(); headers.set('Signify-Resource', hab.prefix); headers.set( 'Signify-Timestamp', @@ -267,7 +267,7 @@ export class SignifyClient { } else { headers.set('Content-Length', '0'); } - let signed_headers = authenticator.sign( + const signed_headers = authenticator.sign( headers, method, path.split('?')[0] @@ -299,9 +299,9 @@ export class SignifyClient { * @returns {Promise} A promise to the result of the approval */ async approveDelegation(): Promise { - let sigs = this.controller.approveDelegation(this.agent!); + const sigs = this.controller.approveDelegation(this.agent!); - let data = { + const data = { ixn: this.controller.serder.ked, sigs: sigs, }; @@ -359,7 +359,7 @@ export class SignifyClient { * @returns {Promise} A promise to the result of the rotation */ async rotate(nbran: string, aids: string[]): Promise { - let data = this.controller.rotate(nbran, aids); + const data = this.controller.rotate(nbran, aids); return await fetch(this.url + '/agent/' + this.controller.pre, { method: 'PUT', body: JSON.stringify(data), diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index 2546ef62..c4485407 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -26,7 +26,7 @@ export class Contacts { filterField?: string, filterValue?: string ): Promise { - let params = new URLSearchParams(); + const params = new URLSearchParams(); if (group !== undefined) { params.append('group', group); } @@ -35,9 +35,9 @@ export class Contacts { params.append('filter_value', filterValue); } - let path = `/contacts` + '?' + params.toString(); - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/contacts` + '?' + params.toString(); + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -48,9 +48,9 @@ export class Contacts { * @returns {Promise} A promise to the contact */ async get(pre: string): Promise { - let path = `/contacts/` + pre; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/contacts/` + pre; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -62,10 +62,10 @@ export class Contacts { * @returns {Promise} A promise to the result of the addition */ async add(pre: string, info: any): Promise { - let path = `/contacts/` + pre; - let method = 'POST'; + const path = `/contacts/` + pre; + const method = 'POST'; - let res = await this.client.fetch(path, method, info); + const res = await this.client.fetch(path, method, info); return await res.json(); } @@ -76,10 +76,10 @@ export class Contacts { * @returns {Promise} A promise to the result of the deletion */ async delete(pre: string): Promise { - let path = `/contacts/` + pre; - let method = 'DELETE'; + const path = `/contacts/` + pre; + const method = 'DELETE'; - let res = await this.client.fetch(path, method, null); + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -91,10 +91,10 @@ export class Contacts { * @returns {Promise} A promise to the result of the update */ async update(pre: string, info: any): Promise { - let path = `/contacts/` + pre; - let method = 'PUT'; + const path = `/contacts/` + pre; + const method = 'PUT'; - let res = await this.client.fetch(path, method, info); + const res = await this.client.fetch(path, method, info); return await res.json(); } } @@ -119,9 +119,9 @@ export class Challenges { * @returns {Promise} A promise to the list of random words */ async generate(strength: number = 128): Promise { - let path = `/challenges?strength=${strength.toString()}`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/challenges?strength=${strength.toString()}`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -138,9 +138,9 @@ export class Challenges { recipient: string, words: string[] ): Promise { - let hab = await this.client.identifiers().get(name); - let exchanges = this.client.exchanges(); - let resp = await exchanges.send( + const hab = await this.client.identifiers().get(name); + const exchanges = this.client.exchanges(); + const resp = await exchanges.send( name, 'challenge', hab, @@ -164,12 +164,12 @@ export class Challenges { source: string, words: string[] ): Promise { - let path = `/challenges/${name}/verify/${source}`; - let method = 'POST'; - let data = { + const path = `/challenges/${name}/verify/${source}`; + const method = 'POST'; + const data = { words: words, }; - let res = await this.client.fetch(path, method, data); + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -186,12 +186,12 @@ export class Challenges { source: string, said: string ): Promise { - let path = `/challenges/${name}/verify/${source}`; - let method = 'PUT'; - let data = { + const path = `/challenges/${name}/verify/${source}`; + const method = 'PUT'; + const data = { said: said, }; - let res = await this.client.fetch(path, method, data); + const res = await this.client.fetch(path, method, data); return res; } } diff --git a/src/keri/app/controller.ts b/src/keri/app/controller.ts index c904427f..e9fdac06 100644 --- a/src/keri/app/controller.ts +++ b/src/keri/app/controller.ts @@ -36,7 +36,7 @@ export class Agent { } private parse(agent: Agent) { - let [state, verfer] = this.event(agent); + const [state, verfer] = this.event(agent); this.sn = new CesrNumber({}, undefined, state['s']).num; this.said = state['d']; @@ -61,20 +61,20 @@ export class Agent { throw new Error(`agent inception event can only have one key`); } - let verfer = new Verfer({ qb64: evt['k'][0] }); + const verfer = new Verfer({ qb64: evt['k'][0] }); if (evt['n'].length !== 1) { throw new Error(`agent inception event can only have one next key`); } - let diger = new Diger({ qb64: evt['n'][0] }); + const diger = new Diger({ qb64: evt['n'][0] }); - let tholder = new Tholder({ sith: evt['kt'] }); + const tholder = new Tholder({ sith: evt['kt'] }); if (tholder.num !== 1) { throw new Error(`invalid threshold ${tholder.num}, must be 1`); } - let ntholder = new Tholder({ sith: evt['nt'] }); + const ntholder = new Tholder({ sith: evt['nt'] }); if (ntholder.num !== 1) { throw new Error( `invalid next threshold ${ntholder.num}, must be 1` @@ -113,7 +113,7 @@ export class Controller { this.salter = new Salter({ qb64: this.bran, tier: this.tier }); - let creator = new SaltyCreator(this.salter.qb64, this.tier, this.stem); + const creator = new SaltyCreator(this.salter.qb64, this.tier, this.stem); this.signer = creator .create( @@ -161,9 +161,9 @@ export class Controller { } approveDelegation(_agent: Agent) { - let seqner = new Seqner({ sn: _agent.sn }); - let anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said }; - let sn = new CesrNumber({}, undefined, this.serder.ked['s']).num + 1; + const seqner = new Seqner({ sn: _agent.sn }); + const anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said }; + const sn = new CesrNumber({}, undefined, this.serder.ked['s']).num + 1; this.serder = interact({ pre: this.serder.pre, dig: this.serder.ked['d'], @@ -180,7 +180,7 @@ export class Controller { } get event() { - let siger = this.signer.sign(this.serder.raw, 0); + const siger = this.signer.sign(this.serder.raw, 0); return [this.serder, siger]; } @@ -205,12 +205,12 @@ export class Controller { } rotate(bran: string, aids: Array) { - let nbran = MtrDex.Salt_128 + 'A' + bran.substring(0, 21); // qb64 salt for seed - let nsalter = new Salter({ qb64: nbran, tier: this.tier }); - let nsigner = this.salter.signer(undefined, false); + const nbran = MtrDex.Salt_128 + 'A' + bran.substring(0, 21); // qb64 salt for seed + const nsalter = new Salter({ qb64: nbran, tier: this.tier }); + const nsigner = this.salter.signer(undefined, false); - let creator = new SaltyCreator(this.salter.qb64, this.tier, this.stem); - let signer = creator + const creator = new SaltyCreator(this.salter.qb64, this.tier, this.stem); + const signer = creator .create( undefined, 1, @@ -223,7 +223,7 @@ export class Controller { ) .signers.pop(); - let ncreator = new SaltyCreator(nsalter.qb64, this.tier, this.stem); + const ncreator = new SaltyCreator(nsalter.qb64, this.tier, this.stem); this.signer = ncreator .create( undefined, @@ -252,7 +252,7 @@ export class Controller { this.keys = [this.signer.verfer.qb64, signer?.verfer.qb64]; this.ndigs = [new Diger({}, this.nsigner.verfer.qb64b).qb64]; - let rot = rotate({ + const rot = rotate({ pre: this.pre, keys: this.keys, dig: this.serder.ked['d'], @@ -261,32 +261,32 @@ export class Controller { ndigs: this.ndigs, }); - let sigs = [ + const sigs = [ signer?.sign(b(rot.raw), 1, false, 0).qb64, this.signer.sign(rot.raw, 0).qb64, ]; - let encrypter = new Encrypter({}, b(nsigner.verfer.qb64)); - let decrypter = new Decrypter({}, nsigner.qb64b); - let sxlt = encrypter.encrypt(b(this.bran)).qb64; + const encrypter = new Encrypter({}, b(nsigner.verfer.qb64)); + const decrypter = new Decrypter({}, nsigner.qb64b); + const sxlt = encrypter.encrypt(b(this.bran)).qb64; - let keys: Record = {}; + const keys: Record = {}; - for (let aid of aids) { - let pre: string = aid['prefix'] as string; + for (const aid of aids) { + const pre: string = aid['prefix'] as string; if ('salty' in aid) { console.log('salty aid to rotate'); console.log(aid); - let salty: any = aid['salty']; - let cipher = new Cipher({ qb64: salty['sxlt'] }); - let dnxt = decrypter.decrypt(null, cipher).qb64; + const salty: any = aid['salty']; + const cipher = new Cipher({ qb64: salty['sxlt'] }); + const dnxt = decrypter.decrypt(null, cipher).qb64; // Now we have the AID salt, use it to verify against the current public keys - let acreator = new SaltyCreator( + const acreator = new SaltyCreator( dnxt, salty['tier'], salty['stem'] ); - let signers = acreator.create( + const signers = acreator.create( salty['icodes'], undefined, MtrDex.Ed25519_Seed, @@ -296,36 +296,36 @@ export class Controller { salty['kidx'], false ); - let _signers = []; - for (let signer of signers.signers) { + const _signers = []; + for (const signer of signers.signers) { _signers.push(signer.verfer.qb64); } - let pubs = aid['state']['k']; + const pubs = aid['state']['k']; if (pubs.join(',') != _signers.join(',')) { throw new Error('Invalid Salty AID'); } - let asxlt = encrypter.encrypt(b(dnxt)).qb64; + const asxlt = encrypter.encrypt(b(dnxt)).qb64; keys[pre] = { sxlt: asxlt, }; } else if ('randy' in aid) { - let randy = aid['randy']; - let prxs = randy['prxs']; - let nxts = randy['nxts']; - - let nprxs = []; - let signers = []; - for (let prx of prxs) { - let cipher = new Cipher({ qb64: prx }); - let dsigner = decrypter.decrypt(null, cipher, true); + const randy = aid['randy']; + const prxs = randy['prxs']; + const nxts = randy['nxts']; + + const nprxs = []; + const signers = []; + for (const prx of prxs) { + const cipher = new Cipher({ qb64: prx }); + const dsigner = decrypter.decrypt(null, cipher, true); signers.push(dsigner); nprxs.push(encrypter.encrypt(b(dsigner.qb64)).qb64); } - let pubs = aid['state']['k']; - let _signers = []; - for (let signer of signers) { + const pubs = aid['state']['k']; + const _signers = []; + for (const signer of signers) { _signers.push(signer.verfer.qb64); } @@ -335,8 +335,8 @@ export class Controller { ); } - let nnxts = []; - for (let nxt of nxts) { + const nnxts = []; + for (const nxt of nxts) { nnxts.push(this.recrypt(nxt, decrypter, encrypter)); } @@ -349,7 +349,7 @@ export class Controller { } } - let data = { + const data = { rot: rot.ked, sigs: sigs, sxlt: sxlt, @@ -359,8 +359,8 @@ export class Controller { } recrypt(enc: string, decrypter: Decrypter, encrypter: Encrypter) { - let cipher = new Cipher({ qb64: enc }); - let dnxt = decrypter.decrypt(null, cipher).qb64; + const cipher = new Cipher({ qb64: enc }); + const dnxt = decrypter.decrypt(null, cipher).qb64; return encrypter.encrypt(b(dnxt)).qb64; } } diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index 193f7588..1b23d79d 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -4,15 +4,15 @@ import { Salter } from '../core/salter'; import { Matter, MtrDex } from '../core/matter'; export function randomPasscode(): string { - let raw = libsodium.randombytes_buf(16); - let salter = new Salter({ raw: raw }); + const raw = libsodium.randombytes_buf(16); + const salter = new Salter({ raw: raw }); return salter.qb64.substring(2); } export function randomNonce(): string { - let seed = libsodium.randombytes_buf(libsodium.crypto_sign_SEEDBYTES); - let seedqb64 = new Matter({ raw: seed, code: MtrDex.Ed25519_Seed }); + const seed = libsodium.randombytes_buf(libsodium.crypto_sign_SEEDBYTES); + const seedqb64 = new Matter({ raw: seed, code: MtrDex.Ed25519_Seed }); return seedqb64.qb64; } @@ -33,9 +33,9 @@ export class Oobis { * @returns {Promise} A promise to the OOBI(s) */ async get(name: string, role: string = 'agent'): Promise { - let path = `/identifiers/${name}/oobis?role=${role}`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/identifiers/${name}/oobis?role=${role}`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -47,15 +47,15 @@ export class Oobis { * @returns {Promise} A promise to the long-running operation */ async resolve(oobi: string, alias?: string): Promise { - let path = `/oobis`; - let data: any = { + const path = `/oobis`; + const data: any = { url: oobi, }; if (alias !== undefined) { data.oobialias = alias; } - let method = 'POST'; - let res = await this.client.fetch(path, method, data); + const method = 'POST'; + const res = await this.client.fetch(path, method, data); return await res.json(); } } @@ -88,10 +88,10 @@ export class Operations { * @returns {Promise} A promise to the status of the operation */ async get(name: string): Promise> { - let path = `/operations/${name}`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data); + const path = `/operations/${name}`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data); return await res.json(); } } @@ -116,10 +116,10 @@ export class KeyEvents { * @returns {Promise} A promise to the key events */ async get(pre: string): Promise { - let path = `/events?pre=${pre}`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data); + const path = `/events?pre=${pre}`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data); return await res.json(); } } @@ -144,10 +144,10 @@ export class KeyStates { * @returns {Promise} A promise to the key states */ async get(pre: string): Promise { - let path = `/states?pre=${pre}`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data); + const path = `/states?pre=${pre}`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -158,10 +158,10 @@ export class KeyStates { * @returns {Promise} A promise to the key states */ async list(pres: string[]): Promise { - let path = `/states?${pres.map((pre) => `pre=${pre}`).join('&')}`; - let data = null; - let method = 'GET'; - let res = await this.client.fetch(path, method, data); + const path = `/states?${pres.map((pre) => `pre=${pre}`).join('&')}`; + const data = null; + const method = 'GET'; + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -174,8 +174,8 @@ export class KeyStates { * @returns {Promise} A promise to the long-running operation */ async query(pre: string, sn?: number, anchor?: string): Promise { - let path = `/queries`; - let data: any = { + const path = `/queries`; + const data: any = { pre: pre, }; if (sn !== undefined) { @@ -185,8 +185,8 @@ export class KeyStates { data.anchor = anchor; } - let method = 'POST'; - let res = await this.client.fetch(path, method, data); + const method = 'POST'; + const res = await this.client.fetch(path, method, data); return await res.json(); } } diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 6676a6d6..5a65b409 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -137,21 +137,21 @@ export class Credentials { * @returns {Promise} A promise to the list of credentials */ async list(kargs: CredentialFilter = {}): Promise { - let path = `/credentials/query`; - let filtr = kargs.filter === undefined ? {} : kargs.filter; - let sort = kargs.sort === undefined ? [] : kargs.sort; - let limit = kargs.limit === undefined ? 25 : kargs.limit; - let skip = kargs.skip === undefined ? 0 : kargs.skip; + const path = `/credentials/query`; + const filtr = kargs.filter === undefined ? {} : kargs.filter; + const sort = kargs.sort === undefined ? [] : kargs.sort; + const limit = kargs.limit === undefined ? 25 : kargs.limit; + const skip = kargs.skip === undefined ? 0 : kargs.skip; - let data = { + const data = { filter: filtr, sort: sort, skip: skip, limit: limit, }; - let method = 'POST'; + const method = 'POST'; - let res = await this.client.fetch(path, method, data, undefined); + const res = await this.client.fetch(path, method, data, undefined); return await res.json(); } @@ -168,12 +168,12 @@ export class Credentials { said: string, includeCESR: boolean = false ): Promise { - let path = `/identifiers/${name}/credentials/${said}`; - let method = 'GET'; - let headers = includeCESR + const path = `/identifiers/${name}/credentials/${said}`; + const method = 'GET'; + const headers = includeCESR ? new Headers({ Accept: 'application/json+cesr' }) : new Headers({ Accept: 'application/json' }); - let res = await this.client.fetch(path, method, null, headers); + const res = await this.client.fetch(path, method, null, headers); return includeCESR ? await res.text() : await res.json(); } @@ -278,16 +278,16 @@ export class Credentials { * @returns {Promise} A promise to the long-running operation */ async revoke(name: string, said: string): Promise { - let hab = await this.client.identifiers().get(name); - let pre: string = hab.prefix; + const hab = await this.client.identifiers().get(name); + const pre: string = hab.prefix; const vs = versify(Ident.KERI, undefined, Serials.JSON, 0); const dt = new Date().toISOString().replace('Z', '000+00:00'); - let cred = await this.get(name, said); + const cred = await this.get(name, said); // Create rev - let _rev = { + const _rev = { v: vs, t: Ilks.rev, d: '', @@ -298,23 +298,23 @@ export class Credentials { dt: dt, }; - let [, rev] = Saider.saidify(_rev); + const [, rev] = Saider.saidify(_rev); // create ixn let ixn = {}; let sigs = []; - let state = hab.state; + const state = hab.state; if (state.c !== undefined && state.c.includes('EO')) { var estOnly = true; } else { var estOnly = false; } - let sn = Number(state.s); - let dig = state.d; + const sn = Number(state.s); + const dig = state.d; - let data: any = [ + const data: any = [ { i: rev.i, s: rev.s, @@ -325,7 +325,7 @@ export class Credentials { // TODO implement rotation event throw new Error('Establishment only not implemented'); } else { - let serder = interact({ + const serder = interact({ pre: pre, sn: sn + 1, data: data, @@ -333,23 +333,23 @@ export class Credentials { version: undefined, kind: undefined, }); - let keeper = this.client!.manager!.get(hab); + const keeper = this.client!.manager!.get(hab); sigs = await keeper.sign(b(serder.raw)); ixn = serder.ked; } - let body = { + const body = { rev: rev, ixn: ixn, sigs: sigs, }; - let path = `/identifiers/${name}/credentials/${said}`; - let method = 'DELETE'; - let headers = new Headers({ + const path = `/identifiers/${name}/credentials/${said}`; + const method = 'DELETE'; + const headers = new Headers({ Accept: 'application/json+cesr', }); - let res = await this.client.fetch(path, method, body, headers); + const res = await this.client.fetch(path, method, body, headers); return await res.json(); } @@ -368,11 +368,11 @@ export class Credentials { recipient: string, include: boolean = true ): Promise { - let hab = await this.client.identifiers().get(name); - let pre: string = hab.prefix; + const hab = await this.client.identifiers().get(name); + const pre: string = hab.prefix; - let cred = await this.get(name, said); - let data = { + const cred = await this.get(name, said); + const data = { i: cred.sad.i, s: cred.sad.s, n: said, @@ -392,28 +392,28 @@ export class Credentials { const [, sad] = Saider.saidify(_sad); const exn = new Serder(sad); - let keeper = this.client!.manager!.get(hab); + const keeper = this.client!.manager!.get(hab); - let sig = keeper.sign(b(exn.raw), true); + const sig = keeper.sign(b(exn.raw), true); - let siger = new Siger({ qb64: sig[0] }); - let seal = ['SealLast', { i: pre }]; + const siger = new Siger({ qb64: sig[0] }); + const seal = ['SealLast', { i: pre }]; let ims = messagize(exn, [siger], seal, undefined, undefined, true); ims = ims.slice(JSON.stringify(exn.ked).length); - let body = { + const body = { exn: exn.ked, sig: new TextDecoder().decode(ims), recipient: recipient, include: include, }; - let path = `/identifiers/${name}/credentials/${said}/presentations`; - let method = 'POST'; - let headers = new Headers({ + const path = `/identifiers/${name}/credentials/${said}/presentations`; + const method = 'POST'; + const headers = new Headers({ Accept: 'application/json+cesr', }); - let res = await this.client.fetch(path, method, body, headers); + const res = await this.client.fetch(path, method, body, headers); return await res.text(); } @@ -432,10 +432,10 @@ export class Credentials { schema: string, issuer?: string ): Promise { - let hab = await this.client.identifiers().get(name); - let pre: string = hab.prefix; + const hab = await this.client.identifiers().get(name); + const pre: string = hab.prefix; - let data: any = { + const data: any = { s: schema, }; if (issuer !== undefined) { @@ -456,27 +456,27 @@ export class Credentials { const [, sad] = Saider.saidify(_sad); const exn = new Serder(sad); - let keeper = this.client!.manager!.get(hab); + const keeper = this.client!.manager!.get(hab); - let sig = await keeper.sign(b(exn.raw), true); + const sig = await keeper.sign(b(exn.raw), true); - let siger = new Siger({ qb64: sig[0] }); - let seal = ['SealLast', { i: pre }]; + const siger = new Siger({ qb64: sig[0] }); + const seal = ['SealLast', { i: pre }]; let ims = messagize(exn, [siger], seal, undefined, undefined, true); ims = ims.slice(JSON.stringify(exn.ked).length); - let body = { + const body = { exn: exn.ked, sig: new TextDecoder().decode(ims), recipient: recipient, }; - let path = `/identifiers/${name}/requests`; - let method = 'POST'; - let headers = new Headers({ + const path = `/identifiers/${name}/requests`; + const method = 'POST'; + const headers = new Headers({ Accept: 'application/json+cesr', }); - let res = await this.client.fetch(path, method, body, headers); + const res = await this.client.fetch(path, method, body, headers); return await res.text(); } } @@ -521,7 +521,7 @@ export class RegistryResult { } async op(): Promise { - let res = await this.promise; + const res = await this.promise; return await res.json(); } } @@ -546,9 +546,9 @@ export class Registries { * @returns {Promise} A promise to the list of registries */ async list(name: string): Promise { - let path = `/identifiers/${name}/registries`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/identifiers/${name}/registries`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -566,30 +566,30 @@ export class Registries { baks = [], nonce, }: CreateRegistryArgs): Promise { - let hab = await this.client.identifiers().get(name); - let pre: string = hab.prefix; + const hab = await this.client.identifiers().get(name); + const pre: string = hab.prefix; - let cnfg: string[] = []; + const cnfg: string[] = []; if (noBackers) { cnfg.push(TraitDex.NoBackers); } - let state = hab.state; - let estOnly = state.c !== undefined && state.c.includes('EO'); + const state = hab.state; + const estOnly = state.c !== undefined && state.c.includes('EO'); if (estOnly) { cnfg.push(TraitDex.EstOnly); } - let regser = vdr.incept({ pre, baks, toad, nonce, cnfg }); + const regser = vdr.incept({ pre, baks, toad, nonce, cnfg }); if (estOnly) { throw new Error('establishment only not implemented'); } else { - let state = hab.state; - let sn = Number(state.s); - let dig = state.d; + const state = hab.state; + const sn = Number(state.s); + const dig = state.d; - let data: any = [ + const data: any = [ { i: regser.pre, s: '0', @@ -597,7 +597,7 @@ export class Registries { }, ]; - let serder = interact({ + const serder = interact({ pre: pre, sn: sn + 1, data: data, @@ -605,9 +605,9 @@ export class Registries { version: Versionage, kind: Serials.JSON, }); - let keeper = this.client.manager!.get(hab); - let sigs = await keeper.sign(b(serder.raw)); - let res = this.createFromEvents( + const keeper = this.client.manager!.get(hab); + const sigs = await keeper.sign(b(serder.raw)); + const res = this.createFromEvents( hab, name, registryName, @@ -627,16 +627,16 @@ export class Registries { ixn: Dict, sigs: any[] ) { - let path = `/identifiers/${name}/registries`; - let method = 'POST'; + const path = `/identifiers/${name}/registries`; + const method = 'POST'; - let data: any = { + const data: any = { name: registryName, vcp: vcp, ixn: ixn, sigs: sigs, }; - let keeper = this.client!.manager!.get(hab); + const keeper = this.client!.manager!.get(hab); data[keeper.algo] = keeper.params(); return this.client.fetch(path, method, data); @@ -662,9 +662,9 @@ export class Schemas { * @returns {Promise} A promise to the schema */ async get(said: string): Promise { - let path = `/schema/${said}`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/schema/${said}`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -674,9 +674,9 @@ export class Schemas { * @returns {Promise} A promise to the list of schemas */ async list(): Promise { - let path = `/schema`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/schema`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } } @@ -745,8 +745,8 @@ export class Ipex { grant: string, datetime?: string ): Promise<[Serder, string[], string]> { - let hab = await this.client.identifiers().get(name); - let data: any = { + const hab = await this.client.identifiers().get(name); + const data: any = { m: message, }; diff --git a/src/keri/app/escrowing.ts b/src/keri/app/escrowing.ts index ec305cf0..dcd8e9c5 100644 --- a/src/keri/app/escrowing.ts +++ b/src/keri/app/escrowing.ts @@ -21,14 +21,14 @@ export class Escrows { * @returns {Promise} A promise to the list of replay messages */ async listReply(route?: string): Promise { - let params = new URLSearchParams(); + const params = new URLSearchParams(); if (route !== undefined) { params.append('route', route); } - let path = `/escrows/rpy` + '?' + params.toString(); - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/escrows/rpy` + '?' + params.toString(); + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } } diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index 4ecde1f9..d000c5a8 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -41,8 +41,8 @@ export class Exchanges { datetime?: string, dig?: string ): Promise<[Serder, string[], string]> { - let keeper = this.client.manager!.get(sender); - let [exn, end] = exchange( + const keeper = this.client.manager!.get(sender); + const [exn, end] = exchange( route, payload, sender['prefix'], @@ -53,7 +53,7 @@ export class Exchanges { embeds ); - let sigs = await keeper.sign(b(exn.raw)); + const sigs = await keeper.sign(b(exn.raw)); return [exn, sigs, d(end)]; } @@ -78,7 +78,7 @@ export class Exchanges { embeds: Dict, recipients: string[] ): Promise { - let [exn, sigs, atc] = await this.createExchangeMessage( + const [exn, sigs, atc] = await this.createExchangeMessage( sender, route, payload, @@ -113,9 +113,9 @@ export class Exchanges { atc: string, recipients: string[] ): Promise { - let path = `/identifiers/${name}/exchanges`; - let method = 'POST'; - let data: any = { + const path = `/identifiers/${name}/exchanges`; + const method = 'POST'; + const data: any = { tpc: topic, exn: exn.ked, sigs: sigs, @@ -123,7 +123,7 @@ export class Exchanges { rec: recipients, }; - let res = await this.client.fetch(path, method, data); + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -164,19 +164,19 @@ export function exchange( let e = {} as Dict; let end = ''; Object.entries(ems).forEach(([key, value]) => { - let serder = value[0]; - let atc = value[1]; + const serder = value[0]; + const atc = value[1]; e[key] = serder.ked; if (atc == undefined) { return; } let pathed = ''; - let pather = new Pather({}, undefined, ['e', key]); + const pather = new Pather({}, undefined, ['e', key]); pathed += pather.qb64; pathed += atc; - let counter = new Counter({ + const counter = new Counter({ code: CtrDex.PathedMaterialQuadlets, count: Math.floor(pathed.length / 4), }); @@ -195,12 +195,12 @@ export function exchange( attrs['i'] = recipient; } - let a = { + const a = { ...attrs, ...payload, }; - let _ked = { + const _ked = { v: vs, t: ilk, d: '', @@ -212,9 +212,9 @@ export function exchange( a: a, e: e, }; - let [, ked] = Saider.saidify(_ked); + const [, ked] = Saider.saidify(_ked); - let exn = new Serder(ked); + const exn = new Serder(ked); return [exn, b(end)]; } diff --git a/src/keri/app/grouping.ts b/src/keri/app/grouping.ts index 153cdf13..0de192c6 100644 --- a/src/keri/app/grouping.ts +++ b/src/keri/app/grouping.ts @@ -22,9 +22,9 @@ export class Groups { * @returns {Promise} A promise to the list of replay messages */ async getRequest(said: string): Promise { - let path = `/multisig/request/` + said; - let method = 'GET'; - let res = await this.client.fetch(path, method, null); + const path = `/multisig/request/` + said; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); return await res.json(); } @@ -43,14 +43,14 @@ export class Groups { sigs: string[], atc: string ): Promise { - let path = `/identifiers/${name}/multisig/request`; - let method = 'POST'; - let data = { + const path = `/identifiers/${name}/multisig/request`; + const method = 'POST'; + const data = { exn: exn, sigs: sigs, atc: atc, }; - let res = await this.client.fetch(path, method, data); + const res = await this.client.fetch(path, method, data); return await res.json(); } @@ -74,9 +74,9 @@ export class Groups { smids: string[], rmids: string[] ): Promise { - let path = `/identifiers/${name}/multisig/join`; - let method = 'POST'; - let data = { + const path = `/identifiers/${name}/multisig/join`; + const method = 'POST'; + const data = { tpc: 'multisig', rot: rot.ked, sigs: sigs, @@ -84,7 +84,7 @@ export class Groups { smids: smids, rmids: rmids }; - let res = await this.client.fetch(path, method, data); + const res = await this.client.fetch(path, method, data); return await res.json(); } diff --git a/src/keri/app/habery.ts b/src/keri/app/habery.ts index e21638de..08da4b3e 100644 --- a/src/keri/app/habery.ts +++ b/src/keri/app/habery.ts @@ -65,8 +65,8 @@ export class Habery { throw new Error('Bran (passcode seed material) too short.'); } - let bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed - let signer = new Salter({ qb64: bran }).signer( + const bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed + const signer = new Salter({ qb64: bran }).signer( MtrDex.Ed25519_Seed, false ); @@ -76,7 +76,7 @@ export class Habery { } } let algo; - let salter = salt != undefined ? new Salter({ qb64: salt }) : undefined; + const salter = salt != undefined ? new Salter({ qb64: salt }) : undefined; if (salt != undefined) { algo = Algos.salty; } else { @@ -133,7 +133,7 @@ export class Habery { code = MtrDex.Ed25519N; } - let [verfers, digers] = this._mgr.incept({ + const [verfers, digers] = this._mgr.incept({ icount: icount, ncount: ncount, stem: this.name, @@ -150,7 +150,7 @@ export class Habery { nsith = `${Math.max(1, Math.ceil(ncount / 2)).toString(16)}`; } - let cnfg = new Array(); + const cnfg = new Array(); if (estOnly) { cnfg.push(TraitDex.EstOnly); } @@ -158,8 +158,8 @@ export class Habery { cnfg.push(TraitDex.DoNotDelegate); } - let keys = Array.from(verfers, (verfer: Verfer) => verfer.qb64); - let ndigs = Array.from(digers, (diger: Diger) => diger.qb64); + const keys = Array.from(verfers, (verfer: Verfer) => verfer.qb64); + const ndigs = Array.from(digers, (diger: Diger) => diger.qb64); const icp = incept({ keys, diff --git a/src/keri/app/notifying.ts b/src/keri/app/notifying.ts index 8a947bb2..5b631f96 100644 --- a/src/keri/app/notifying.ts +++ b/src/keri/app/notifying.ts @@ -23,16 +23,16 @@ export class Notifications { * @returns {Promise} A promise to the list of notifications */ async list(start: number = 0, end: number = 24): Promise { - let extraHeaders = new Headers(); + const extraHeaders = new Headers(); extraHeaders.append('Range', `notes=${start}-${end}`); - let path = `/notifications`; - let method = 'GET'; - let res = await this.client.fetch(path, method, null, extraHeaders); + const path = `/notifications`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null, extraHeaders); - let cr = res.headers.get('content-range'); - let range = parseRangeHeaders(cr, 'notes'); - let notes = await res.json(); + const cr = res.headers.get('content-range'); + const range = parseRangeHeaders(cr, 'notes'); + const notes = await res.json(); return { start: range.start, @@ -49,9 +49,9 @@ export class Notifications { * @returns {Promise} A promise to the result of the marking */ async mark(said: string): Promise { - let path = `/notifications/` + said; - let method = 'PUT'; - let res = await this.client.fetch(path, method, null); + const path = `/notifications/` + said; + const method = 'PUT'; + const res = await this.client.fetch(path, method, null); return await res.text(); } @@ -62,9 +62,9 @@ export class Notifications { * @returns {Promise} A promise to the result of the deletion */ async delete(said: string): Promise { - let path = `/notifications/` + said; - let method = 'DELETE'; - let res = await this.client.fetch(path, method, null); + const path = `/notifications/` + said; + const method = 'DELETE'; + const res = await this.client.fetch(path, method, null); return await res.json(); } } diff --git a/src/keri/core/authing.ts b/src/keri/core/authing.ts index 3e0c8930..5f816f0e 100644 --- a/src/keri/core/authing.ts +++ b/src/keri/core/authing.ts @@ -20,11 +20,11 @@ export class Authenticater { } verify(headers: Headers, method: string, path: string): boolean { - let siginput = headers.get('Signature-Input'); + const siginput = headers.get('Signature-Input'); if (siginput == null) { return false; } - let signature = headers.get('Signature'); + const signature = headers.get('Signature'); if (signature == null) { return false; } @@ -34,7 +34,7 @@ export class Authenticater { return false; } inputs.forEach((input) => { - let items = new Array(); + const items = new Array(); input.fields!.forEach((field: string) => { if (field.startsWith('@')) { if (field == '@method') { @@ -44,12 +44,12 @@ export class Authenticater { } } else { if (headers.has(field)) { - let value = normalize(headers.get(field) as string); + const value = normalize(headers.get(field) as string); items.push(`"${field}": ${value}`); } } }); - let values = new Array(); + const values = new Array(); values.push(`(${input.fields!.join(' ')})`); values.push(`created=${input.created}`); if (input.expires != undefined) { @@ -67,11 +67,11 @@ export class Authenticater { if (input.alg != undefined) { values.push(`alg=${input.alg}`); } - let params = values.join(';'); + const params = values.join(';'); items.push(`"@signature-params: ${params}"`); - let ser = items.join('\n'); - let signage = designature(signature!); - let cig = signage[0].markers.get(input.name); + const ser = items.join('\n'); + const signage = designature(signature!); + const cig = signage[0].markers.get(input.name); if (!this._verfer.verify(cig.raw, ser)) { throw new Error(`Signature for ${input.keyid} invalid.`); } @@ -90,7 +90,7 @@ export class Authenticater { fields = Authenticater.DefaultFields; } - let [header, sig] = siginput(this._csig, { + const [header, sig] = siginput(this._csig, { name: 'signify', method, path, @@ -104,10 +104,10 @@ export class Authenticater { headers.append(key, value); }); - let markers = new Map(); + const markers = new Map(); markers.set('signify', sig); - let signage = new Signage(markers, false); - let signed = signature([signage]); + const signage = new Signage(markers, false); + const signed = signature([signage]); signed.forEach((value, key) => { headers.append(key, value); }); diff --git a/src/keri/core/bexter.ts b/src/keri/core/bexter.ts index 4920181a..bf1abfcb 100644 --- a/src/keri/core/bexter.ts +++ b/src/keri/core/bexter.ts @@ -95,7 +95,7 @@ export class Bexter extends Matter { if (bext === undefined) throw new EmptyMaterialError('Missing bext string.'); - let match = Reb64.exec(bext); + const match = Reb64.exec(bext); if (!match) throw new Error('Invalid Base64.'); raw = Bexter._rawify(bext); @@ -108,21 +108,21 @@ export class Bexter extends Matter { } static _rawify(bext: string): Uint8Array { - let ts = bext.length % 4; // bext size mod 4 - let ws = (4 - ts) % 4; // pre conv wad size in chars - let ls = (3 - ts) % 3; // post conv lead size in bytes - let wad = new Array(ws); + const ts = bext.length % 4; // bext size mod 4 + const ws = (4 - ts) % 4; // pre conv wad size in chars + const ls = (3 - ts) % 3; // post conv lead size in bytes + const wad = new Array(ws); wad.fill('A'); - let base = wad.join('') + bext; // pre pad with wad of zeros in Base64 == 'A' - let raw = Base64.decode(base); // [ls:] // convert and remove leader + const base = wad.join('') + bext; // pre pad with wad of zeros in Base64 == 'A' + const raw = Base64.decode(base); // [ls:] // convert and remove leader return Uint8Array.from(raw).subarray(ls); // raw binary equivalent of text } get bext(): string { - let sizage = Matter.Sizes.get(this.code); - let wad = Uint8Array.from(new Array(sizage?.ls).fill(0)); - let bext = Base64.encode(Buffer.from([...wad, ...this.raw])); + const sizage = Matter.Sizes.get(this.code); + const wad = Uint8Array.from(new Array(sizage?.ls).fill(0)); + const bext = Base64.encode(Buffer.from([...wad, ...this.raw])); let ws = 0; if (sizage?.ls === 0 && bext !== undefined) { diff --git a/src/keri/core/cipher.ts b/src/keri/core/cipher.ts index 53095a5f..ba11262e 100644 --- a/src/keri/core/cipher.ts +++ b/src/keri/core/cipher.ts @@ -28,7 +28,7 @@ export class Cipher extends Matter { prikey: Uint8Array | undefined = undefined, seed: Uint8Array | undefined = undefined ) { - let decrypter = new Decrypter({ qb64b: prikey }, seed); + const decrypter = new Decrypter({ qb64b: prikey }, seed); return decrypter.decrypt(this.qb64b); } } diff --git a/src/keri/core/core.ts b/src/keri/core/core.ts index c607a453..6d4d148f 100644 --- a/src/keri/core/core.ts +++ b/src/keri/core/core.ts @@ -171,9 +171,9 @@ export function deversify( throw new Error(`Invalid serialization kind = ${kind}`); } - let ta = kind as keyof typeof Serials; + const ta = kind as keyof typeof Serials; kind = Serials[ta]; - let pa = proto as keyof typeof Ident; + const pa = proto as keyof typeof Ident; proto = Ident[pa]; return [proto, kind, version, size]; @@ -275,7 +275,7 @@ export function intToB64(i: number, l = 1): string { } } - let x = l - out.length; + const x = l - out.length; for (let i = 0; i < x; i++) { out = 'A' + out; } @@ -284,7 +284,7 @@ export function intToB64(i: number, l = 1): string { } export function intToB64b(n: number, l: number = 1): Uint8Array { - let s = intToB64(n, l); + const s = intToB64(n, l); return b(s); } @@ -294,7 +294,7 @@ export function b64ToInt(s: string): number { } let i = 0; - let rev = s.split('').reverse(); + const rev = s.split('').reverse(); rev.forEach((c: string, e: number) => { i |= B64IdxByChr.get(c)! << (e * 6); }); @@ -311,7 +311,7 @@ export function d(u?: Uint8Array): string { } export function concat(one: Uint8Array, two: Uint8Array): Uint8Array { - let out = new Uint8Array(one.length + two.length); + const out = new Uint8Array(one.length + two.length); out.set(one); out.set(two, one.length); return out; diff --git a/src/keri/core/counter.ts b/src/keri/core/counter.ts index 814da818..00fcdc0d 100644 --- a/src/keri/core/counter.ts +++ b/src/keri/core/counter.ts @@ -118,8 +118,8 @@ export class Counter { throw new Error(`"Unsupported code=${code}.`); } - let sizage = Counter.Sizes.get(code)!; - let cs = sizage.hs + sizage.ss; + const sizage = Counter.Sizes.get(code)!; + const cs = sizage.hs + sizage.ss; if (sizage.fs != cs || cs % 4 != 0) { throw new Error( `Whole code size not full size or not multiple of 4. cs=${cs} fs=${sizage.fs}.` @@ -137,7 +137,7 @@ export class Counter { this._code = code; this._count = count; } else if (qb64b != undefined) { - let qb64 = d(qb64b); + const qb64 = d(qb64b); this._exfil(qb64); } else if (qb64 != undefined) { this._exfil(qb64); @@ -167,7 +167,7 @@ export class Counter { countToB64(l?: number): string { if (l == undefined) { - let sizage = Counter.Sizes.get(this.code)!; + const sizage = Counter.Sizes.get(this.code)!; l = sizage.ss; } return intToB64(this.count, l); @@ -181,14 +181,14 @@ export class Counter { ): string { let parts = [major, minor, patch]; if (version != '') { - let ssplits = version.split('.'); - let splits = ssplits.map((x) => { + const ssplits = version.split('.'); + const splits = ssplits.map((x) => { if (x == '') return 0; return parseInt(x); }); - let off = splits.length; - let x = 3 - off; + const off = splits.length; + const x = 3 - off; for (let i = 0; i < x; i++) { splits.push(parts[i + off]); } @@ -211,11 +211,11 @@ export class Counter { } private _infil(): string { - let code = this.code; - let count = this.count; + const code = this.code; + const count = this.count; - let sizage = Counter.Sizes.get(code)!; - let cs = sizage.hs + sizage.ss; + const sizage = Counter.Sizes.get(code)!; + const cs = sizage.hs + sizage.ss; if (sizage.fs != cs || cs % 4 != 0) { throw new Error( `Whole code size not full size or not multiple of 4. cs=${cs} fs=${sizage.fs}.` @@ -226,7 +226,7 @@ export class Counter { throw new Error(`Invalid count=${count} for code=${code}.`); } - let both = `${code}${intToB64(count, sizage.ss)}`; + const both = `${code}${intToB64(count, sizage.ss)}`; if (both.length % 4) { throw new Error( @@ -242,30 +242,30 @@ export class Counter { throw new Error('Empty Material'); } - let first = qb64.slice(0, 2); + const first = qb64.slice(0, 2); if (!Counter.Hards.has(first)) { throw new Error(`Unexpected code ${first}`); } - let hs = Counter.Hards.get(first)!; + const hs = Counter.Hards.get(first)!; if (qb64.length < hs) { throw new Error(`Need ${hs - qb64.length} more characters.`); } - let hard = qb64.slice(0, hs); + const hard = qb64.slice(0, hs); if (!Counter.Sizes.has(hard)) { throw new Error(`Unsupported code ${hard}`); } - let sizage = Counter.Sizes.get(hard)!; - let cs = sizage!.hs + sizage!.ss; + const sizage = Counter.Sizes.get(hard)!; + const cs = sizage!.hs + sizage!.ss; if (qb64.length < cs) { throw new Error(`Need ${cs - qb64.length} more chars.`); } - let scount = qb64.slice(sizage.hs, sizage.hs + sizage.ss); - let count = b64ToInt(scount); + const scount = qb64.slice(sizage.hs, sizage.hs + sizage.ss); + const count = b64ToInt(scount); this._code = hard; this._count = count; diff --git a/src/keri/core/decrypter.ts b/src/keri/core/decrypter.ts index 840aaea9..b1ca0538 100644 --- a/src/keri/core/decrypter.ts +++ b/src/keri/core/decrypter.ts @@ -17,13 +17,13 @@ export class Decrypter extends Matter { } catch (e) { if (e instanceof EmptyMaterialError) { if (seed != undefined) { - let signer = new Signer({ qb64b: seed }); + const signer = new Signer({ qb64b: seed }); if (signer.code != MtrDex.Ed25519_Seed) { throw new Error( `Unsupported signing seed derivation code ${signer.code}` ); } - let sigkey = new Uint8Array( + const sigkey = new Uint8Array( signer.raw.length + signer.verfer.raw.length ); sigkey.set(signer.raw); @@ -63,8 +63,8 @@ export class Decrypter extends Matter { } _x25519(cipher: Cipher, prikey: Uint8Array, transferable: boolean = false) { - let pubkey = libsodium.crypto_scalarmult_base(prikey); - let plain = libsodium.crypto_box_seal_open(cipher.raw, pubkey, prikey); + const pubkey = libsodium.crypto_scalarmult_base(prikey); + const plain = libsodium.crypto_box_seal_open(cipher.raw, pubkey, prikey); if (cipher.code == MtrDex.X25519_Cipher_Salt) { return new Salter({ qb64b: plain }); } else if (cipher.code == MtrDex.X25519_Cipher_Seed) { diff --git a/src/keri/core/diger.ts b/src/keri/core/diger.ts index f3323e44..6ee17063 100644 --- a/src/keri/core/diger.ts +++ b/src/keri/core/diger.ts @@ -75,7 +75,7 @@ export class Diger extends Matter { blake3_256(ser: Uint8Array, dig: any) { const hasher = createHash(); - let digest = hasher.update(ser).digest(''); + const digest = hasher.update(ser).digest(''); return digest.toString() === dig.toString(); } } diff --git a/src/keri/core/encrypter.ts b/src/keri/core/encrypter.ts index ddaff633..0ac77b26 100644 --- a/src/keri/core/encrypter.ts +++ b/src/keri/core/encrypter.ts @@ -13,7 +13,7 @@ export class Encrypter extends Matter { verkey: Uint8Array | null = null ) { if (raw == undefined && verkey != null) { - let verfer = new Verfer({ qb64b: verkey }); + const verfer = new Verfer({ qb64b: verkey }); if ( !Array.from([MtrDex.Ed25519N, MtrDex.Ed25519]).includes( verfer.code @@ -36,9 +36,9 @@ export class Encrypter extends Matter { } verifySeed(seed: Uint8Array) { - let signer = new Signer({ qb64b: seed }); - let keypair = libsodium.crypto_sign_seed_keypair(signer.raw); - let pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( + const signer = new Signer({ qb64b: seed }); + const keypair = libsodium.crypto_sign_seed_keypair(signer.raw); + const pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( keypair.publicKey ); return arrayEquals(pubkey, this.raw); @@ -64,7 +64,7 @@ export class Encrypter extends Matter { } _x25519(ser: Uint8Array, pubkey: Uint8Array, code: string) { - let raw = libsodium.crypto_box_seal(ser, pubkey); + const raw = libsodium.crypto_box_seal(ser, pubkey); return new Cipher({ raw: raw, code: code }); } } diff --git a/src/keri/core/eventing.ts b/src/keri/core/eventing.ts index 669b4c0c..ff4af89b 100644 --- a/src/keri/core/eventing.ts +++ b/src/keri/core/eventing.ts @@ -21,7 +21,7 @@ import { Counter, CtrDex } from './counter'; import { Seqner } from './seqner'; import { TextEncoder } from 'util'; -let MaxIntThold = 2 ** 32 - 1; +const MaxIntThold = 2 ** 32 - 1; export interface RotateArgs { pre?: string; @@ -62,13 +62,13 @@ export function rotate({ kind = undefined, intive = true, }: RotateArgs) { - let vs = versify(Ident.KERI, version, kind, 0); - let _ilk = ilk; + const vs = versify(Ident.KERI, version, kind, 0); + const _ilk = ilk; if (_ilk != Ilks.rot && _ilk != Ilks.drt) { throw new Error(`Invalid ilk = ${ilk} for rot or drt.`); } - let sner = Number(sn); + const sner = Number(sn); if (sner < 1) { throw new Error(`Invalid sn = 0x${sner.toString()} for rot or drt.`); } @@ -80,7 +80,7 @@ export function rotate({ _isit = isith as number; } - let tholder = new Tholder({ sith: _isit }); + const tholder = new Tholder({ sith: _isit }); if (tholder.num != undefined && tholder.num < 1) { throw new Error(`Invalid sith = ${tholder.num} less than 1.`); } @@ -103,7 +103,7 @@ export function rotate({ _nsith = nsith; } - let ntholder = new Tholder({ sith: _nsith }); + const ntholder = new Tholder({ sith: _nsith }); if (ntholder.num != undefined && ntholder.num < 1) { throw new Error(`Invalid sith = ${ntholder.num} less than 1.`); } @@ -117,7 +117,7 @@ export function rotate({ } else { _wits = wits; } - let witset = new Set(_wits); + const witset = new Set(_wits); if (witset.size != _wits.length) { throw new Error(`Invalid wits = ${wits}, has duplicates.`); } @@ -128,7 +128,7 @@ export function rotate({ } else { _cuts = cuts; } - let cutset = new Set(_cuts); + const cutset = new Set(_cuts); if (cutset.size != _cuts.length) { throw new Error(`Invalid cuts = ${cuts}, has duplicates.`); } @@ -139,10 +139,10 @@ export function rotate({ } else { _adds = adds; } - let addset = new Set(_adds); + const addset = new Set(_adds); //non empty intersection of witset and addset - let witaddset = new Set([...witset].filter((x) => addset.has(x))); + const witaddset = new Set([...witset].filter((x) => addset.has(x))); if (witaddset.size > 0) { throw new Error( `Invalid member combination among wits = ${wits}, and adds = ${adds}.` @@ -150,18 +150,18 @@ export function rotate({ } // non empty intersection of cutset and addset - let cutaddset = new Set([...cutset].filter((x) => addset.has(x))); + const cutaddset = new Set([...cutset].filter((x) => addset.has(x))); if (cutaddset.size > 0) { throw new Error( `Invalid member combination among cuts = ${cuts}, and adds = ${adds}.` ); } - let newitsetdiff = new Set(_wits); + const newitsetdiff = new Set(_wits); _cuts.forEach(function (v) { newitsetdiff.delete(v); }); - let newitset = new Set( + const newitset = new Set( (function* () { yield* newitsetdiff; yield* addset; @@ -195,7 +195,7 @@ export function rotate({ throw new Error(`Invalid toad = ${_toad} for wit = ${wits}`); } } - let _ked = { + const _ked = { v: vs, t: _ilk, d: '', @@ -226,7 +226,7 @@ export function rotate({ ba: adds, a: data != undefined ? data : [], }; - let [, ked] = Saider.saidify(_ked); + const [, ked] = Saider.saidify(_ked); return new Serder(ked); } @@ -236,7 +236,7 @@ export function ample(n: number, f?: number, weak = true) { if (f == undefined) { f1 = Math.max(1, Math.floor(Math.max(0, n - 1) / 3)); // least floor f subject to n >= 3*f+1 - let f2 = Math.max(1, Math.ceil(Math.max(0, n - 1) / 3)); // most Math.ceil f subject to n >= 3*f+1 + const f2 = Math.max(1, Math.ceil(Math.max(0, n - 1) / 3)); // most Math.ceil f subject to n >= 3*f+1 if (weak) { // try both fs to see which one has lowest m return Math.min( @@ -252,8 +252,8 @@ export function ample(n: number, f?: number, weak = true) { } } else { f = Math.max(0, f); - let m1 = Math.ceil((n + f + 1) / 2); - let m2 = Math.max(0, n - f); + const m1 = Math.ceil((n + f + 1) / 2); + const m2 = Math.max(0, n - f); if (m2 < m1 && n > 0) { throw new Error(`Invalid f=${f} is too big for n=${n}.`); } @@ -296,15 +296,15 @@ export function incept({ intive = false, delpre, }: InceptArgs) { - let vs = versify(Ident.KERI, version, kind, 0); - let ilk = delpre == undefined ? Ilks.icp : Ilks.dip; - let sner = new CesrNumber({}, 0); + const vs = versify(Ident.KERI, version, kind, 0); + const ilk = delpre == undefined ? Ilks.icp : Ilks.dip; + const sner = new CesrNumber({}, 0); if (isith == undefined) { isith = Math.max(1, Math.ceil(keys.length / 2)); } - let tholder = new Tholder({ sith: isith }); + const tholder = new Tholder({ sith: isith }); if (tholder.num != undefined && tholder.num < 1) { throw new Error(`Invalid sith = ${tholder.num} less than 1.`); } @@ -320,7 +320,7 @@ export function incept({ nsith = Math.max(0, Math.ceil(ndigs.length / 2)); } - let ntholder = new Tholder({ sith: nsith }); + const ntholder = new Tholder({ sith: nsith }); if (ntholder.num != undefined && ntholder.num < 0) { throw new Error(`Invalid nsith = ${ntholder.num} less than 0.`); } @@ -341,7 +341,7 @@ export function incept({ } } - let toader = new CesrNumber({}, toad); + const toader = new CesrNumber({}, toad); if (wits.length > 0) { if (toader.num < 1 || toader.num > wits.length) { throw new Error(`Invalid toad = ${toader.num} for wits = ${wits}`); @@ -516,8 +516,8 @@ export function messagize( } interface InteractArgs { - pre: String; - dig: String; + pre: string; + dig: string; sn: number; data: Array; version: Version | undefined; @@ -526,9 +526,9 @@ interface InteractArgs { export function interact(args: InteractArgs): Serder { let { pre, dig, sn, data, version, kind } = args; - let vs = versify(Ident.KERI, version, kind, 0); - let ilk = Ilks.ixn; - let sner = new CesrNumber({}, sn); + const vs = versify(Ident.KERI, version, kind, 0); + const ilk = Ilks.ixn; + const sner = new CesrNumber({}, sn); if (sner.num < 1) { throw new Error(`Invalid sn = 0x${sner.numh} for ixn.`); diff --git a/src/keri/core/httping.ts b/src/keri/core/httping.ts index 95f17561..70b59dd5 100644 --- a/src/keri/core/httping.ts +++ b/src/keri/core/httping.ts @@ -45,8 +45,8 @@ export function siginput( context, }: SiginputArgs ): [Map, Siger | Cigar] { - let items = new Array(); - let ifields = new Array<[string, Map]>(); + const items = new Array(); + const ifields = new Array<[string, Map]>(); fields.forEach((field) => { if (field.startsWith('@')) { @@ -64,16 +64,16 @@ export function siginput( if (!headers.has(field)) return; ifields.push([field, new Map()]); - let value = normalize(headers.get(field)!); + const value = normalize(headers.get(field)!); items.push(`"${field}": ${value}`); } }); - let nameParams = new Map(); - let now = Math.floor(nowUTC().getTime() / 1000); + const nameParams = new Map(); + const now = Math.floor(nowUTC().getTime() / 1000); nameParams.set('created', now); - let values = [ + const values = [ `(${ifields.map((field) => field[0]).join(' ')})`, `created=${now}`, ]; @@ -97,13 +97,13 @@ export function siginput( values.push(`alg=${alg}`); nameParams.set('alg', alg); } - let sid = new Map([[name, [ifields, nameParams]]]); + const sid = new Map([[name, [ifields, nameParams]]]); - let params = values.join(';'); + const params = values.join(';'); items.push(`"@signature-params: ${params}"`); - let ser = items.join('\n'); - let sig = signer.sign(b(ser)); + const ser = items.join('\n'); + const sig = signer.sign(b(ser)); return [ new Map([ @@ -141,11 +141,11 @@ export class Inputage { } export function desiginput(value: string): Array { - let sid = parseDictionary(value); - let siginputs = new Array(); + const sid = parseDictionary(value); + const siginputs = new Array(); sid.forEach((value, key) => { - let siginput = new Inputage(); + const siginput = new Inputage(); siginput.name = key; let list: Item[]; let params; @@ -194,9 +194,9 @@ export function parseRangeHeaders( typ: string ): { start: number; end: number; total: number } { if (header !== null) { - let data = header.replace(`${typ} `, ''); - let values = data.split('/'); - let rng = values[0].split('-'); + const data = header.replace(`${typ} `, ''); + const values = data.split('/'); + const rng = values[0].split('-'); return { start: parseInt(rng[0]), diff --git a/src/keri/core/indexer.ts b/src/keri/core/indexer.ts index aa69053c..a4f52b9c 100644 --- a/src/keri/core/indexer.ts +++ b/src/keri/core/indexer.ts @@ -43,7 +43,7 @@ export class IndexedSigCodex { Ed448_Big_Crt_Sig: string = '3B'; // Ed448 signature appears in current list only. has(prop: string): boolean { - let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); + const m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); return m.has(prop); } } @@ -61,7 +61,7 @@ export class IndexedCurrentSigCodex { Ed448_Big_Crt_Sig: string = '3B'; // Ed448 signature appears in current list only. has(prop: string): boolean { - let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); + const m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); return m.has(prop); } } @@ -77,7 +77,7 @@ export class IndexedBothSigCodex { Ed448_Big_Sig: string = '3A'; // Ed448 signature appears in both lists. has(prop: string): boolean { - let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); + const m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); return m.has(prop); } } @@ -225,11 +225,11 @@ export class Indexer { throw new Error(`Unsupported code=${code}.`); } - let xizage = Indexer.Sizes.get(code)!; - let os = xizage.os; - let fs = xizage.fs; - let cs = xizage.hs + xizage.ss; - let ms = xizage.ss - xizage.os; + const xizage = Indexer.Sizes.get(code)!; + const os = xizage.os; + const fs = xizage.fs; + const cs = xizage.hs + xizage.ss; + const ms = xizage.ss - xizage.os; if (!Number.isInteger(index) || index < 0 || index > 64 ** ms - 1) { throw new Error(`Invalid index=${index} for code=${code}.`); @@ -271,7 +271,7 @@ export class Indexer { // raise InvalidCodeSizeError(f"Non-zero other index size for " // f"variable length material. os={os}.") // fs = (index * 4) + cs - let rawsize = Math.floor(((fs - cs) * 3) / 4); + const rawsize = Math.floor(((fs - cs) * 3) / 4); raw = raw.slice(0, rawsize); if (raw.length != rawsize) { @@ -285,7 +285,7 @@ export class Indexer { this._ondex = ondex; this._raw = raw; } else if (qb64b != undefined) { - let qb64 = d(qb64b); + const qb64 = d(qb64b); this._exfil(qb64); } else if (qb64 != undefined) { this._exfil(qb64); @@ -303,7 +303,7 @@ export class Indexer { } public static _rawSize(code: string) { - let xizage = Indexer.Sizes.get(code)!; + const xizage = Indexer.Sizes.get(code)!; return Math.floor(xizage.fs! - ((xizage.hs + xizage.ss) * 3) / 4); } @@ -332,15 +332,15 @@ export class Indexer { } private _infil(): string { - let code = this.code; - let index = this.index; - let ondex = this.ondex; - let raw = this.raw; + const code = this.code; + const index = this.index; + const ondex = this.ondex; + const raw = this.raw; - let ps = (3 - (raw.length % 3)) % 3; - let xizage = Indexer.Sizes.get(code)!; - let cs = xizage.hs + xizage.ss; - let ms = xizage.ss - xizage.os; + const ps = (3 - (raw.length % 3)) % 3; + const xizage = Indexer.Sizes.get(code)!; + const cs = xizage.hs + xizage.ss; + const ms = xizage.ss - xizage.os; // TODO: don't support this code // if not fs: # compute fs from index @@ -366,7 +366,7 @@ export class Indexer { ); } - let both = `${code}${intToB64(index, ms)}${intToB64( + const both = `${code}${intToB64(index, ms)}${intToB64( ondex == undefined ? 0 : ondex, xizage.os )}`; @@ -383,16 +383,16 @@ export class Indexer { ); } - let bytes = new Uint8Array(ps + raw.length); + const bytes = new Uint8Array(ps + raw.length); for (let i = 0; i < ps; i++) { bytes[i] = 0; } for (let i = 0; i < raw.length; i++) { - let odx = i + ps; + const odx = i + ps; bytes[odx] = raw[i]; } - let full = + const full = both + Base64.encode(Buffer.from(bytes)).slice(ps - xizage.ls); if (full.length != xizage.fs) { throw new Error(`Invalid code=${both} for raw size=${raw.length}.`); @@ -406,33 +406,33 @@ export class Indexer { throw new Error('Empty Material'); } - let first = qb64[0]; + const first = qb64[0]; if (!Array.from(Indexer.Hards.keys()).includes(first)) { throw new Error(`Unexpected code ${first}`); } - let hs = Indexer.Hards.get(first)!; + const hs = Indexer.Hards.get(first)!; if (qb64.length < hs) { throw new Error(`Need ${hs - qb64.length} more characters.`); } - let hard = qb64.slice(0, hs); + const hard = qb64.slice(0, hs); if (!Array.from(Indexer.Sizes.keys()).includes(hard)) { throw new Error(`Unsupported code ${hard}`); } - let xizage = Indexer.Sizes.get(hard)!; - let cs = xizage.hs + xizage.ss; // both hard + soft code size - let ms = xizage.ss - xizage.os; + const xizage = Indexer.Sizes.get(hard)!; + const cs = xizage.hs + xizage.ss; // both hard + soft code size + const ms = xizage.ss - xizage.os; if (qb64.length < cs) { throw new Error(`Need ${cs - qb64.length} more characters.`); } - let sindex = qb64.slice(hs, hs + ms); - let index = b64ToInt(sindex); + const sindex = qb64.slice(hs, hs + ms); + const index = b64ToInt(sindex); - let sondex = qb64.slice(hs + ms, hs + ms + xizage.os); + const sondex = qb64.slice(hs + ms, hs + ms + xizage.os); let ondex; if (IdxCrtSigDex.has(hard)) { ondex = xizage.os != 0 ? b64ToInt(sondex) : undefined; @@ -463,13 +463,13 @@ export class Indexer { } qb64 = qb64.slice(0, xizage.fs); - let ps = cs % 4; - let pbs = 2 * ps != 0 ? ps : xizage.ls; + const ps = cs % 4; + const pbs = 2 * ps != 0 ? ps : xizage.ls; let raw; if (ps != 0) { - let base = new Array(ps + 1).join('A') + qb64.slice(cs); - let paw = Base64.decode(base); // decode base to leave prepadded raw - let pi = readInt(paw.slice(0, ps)); // prepad as int + const base = new Array(ps + 1).join('A') + qb64.slice(cs); + const paw = Base64.decode(base); // decode base to leave prepadded raw + const pi = readInt(paw.slice(0, ps)); // prepad as int if (pi & (2 ** pbs - 1)) { // masked pad bits non-zero throw new Error( @@ -478,9 +478,9 @@ export class Indexer { } raw = paw.slice(ps); // strip off ps prepad paw bytes } else { - let base = qb64.slice(cs); - let paw = Base64.decode(base); - let li = readInt(paw.slice(0, xizage!.ls)); + const base = qb64.slice(cs); + const paw = Base64.decode(base); + const li = readInt(paw.slice(0, xizage!.ls)); if (li != 0) { if (li == 1) { throw new Error(`Non zeroed lead byte = 0x{li:02x}.`); diff --git a/src/keri/core/keeping.ts b/src/keri/core/keeping.ts index 456266cf..13f199b6 100644 --- a/src/keri/core/keeping.ts +++ b/src/keri/core/keeping.ts @@ -77,9 +77,9 @@ export class KeyManager { kargs['ndigs'] ); case Algos.extern: - let typ = kargs.extern_type; + const typ = kargs.extern_type; if (typ in this.modules) { - let mod = new this.modules[typ](pidx, kargs); + const mod = new this.modules[typ](pidx, kargs); return mod; } else { throw new Error(`unsupported external module type ${typ}`); @@ -90,9 +90,9 @@ export class KeyManager { } get(aid: any) { - let pre = new Prefixer({ qb64: aid['prefix'] }); + const pre = new Prefixer({ qb64: aid['prefix'] }); if (Algos.salty in aid) { - let kargs = aid[Algos.salty]; + const kargs = aid[Algos.salty]; return new SaltyKeeper( this.salter!, kargs['pidx'], @@ -111,7 +111,7 @@ export class KeyManager { kargs['sxlt'] ); } else if (Algos.randy in aid) { - let kargs = aid[Algos.randy]; + const kargs = aid[Algos.randy]; return new RandyKeeper( this.salter!, kargs['code'], @@ -126,7 +126,7 @@ export class KeyManager { kargs['nxts'] ); } else if (Algos.group in aid) { - let kargs = aid[Algos.group]; + const kargs = aid[Algos.group]; return new GroupKeeper( this, kargs['mhab'], @@ -136,10 +136,10 @@ export class KeyManager { kargs['ndigs'] ); } else if (Algos.extern in aid) { - let kargs = aid[Algos.randy]; - let typ = kargs.extern_type; + const kargs = aid[Algos.randy]; + const typ = kargs.extern_type; if (typ in this.modules) { - let mod = new this.modules[typ](kargs['pidx'], kargs); + const mod = new this.modules[typ](kargs['pidx'], kargs); return mod; } else { throw new Error(`unsupported external module type ${typ}`); @@ -192,7 +192,7 @@ export class SaltyKeeper { ) { // # Salter is the entered passcode and used for enc/dec of salts for each AID this.salter = salter; - let signer = this.salter.signer(undefined, (transferable = false)); + const signer = this.salter.signer(undefined, (transferable = false)); this.aeid = signer.verfer.qb64; @@ -225,7 +225,7 @@ export class SaltyKeeper { this.sxlt = this.encrypter.encrypt(b(this.creator.salt)).qb64; } else { this.sxlt = sxlt; - let ciph = new Cipher({ qb64: this.sxlt }); + const ciph = new Cipher({ qb64: this.sxlt }); this.creator = new SaltyCreator( this.decrypter.decrypt(null, ciph).qb64, (tier = tier), @@ -274,7 +274,7 @@ export class SaltyKeeper { this.transferable = transferable; this.kidx = 0; - let signers = this.creator.create( + const signers = this.creator.create( this.icodes, this.count, this.code, @@ -284,9 +284,9 @@ export class SaltyKeeper { this.kidx, false ); - let verfers = signers.signers.map((signer) => signer.verfer.qb64); + const verfers = signers.signers.map((signer) => signer.verfer.qb64); - let nsigners = this.creator.create( + const nsigners = this.creator.create( this.ncodes, this.ncount, this.ncode, @@ -296,7 +296,7 @@ export class SaltyKeeper { this.icodes?.length, false ); - let digers = nsigners.signers.map( + const digers = nsigners.signers.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -317,7 +317,7 @@ export class SaltyKeeper { this.ncodes = ncodes; this.transferable = transferable; - let signers = this.creator.create( + const signers = this.creator.create( this.ncodes, this.ncount, this.ncode, @@ -327,10 +327,10 @@ export class SaltyKeeper { this.kidx + this.icodes!.length, false ); - let verfers = signers.signers.map((signer) => signer.verfer.qb64); + const verfers = signers.signers.map((signer) => signer.verfer.qb64); this.kidx = this.kidx! + this.icodes!.length; - let nsigners = this.creator.create( + const nsigners = this.creator.create( this.ncodes, this.ncount, this.ncode, @@ -340,7 +340,7 @@ export class SaltyKeeper { this.kidx + this.icodes!.length, false ); - let digers = nsigners.signers.map( + const digers = nsigners.signers.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -354,7 +354,7 @@ export class SaltyKeeper { indices: number[] | undefined = undefined, ondices: number[] | undefined = undefined ) { - let signers = this.creator.create( + const signers = this.creator.create( this.icodes, this.ncount, this.ncode, @@ -366,7 +366,7 @@ export class SaltyKeeper { ); if (indexed) { - let sigers = []; + const sigers = []; let i = 0; for (const [j, signer] of signers.signers.entries()) { if (indices != undefined) { @@ -401,7 +401,7 @@ export class SaltyKeeper { } return sigers.map((siger) => siger.qb64); } else { - let cigars = []; + const cigars = []; for (const [_, signer] of signers.signers.entries()) { cigars.push(signer.sign(ser)); } @@ -455,7 +455,7 @@ export class RandyKeeper { this.count = count; this.ncount = ncount; - let signer = this.salter.signer(undefined, (transferable = false)); + const signer = this.salter.signer(undefined, (transferable = false)); this.aeid = signer.verfer.qb64; this.encrypter = new Encrypter({}, b(this.aeid)); @@ -491,7 +491,7 @@ export class RandyKeeper { incept(transferable: boolean) { this.transferable = transferable; - let signers = this.creator.create( + const signers = this.creator.create( this.icodes, this.count, this.code, @@ -501,9 +501,9 @@ export class RandyKeeper { (signer) => this.encrypter.encrypt(undefined, signer).qb64 ); - let verfers = signers.signers.map((signer) => signer.verfer.qb64); + const verfers = signers.signers.map((signer) => signer.verfer.qb64); - let nsigners = this.creator.create( + const nsigners = this.creator.create( this.ncodes, this.ncount, this.ncode, @@ -514,7 +514,7 @@ export class RandyKeeper { (signer) => this.encrypter.encrypt(undefined, signer).qb64 ); - let digers = nsigners.signers.map( + const digers = nsigners.signers.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -527,15 +527,15 @@ export class RandyKeeper { this.transferable = transferable; this.prxs = this.nxts; - let signers = this.nxts!.map((nxt) => + const signers = this.nxts!.map((nxt) => this.decrypter.decrypt( undefined, new Cipher({ qb64: nxt }), this.transferable ) ); - let verfers = signers.map((signer) => signer.verfer.qb64); - let nsigners = this.creator.create( + const verfers = signers.map((signer) => signer.verfer.qb64); + const nsigners = this.creator.create( this.ncodes, this.ncount, this.ncode, @@ -546,7 +546,7 @@ export class RandyKeeper { (signer) => this.encrypter.encrypt(undefined, signer).qb64 ); - let digers = nsigners.signers.map( + const digers = nsigners.signers.map( (nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64 ); @@ -560,7 +560,7 @@ export class RandyKeeper { indices: number[] | undefined = undefined, ondices: number[] | undefined = undefined ) { - let signers = this.prxs!.map((prx) => + const signers = this.prxs!.map((prx) => this.decrypter.decrypt( new Cipher({ qb64: prx }).qb64b, undefined, @@ -569,7 +569,7 @@ export class RandyKeeper { ); if (indexed) { - let sigers = []; + const sigers = []; let i = 0; for (const [j, signer] of signers.entries()) { if (indices != undefined) { @@ -604,7 +604,7 @@ export class RandyKeeper { } return sigers.map((siger) => siger.qb64); } else { - let cigars = []; + const cigars = []; for (const [_, signer] of signers.entries()) { cigars.push(signer.sign(ser)); } @@ -664,12 +664,12 @@ export class GroupKeeper { _indices: number[] | undefined = undefined, _ondices: number[] | undefined = undefined ): Promise { - let key = this.mhab['state']['k'][0]; - let ndig = this.mhab['state']['n'][0]; + const key = this.mhab['state']['k'][0]; + const ndig = this.mhab['state']['n'][0]; - let csi = this.gkeys!.indexOf(key); - let pni = this.gdigs!.indexOf(ndig); - let mkeeper = this.manager.get(this.mhab); + const csi = this.gkeys!.indexOf(key); + const pni = this.gdigs!.indexOf(ndig); + const mkeeper = this.manager.get(this.mhab); return await mkeeper.sign(ser, indexed, [csi], [pni]); } diff --git a/src/keri/core/manager.ts b/src/keri/core/manager.ts index 3a6043fa..8742043f 100644 --- a/src/keri/core/manager.ts +++ b/src/keri/core/manager.ts @@ -96,7 +96,7 @@ export class RandyCreator implements Creator { code: string = MtrDex.Ed25519_Seed, transferable: boolean = true ): Keys { - let signers = new Array(); + const signers = new Array(); if (codes == undefined) { codes = new Array(count).fill(code); } @@ -157,8 +157,8 @@ export class SaltyCreator implements Creator { kidx: number = 0, temp: boolean = false ): Keys { - let signers = new Array(); - let paths = new Array(); + const signers = new Array(); + const paths = new Array(); if (codes == undefined) { codes = new Array(count).fill(code); @@ -167,7 +167,7 @@ export class SaltyCreator implements Creator { codes.forEach((code, idx) => { // Previuos definition of path // let path = this.stem + pidx.toString(16) + ridx.toString(16) + (kidx+idx).toString(16) - let path = + const path = this.stem == '' ? pidx.toString(16) : this.stem + ridx.toString(16) + (kidx + idx).toString(16); @@ -215,14 +215,14 @@ export function openManager(passcode: string, salt?: string) { throw new Error('Bran (passcode seed material) too short.'); } - let bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed - let signer = new Salter({ qb64: bran }).signer(MtrDex.Ed25519_Seed, false); - let seed = signer.qb64; - let aeid = signer.verfer.qb64; // lest it remove encryption + const bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed + const signer = new Salter({ qb64: bran }).signer(MtrDex.Ed25519_Seed, false); + const seed = signer.qb64; + const aeid = signer.verfer.qb64; // lest it remove encryption let algo; - let salter = salt != undefined ? new Salter({ qb64: salt }) : undefined; + const salter = salt != undefined ? new Salter({ qb64: salt }) : undefined; if (salt != undefined) { algo = Algos.salty; } else { @@ -296,7 +296,7 @@ export class Manager { pidx = pidx == undefined ? 0 : pidx; algo = algo == undefined ? Algos.salty : algo; - let salt = salter?.qb64; + const salt = salter?.qb64; tier = tier == undefined ? Tier.low : tier; @@ -342,7 +342,7 @@ export class Manager { } get pidx(): number | undefined { - let pidx = this.ks.getGbls('pidx'); + const pidx = this.ks.getGbls('pidx'); if (pidx != undefined) { return parseInt(pidx, 16); } @@ -357,7 +357,7 @@ export class Manager { if (this._decrypter == undefined) { return this._salt; } else { - let salt = this.ks.getGbls('salt'); + const salt = this.ks.getGbls('salt'); return this._decrypter.decrypt(b(salt)).qb64; } } @@ -380,8 +380,8 @@ export class Manager { } get algo(): Algos | undefined { - let a = this.ks.getGbls('algo'); - let ta = a as keyof typeof Algos; + const a = this.ks.getGbls('algo'); + const ta = a as keyof typeof Algos; return Algos[ta]; } @@ -391,7 +391,7 @@ export class Manager { private updateAeid(aeid: string | undefined, seed?: string) { if (this.aeid != undefined) { - let seed = b(this._seed); + const seed = b(this._seed); if (this._seed == undefined || !this._encrypter?.verifySeed(seed)) { throw new Error(`Last seed missing or provided last seed " "not associated with last aeid=${this.aeid}.`); @@ -415,7 +415,7 @@ export class Manager { this._encrypter = undefined; } - let salt = this.salt; + const salt = this.salt; if (salt != undefined) { this.salt = salt; } @@ -423,7 +423,7 @@ export class Manager { if (this._decrypter != undefined) { for (const [keys, data] of this.ks.prmsElements()) { if (data.salt != undefined) { - let salter = this._decrypter.decrypt(b(data.salt)); + const salter = this._decrypter.decrypt(b(data.salt)); data.salt = this._encrypter == undefined ? salter.qb64 @@ -473,11 +473,11 @@ export class Manager { tier = this.tier; } - let pidx = this.pidx!; - let ridx = 0; - let kidx = 0; + const pidx = this.pidx!; + const ridx = 0; + const kidx = 0; - let creator = new Creatory(algo).make(salt, tier, stem); + const creator = new Creatory(algo).make(salt, tier, stem); if (icodes == undefined) { if (icount < 0) { @@ -487,7 +487,7 @@ export class Manager { icodes = new Array(icount).fill(icode); } - let ikeys = creator.create( + const ikeys = creator.create( icodes, 0, MtrDex.Ed25519_Seed, @@ -497,7 +497,7 @@ export class Manager { kidx, temp ); - let verfers = Array.from( + const verfers = Array.from( ikeys.signers, (signer: Signer) => signer.verfer ); @@ -510,7 +510,7 @@ export class Manager { ncodes = new Array(ncount).fill(ncode); } - let nkeys = creator.create( + const nkeys = creator.create( ncodes, 0, MtrDex.Ed25519_Seed, @@ -521,12 +521,12 @@ export class Manager { temp ); - let digers = Array.from( + const digers = Array.from( nkeys.signers, (signer: Signer) => new Diger({ code: dcode }, signer.verfer.qb64b) ); - let pp = new PrePrm(); + const pp = new PrePrm(); pp.pidx = pidx!; pp.algo = algo!; pp.salt = @@ -536,14 +536,14 @@ export class Manager { pp.stem = creator.stem; pp.tier = creator.tier; - let dt = new Date().toString(); - let nw = new PubLot(); + const dt = new Date().toString(); + const nw = new PubLot(); nw.pubs = Array.from(verfers, (verfer: Verfer) => verfer.qb64); nw.ridx = ridx; nw.kidx = kidx; nw.dt = dt; - let nt = new PubLot(); + const nt = new PubLot(); nt.pubs = Array.from( nkeys.signers, (signer: Signer) => signer.verfer.qb64 @@ -552,11 +552,11 @@ export class Manager { nt.kidx = kidx + icodes.length; nt.dt = dt; - let ps = new PreSit(); + const ps = new PreSit(); ps.new = nw; ps.nxt = nt; - let pre = verfers[0].qb64; + const pre = verfers[0].qb64; if (!this.ks.putPres(pre, verfers[0].qb64b)) { throw new Error(`Already incepted pre=${pre}.`); } @@ -586,8 +586,8 @@ export class Manager { nkeys.paths != undefined ) { ikeys.paths.forEach((path: string, idx: number) => { - let signer = ikeys.signers[idx]; - let ppt = new PubPath(); + const signer = ikeys.signers[idx]; + const ppt = new PubPath(); ppt.path = path; ppt.code = icodes[idx]; ppt.tier = pp.tier; @@ -595,8 +595,8 @@ export class Manager { this.ks.putPths(signer.verfer.qb64, ppt); }); nkeys.paths.forEach((path: string, idx: number) => { - let signer = nkeys.signers[idx]; - let ppt = new PubPath(); + const signer = nkeys.signers[idx]; + const ppt = new PubPath(); ppt.path = path; ppt.code = ncodes[idx]; ppt.tier = pp.tier; @@ -609,11 +609,11 @@ export class Manager { ); } - let pubSet = new PubSet(); + const pubSet = new PubSet(); pubSet.pubs = ps.new.pubs; this.ks.putPubs(riKey(pre, ridx), pubSet); - let nxtPubSet = new PubSet(); + const nxtPubSet = new PubSet(); nxtPubSet.pubs = ps.nxt.pubs; this.ks.putPubs(riKey(pre, ridx + 1), nxtPubSet); @@ -633,7 +633,7 @@ export class Manager { throw new Error(`Preexistent new pre=${gnu} may not clobber.`); } - let oldprm = this.ks.getPrms(old); + const oldprm = this.ks.getPrms(old); if (oldprm == undefined) { throw new Error( `Nonexistent old prm for pre=${old}, nothing to move.` @@ -646,7 +646,7 @@ export class Manager { ); } - let oldsit = this.ks.getSits(old); + const oldsit = this.ks.getSits(old); if (oldsit == undefined) { throw new Error( `Nonexistent old sit for pre=${old}, nothing to move.` @@ -677,7 +677,7 @@ export class Manager { let i = 0; while (true) { - let pl = this.ks.getPubs(riKey(old, i)); + const pl = this.ks.getPubs(riKey(old, i)); if (pl == undefined) { break; } @@ -711,12 +711,12 @@ export class Manager { temp = false, erase = true, }: RotateArgs): [Array, Array] { - let pp = this.ks.getPrms(pre); + const pp = this.ks.getPrms(pre); if (pp == undefined) { throw new Error(`Attempt to rotate nonexistent pre=${pre}.`); } - let ps = this.ks.getSits(pre); + const ps = this.ks.getSits(pre); if (ps == undefined) { throw new Error(`Attempt to rotate nonexistent pre=${pre}.`); } @@ -725,7 +725,7 @@ export class Manager { throw new Error(`Attempt to rotate nontransferable pre=${pre}.`); } - let old = ps.old; + const old = ps.old; ps.old = ps.new; ps.new = ps.nxt; @@ -735,10 +735,10 @@ export class Manager { ); } - let verfers = new Array(); + const verfers = new Array(); ps.new.pubs.forEach((pub) => { if (this.decrypter != undefined) { - let signer = this.ks.getPris(pub, this.decrypter); + const signer = this.ks.getPris(pub, this.decrypter); if (signer == undefined) { throw new Error(`Missing prikey in db for pubkey=${pub}`); } @@ -762,7 +762,7 @@ export class Manager { salt = this.salt!; } - let creator = new Creatory(pp.algo).make(salt, pp.tier, pp.stem); + const creator = new Creatory(pp.algo).make(salt, pp.tier, pp.stem); if (ncodes == undefined) { if (ncount < 0) { @@ -771,11 +771,11 @@ export class Manager { ncodes = new Array(ncount).fill(ncode); } - let pidx = pp.pidx; - let ridx = ps.new.ridx + 1; - let kidx = ps.nxt.kidx + ps.new.pubs.length; + const pidx = pp.pidx; + const ridx = ps.new.ridx + 1; + const kidx = ps.nxt.kidx + ps.new.pubs.length; - let keys = creator.create( + const keys = creator.create( ncodes, 0, '', @@ -785,12 +785,12 @@ export class Manager { kidx, temp ); - let digers = Array.from( + const digers = Array.from( keys.signers, (signer: Signer) => new Diger({ code: dcode }, signer.verfer.qb64b) ); - let dt = new Date().toString(); + const dt = new Date().toString(); ps.nxt = new PubLot(); ps.nxt.pubs = Array.from( keys.signers, @@ -811,8 +811,8 @@ export class Manager { }); } else if (this._encrypter == undefined && keys.paths != undefined) { keys.paths.forEach((path: string, idx: number) => { - let signer = keys.signers[idx]; - let ppt = new PubPath(); + const signer = keys.signers[idx]; + const ppt = new PubPath(); ppt.path = path; ppt.tier = pp!.tier; ppt.temp = temp; @@ -824,7 +824,7 @@ export class Manager { ); } - let newPs = new PubSet(); + const newPs = new PubSet(); newPs.pubs = ps.nxt.pubs; this.ks.putPubs(riKey(pre, ps.nxt.ridx), newPs); @@ -845,7 +845,7 @@ export class Manager { indices = undefined, ondices = undefined, }: SignArgs) { - let signers = new Array(); + const signers = new Array(); if (pubs == undefined && verfers == undefined) { throw new Error('pubs or verfers required'); @@ -861,7 +861,7 @@ export class Manager { pubs.forEach((pub) => { //If no decrypter then get SaltyState and regenerate prikey if (this.decrypter != undefined) { - let signer = this.ks.getPris(pub, this.decrypter); + const signer = this.ks.getPris(pub, this.decrypter); if (signer == undefined) { throw new Error( `Missing prikey in db for pubkey=${pub}` @@ -869,14 +869,14 @@ export class Manager { } signers.push(signer); } else { - let verfer = new Verfer({ qb64: pub }); - let ppt = this.ks.getPths(pub); + const verfer = new Verfer({ qb64: pub }); + const ppt = this.ks.getPths(pub); if (ppt == undefined) { throw new Error( `Missing prikey in db for pubkey=${pub}` ); } - let salter = new Salter({ qb64: this.salt }); + const salter = new Salter({ qb64: this.salt }); signers.push( salter.signer( ppt.code, @@ -891,7 +891,7 @@ export class Manager { } else { verfers!.forEach((verfer: Verfer) => { if (this.decrypter != undefined) { - let signer = this.ks.getPris(verfer.qb64, this.decrypter); + const signer = this.ks.getPris(verfer.qb64, this.decrypter); if (signer == undefined) { throw new Error( `Missing prikey in db for pubkey=${verfer.qb64}` @@ -899,13 +899,13 @@ export class Manager { } signers.push(signer); } else { - let ppt = this.ks.getPths(verfer.qb64); + const ppt = this.ks.getPths(verfer.qb64); if (ppt == undefined) { throw new Error( `Missing prikey in db for pubkey=${verfer.qb64}` ); } - let salter = new Salter({ qb64: this.salt }); + const salter = new Salter({ qb64: this.salt }); signers.push( salter.signer( ppt.code, @@ -932,7 +932,7 @@ export class Manager { } if (indexed) { - let sigers = new Array(); + const sigers = new Array(); signers.forEach((signer, idx) => { let i; if (indices != undefined) { @@ -958,12 +958,12 @@ export class Manager { o = i; } - let only = o == undefined; + const only = o == undefined; sigers.push(signer.sign(ser, i, only, o) as Siger); }); return sigers; } else { - let cigars = new Array(); + const cigars = new Array(); signers.forEach((signer: Signer) => { cigars.push(signer.sign(ser) as Cigar); }); @@ -1042,7 +1042,7 @@ class Keeper implements KeyStore { } prmsElements(): Array<[string, PrePrm]> { - let out = new Array<[string, PrePrm]>(); + const out = new Array<[string, PrePrm]>(); this._prms.forEach((value, key) => { out.push([key, value]); }); @@ -1071,17 +1071,17 @@ class Keeper implements KeyStore { } prisElements(decrypter: Decrypter): Array<[string, Signer]> { - let out = new Array<[string, Signer]>(); + const out = new Array<[string, Signer]>(); this._pris.forEach(function (val, pubKey) { - let verfer = new Verfer({ qb64: pubKey }); - let signer = decrypter.decrypt(val, null, verfer.transferable); + const verfer = new Verfer({ qb64: pubKey }); + const signer = decrypter.decrypt(val, null, verfer.transferable); out.push([pubKey, signer]); }); return out; } pinPris(pubKey: string, signer: Signer, encrypter: Encrypter): void { - let cipher = encrypter.encrypt(null, signer); + const cipher = encrypter.encrypt(null, signer); this._pris.set(pubKey, cipher.qb64b); } @@ -1089,17 +1089,17 @@ class Keeper implements KeyStore { if (this._pris.has(pubKey)) { return false; } - let cipher = encrypter.encrypt(null, signer); + const cipher = encrypter.encrypt(null, signer); this._pris.set(pubKey, cipher.qb64b); return true; } getPris(pubKey: string, decrypter: Decrypter): Signer | undefined { - let val = this._pris.get(pubKey); + const val = this._pris.get(pubKey); if (val == undefined) { return undefined; } - let verfer = new Verfer({ qb64: pubKey }); + const verfer = new Verfer({ qb64: pubKey }); return decrypter.decrypt(val, null, verfer.transferable); } diff --git a/src/keri/core/matter.ts b/src/keri/core/matter.ts index e7e3afe4..03e51b27 100644 --- a/src/keri/core/matter.ts +++ b/src/keri/core/matter.ts @@ -7,7 +7,7 @@ import { Buffer } from 'buffer'; export class Codex { has(prop: string): boolean { - let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); + const m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]])); return m.has(prop); } } @@ -276,16 +276,16 @@ export class Matter { rize = raw.length; } - let ls = (3 - (rize % 3)) % 3; // calc actual lead (pad) size + const ls = (3 - (rize % 3)) % 3; // calc actual lead (pad) size size = Math.floor((rize + ls) / 3); // calculate value of size in triplets if (SmallVrzDex.has(code[0])) { if (size <= 64 ** 2 - 1) { - let hs = 2; - let s = Object.values(SmallVrzDex)[ls]; + const hs = 2; + const s = Object.values(SmallVrzDex)[ls]; code = `${s}${code.substring(1, hs)}`; } else if (size <= 64 ** 4 - 1) { - let hs = 4; - let s = Object.values(LargeVrzDex)[ls]; + const hs = 4; + const s = Object.values(LargeVrzDex)[ls]; code = `${s}${'AAAA'.substring(0, hs - 2)}${code[1]}`; } else { throw new Error( @@ -294,8 +294,8 @@ export class Matter { } } else { if (size <= 64 ** 4 - 1) { - let hs = 4; - let s = Object.values(LargeVrzDex)[ls]; + const hs = 4; + const s = Object.values(LargeVrzDex)[ls]; code = `${s}${code.substring(1, hs)}`; } else { throw new Error( @@ -304,7 +304,7 @@ export class Matter { } } } else { - let sizage = Matter.Sizes.get(code); + const sizage = Matter.Sizes.get(code); if (sizage!.fs == -1) { // invalid throw new Error(`Unsupported variable size code=${code}`); @@ -326,7 +326,7 @@ export class Matter { } else if (qb64 !== undefined) { this._exfil(qb64); } else if (qb64b !== undefined) { - let qb64 = d(qb64b); + const qb64 = d(qb64b); this._exfil(qb64); } else if (qb2 !== undefined) { this._bexfil(qb2); @@ -364,8 +364,8 @@ export class Matter { } static _rawSize(code: string) { - let sizage = this.Sizes.get(code); // get sizes - let cs = sizage!.hs + sizage!.ss; // both hard + soft code size + const sizage = this.Sizes.get(code); // get sizes + const cs = sizage!.hs + sizage!.ss; // both hard + soft code size if (sizage!.fs === -1) { throw Error(`Non-fixed raw size code ${code}.`); } @@ -374,26 +374,26 @@ export class Matter { } static _leadSize(code: string) { - let sizage = this.Sizes.get(code); + const sizage = this.Sizes.get(code); return sizage!.ls; } get both() { - let sizage = Matter.Sizes.get(this.code); + const sizage = Matter.Sizes.get(this.code); return `${this.code}${intToB64(this.size, sizage!.ss)}`; } private _infil() { - let code = this.code; - let size = this.size; - let raw = this.raw; + const code = this.code; + const size = this.size; + const raw = this.raw; - let ps = (3 - (raw.length % 3)) % 3; // pad size chars or lead size bytes - let sizage = Matter.Sizes.get(code); + const ps = (3 - (raw.length % 3)) % 3; // pad size chars or lead size bytes + const sizage = Matter.Sizes.get(code); if (sizage!.fs === undefined) { // Variable size code, NOT SUPPORTED - let cs = sizage!.hs + sizage!.ss; + const cs = sizage!.hs + sizage!.ss; if (cs % 4) { throw new Error( `Whole code size not multiple of 4 for variable length material. cs=${cs}` @@ -403,26 +403,26 @@ export class Matter { throw new Error(`Invalid size=${size} for code=${code}.`); } - let both = `${code}${intToB64(size, sizage!.ss)}`; + const both = `${code}${intToB64(size, sizage!.ss)}`; if (both.length % 4 !== ps - sizage!.ls!) { throw new Error( `Invalid code=${both} for converted raw pad size=${ps}.` ); } - let bytes = new Uint8Array(sizage!.ls! + raw.length); + const bytes = new Uint8Array(sizage!.ls! + raw.length); for (let i = 0; i < sizage!.ls!; i++) { bytes[i] = 0; } for (let i = 0; i < raw.length; i++) { - let odx = i + ps; + const odx = i + ps; bytes[odx] = raw[i]; } return both + Base64.encode(Buffer.from(bytes)); } else { - let both = code; - let cs = both.length; + const both = code; + const cs = both.length; if (cs % 4 != ps - sizage!.ls!) { // adjusted pad given lead bytes throw new Error( @@ -432,12 +432,12 @@ export class Matter { // prepad, convert, and replace upfront // when fixed and ls != 0 then cs % 4 is zero and ps==ls // otherwise fixed and ls == 0 then cs % 4 == ps - let bytes = new Uint8Array(ps + raw.length); + const bytes = new Uint8Array(ps + raw.length); for (let i = 0; i < ps; i++) { bytes[i] = 0; } for (let i = 0; i < raw.length; i++) { - let odx = i + ps; + const odx = i + ps; bytes[odx] = raw[i]; } @@ -450,23 +450,23 @@ export class Matter { throw new Error('Empty Material'); } - let first = qb64[0]; + const first = qb64[0]; if (!Array.from(Matter.Hards.keys()).includes(first)) { throw new Error(`Unexpected code ${first}`); } - let hs = Matter.Hards.get(first); + const hs = Matter.Hards.get(first); if (qb64.length < hs!) { throw new Error(`Shortage Error`); } - let hard = qb64.slice(0, hs); + const hard = qb64.slice(0, hs); if (!Array.from(Matter.Sizes.keys()).includes(hard)) { throw new Error(`Unsupported code ${hard}`); } - let sizage = Matter.Sizes.get(hard); - let cs = sizage!.hs + sizage!.ss; + const sizage = Matter.Sizes.get(hard); + const cs = sizage!.hs + sizage!.ss; let size = -1; if (sizage!.fs == -1) { // Variable size code, Not supported @@ -480,13 +480,13 @@ export class Matter { } qb64 = qb64.slice(0, sizage!.fs); - let ps = cs % 4; - let pbs = 2 * (ps == 0 ? sizage!.ls! : ps); + const ps = cs % 4; + const pbs = 2 * (ps == 0 ? sizage!.ls! : ps); let raw; if (ps != 0) { - let base = new Array(ps + 1).join('A') + qb64.slice(cs); - let paw = Base64.decode(base); // decode base to leave prepadded raw - let pi = readInt(paw.subarray(0, ps)); // prepad as int + const base = new Array(ps + 1).join('A') + qb64.slice(cs); + const paw = Base64.decode(base); // decode base to leave prepadded raw + const pi = readInt(paw.subarray(0, ps)); // prepad as int if (pi & (2 ** pbs - 1)) { // masked pad bits non-zero throw new Error( @@ -495,9 +495,9 @@ export class Matter { } raw = paw.subarray(ps); // strip off ps prepad paw bytes } else { - let base = qb64.slice(cs); - let paw = Base64.decode(base); - let li = readInt(paw.subarray(0, sizage!.ls)); + const base = qb64.slice(cs); + const paw = Base64.decode(base); + const li = readInt(paw.subarray(0, sizage!.ls)); if (li != 0) { if (li == 1) { throw new Error(`Non zeroed lead byte = 0x{li:02x}.`); diff --git a/src/keri/core/pather.ts b/src/keri/core/pather.ts index 137a6d38..edc2bf17 100644 --- a/src/keri/core/pather.ts +++ b/src/keri/core/pather.ts @@ -68,7 +68,7 @@ export class Pather extends Bexter { path = path.substring(1); } - let apath = path.split('-'); + const apath = path.split('-'); if (apath[0] !== '') { return apath; } else { @@ -77,7 +77,7 @@ export class Pather extends Bexter { } static _bextify(path: any[]): string { - let vath = []; + const vath = []; for (const p of path) { let sp = ''; if (typeof p === 'number') { @@ -86,7 +86,7 @@ export class Pather extends Bexter { sp = p; } - let match = Reb64.exec(sp); + const match = Reb64.exec(sp); if (!match) { throw new Error(`"Non Base64 path component = ${p}.`); } diff --git a/src/keri/core/prefixer.ts b/src/keri/core/prefixer.ts index 97ddf5d6..53b7fe55 100644 --- a/src/keri/core/prefixer.ts +++ b/src/keri/core/prefixer.ts @@ -76,7 +76,7 @@ export class Prefixer extends Matter { static _derive_ed25519N(ked: Dict): [Uint8Array, string] { let verfer; - let keys = ked['k']; + const keys = ked['k']; if (keys.length != 1) { throw new Error( `Basic derivation needs at most 1 key got ${keys.length} keys instead` @@ -92,21 +92,21 @@ export class Prefixer extends Matter { throw new Error(`Mismatch derivation code = ${verfer.code}`); } - let next = 'n' in ked ? ked['n'] : []; + const next = 'n' in ked ? ked['n'] : []; if (verfer.code == MtrDex.Ed25519N && next.length > 0) { throw new Error( `Non-empty nxt = ${next} for non-transferable code = ${verfer.code}` ); } - let backers = 'b' in ked ? ked['b'] : []; + const backers = 'b' in ked ? ked['b'] : []; if (verfer.code == MtrDex.Ed25519N && backers.length > 0) { throw new Error( `Non-empty b =${backers} for non-transferable code = ${verfer.code}` ); } - let anchor = 'a' in ked ? ked['a'] : []; + const anchor = 'a' in ked ? ked['a'] : []; if (verfer.code == MtrDex.Ed25519N && anchor.length > 0) { throw new Error( `Non-empty a = ${verfer.code} for non-transferable code = ${verfer.code}` @@ -118,7 +118,7 @@ export class Prefixer extends Matter { static _derive_ed25519(ked: Dict): [Uint8Array, string] { let verfer; - let keys = ked['k']; + const keys = ked['k']; if (keys.length != 1) { throw new Error( `Basic derivation needs at most 1 key got ${keys.length} keys instead` @@ -139,15 +139,15 @@ export class Prefixer extends Matter { } static _derive_blake3_256(ked: Dict): [Uint8Array, string] { - let kd = ked; - let ilk = ked['t']; + const kd = ked; + const ilk = ked['t']; if (![Ilks.icp, Ilks.dip, Ilks.vcp, Ilks.dip].includes(ilk)) { throw new Error(`Invalid ilk = ${ilk} to derive pre.`); } kd['i'] = ''.padStart(Matter.Sizes.get(MtrDex.Blake3_256)!.fs!, Dummy); kd['d'] = ked['i']; - let [raw] = sizeify(ked); + const [raw] = sizeify(ked); const hasher = createHash(); const dig = hasher.update(raw).digest(''); return [dig, MtrDex.Blake3_256]; @@ -159,7 +159,7 @@ export class Prefixer extends Matter { prefixed: boolean = false ): boolean { try { - let keys = ked['k']; + const keys = ked['k']; if (keys.length != 1) { return false; } @@ -172,7 +172,7 @@ export class Prefixer extends Matter { return false; } - let next = 'n' in ked ? ked['n'] : []; + const next = 'n' in ked ? ked['n'] : []; if (next.length > 0) { // must be empty return false; @@ -190,7 +190,7 @@ export class Prefixer extends Matter { prefixed: boolean = false ): boolean { try { - let keys = ked['k']; + const keys = ked['k']; if (keys.length != 1) { return false; } @@ -215,8 +215,8 @@ export class Prefixer extends Matter { prefixed: boolean = false ): boolean { try { - let [raw] = Prefixer._derive_blake3_256(ked); - let crymat = new Matter({ raw: raw, code: MtrDex.Blake3_256 }); + const [raw] = Prefixer._derive_blake3_256(ked); + const crymat = new Matter({ raw: raw, code: MtrDex.Blake3_256 }); if (crymat.qb64 != pre) { return false; } diff --git a/src/keri/core/saider.ts b/src/keri/core/saider.ts index 295db7ab..af9ee7fc 100644 --- a/src/keri/core/saider.ts +++ b/src/keri/core/saider.ts @@ -94,12 +94,12 @@ export class Saider extends Matter { [, , kind, sad] = sizeify(sad, kind); } - let ser = { ...sad }; + const ser = { ...sad }; - let digestage = Saider.Digests.get(code); + const digestage = Saider.Digests.get(code); - let cpa = Saider._serialze(ser, kind); - let args: any[] = []; + const cpa = Saider._serialze(ser, kind); + const args: any[] = []; if (digestage!.size != undefined) { args.push(digestage!.size); } @@ -129,8 +129,8 @@ export class Saider extends Matter { label: string = Ids.d ): boolean { try { - let [raw, dsad] = Saider._derive(sad, this.code, kind, label); - let saider = new Saider({ raw: raw, code: this.code }); + const [raw, dsad] = Saider._derive(sad, this.code, kind, label); + const saider = new Saider({ raw: raw, code: this.code }); if (this.qb64 != saider.qb64) { return false; } @@ -175,7 +175,7 @@ export class Saider extends Matter { } let raw; [raw, sad] = Saider._derive(sad, code, kind, label); - let saider = new Saider( + const saider = new Saider( { raw: raw, code: code }, undefined, kind, diff --git a/src/keri/core/salter.ts b/src/keri/core/salter.ts index 654c4c13..0f821d9b 100644 --- a/src/keri/core/salter.ts +++ b/src/keri/core/salter.ts @@ -34,7 +34,7 @@ export class Salter extends Matter { } catch (e) { if (e instanceof EmptyMaterialError) { if (code == MtrDex.Salt_128) { - let salt = libsodium.randombytes_buf( + const salt = libsodium.randombytes_buf( libsodium.crypto_pwhash_SALTBYTES ); super({ raw: salt, code: code }); @@ -105,7 +105,7 @@ export class Salter extends Matter { tier: Tier | null = null, temp: boolean = false ): Signer { - let seed = this.stretch(Matter._rawSize(code), path, tier, temp); + const seed = this.stretch(Matter._rawSize(code), path, tier, temp); return new Signer({ raw: seed, diff --git a/src/keri/core/serder.ts b/src/keri/core/serder.ts index 2a346fa1..d2cd3dfd 100644 --- a/src/keri/core/serder.ts +++ b/src/keri/core/serder.ts @@ -32,8 +32,8 @@ export class Serder { } set ked(ked: Dict) { - let [raw, ident, kind, kd, version] = this._exhale(ked, this._kind); - let size = raw.length; + const [raw, ident, kind, kd, version] = this._exhale(ked, this._kind); + const size = raw.length; this._raw = raw; this._ident = ident; this._ked = kd; @@ -98,8 +98,8 @@ export class Serder { keys = []; } // create a new Verfer for each key - let verfers = []; - for (let key of keys) { + const verfers = []; + for (const key of keys) { verfers.push(new Verfer({ qb64: key })); } return verfers; @@ -115,8 +115,8 @@ export class Serder { keys = []; } // create a new Verfer for each key - let digers = []; - for (let key of keys) { + const digers = []; + for (const key of keys) { digers.push(new Diger({ qb64: key })); } return digers; @@ -143,7 +143,7 @@ export function sizeify( throw new Error('Missing or empty version string'); } - let [ident, knd, version] = deversify(ked['v'] as string); + const [ident, knd, version] = deversify(ked['v'] as string); if (version != Versionage) { throw new Error(`unsupported version ${version.toString()}`); } @@ -153,7 +153,7 @@ export function sizeify( } let raw = dumps(ked, kind); - let size = raw.length; + const size = raw.length; ked['v'] = versify(ident, version, kind, size); diff --git a/src/keri/core/signer.ts b/src/keri/core/signer.ts index 0736bd81..0c99fc24 100644 --- a/src/keri/core/signer.ts +++ b/src/keri/core/signer.ts @@ -44,7 +44,7 @@ export class Signer extends Matter { } catch (e) { if (e instanceof EmptyMaterialError) { if (code == MtrDex.Ed25519_Seed) { - let raw = libsodium.randombytes_buf( + const raw = libsodium.randombytes_buf( libsodium.crypto_sign_SEEDBYTES ); super({ raw, code, qb64, qb64b, qb2 }); @@ -96,7 +96,7 @@ export class Signer extends Matter { only: boolean = false, ondex: number | undefined ) { - let sig = libsodium.crypto_sign_detached( + const sig = libsodium.crypto_sign_detached( ser, Buffer.concat([seed, verfer.raw]) ); diff --git a/src/keri/core/tholder.ts b/src/keri/core/tholder.ts index 55535c3c..b6d18c0d 100644 --- a/src/keri/core/tholder.ts +++ b/src/keri/core/tholder.ts @@ -78,9 +78,9 @@ export class Tholder { } private _processLimen(limen: string) { - let matter = new Matter({ qb64: limen }); + const matter = new Matter({ qb64: limen }); if (NumDex.has(matter.code)) { - let number = new CesrNumber({ raw: matter.raw, code: matter.code }); + const number = new CesrNumber({ raw: matter.raw, code: matter.code }); this._processUnweighted(number.num); } else if (BexDex.has(matter.code)) { // TODO: Implement Bexter @@ -104,7 +104,7 @@ export class Tholder { throw new Error('Empty weight list'); } - let mask = _sith.map((x: any) => { + const mask = _sith.map((x: any) => { return typeof x !== 'string'; }); @@ -112,8 +112,8 @@ export class Tholder { _sith = [_sith]; } - for (let c of _sith) { - let mask = c.map((x: any) => { + for (const c of _sith) { + const mask = c.map((x: any) => { return typeof x === 'string'; }); if (mask.length > 0 && !mask.every((x: boolean) => x)) { @@ -125,13 +125,13 @@ export class Tholder { } } - let thold = this._processClauses(_sith); + const thold = this._processClauses(_sith); this._processWeighted(thold); } } private _processClauses(sith: Array>): Fraction[][] { - let thold = new Array>(); + const thold = new Array>(); sith.forEach((clause) => { thold.push( clause.map((w) => { @@ -155,7 +155,7 @@ export class Tholder { } private _processWeighted(thold: Array>) { - for (let clause of thold) { + for (const clause of thold) { if (Number(math.sum(clause)) < 1) { throw new Error( 'Invalid sith clause: ' + @@ -187,15 +187,15 @@ export class Tholder { return false; } - let indexes: Set = new Set(indices.sort()); - let sats = new Array(indices.length).fill(false); - for (let idx of indexes) { + const indexes: Set = new Set(indices.sort()); + const sats = new Array(indices.length).fill(false); + for (const idx of indexes) { sats[idx] = true; } let wio = 0; - for (let clause of this.thold) { + for (const clause of this.thold) { let cw = 0; - for (let w of clause) { + for (const w of clause) { if (sats[wio]) { cw += Number(w); } diff --git a/src/keri/core/utils.ts b/src/keri/core/utils.ts index 15e8f7c5..82b85d1c 100644 --- a/src/keri/core/utils.ts +++ b/src/keri/core/utils.ts @@ -18,7 +18,7 @@ export function pad(n: any, width = 3, z = 0) { */ export function extractValues(ked: any, labels: any) { let values = []; - for (let label of labels) { + for (const label of labels) { values = extractElementValues(ked[label], values); } @@ -46,7 +46,7 @@ function extractElementValues(element: any, values: any) { try { if (element instanceof Array && !(typeof element == 'string')) { - for (let k in element) extractElementValues(element[k], values); + for (const k in element) extractElementValues(element[k], values); } else if (typeof element == 'string') { values.push(element); } @@ -88,7 +88,7 @@ export function range(start: number, stop: number, step: number) { return []; } - let result = new Array(); + const result = new Array(); for (let i: number = start; step > 0 ? i < stop : i > stop; i += step) { result.push(i); } @@ -100,7 +100,7 @@ export function intToBytes(value: number, length: number): Uint8Array { const byteArray = new Uint8Array(length); // Assuming a 4-byte integer (32 bits) for (let index = byteArray.length - 1; index >= 0; index--) { - let byte = value & 0xff; + const byte = value & 0xff; byteArray[index] = byte; value = (value - byte) / 256; } @@ -116,15 +116,15 @@ export function bytesToInt(ar: Uint8Array): number { } export function serializeACDCAttachment(acdc: Serder): Uint8Array { - let prefixer = new Prefixer({ raw: b(acdc.raw) }); - let seqner = new Seqner({ sn: acdc.sn }); - let saider = new Saider({ qb64: acdc.ked['d'] }); - let craw = new Uint8Array(); - let ctr = new Counter({ code: CtrDex.SealSourceTriples, count: 1 }).qb64b; - let prefix = prefixer.qb64b; - let seq = seqner.qb64b; - let said = saider.qb64b; - let newCraw = new Uint8Array( + const prefixer = new Prefixer({ raw: b(acdc.raw) }); + const seqner = new Seqner({ sn: acdc.sn }); + const saider = new Saider({ qb64: acdc.ked['d'] }); + const craw = new Uint8Array(); + const ctr = new Counter({ code: CtrDex.SealSourceTriples, count: 1 }).qb64b; + const prefix = prefixer.qb64b; + const seq = seqner.qb64b; + const said = saider.qb64b; + const newCraw = new Uint8Array( craw.length + ctr.length + prefix.length + seq.length + said.length ); newCraw.set(craw); @@ -136,19 +136,19 @@ export function serializeACDCAttachment(acdc: Serder): Uint8Array { } export function serializeIssExnAttachment(iss: Serder): Uint8Array { - let seqner = new Seqner({ sn: iss.sn }); - let ancSaider = new Saider({ qb64: iss.ked['d'] }); - let coupleArray = new Uint8Array( + const seqner = new Seqner({ sn: iss.sn }); + const ancSaider = new Saider({ qb64: iss.ked['d'] }); + const coupleArray = new Uint8Array( seqner.qb64b.length + ancSaider.qb64b.length ); coupleArray.set(seqner.qb64b); coupleArray.set(ancSaider.qb64b, seqner.qb64b.length); - let counter = new Counter({ + const counter = new Counter({ code: CtrDex.SealSourceCouples, count: 1, }); - let counterQb64b = counter.qb64b; - let atc = new Uint8Array(counter.qb64b.length + coupleArray.length); + const counterQb64b = counter.qb64b; + const atc = new Uint8Array(counter.qb64b.length + coupleArray.length); atc.set(counterQb64b); atc.set(coupleArray, counterQb64b.length); @@ -157,11 +157,11 @@ export function serializeIssExnAttachment(iss: Serder): Uint8Array { `Invalid attachments size: ${atc.length}, non-integral quadlets detected.` ); } - let pcnt = new Counter({ + const pcnt = new Counter({ code: CtrDex.AttachedMaterialQuadlets, count: Math.floor(atc.length / 4), }); - let msg = new Uint8Array(pcnt.qb64b.length + atc.length); + const msg = new Uint8Array(pcnt.qb64b.length + atc.length); msg.set(pcnt.qb64b); msg.set(atc, pcnt.qb64b.length); diff --git a/src/keri/core/vdring.ts b/src/keri/core/vdring.ts index 5da1ddb3..df601a7a 100644 --- a/src/keri/core/vdring.ts +++ b/src/keri/core/vdring.ts @@ -36,8 +36,8 @@ namespace vdr { code = MtrDex.Blake3_256, }: VDRInceptArgs): Serder { const vs = versify(Ident.KERI, version, kind, 0); - let isn = 0; - let ilk = Ilks.vcp; + const isn = 0; + const ilk = Ilks.vcp; if (cnfg.includes(TraitDex.NoBackers) && baks.length > 0) { throw new Error( @@ -70,7 +70,7 @@ namespace vdr { } } - let ked = { + const ked = { v: vs, t: ilk, d: '', @@ -83,7 +83,7 @@ namespace vdr { n: nonce, }; - let prefixer = new Prefixer({ code }, ked); + const prefixer = new Prefixer({ code }, ked); ked.i = prefixer.qb64; ked.d = prefixer.qb64; diff --git a/src/keri/end/ending.ts b/src/keri/end/ending.ts index 5811ec46..bc8f75dd 100644 --- a/src/keri/end/ending.ts +++ b/src/keri/end/ending.ts @@ -29,15 +29,15 @@ export class Signage { } export function signature(signages: Array): Headers { - let values = new Array(); + const values = new Array(); - for (let signage of signages) { + for (const signage of signages) { let markers: Array; let indexed = signage.indexed; - let signer = signage.signer; - let ordinal = signage.ordinal; - let digest = signage.digest; - let kind = signage.kind; + const signer = signage.signer; + const ordinal = signage.ordinal; + const digest = signage.digest; + const kind = signage.kind; let tags: Array; if (signage.markers instanceof Map) { @@ -52,8 +52,8 @@ export function signature(signages: Array): Headers { indexed = markers[0] instanceof Siger; } - let items = new Array(); - let tag = 'indexed'; + const items = new Array(); + const tag = 'indexed'; let val = indexed ? '?1' : '?0'; items.push(`${tag}="${val}"`); @@ -102,13 +102,13 @@ export function signature(signages: Array): Headers { } export function designature(value: string) { - let values = value.replace(' ', '').split(','); + const values = value.replace(' ', '').split(','); - let signages = new Array(); + const signages = new Array(); values.forEach((val) => { - let dict = new Map(); + const dict = new Map(); val.split(';').forEach((v) => { - let splits = v.split('=', 2); + const splits = v.split('=', 2); dict.set(splits[0], splits[1].replaceAll('"', '')); }); @@ -117,8 +117,8 @@ export function designature(value: string) { 'Missing indexed field in Signature header signage.' ); } - let item = dict.get('indexed')!; - let indexed = !FALSY.includes(item); + const item = dict.get('indexed')!; + const indexed = !FALSY.includes(item); dict.delete('indexed'); let signer; diff --git a/test/app/aiding.test.ts b/test/app/aiding.test.ts index a2e138d0..3b601765 100644 --- a/test/app/aiding.test.ts +++ b/test/app/aiding.test.ts @@ -120,7 +120,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -134,21 +134,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -164,12 +164,12 @@ describe('Aiding', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let identifiers = client.identifiers(); + const identifiers = client.identifiers(); await identifiers.list(); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; @@ -293,7 +293,7 @@ describe('Aiding', () => { assert.deepEqual(lastBody.salty.dcode, 'E'); assert.deepEqual(lastBody.salty.transferable, true); - let data = [ + const data = [ { i: 'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK', s: 0, @@ -346,12 +346,12 @@ describe('Aiding', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let identifiers = client.identifiers(); + const identifiers = client.identifiers(); await identifiers.list(); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; @@ -363,7 +363,7 @@ describe('Aiding', () => { algo: Algos.randy, }); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - let lastBody = JSON.parse(lastCall[1]!.body!.toString()); + const lastBody = JSON.parse(lastCall[1]!.body!.toString()); assert.equal(lastCall[0]!, url + '/identifiers'); assert.equal(lastCall[1]!.method, 'POST'); assert.equal(lastBody.name, 'aid1'); diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index e748f174..1506b4c8 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -134,7 +134,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -148,21 +148,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -177,12 +177,12 @@ describe('SignifyClient', () => { it('SignifyClient initialization', async () => { await libsodium.ready; - let t = () => { + const t = () => { new SignifyClient(url, 'short', Tier.low, boot_url); }; expect(t).toThrow('bran must be 21 characters'); - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); assert.equal(client.bran, '0123456789abcdefghijk'); assert.equal(client.url, url); assert.equal(client.bootUrl, boot_url); @@ -205,7 +205,7 @@ describe('SignifyClient', () => { ); assert.deepEqual(client.controller.serder.ked.s, '0'); - let res = await client.boot(); + const res = await client.boot(); assert.equal(fetchMock.mock.calls[0]![0]!, boot_url + '/boot'); assert.equal( fetchMock.mock.calls[0]![1]!.body!.toString(), @@ -247,7 +247,7 @@ describe('SignifyClient', () => { ); assert.equal(client.controller.serder.ked.a[0].s, '0'); - let data = client.data; + const data = client.data; assert(data[0], url); assert(data[0], bran); diff --git a/test/app/contacting.test.ts b/test/app/contacting.test.ts index 0a0c8409..7018720d 100644 --- a/test/app/contacting.test.ts +++ b/test/app/contacting.test.ts @@ -115,7 +115,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -129,21 +129,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -159,12 +159,12 @@ describe('Contacting', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let contacts = client.contacts(); + const contacts = client.contacts(); await contacts.list('mygroup', 'company', 'mycompany'); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; @@ -183,7 +183,7 @@ describe('Contacting', () => { ); assert.equal(lastCall[1]!.method, 'GET'); - let info = { + const info = { name: 'John Doe', company: 'My Company', }; @@ -227,12 +227,12 @@ describe('Contacting', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let challenges = client.challenges(); + const challenges = client.challenges(); await challenges.generate(128); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; diff --git a/test/app/controller.test.ts b/test/app/controller.test.ts index b83479d2..6550627d 100644 --- a/test/app/controller.test.ts +++ b/test/app/controller.test.ts @@ -10,15 +10,15 @@ describe('Controller', () => { it('manage account AID signing and agent verification', async () => { await libsodium.ready; let passcode = '0123456789abcdefghijk'; - let mgr = openManager(passcode); + const mgr = openManager(passcode); assert.equal(mgr.aeid, 'BMbZTXzB7LmWPT2TXLGV88PQz5vDEM2L2flUs2yxn3U9'); - let raw = new Uint8Array([ + const raw = new Uint8Array([ 187, 140, 234, 145, 219, 254, 20, 194, 16, 18, 97, 194, 140, 192, 61, 145, 222, 110, 59, 160, 152, 2, 72, 122, 87, 143, 109, 39, 98, 153, 192, 148, ]); - let agentSigner = new Signer({ + const agentSigner = new Signer({ raw: raw, code: MtrDex.Ed25519_Seed, transferable: false, diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index 7490bfd2..56b857d9 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -118,7 +118,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -132,21 +132,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -160,13 +160,13 @@ fetchMock.mockResponse((req) => { describe('Coring', () => { it('Random passcode', async () => { await libsodium.ready; - let passcode = randomPasscode(); + const passcode = randomPasscode(); assert.equal(passcode.length, 22); }); it('Random nonce', async () => { await libsodium.ready; - let nonce = randomNonce(); + const nonce = randomNonce(); assert.equal(nonce.length, 44); }); @@ -174,12 +174,12 @@ describe('Coring', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let oobis = client.oobis(); + const oobis = client.oobis(); await oobis.get('aid', 'agent'); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; @@ -206,15 +206,15 @@ describe('Coring', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let ops = client.operations(); + const ops = client.operations(); await ops.get('operationName'); - let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + const lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, url + '/operations/operationName'); assert.equal(lastCall[1]!.method, 'GET'); }); @@ -223,13 +223,13 @@ describe('Coring', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let keyEvents = client.keyEvents(); - let keyStates = client.keyStates(); + const keyEvents = client.keyEvents(); + const keyStates = client.keyStates(); await keyEvents.get('EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX'); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; @@ -265,7 +265,7 @@ describe('Coring', () => { 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao' ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - let lastBody = JSON.parse(lastCall[1]!.body!.toString()); + const lastBody = JSON.parse(lastCall[1]!.body!.toString()); assert.equal(lastCall[0]!, url + '/queries'); assert.equal(lastCall[1]!.method, 'POST'); assert.equal( diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index dfaa966a..68c16395 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -126,7 +126,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -140,21 +140,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -170,14 +170,14 @@ describe('Credentialing', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let credentials = client.credentials(); + const credentials = client.credentials(); - let kargs = { + const kargs = { filter: { '-i': { $eq: 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' }, }, @@ -326,19 +326,19 @@ describe('Ipex', () => { it('Ipex', async () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let ipex = client.ipex(); + const ipex = client.ipex(); - let holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k'; - let [acdcSaider, acdc] = Saider.saidify(mockCredential.sad); + const holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k'; + const [acdcSaider, acdc] = Saider.saidify(mockCredential.sad); // Create iss const vs = versify(Ident.KERI, undefined, Serials.JSON, 0); - let _iss = { + const _iss = { v: vs, t: Ilks.iss, d: '', @@ -348,9 +348,9 @@ describe('Ipex', () => { dt: mockCredential.sad.a.dt, }; - let [issSaider, iss] = Saider.saidify(_iss); - let iserder = new Serder(iss); - let anc = interact({ + const [issSaider, iss] = Saider.saidify(_iss); + const iserder = new Serder(iss); + const anc = interact({ pre: mockCredential.sad.i, sn: 1, data: [{}], @@ -359,7 +359,7 @@ describe('Ipex', () => { kind: undefined, }); - let [grant, gsigs, end] = await ipex.grant({ + const [grant, gsigs, end] = await ipex.grant({ senderName: 'multisig', recipient: holder, message: '', @@ -426,7 +426,7 @@ describe('Ipex', () => { '-e-anc-AABAADMtDfNihvCSXJNp1VronVojcPGo--0YZ4Kh6CAnowRnn4Or4FgZQqaqCEv6XVS413qfZoVp8j2uxTTPkItO7ED' ); - let [admit, asigs, aend] = await ipex.admit( + const [admit, asigs, aend] = await ipex.admit( 'holder', '', grant.ked.d, diff --git a/test/app/escrowing.test.ts b/test/app/escrowing.test.ts index 70eb71ce..10049123 100644 --- a/test/app/escrowing.test.ts +++ b/test/app/escrowing.test.ts @@ -115,7 +115,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -129,21 +129,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -159,12 +159,12 @@ describe('SignifyClient', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let escrows = client.escrows(); + const escrows = client.escrows(); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; await escrows.listReply('/presentation/request'); diff --git a/test/app/exchanging.test.ts b/test/app/exchanging.test.ts index 3d367c14..d9b4abb4 100644 --- a/test/app/exchanging.test.ts +++ b/test/app/exchanging.test.ts @@ -126,7 +126,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -140,21 +140,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -168,7 +168,7 @@ fetchMock.mockResponse((req) => { describe('exchange', () => { it('should create an exchange message with no transposed attachments', async () => { await libsodium.ready; - let dt = '2023-08-30T17:22:54.183Z'; + const dt = '2023-08-30T17:22:54.183Z'; let [exn, end] = exchange('/multisig/vcp', {}, 'test', undefined, dt); assert.deepStrictEqual(exn.ked, { @@ -185,39 +185,39 @@ describe('exchange', () => { }); assert.deepStrictEqual(end, new Uint8Array()); - let sith = 1; - let nsith = 1; - let sn = 0; - let toad = 0; + const sith = 1; + const nsith = 1; + const sn = 0; + const toad = 0; - let raw = new Uint8Array([ + const raw = new Uint8Array([ 5, 170, 143, 45, 83, 154, 233, 250, 85, 156, 2, 156, 155, 8, 72, 117, ]); - let salter = new Salter({ raw: raw }); - let skp0 = salter.signer( + const salter = new Salter({ raw: raw }); + const skp0 = salter.signer( MtrDex.Ed25519_Seed, true, 'A', Tier.low, true ); - let keys = [skp0.verfer.qb64]; + const keys = [skp0.verfer.qb64]; - let skp1 = salter.signer( + const skp1 = salter.signer( MtrDex.Ed25519_Seed, true, 'N', Tier.low, true ); - let ndiger = new Diger({}, skp1.verfer.qb64b); - let nxt = [ndiger.qb64]; + const ndiger = new Diger({}, skp1.verfer.qb64b); + const nxt = [ndiger.qb64]; assert.deepStrictEqual(nxt, [ 'EAKUR-LmLHWMwXTLWQ1QjxHrihBmwwrV2tYaSG7hOrWj', ]); - let ked0 = { + const ked0 = { v: 'KERI10JSON000000_', t: Ilks.icp, d: '', @@ -233,14 +233,14 @@ describe('exchange', () => { a: [], } as Dict; - let serder = new Serder(ked0); - let siger = skp0.sign(b(serder.raw), 0); + const serder = new Serder(ked0); + const siger = skp0.sign(b(serder.raw), 0); assert.equal( siger.qb64, 'AAAPkMTS3LrrhVuQB0k4UndDN0xIfEiKYaN7rTlQ_q9ImnBcugwNO8VWTALXzWoaldJEC1IOpEGkEnjZfxxIleoI' ); - let ked1 = { + const ked1 = { v: 'KERI10JSON000000_', t: Ilks.vcp, d: '', @@ -249,9 +249,9 @@ describe('exchange', () => { bt: toad.toString(16), b: [], } as Dict; - let vcp = new Serder(ked1); + const vcp = new Serder(ked1); - let embeds = { + const embeds = { icp: [serder, siger.qb64], vcp: [vcp, undefined], } as Dict; @@ -315,45 +315,45 @@ describe('exchange', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let exchange = client.exchanges(); - let sith = 1; - let nsith = 1; - let sn = 0; - let toad = 0; + const exchange = client.exchanges(); + const sith = 1; + const nsith = 1; + const sn = 0; + const toad = 0; - let raw = new Uint8Array([ + const raw = new Uint8Array([ 5, 170, 143, 45, 83, 154, 233, 250, 85, 156, 2, 156, 155, 8, 72, 117, ]); - let salter = new Salter({ raw: raw }); - let skp0 = salter.signer( + const salter = new Salter({ raw: raw }); + const skp0 = salter.signer( MtrDex.Ed25519_Seed, true, 'A', Tier.low, true ); - let keys = [skp0.verfer.qb64]; + const keys = [skp0.verfer.qb64]; - let skp1 = salter.signer( + const skp1 = salter.signer( MtrDex.Ed25519_Seed, true, 'N', Tier.low, true ); - let ndiger = new Diger({}, skp1.verfer.qb64b); - let nxt = [ndiger.qb64]; + const ndiger = new Diger({}, skp1.verfer.qb64b); + const nxt = [ndiger.qb64]; assert.deepStrictEqual(nxt, [ 'EAKUR-LmLHWMwXTLWQ1QjxHrihBmwwrV2tYaSG7hOrWj', ]); - let ked0 = { + const ked0 = { v: 'KERI10JSON000000_', t: Ilks.icp, d: '', @@ -369,7 +369,7 @@ describe('exchange', () => { a: [], } as Dict; - let serder = new Serder(ked0); + const serder = new Serder(ked0); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; await exchange.sendFromEvents('aid1', '', serder, [''], '', []); diff --git a/test/app/grouping.test.ts b/test/app/grouping.test.ts index 5992bc2d..4b408725 100644 --- a/test/app/grouping.test.ts +++ b/test/app/grouping.test.ts @@ -115,7 +115,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -129,21 +129,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -159,12 +159,12 @@ describe('Grouping', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let groups = client.groups(); + const groups = client.groups(); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; await groups.sendRequest('aid1', {}, [], ''); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; diff --git a/test/app/habery.test.ts b/test/app/habery.test.ts index 3b46e04a..a2fe343c 100644 --- a/test/app/habery.test.ts +++ b/test/app/habery.test.ts @@ -8,8 +8,8 @@ import { MtrDex } from '../../src/keri/core/matter'; describe('Habery', () => { it('should manage AID creation and rotation', async () => { await libsodium.ready; - let salt = new Salter({ raw: b('0123456789abcdef') }).qb64; - let hby = new Habery({ + const salt = new Salter({ raw: b('0123456789abcdef') }).qb64; + const hby = new Habery({ name: 'signify', salt: salt, passcode: '0123456789abcdefghijk', @@ -20,7 +20,7 @@ describe('Habery', () => { 'BMbZTXzB7LmWPT2TXLGV88PQz5vDEM2L2flUs2yxn3U9' ); - let hab = hby.makeHab('test', {}); + const hab = hby.makeHab('test', {}); assert.deepStrictEqual(hab.serder.ked['k'], [ 'DAQVURvW74OJH1Q0C6YLim_tdBYoXABwg6GsAlPaUJXE', @@ -32,14 +32,14 @@ describe('Habery', () => { it('should use passcode as salt', async () => { await libsodium.ready; - let passcode = '0123456789abcdefghijk'; + const passcode = '0123456789abcdefghijk'; if (passcode.length < 21) { throw new Error('Bran (passcode seed material) too short.'); } - let bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed - let salter = new Salter({ qb64: bran }); - let signer = salter.signer(MtrDex.Ed25519_Seed, true); + const bran = MtrDex.Salt_128 + 'A' + passcode.substring(0, 21); // qb64 salt for seed + const salter = new Salter({ qb64: bran }); + const signer = salter.signer(MtrDex.Ed25519_Seed, true); assert.equal( signer.qb64, 'AKeXgiAUIN7OHGXO6rbw_IzWeaQTr1LF7jWD6YEdrpa6' @@ -49,8 +49,8 @@ describe('Habery', () => { 'DMbZTXzB7LmWPT2TXLGV88PQz5vDEM2L2flUs2yxn3U9' ); - let hby = new Habery({ name: 'test', salt: salter.qb64 }); - let hab = hby.makeHab('test', { transferable: true }); + const hby = new Habery({ name: 'test', salt: salter.qb64 }); + const hab = hby.makeHab('test', { transferable: true }); assert.equal(hab.pre, 'EMRbh7mWJTijcWiQKT3uxozncpa9_gEX1IU0fM1wnKxi'); }); diff --git a/test/app/notifying.test.ts b/test/app/notifying.test.ts index ba265cb6..b40b481b 100644 --- a/test/app/notifying.test.ts +++ b/test/app/notifying.test.ts @@ -115,7 +115,7 @@ fetchMock.mockResponse((req) => { } else if (req.url == boot_url + '/boot') { return Promise.resolve({ body: '', init: { status: 202 } }); } else { - let headers = new Headers(); + const headers = new Headers(); let signed_headers = new Headers(); headers.set( @@ -129,21 +129,21 @@ fetchMock.mockResponse((req) => { headers.set('Content-Type', 'application/json'); const requrl = new URL(req.url); - let salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); - let signer = salter.signer( + const salter = new Salter({ qb64: '0AAwMTIzNDU2Nzg5YWJjZGVm' }); + const signer = salter.signer( 'A', true, 'agentagent-ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', Tier.low ); - let authn = new Authenticater(signer!, signer!.verfer); + const authn = new Authenticater(signer!, signer!.verfer); signed_headers = authn.sign( headers, req.method, requrl.pathname.split('?')[0] ); - let body = req.url.startsWith(url + '/identifiers/aid1/credentials') + const body = req.url.startsWith(url + '/identifiers/aid1/credentials') ? mockCredential : mockGetAID; @@ -159,18 +159,18 @@ describe('SignifyClient', () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; - let client = new SignifyClient(url, bran, Tier.low, boot_url); + const client = new SignifyClient(url, bran, Tier.low, boot_url); await client.boot(); await client.connect(); - let notifications = client.notifications(); + const notifications = client.notifications(); await notifications.list(20, 40); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, url + '/notifications'); assert.equal(lastCall[1]!.method, 'GET'); - let lastHeaders = new Headers(lastCall[1]!.headers!); + const lastHeaders = new Headers(lastCall[1]!.headers!); assert.equal(lastHeaders.get('Range'), 'notes=20-40'); await notifications.mark('notificationSAID'); diff --git a/test/app/registry.test.ts b/test/app/registry.test.ts index c4ee638b..14971493 100644 --- a/test/app/registry.test.ts +++ b/test/app/registry.test.ts @@ -9,12 +9,12 @@ import { strict as assert } from 'assert'; describe('registry', () => { it('should create a registry', async () => { await libsodium.ready; - let mockedClient = mock(SignifyClient); - let mockedIdentifiers = mock(Identifier); - let mockedKeyManager = mock(KeyManager); - let mockedKeeper = mock(SaltyKeeper); + const mockedClient = mock(SignifyClient); + const mockedIdentifiers = mock(Identifier); + const mockedKeyManager = mock(KeyManager); + const mockedKeeper = mock(SaltyKeeper); - let hab = { prefix: 'hab prefix', state: { s: 0, d: 'a digest' } }; + const hab = { prefix: 'hab prefix', state: { s: 0, d: 'a digest' } }; when(mockedClient.manager).thenReturn(instance(mockedKeyManager)); when(mockedKeyManager.get(hab)).thenReturn(instance(mockedKeeper)); @@ -28,7 +28,7 @@ describe('registry', () => { instance(mockedIdentifiers) ); - let mockedResponse = mock(Response); + const mockedResponse = mock(Response); when( mockedClient.fetch( '/identifiers/a name/registries', @@ -37,9 +37,9 @@ describe('registry', () => { ) ).thenResolve(instance(mockedResponse)); - let registries = new Registries(instance(mockedClient)); + const registries = new Registries(instance(mockedClient)); - let actual = await registries.create({ + const actual = await registries.create({ name: 'a name', registryName: 'a registry name', nonce: '', @@ -57,10 +57,10 @@ describe('registry', () => { it('should fail on estanblishmnet only for now', async () => { await libsodium.ready; - let mockedClient = mock(SignifyClient); - let mockedIdentifiers = mock(Identifier); + const mockedClient = mock(SignifyClient); + const mockedIdentifiers = mock(Identifier); - let hab = { + const hab = { prefix: 'hab prefix', state: { s: 0, d: 'a digest', c: ['EO'] }, }; @@ -70,7 +70,7 @@ describe('registry', () => { instance(mockedIdentifiers) ); - let registries = new Registries(instance(mockedClient)); + const registries = new Registries(instance(mockedClient)); assert.rejects( async () => { diff --git a/test/core/authing.test.ts b/test/core/authing.test.ts index 68984d36..27466437 100644 --- a/test/core/authing.test.ts +++ b/test/core/authing.test.ts @@ -9,13 +9,13 @@ import { Verfer } from '../../src/keri/core/verfer'; describe('Authenticater.verify', () => { it('verify signature on Response', async () => { await libsodium.ready; - let salt = '0123456789abcdef'; - let salter = new Salter({ raw: b(salt) }); - let signer = salter.signer(); - let aaid = 'DMZh_y-H5C3cSbZZST-fqnsmdNTReZxIh0t2xSTOJQ8a'; - let verfer = new Verfer({ qb64: aaid }); + const salt = '0123456789abcdef'; + const salter = new Salter({ raw: b(salt) }); + const signer = salter.signer(); + const aaid = 'DMZh_y-H5C3cSbZZST-fqnsmdNTReZxIh0t2xSTOJQ8a'; + const verfer = new Verfer({ qb64: aaid }); - let headers = new Headers([ + const headers = new Headers([ ['Content-Length', '898'], ['Content-Type', 'application/json'], [ @@ -33,7 +33,7 @@ describe('Authenticater.verify', () => { ['Signify-Timestamp', '2023-05-22T00:37:00.248708+00:00'], ]); - let authn = new Authenticater(signer, verfer); + const authn = new Authenticater(signer, verfer); assert.notEqual(authn, undefined); assert.equal( @@ -46,11 +46,11 @@ describe('Authenticater.verify', () => { describe('Authenticater.sign', () => { it('Create signed headers for a request', async () => { await libsodium.ready; - let salt = '0123456789abcdef'; - let salter = new Salter({ raw: b(salt) }); - let signer = salter.signer(); - let aaid = 'DDK2N5_fVCWIEO9d8JLhk7hKrkft6MbtkUhaHQsmABHY'; - let verfer = new Verfer({ qb64: aaid }); + const salt = '0123456789abcdef'; + const salter = new Salter({ raw: b(salt) }); + const signer = salter.signer(); + const aaid = 'DDK2N5_fVCWIEO9d8JLhk7hKrkft6MbtkUhaHQsmABHY'; + const verfer = new Verfer({ qb64: aaid }); let headers = new Headers([ ['Content-Type', 'application/json'], @@ -66,7 +66,7 @@ describe('Authenticater.sign', () => { new Date('2021-01-01T00:00:00.000000+00:00') ); - let authn = new Authenticater(signer, verfer); + const authn = new Authenticater(signer, verfer); headers = authn.sign(headers, 'POST', '/boot'); assert.equal(headers.has('Signature-Input'), true); diff --git a/test/core/counter.test.ts b/test/core/counter.test.ts index 4934a296..deb9c2ec 100644 --- a/test/core/counter.test.ts +++ b/test/core/counter.test.ts @@ -11,7 +11,7 @@ describe('int to b64 and back', () => { // verify first hs Sizes matches hs in Codes for same first char Counter.Sizes.forEach((_, ckey) => { - let key = ckey.slice(0, 2); + const key = ckey.slice(0, 2); assert.equal(Counter.Hards.get(key), Counter.Sizes.get(ckey)!.hs); }); @@ -59,11 +59,11 @@ describe('int to b64 and back', () => { assert.deepStrictEqual(counter.qb64b, qscb); assert.equal(counter.qb64, qsc); - let longqs64 = `${qsc}ABCD`; + const longqs64 = `${qsc}ABCD`; counter = new Counter({ qb64: longqs64 }); assert.equal(counter.qb64.length, Counter.Sizes.get(counter.code)!.fs); - let shortqcs = qsc.slice(0, -1); + const shortqcs = qsc.slice(0, -1); assert.throws(() => { new Counter({ qb64: shortqcs }); }); @@ -118,8 +118,8 @@ describe('int to b64 and back', () => { assert.deepStrictEqual(counter.qb64b, qscb); assert.equal(counter.qb64, qsc); - let verint = 0; - let version = intToB64(verint, 3); + const verint = 0; + const version = intToB64(verint, 3); assert.equal(version, 'AAA'); assert.equal(verint, b64ToInt(version)); qsc = CtrDex.KERIProtocolStack + version; diff --git a/test/core/decrypter.test.ts b/test/core/decrypter.test.ts index f840c950..539f1b9a 100644 --- a/test/core/decrypter.test.ts +++ b/test/core/decrypter.test.ts @@ -12,17 +12,17 @@ describe('Decrypter', () => { await libsodium.ready; // (b'\x18;0\xc4\x0f*vF\xfa\xe3\xa2Eee\x1f\x96o\xce)G\x85\xe3X\x86\xda\x04\xf0\xdc\xde\x06\xc0+') - let seed = new Uint8Array([ + const seed = new Uint8Array([ 24, 59, 48, 196, 15, 42, 118, 70, 250, 227, 162, 69, 101, 101, 31, 150, 111, 206, 41, 71, 133, 227, 88, 134, 218, 4, 240, 220, 222, 6, 192, 43, ]); - let signer = new Signer({ raw: seed, code: MtrDex.Ed25519_Seed }); + const signer = new Signer({ raw: seed, code: MtrDex.Ed25519_Seed }); assert.equal(signer.verfer.code, MtrDex.Ed25519); assert.equal(signer.verfer.transferable, true); // default - let seedqb64 = signer.qb64; - let seedqb64b = signer.qb64b; + const seedqb64 = signer.qb64; + const seedqb64b = signer.qb64b; assert.equal(seedqb64, 'ABg7MMQPKnZG-uOiRWVlH5ZvzilHheNYhtoE8NzeBsAr'); // also works for Matter @@ -32,14 +32,14 @@ describe('Decrypter', () => { ); // raw = b'6\x08d\r\xa1\xbb9\x8dp\x8d\xa0\xc0\x13J\x87r' - let raw = new Uint8Array([ + const raw = new Uint8Array([ 54, 8, 100, 13, 161, 187, 57, 141, 112, 141, 160, 192, 19, 74, 135, 114, ]); - let salter = new Salter({ raw: raw, code: MtrDex.Salt_128 }); + const salter = new Salter({ raw: raw, code: MtrDex.Salt_128 }); assert.equal(salter.code, MtrDex.Salt_128); - let saltqb64 = salter.qb64; - let saltqb64b = salter.qb64b; + const saltqb64 = salter.qb64; + const saltqb64b = salter.qb64b; assert.deepStrictEqual(saltqb64, '0AA2CGQNobs5jXCNoMATSody'); // also works for Matter @@ -49,21 +49,21 @@ describe('Decrypter', () => { ); // cryptseed = b'h,#|\x8ap"\x12\xc43t2\xa6\xe1\x18\x19\xf0f2,y\xc4\xc21@\xf5@\x15.\xa2\x1a\xcf' - let cryptseed = new Uint8Array([ + const cryptseed = new Uint8Array([ 104, 44, 35, 124, 138, 112, 34, 18, 196, 51, 116, 50, 166, 225, 24, 25, 240, 102, 50, 44, 121, 196, 194, 49, 64, 245, 64, 21, 46, 162, 26, 207, ]); - let cryptsigner = new Signer({ + const cryptsigner = new Signer({ raw: cryptseed, code: MtrDex.Ed25519_Seed, transferable: true, }); - let keypair = libsodium.crypto_sign_seed_keypair(cryptseed); // raw - let pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( + const keypair = libsodium.crypto_sign_seed_keypair(cryptseed); // raw + const pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( keypair.publicKey ); - let prikey = libsodium.crypto_sign_ed25519_sk_to_curve25519( + const prikey = libsodium.crypto_sign_ed25519_sk_to_curve25519( keypair.privateKey ); @@ -72,7 +72,7 @@ describe('Decrypter', () => { }); // create encrypter - let encrypter = new Encrypter({ raw: pubkey }); + const encrypter = new Encrypter({ raw: pubkey }); assert.equal(encrypter.code, MtrDex.X25519); assert.equal( encrypter.qb64, @@ -81,7 +81,7 @@ describe('Decrypter', () => { assert.deepStrictEqual(encrypter.raw, pubkey); // create cipher of seed - let seedcipher = encrypter.encrypt(seedqb64b); + const seedcipher = encrypter.encrypt(seedqb64b); assert.equal(seedcipher.code, MtrDex.X25519_Cipher_Seed); // each encryption uses a nonce so not a stable representation for testing @@ -117,7 +117,7 @@ describe('Decrypter', () => { assert.equal(signer.verfer.transferable, true); // create cipher of salt - let saltcipher = encrypter.encrypt(saltqb64b); + const saltcipher = encrypter.encrypt(saltqb64b); assert.equal(saltcipher.code, MtrDex.X25519_Cipher_Salt); // each encryption uses a nonce so not a stable representation for testing @@ -133,7 +133,7 @@ describe('Decrypter', () => { // use previously stored fully qualified seed cipher with different nonce // get from seedcipher above - let cipherseed = + const cipherseed = 'PM9jOGWNYfjM_oLXJNaQ8UlFSAV5ACjsUY7J16xfzrlpc9Ve3A5WYrZ4o_NHtP5lhp78Usspl9fyFdnCdItNd5JyqZ6dt8SXOt6TOqOCs-gy0obrwFkPPqBvVkEw'; designer = decrypter.decrypt( b(cipherseed), @@ -146,7 +146,7 @@ describe('Decrypter', () => { // use previously stored fully qualified salt cipher with different nonce // get from saltcipher above - let ciphersalt = + const ciphersalt = '1AAHjlR2QR9J5Et67Wy-ZaVdTryN6T6ohg44r73GLRPnHw-5S3ABFkhWyIwLOI6TXUB_5CT13S8JvknxLxBaF8ANPK9FSOPD8tYu'; desalter = decrypter.decrypt(b(ciphersalt)); assert.deepStrictEqual(desalter.qb64b, saltqb64b); diff --git a/test/core/encrypter.test.ts b/test/core/encrypter.test.ts index 445be03a..53c27d79 100644 --- a/test/core/encrypter.test.ts +++ b/test/core/encrypter.test.ts @@ -13,12 +13,12 @@ describe('Encrypter', () => { await libsodium.ready; // (b'\x18;0\xc4\x0f*vF\xfa\xe3\xa2Eee\x1f\x96o\xce)G\x85\xe3X\x86\xda\x04\xf0\xdc\xde\x06\xc0+') - let seed = new Uint8Array([ + const seed = new Uint8Array([ 24, 59, 48, 196, 15, 42, 118, 70, 250, 227, 162, 69, 101, 101, 31, 150, 111, 206, 41, 71, 133, 227, 88, 134, 218, 4, 240, 220, 222, 6, 192, 43, ]); - let seedqb64b = new Matter({ raw: seed, code: MtrDex.Ed25519_Seed }) + const seedqb64b = new Matter({ raw: seed, code: MtrDex.Ed25519_Seed }) .qb64b; assert.equal( @@ -27,30 +27,30 @@ describe('Encrypter', () => { ); // b'6\x08d\r\xa1\xbb9\x8dp\x8d\xa0\xc0\x13J\x87r' - let salt = new Uint8Array([ + const salt = new Uint8Array([ 54, 8, 100, 13, 161, 187, 57, 141, 112, 141, 160, 192, 19, 74, 135, 114, ]); - let saltqb64 = new Matter({ raw: salt, code: MtrDex.Salt_128 }).qb64; - let saltqb64b = new Matter({ raw: salt, code: MtrDex.Salt_128 }).qb64b; + const saltqb64 = new Matter({ raw: salt, code: MtrDex.Salt_128 }).qb64; + const saltqb64b = new Matter({ raw: salt, code: MtrDex.Salt_128 }).qb64b; assert.equal(saltqb64, '0AA2CGQNobs5jXCNoMATSody'); // b'h,#|\x8ap"\x12\xc43t2\xa6\xe1\x18\x19\xf0f2,y\xc4\xc21@\xf5@\x15.\xa2\x1a\xcf' - let cryptseed = new Uint8Array([ + const cryptseed = new Uint8Array([ 104, 44, 35, 124, 138, 112, 34, 18, 196, 51, 116, 50, 166, 225, 24, 25, 240, 102, 50, 44, 121, 196, 194, 49, 64, 245, 64, 21, 46, 162, 26, 207, ]); - let cryptsigner = new Signer({ + const cryptsigner = new Signer({ raw: cryptseed, code: MtrDex.Ed25519_Seed, transferable: true, }); - let keypair = libsodium.crypto_sign_seed_keypair(cryptseed); // raw - let pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( + const keypair = libsodium.crypto_sign_seed_keypair(cryptseed); // raw + const pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519( keypair.publicKey ); - let prikey = libsodium.crypto_sign_ed25519_sk_to_curve25519( + const prikey = libsodium.crypto_sign_ed25519_sk_to_curve25519( keypair.privateKey ); @@ -85,7 +85,7 @@ describe('Encrypter', () => { ); assert.deepStrictEqual(uncb, saltqb64b); - let verfer = new Verfer({ + const verfer = new Verfer({ raw: keypair.publicKey, code: MtrDex.Ed25519, }); diff --git a/test/core/eventing.test.ts b/test/core/eventing.test.ts index 41e52d63..b730a364 100644 --- a/test/core/eventing.test.ts +++ b/test/core/eventing.test.ts @@ -12,7 +12,7 @@ describe('key event function', () => { it('incept should create inception events', async () => { await libsodium.ready; - let seed = new Uint8Array([ + const seed = new Uint8Array([ 159, 123, 168, 167, 168, 67, 57, 150, 38, 250, 177, 153, 235, 170, 32, 196, 27, 71, 17, 196, 174, 83, 65, 82, 201, 189, 4, 157, 133, 41, 126, 147, @@ -158,13 +158,13 @@ describe('key event function', () => { 'M52w4H-S7NGU2qVIfraXVIlV9hEAaMHg7W"],"bt":0,"b":[],"c":[],"a":[]}' ); - let siger = signer0.sign(b(serder0.raw), 0) as Siger; + const siger = signer0.sign(b(serder0.raw), 0) as Siger; assert.equal( siger.qb64, 'AABB3MJGmBXxSEryNHw3YwZZLRl_6Ws4Me2WFq8PrQ6WlluSOpPqbwXuiG9RvNWZkqeW8A_0VRjokGMVRZ3m-c0I' ); - let msg = messagize(serder0, [siger]); + const msg = messagize(serder0, [siger]); assert.equal( d(msg), '{"v":"KERI10JSON000125_","t":"icp","d":"EIflL4H4134zYoRM6ls6Q086RLC_BhfNFh5uk-WxvhsL","i"' + @@ -172,7 +172,7 @@ describe('key event function', () => { '"nt":1,"n":["EIf-ENw7PrM52w4H-S7NGU2qVIfraXVIlV9hEAaMHg7W"],"bt":0,"b":[],"c":[],"a":[]}' + '-AABAABB3MJGmBXxSEryNHw3YwZZLRl_6Ws4Me2WFq8PrQ6WlluSOpPqbwXuiG9RvNWZkqeW8A_0VRjokGMVRZ3m-c0I' ); - let seal = [ + const seal = [ 'SealEvent', { i: 'EIflL4H4134zYoRM6ls6Q086RLC_BhfNFh5uk-WxvhsL', @@ -180,7 +180,7 @@ describe('key event function', () => { d: 'EIflL4H4134zYoRM6ls6Q086RLC_BhfNFh5uk-WxvhsL', }, ]; - let msgseal = messagize(serder0, [siger], seal); + const msgseal = messagize(serder0, [siger], seal); assert.equal( d(msgseal), '{"v":"KERI10JSON000125_","t":"icp","d":"EIflL4H4134zYoRM6ls6Q086RLC_BhfNFh5uk-WxvhsL","i"' + diff --git a/test/core/httping.test.ts b/test/core/httping.test.ts index a1851f76..c482fc25 100644 --- a/test/core/httping.test.ts +++ b/test/core/httping.test.ts @@ -12,11 +12,11 @@ import * as utilApi from '../../src/keri/core/utils'; describe('siginput', () => { it('create valid Signature-Input header with signature', async () => { await libsodium.ready; - let salt = '0123456789abcdef'; - let salter = new Salter({ raw: b(salt) }); - let signer = salter.signer(); + const salt = '0123456789abcdef'; + const salter = new Salter({ raw: b(salt) }); + const signer = salter.signer(); - let headers: Headers = new Headers([ + const headers: Headers = new Headers([ ['Content-Type', 'application/json'], ['Content-Length', '256'], ['Connection', 'close'], @@ -30,7 +30,7 @@ describe('siginput', () => { new Date('2021-01-01T00:00:00.000000+00:00') ); - let [header, sig] = siginput(signer, { + const [header, sig] = siginput(signer, { name: 'sig0', method: 'POST', path: '/signify', @@ -47,7 +47,7 @@ describe('siginput', () => { assert.equal(header.size, 1); assert.equal(header.has('Signature-Input'), true); - let sigipt = header.get('Signature-Input'); + const sigipt = header.get('Signature-Input'); assert.equal( sigipt, 'sig0=("Signify-Resource" "@method" "@path" "Signify-Timestamp");created=1609459200;keyid="DN54yRad_BTqgZYUSi_NthRBQrxSnqQdJXWI5UHcGOQt";alg="ed25519"' @@ -62,12 +62,12 @@ describe('siginput', () => { describe('desiginput', () => { it('create valid Signature-Input header with signature', async () => { await libsodium.ready; - let siginput = + const siginput = 'sig0=("signify-resource" "@method" "@path" "signify-timestamp");created=1609459200;keyid="EIaGMMWJFPmtXznY1IIiKDIrg-vIyge6mBl2QV8dDjI3";alg="ed25519"'; - let inputs = desiginput(siginput); + const inputs = desiginput(siginput); assert.equal(inputs.length, 1); - let input = inputs[0]; + const input = inputs[0]; assert.deepStrictEqual(input.fields, [ 'signify-resource', '@method', diff --git a/test/core/indexer.test.ts b/test/core/indexer.test.ts index bff64dcc..e0e53864 100644 --- a/test/core/indexer.test.ts +++ b/test/core/indexer.test.ts @@ -51,7 +51,7 @@ describe('Indexer', () => { // sig = (b"\x99\xd2<9$$0\x9fk\xfb\x18\xa0\x8c@r\x122.k\xb2\xc7\x1fp\x0e'm\x8f@" // b'\xaa\xa5\x8c\xc8n\x85\xc8!\xf6q\x91p\xa9\xec\xcf\x92\xaf)\xde\xca' // b'\xfc\x7f~\xd7o|\x17\x82\x1d\xd4 { 60, 111, 34, 129, 38, 9, ]); assert.equal(sig.length, 64); - let ps = (3 - (sig.length % 3)) % 3; - let bytes = new Uint8Array(ps + sig.length); + const ps = (3 - (sig.length % 3)) % 3; + const bytes = new Uint8Array(ps + sig.length); for (let i = 0; i < ps; i++) { bytes[i] = 0; } for (let i = 0; i < sig.length; i++) { - let odx = i + ps; + const odx = i + ps; bytes[odx] = sig[i]; } - let sig64 = Base64.encode(Buffer.from(bytes)); + const sig64 = Base64.encode(Buffer.from(bytes)); assert.equal(sig64.length, 88); assert.equal( sig64, 'AACZ0jw5JCQwn2v7GKCMQHISMi5rsscfcA4nbY9AqqWMyG6FyCH2cZFwqezPkq8p3sr8f37Xb3wXgh3UPG8igSYJ' ); - let qsc = IdrDex.Ed25519_Sig + intToB64(0, 1); + const qsc = IdrDex.Ed25519_Sig + intToB64(0, 1); assert.equal(qsc, 'AA'); let qsig64 = qsc + sig64.slice(ps); // replace prepad chars with clause assert.equal( @@ -118,7 +118,7 @@ describe('Indexer', () => { assert.equal(indexer.ondex, 0); assert.deepStrictEqual(indexer.qb64b, qsig64b); - let longsig = new Uint8Array(sig.length + 3); + const longsig = new Uint8Array(sig.length + 3); longsig.set(sig); longsig.set(new Uint8Array([10, 11, 12]), sig.length); indexer = new Indexer({ raw: longsig }); @@ -127,7 +127,7 @@ describe('Indexer', () => { assert.equal(indexer.index, 0); assert.equal(indexer.ondex, 0); - let shortsig = sig.slice(0, sig.length - 3); + const shortsig = sig.slice(0, sig.length - 3); assert.throws(() => { new Indexer({ raw: shortsig }); }); @@ -148,17 +148,17 @@ describe('Indexer', () => { assert.deepStrictEqual(indexer.qb64b, qsig64b); assert.deepStrictEqual(indexer.qb64, qsig64); - let badq64sig2 = + const badq64sig2 = 'AA_Z0jw5JCQwn2v7GKCMQHISMi5rsscfcA4nbY9AqqWMyG6FyCH2cZFwqezPkq8p3sr8f37Xb3wXgh3UPG8igSYJ'; assert.throws(() => { new Indexer({ qb64: badq64sig2 }); }); - let longqsig64 = qsig64 + 'ABCD'; + const longqsig64 = qsig64 + 'ABCD'; indexer = new Indexer({ qb64: longqsig64 }); assert.equal(indexer.qb64.length, Indexer.Sizes.get(indexer.code)!.fs); - let shortqsig64 = qsig64.slice(0, -4); + const shortqsig64 = qsig64.slice(0, -4); assert.throws(() => { new Indexer({ qb64: shortqsig64 }); }); @@ -283,7 +283,7 @@ describe('Indexer', () => { assert.deepStrictEqual(indexer.qb64b, qb64b); index = 90; - let ondex = 65; + const ondex = 65; qb64 = '2ABaBBCZ0jw5JCQwn2v7GKCMQHISMi5rsscfcA4nbY9AqqWMyG6FyCH2cZFwqezPkq8p3sr8f37Xb3wXgh3UPG8igSYJ'; qb64b = b(qb64); diff --git a/test/core/manager.test.ts b/test/core/manager.test.ts index 4879fce9..ce4881b6 100644 --- a/test/core/manager.test.ts +++ b/test/core/manager.test.ts @@ -24,7 +24,7 @@ describe('RandyCreator', () => { it('should create sets of random signers', async () => { await libsodium.ready; - let randy = new RandyCreator(); + const randy = new RandyCreator(); // test default arguments let keys = randy.create(); @@ -82,9 +82,9 @@ describe('SaltyCreator', () => { assert.equal(signer.qb64.length, 44); }); - let raw = '0123456789abcdef'; - let salter = new Salter({ raw: b(raw) }); - let salt = salter.qb64; + const raw = '0123456789abcdef'; + const salter = new Salter({ raw: b(raw) }); + const salt = salter.qb64; assert.equal(salter.qb64, '0AAwMTIzNDU2Nzg5YWJjZGVm'); salty = new SaltyCreator(salter.qb64); assert.equal(salty.salter.code, MtrDex.Salt_128); @@ -134,9 +134,9 @@ describe('Creator', () => { it('should create Randy or Salty creator', async () => { await libsodium.ready; - let raw = '0123456789abcdef'; - let salter = new Salter({ raw: b(raw) }); - let salt = salter.qb64; + const raw = '0123456789abcdef'; + const salter = new Salter({ raw: b(raw) }); + const salt = salter.qb64; let creator = new Creatory(Algos.salty).make(salt) as SaltyCreator; assert.equal(creator instanceof SaltyCreator, true); @@ -146,7 +146,7 @@ describe('Creator', () => { assert.equal(creator instanceof SaltyCreator, true); assert.equal(creator.salter.qb64, salt); - let rcreator = new Creatory(Algos.randy).make(salt) as RandyCreator; + const rcreator = new Creatory(Algos.randy).make(salt) as RandyCreator; assert.equal(rcreator instanceof RandyCreator, true); }); }); @@ -163,11 +163,11 @@ describe('Manager', () => { it('should manage key pairs for identifiers', async () => { await libsodium.ready; - let raw = '0123456789abcdef'; - let salter = new Salter({ raw: b(raw) }); - let salt = salter.qb64; + const raw = '0123456789abcdef'; + const salter = new Salter({ raw: b(raw) }); + const salt = salter.qb64; assert.equal(salt, '0AAwMTIzNDU2Nzg5YWJjZGVm'); - let stem = 'red'; + const stem = 'red'; // Create a randy Manager without encryption should raise an exception assert.throws(() => { @@ -175,44 +175,44 @@ describe('Manager', () => { }); // cryptseed0 = b('h,#|\x8ap"\x12\xc43t2\xa6\xe1\x18\x19\xf0f2,y\xc4\xc21@\xf5@\x15.\xa2\x1a\xcf') - let cryptseed0 = new Uint8Array([ + const cryptseed0 = new Uint8Array([ 104, 44, 35, 124, 138, 112, 34, 18, 196, 51, 116, 50, 166, 225, 24, 25, 240, 102, 50, 44, 121, 196, 194, 49, 64, 245, 64, 21, 46, 162, 26, 207, ]); - let cryptsigner0 = new Signer({ + const cryptsigner0 = new Signer({ raw: cryptseed0, code: MtrDex.Ed25519_Seed, transferable: false, }); - let seed0 = cryptsigner0.qb64; - let seed0b = cryptsigner0.qb64b; - let aeid0 = cryptsigner0.verfer.qb64; + const seed0 = cryptsigner0.qb64; + const seed0b = cryptsigner0.qb64b; + const aeid0 = cryptsigner0.verfer.qb64; assert.equal(aeid0, 'BCa7mK96FwxkU0TdF54Yqg3qBDXUWpOhQ_Mtr7E77yZB'); - let decrypter0 = new Decrypter({}, seed0b); - let encrypter0 = new Encrypter({}, b(aeid0)); + const decrypter0 = new Decrypter({}, seed0b); + const encrypter0 = new Encrypter({}, b(aeid0)); assert.equal(encrypter0.verifySeed(seed0b), true); // cryptseed1 = (b"\x89\xfe{\xd9'\xa7\xb3\x89#\x19\xbec\xee\xed\xc0\xf9\x97\xd0\x8f9\x1dyNI" // b'I\x98\xbd\xa4\xf6\xfe\xbb\x03') - let cryptseed1 = new Uint8Array([ + const cryptseed1 = new Uint8Array([ 137, 254, 123, 217, 39, 167, 179, 137, 35, 25, 190, 99, 238, 237, 192, 249, 151, 208, 143, 57, 29, 121, 78, 73, 73, 152, 189, 164, 246, 254, 187, 3, ]); - let cryptsigner1 = new Signer({ + const cryptsigner1 = new Signer({ raw: cryptseed1, code: MtrDex.Ed25519_Seed, transferable: false, }); - let seed1 = cryptsigner1.qb64b; - let aeid1 = cryptsigner1.verfer.qb64; + const seed1 = cryptsigner1.qb64b; + const aeid1 = cryptsigner1.verfer.qb64; assert.equal(aeid1, 'BEcOrMrG_7r_NWaLl6h8UJapwIfQWIkjrIPXkCZm2fFM'); // let decrypter1 = new Decrypter({}, seed1) - let encrypter1 = new Encrypter({}, b(aeid1)); + const encrypter1 = new Encrypter({}, b(aeid1)); assert.equal(encrypter1.verifySeed(seed1), true); - let manager = new Manager({ seed: seed0, salter: salter, aeid: aeid0 }); + const manager = new Manager({ seed: seed0, salter: salter, aeid: aeid0 }); assert.equal(manager.encrypter!.qb64, encrypter0.qb64); assert.equal(manager.decrypter!.qb64, decrypter0.qb64); assert.equal(manager.seed, seed0); @@ -222,7 +222,7 @@ describe('Manager', () => { assert.equal(manager.salt, salt); assert.equal(manager.pidx, 0); assert.equal(manager.tier, Tier.low); - let saltCipher0 = new Cipher({ qb64: manager.ks.getGbls('salt') }); + const saltCipher0 = new Cipher({ qb64: manager.ks.getGbls('salt') }); assert.equal(saltCipher0.decrypt(undefined, seed0b).qb64, salt); let [verfers, digers] = manager.incept({ salt: salt, temp: true }); @@ -268,7 +268,7 @@ describe('Manager', () => { 'ENmcKrctbztF36MttN7seUYJqH2IMnkavBgGLR6Mj2-B', ]); - let oldspre = spre; + const oldspre = spre; spre = 'DCu5o5cxzv1lgMqxMVG3IcCNK4lpFfpMM-9rfkY3XVUc'; manager.move(oldspre, spre); @@ -277,7 +277,7 @@ describe('Manager', () => { pl = manager.ks.getPubs(riKey(spre, ps.nxt.ridx))!; assert.deepStrictEqual(pl.pubs, ps.nxt.pubs); - let serb = b(ser); + const serb = b(ser); let psigers = manager.sign({ ser: serb, pubs: ps.new.pubs }); assert.equal(psigers.length, 1); assert.equal(psigers[0] instanceof Siger, true); @@ -297,7 +297,7 @@ describe('Manager', () => { ); // Test sign with indices - let indices = [3]; + const indices = [3]; psigers = manager.sign({ ser: serb, pubs: ps.new.pubs, @@ -323,24 +323,24 @@ describe('Manager', () => { vsigs = Array.from(vsigers as Array, (vsiger) => vsiger.qb64); assert.deepStrictEqual(psigs, vsigs); - let pcigars = manager.sign({ + const pcigars = manager.sign({ ser: serb, pubs: ps.new.pubs, indexed: false, }); assert.equal(pcigars.length, 1); assert.equal(pcigars[0] instanceof Cigar, true); - let vcigars = manager.sign({ + const vcigars = manager.sign({ ser: serb, verfers: verfers, indexed: false, }); assert.equal(vcigars.length, 1); - let pcigs = Array.from( + const pcigs = Array.from( pcigars as Array, (psiger) => psiger.qb64 ); - let vcigs = Array.from( + const vcigs = Array.from( vcigars as Array, (vsiger) => vsiger.qb64 ); @@ -392,7 +392,7 @@ describe('Manager', () => { assert.deepStrictEqual(oldpubs, ps.old.pubs); oldpubs = Array.from(verfers, (verfer: Verfer) => verfer.qb64); - let deadpubs = ps.old.pubs; + const deadpubs = ps.old.pubs; manager.rotate({ pre: spre }); @@ -457,7 +457,7 @@ describe('Manager', () => { assert.notEqual(manager.ks.getPris(key, decrypter0), undefined); }); - let oldrpre = rpre; + const oldrpre = rpre; rpre = 'DMqxMVG3IcCNK4lpFfCu5o5cxzv1lgpMM-9rfkY3XVUc'; manager.move(oldrpre, rpre); @@ -541,7 +541,7 @@ describe('Manager', () => { verfers = hashes[0]; digers = hashes[1]; - let witpre0 = verfers[0].qb64; + const witpre0 = verfers[0].qb64; assert.equal( verfers[0].qb64, 'BOTNI4RzN706NecNdqTlGEcMSTWiFUvesEqmxWR_op8n' @@ -559,7 +559,7 @@ describe('Manager', () => { verfers = hashes[0]; digers = hashes[1]; - let witpre1 = verfers[0].qb64; + const witpre1 = verfers[0].qb64; assert.equal( verfers[0].qb64, 'BAB_5xNXH4hoxDCtAHPFPDedZ6YwTo8mbdw_v0AOHOMt' @@ -574,11 +574,11 @@ describe('Manager', () => { await libsodium.ready; // Support Salty/Unencrypted - pass only stretched passcode as Salt. - let passcode = '0123456789abcdefghijk'; - let salter = new Salter({ raw: b(passcode) }); - let salt = salter.qb64; + const passcode = '0123456789abcdefghijk'; + const salter = new Salter({ raw: b(passcode) }); + const salt = salter.qb64; - let manager = new Manager({ salter: salter }); + const manager = new Manager({ salter: salter }); assert.equal(manager.encrypter, undefined); let [verfers, digers] = manager.incept({ salt: salt, temp: true }); @@ -609,7 +609,7 @@ describe('Manager', () => { 'ENmcKrctbztF36MttN7seUYJqH2IMnkavBgGLR6Mj2-B', ]); - let serb = b(ser); + const serb = b(ser); let psigers = manager.sign({ ser: serb, pubs: ps.new.pubs }); assert.equal(psigers.length, 1); assert.equal(psigers[0] instanceof Siger, true); @@ -628,18 +628,18 @@ describe('Manager', () => { 'AACRPqO6vdXm1oSSa82rmVVHikf7NdN4JXjOWEk30Ub5JHChL0bW6DzJfA-7VlgLm_B1XR0Z61FweP87bBQpVawI' ); - let oldspre = spre; + const oldspre = spre; spre = 'DCu5o5cxzv1lgMqxMVG3IcCNK4lpFfpMM-9rfkY3XVUc'; manager.move(oldspre, spre); - let oldpubs = Array.from(verfers, (verfer) => verfer.qb64); - let hashes = manager.rotate({ pre: spre }); + const oldpubs = Array.from(verfers, (verfer) => verfer.qb64); + const hashes = manager.rotate({ pre: spre }); verfers = hashes[0]; digers = hashes[1]; assert.equal(verfers.length, 1); assert.equal(digers.length, 1); - let pp = manager.ks.getPrms(spre)!; + const pp = manager.ks.getPrms(spre)!; assert.equal(pp.pidx, 0); assert.equal(pp.algo, Algos.salty); assert.equal(pp.salt, ''); diff --git a/test/core/matter.test.ts b/test/core/matter.test.ts index 741492ac..62b93f89 100644 --- a/test/core/matter.test.ts +++ b/test/core/matter.test.ts @@ -4,7 +4,7 @@ import { Sizage } from '../../src/keri/core/matter'; describe('Sizage', () => { it('should hold size values in 4 properties', async () => { - let sizage = new Sizage(1, 2, 3, 4); + const sizage = new Sizage(1, 2, 3, 4); assert.equal(sizage.hs, 1); assert.equal(sizage.ss, 2); assert.equal(sizage.fs, 3); diff --git a/test/core/prefixer.test.ts b/test/core/prefixer.test.ts index 98f3cbde..8ae25b5d 100644 --- a/test/core/prefixer.test.ts +++ b/test/core/prefixer.test.ts @@ -16,7 +16,7 @@ describe('Prefixer', () => { await libsodium.ready; // (b'\xacr\xda\xc83~\x99r\xaf\xeb`\xc0\x8cR\xd7\xd7\xf69\xc8E\x1e\xd2\xf0=`\xf7\xbf\x8a\x18\x8a`q') // from keripy - let verkey = new Uint8Array([ + const verkey = new Uint8Array([ 172, 114, 218, 200, 51, 126, 153, 114, 175, 235, 96, 192, 140, 82, 215, 215, 246, 57, 200, 69, 30, 210, 240, 61, 96, 247, 191, 138, 24, 138, 96, 113, @@ -29,17 +29,17 @@ describe('Prefixer', () => { ); // Test digest derivation from inception ked - let vs = versify(Ident.KERI, Versionage, Serials.JSON, 0); - let sn = 0; - let ilk = Ilks.icp; - let sith = '1'; - let keys = [new Prefixer({ raw: verkey, code: MtrDex.Ed25519 }).qb64]; - let nxt = ''; - let toad = 0; - let wits = new Array(); - let cnfg = new Array(); + const vs = versify(Ident.KERI, Versionage, Serials.JSON, 0); + const sn = 0; + const ilk = Ilks.icp; + const sith = '1'; + const keys = [new Prefixer({ raw: verkey, code: MtrDex.Ed25519 }).qb64]; + const nxt = ''; + const toad = 0; + const wits = new Array(); + const cnfg = new Array(); - let ked = { + const ked = { v: vs, // version string i: '', // qb64 prefix s: sn.toString(16), // hex string no leading zeros lowercase diff --git a/test/core/saider.test.ts b/test/core/saider.test.ts index 9b55325c..542e022a 100644 --- a/test/core/saider.test.ts +++ b/test/core/saider.test.ts @@ -14,12 +14,12 @@ describe('Saider', () => { it('should create Saidified dicts', async () => { await libsodium.ready; - let kind = Serials.JSON; - let code = MtrDex.Blake3_256; + const kind = Serials.JSON; + const code = MtrDex.Blake3_256; - let vs = versify(Ident.KERI, Versionage, kind, 0); // vaccuous size == 0 + const vs = versify(Ident.KERI, Versionage, kind, 0); // vaccuous size == 0 assert.equal(vs, 'KERI10JSON000000_'); - let sad4 = { + const sad4 = { v: vs, t: 'rep', d: '', // vacuous said @@ -32,7 +32,7 @@ describe('Saider', () => { role: 'Founder', } as Dict, } as Dict; - let saider = new Saider({}, sad4); // default version string code, kind, and label + const saider = new Saider({}, sad4); // default version string code, kind, and label assert.equal(saider.code, code); assert.equal( saider.qb64, diff --git a/test/core/salter.test.ts b/test/core/salter.test.ts index e921c405..1802d9ce 100644 --- a/test/core/salter.test.ts +++ b/test/core/salter.test.ts @@ -11,7 +11,7 @@ describe('Salter', () => { assert.notEqual(salter, null); assert.equal(salter.qb64.length, 24); - let salt = new Uint8Array([ + const salt = new Uint8Array([ 146, 78, 142, 186, 189, 77, 130, 3, 232, 248, 186, 197, 8, 0, 73, 182, ]); @@ -37,8 +37,8 @@ describe('Salter', () => { describe('Salter.signer', () => { it('should return a signer', async () => { - let salter = new Salter({ qb64: '0ACSTo66vU2CA-j4usUIAEm2' }); - let signer = salter.signer(); + const salter = new Salter({ qb64: '0ACSTo66vU2CA-j4usUIAEm2' }); + const signer = salter.signer(); assert.notEqual(signer, null); assert.equal( signer.verfer.qb64, diff --git a/test/core/serder.test.ts b/test/core/serder.test.ts index 679b69ef..1b489e07 100644 --- a/test/core/serder.test.ts +++ b/test/core/serder.test.ts @@ -15,7 +15,7 @@ import { Prefixer } from '../../src/keri/core/prefixer'; describe('deversify', () => { it('should parse a KERI event version string', async () => { - let [, kind, version, size] = deversify('KERI10JSON00011c_'); + const [, kind, version, size] = deversify('KERI10JSON00011c_'); assert.equal(kind, Serials.JSON); assert.deepStrictEqual(version, new Version(1, 0)); assert.equal(size, '00011c'); @@ -26,39 +26,39 @@ describe('Serder', () => { it('should create KERI events from dicts', async () => { await libsodium.ready; - let sith = 1; - let nsith = 1; - let sn = 0; - let toad = 0; + const sith = 1; + const nsith = 1; + const sn = 0; + const toad = 0; - let raw = new Uint8Array([ + const raw = new Uint8Array([ 5, 170, 143, 45, 83, 154, 233, 250, 85, 156, 2, 156, 155, 8, 72, 117, ]); - let salter = new Salter({ raw: raw }); - let skp0 = salter.signer( + const salter = new Salter({ raw: raw }); + const skp0 = salter.signer( MtrDex.Ed25519_Seed, true, 'A', Tier.low, true ); - let keys = [skp0.verfer.qb64]; + const keys = [skp0.verfer.qb64]; - let skp1 = salter.signer( + const skp1 = salter.signer( MtrDex.Ed25519_Seed, true, 'N', Tier.low, true ); - let ndiger = new Diger({}, skp1.verfer.qb64b); - let nxt = [ndiger.qb64]; + const ndiger = new Diger({}, skp1.verfer.qb64b); + const nxt = [ndiger.qb64]; assert.deepStrictEqual(nxt, [ 'EAKUR-LmLHWMwXTLWQ1QjxHrihBmwwrV2tYaSG7hOrWj', ]); - let ked0 = { + const ked0 = { v: 'KERI10JSON000000_', t: Ilks.icp, d: '', @@ -74,7 +74,7 @@ describe('Serder', () => { a: [], } as Dict; - let serder = new Serder(ked0); + const serder = new Serder(ked0); assert.equal( serder.raw, '{"v":"KERI10JSON0000d3_","t":"icp","d":"","i":"","s":"0","kt":"1","k":' + diff --git a/test/core/signer.test.ts b/test/core/signer.test.ts index b0286add..439a08b7 100644 --- a/test/core/signer.test.ts +++ b/test/core/signer.test.ts @@ -9,7 +9,7 @@ describe('Signer', () => { it('should sign things', async () => { await libsodium.ready; - let signer = new Signer({}); // defaults provide Ed25519 signer Ed25519 verfer + const signer = new Signer({}); // defaults provide Ed25519 signer Ed25519 verfer assert.equal(signer.code, MtrDex.Ed25519_Seed); assert.equal(signer.raw.length, Matter._rawSize(signer.code)); assert.equal(signer.verfer.code, MtrDex.Ed25519); @@ -18,12 +18,12 @@ describe('Signer', () => { Matter._rawSize(signer.verfer.code) ); - let ser = b('abcdefghijklmnopqrstuvwxyz0123456789'); + const ser = b('abcdefghijklmnopqrstuvwxyz0123456789'); - let cigar = signer.sign(ser); + const cigar = signer.sign(ser); assert.equal(cigar.code, MtrDex.Ed25519_Sig); assert.equal(cigar.raw.length, Matter._rawSize(cigar.code)); - let result = signer.verfer.verify(cigar.raw, ser); + const result = signer.verfer.verify(cigar.raw, ser); assert.equal(result, true); }); }); diff --git a/test/core/vdring.test.ts b/test/core/vdring.test.ts index fbee01a1..4cbe81f7 100644 --- a/test/core/vdring.test.ts +++ b/test/core/vdring.test.ts @@ -30,7 +30,7 @@ describe('vdr', () => { it('should fail on NB config with backers', async () => { await libsodium.ready; - let cnfg = ['NB']; + const cnfg = ['NB']; assert.throws( () => { vdr.incept({ @@ -103,7 +103,7 @@ describe('vdr', () => { it('should allow optional toad and no backers', async () => { await libsodium.ready; - let actual = vdr.incept({ + const actual = vdr.incept({ pre: 'ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', }); @@ -122,7 +122,7 @@ describe('vdr', () => { it('should allow optional toad and backers', async () => { await libsodium.ready; - let actual = vdr.incept({ + const actual = vdr.incept({ pre: 'ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g', nonce: 'AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s', baks: ['a backer'], diff --git a/test/core/verfer.test.ts b/test/core/verfer.test.ts index 3669e69d..b75f0639 100644 --- a/test/core/verfer.test.ts +++ b/test/core/verfer.test.ts @@ -5,9 +5,9 @@ import { Verfer } from '../../src/keri/core/verfer'; import secp256r1 from 'ecdsa-secp256r1'; function base64ToUint8Array(base64: string) { - var binaryString = atob(base64); - var bytes = new Uint8Array(binaryString.length); - for (var i = 0; i < binaryString.length; i++) { + const binaryString = atob(base64); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); } return new Uint8Array(bytes.buffer); @@ -16,11 +16,11 @@ function base64ToUint8Array(base64: string) { describe('Verfer', () => { it('should verify digests', async () => { await libsodium.ready; - let seed = libsodium.randombytes_buf(libsodium.crypto_sign_SEEDBYTES); + const seed = libsodium.randombytes_buf(libsodium.crypto_sign_SEEDBYTES); const keypair = libsodium.crypto_sign_seed_keypair(seed); - let verkey = keypair.publicKey; - let sigkey = keypair.privateKey; + const verkey = keypair.publicKey; + const sigkey = keypair.privateKey; let verfer = new Verfer({ raw: verkey, code: MtrDex.Ed25519N }); assert.notEqual(verfer, null); @@ -28,9 +28,9 @@ describe('Verfer', () => { assert.deepStrictEqual(verfer.raw, verkey); assert.deepStrictEqual(verfer.code, MtrDex.Ed25519N); - let ser = 'abcdefghijklmnopqrstuvwxyz0123456789'; + const ser = 'abcdefghijklmnopqrstuvwxyz0123456789'; - let sig = libsodium.crypto_sign_detached(ser, sigkey); + const sig = libsodium.crypto_sign_detached(ser, sigkey); assert.equal(verfer.verify(sig, ser), true); @@ -57,9 +57,9 @@ describe('Verfer', () => { assert.deepStrictEqual(verfer.raw, publicKey); assert.deepStrictEqual(verfer.code, MtrDex.ECDSA_256r1); - let ser = 'abcdefghijklmnopqrstuvwxyz0123456789'; + const ser = 'abcdefghijklmnopqrstuvwxyz0123456789'; - let sig = privateKey.sign(ser); + const sig = privateKey.sign(ser); assert.equal(verfer.verify(sig, ser), true); @@ -76,7 +76,7 @@ describe('Verfer', () => { ); }); it('should not verify secp256k1', async () => { - let publicKey = new Uint8Array([ + const publicKey = new Uint8Array([ 2, 79, 93, 30, 107, 249, 254, 237, 205, 87, 8, 149, 203, 214, 36, 187, 162, 251, 58, 206, 241, 203, 27, 76, 236, 37, 189, 148, 240, 178, 204, 133, 31, diff --git a/test/end/ending.test.ts b/test/end/ending.test.ts index ae7f971b..bea7bf21 100644 --- a/test/end/ending.test.ts +++ b/test/end/ending.test.ts @@ -11,43 +11,43 @@ describe('ending_signature_designature', () => { it('should create and parse signature headers', async () => { await libsodium.ready; - let name = 'Hilga'; - let temp = true; + const name = 'Hilga'; + const temp = true; - let salter = new Salter({ raw: b('0123456789abcdef') }); - let signer0 = salter.signer( + const salter = new Salter({ raw: b('0123456789abcdef') }); + const signer0 = salter.signer( MtrDex.Ed25519_Seed, true, `${name}00`, Tier.low, temp ); - let signer1 = salter.signer( + const signer1 = salter.signer( MtrDex.Ed25519_Seed, true, `${name}01`, Tier.low, temp ); - let signer2 = salter.signer( + const signer2 = salter.signer( MtrDex.Ed25519_Seed, true, `${name}02`, Tier.low, temp ); - let signers = [signer0, signer1, signer2]; + const signers = [signer0, signer1, signer2]; - let text = b( + const text = b( '{"seid":"BA89hKezugU2LFKiFVbitoHAxXqJh6HQ8Rn9tH7fxd68","name":"wit0","dts":"2021-01-01T00' + ':00:00.000000+00:00","scheme":"http","host":"localhost","port":8080,"path":"/witness"}' ); - let sigers = Array.from(signers, (signer, idx) => + const sigers = Array.from(signers, (signer, idx) => signer.sign(text, idx) ); - let pre = 'EGqHykT1gVyuWxsVW6LUUsz_KtLJGYMi_SrohInwvjC-'; // Hab.pre from KERIpy test - let digest = pre; + const pre = 'EGqHykT1gVyuWxsVW6LUUsz_KtLJGYMi_SrohInwvjC-'; // Hab.pre from KERIpy test + const digest = pre; let signage = new Signage(sigers); let header = signature([signage]); @@ -62,9 +62,9 @@ describe('ending_signature_designature', () => { signage = signages[0]; assert.equal(signage.markers.size, 3); signage.markers.forEach((item: string | Siger | Cigar, tag: string) => { - let marker = item as Siger; - let idx = parseInt(tag); - let siger = sigers[idx] as Siger; + const marker = item as Siger; + const idx = parseInt(tag); + const siger = sigers[idx] as Siger; assert.equal(marker.qb64, siger.qb64); assert.equal(parseInt(tag), siger.index); }); @@ -87,14 +87,14 @@ describe('ending_signature_designature', () => { assert.equal(signage.markers.size, 3); signage.markers.forEach((item: string | Siger | Cigar, tag: string) => { - let marker = item as Siger; - let idx = parseInt(tag); - let siger = sigers[idx] as Siger; + const marker = item as Siger; + const idx = parseInt(tag); + const siger = sigers[idx] as Siger; assert.equal(marker.qb64, siger.qb64); assert.equal(parseInt(tag), siger.index); }); - let cigars = Array.from(signers, (signer) => signer.sign(text)); + const cigars = Array.from(signers, (signer) => signer.sign(text)); signage = new Signage(cigars); header = signature([signage]); assert.equal(header.has('Signature'), true); @@ -108,7 +108,7 @@ describe('ending_signature_designature', () => { assert.equal(signage.indexed, false); assert.equal(signage.markers.size, 3); signage.markers.forEach((marker: Cigar, tag: string) => { - let cigar = cigars.find((cigar) => cigar.verfer!.qb64 == tag); + const cigar = cigars.find((cigar) => cigar.verfer!.qb64 == tag); assert.notEqual(cigar, undefined); assert.equal(marker.qb64, cigar!.qb64); assert.equal(tag, cigar!.verfer!.qb64); @@ -138,9 +138,9 @@ describe('ending_signature_designature', () => { assert.equal(signage.kind, 'CESR'); assert.equal(signage.markers.size, 3); signage.markers.forEach((item: string | Siger | Cigar, tag: string) => { - let marker = item as Siger; - let idx = parseInt(tag); - let siger = sigers[idx] as Siger; + const marker = item as Siger; + const idx = parseInt(tag); + const siger = sigers[idx] as Siger; assert.equal(marker.qb64, siger.qb64); assert.equal(parseInt(tag), siger.index); }); @@ -151,7 +151,7 @@ describe('ending_signature_designature', () => { assert.equal(signage.kind, 'CESR'); assert.equal(signage.markers.size, 3); signage.markers.forEach((marker: Cigar, tag: string) => { - let cigar = cigars.find((cigar) => cigar.verfer!.qb64 == tag); + const cigar = cigars.find((cigar) => cigar.verfer!.qb64 == tag); assert.notEqual(cigar, undefined); assert.equal(marker.qb64, cigar!.qb64); assert.equal(tag, cigar!.verfer!.qb64);