From fa0fe7d836aa9b4094af857e76dec5d1317114f5 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Fri, 26 Apr 2024 16:34:14 -0400 Subject: [PATCH 01/23] testing again vlei verification service Signed-off-by: 2byrds <2byrds@gmail.com> --- .../vlei-verification.test.ts | 646 ++++++++++++++++++ src/keri/app/clienting.ts | 9 +- 2 files changed, 653 insertions(+), 2 deletions(-) create mode 100644 examples/integration-scripts/vlei-verification.test.ts diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts new file mode 100644 index 00000000..3c7a70d4 --- /dev/null +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -0,0 +1,646 @@ +import { strict as assert } from 'assert'; +import { RotLabels, Saider, Salter, Serder, SignifyClient } from 'signify-ts'; +import { resolveEnvironment } from './utils/resolve-env'; +import { + assertOperations, + markAndRemoveNotification, + resolveOobi, + waitForNotifications, + waitOperation, + warnNotifications, +} from './utils/test-util'; +import { retry } from './utils/retry'; +import { + getOrCreateClients, + getOrCreateContact, + getOrCreateIdentifier, +} from './utils/test-setup'; + +const { vleiServerUrl } = resolveEnvironment(); + +const QVI_SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; +const LE_SCHEMA_SAID = 'ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY'; +const ECR_AUTH_SCHEMA_SAID = 'EH6ekLjSr8V32WyFbGe1zXjTzFs9PkTYmupJ9H65O14g'; +const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; +const OOR_AUTH_SCHEMA_SAID = 'EKA57bKBKxr_kN7iN5i7lMUxpMG-s19dRcmov1iDxz-E'; +const OOR_SCHEMA_SAID = 'EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy'; + +const vLEIServerHostUrl = `${vleiServerUrl}/oobi`; +const QVI_SCHEMA_URL = `${vLEIServerHostUrl}/${QVI_SCHEMA_SAID}`; +const LE_SCHEMA_URL = `${vLEIServerHostUrl}/${LE_SCHEMA_SAID}`; +const ECR_AUTH_SCHEMA_URL = `${vLEIServerHostUrl}/${ECR_AUTH_SCHEMA_SAID}`; +const ECR_SCHEMA_URL = `${vLEIServerHostUrl}/${ECR_SCHEMA_SAID}`; +const OOR_AUTH_SCHEMA_URL = `${vLEIServerHostUrl}/${OOR_AUTH_SCHEMA_SAID}`; +const OOR_SCHEMA_URL = `${vLEIServerHostUrl}/${OOR_SCHEMA_SAID}`; + +const qviData = { + LEI: '254900OPPU84GM83MG36', +}; + +const leData = { + LEI: '875500ELOZEL05BVXV37', +}; + +const ecrData = { + LEI: leData.LEI, + personLegalName: 'John Doe', + engagementContextRole: 'EBA Data Submitter', +}; + +const ecrAuthData = { + AID: '', + LEI: ecrData.LEI, + personLegalName: ecrData.personLegalName, + engagementContextRole: ecrData.engagementContextRole, +}; + +const oorData = { + LEI: leData.LEI, + personLegalName: 'John Doe', + officialRole: 'HR Manager', +}; + +const oorAuthData = { + AID: '', + LEI: oorData.LEI, + personLegalName: oorData.personLegalName, + officialRole: oorData.officialRole, +}; + +const LE_RULES = Saider.saidify({ + d: '', + usageDisclaimer: { + l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', + }, + issuanceDisclaimer: { + l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', + }, +})[1]; + +const ECR_RULES = Saider.saidify({ + d: '', + usageDisclaimer: { + l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', + }, + issuanceDisclaimer: { + l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', + }, + privacyDisclaimer: { + l: 'It is the sole responsibility of Holders as Issuees of an ECR vLEI Credential to present that Credential in a privacy-preserving manner using the mechanisms provided in the Issuance and Presentation Exchange (IPEX) protocol specification and the Authentic Chained Data Container (ACDC) specification. https://github.com/WebOfTrust/IETF-IPEX and https://github.com/trustoverip/tswg-acdc-specification.', + }, +})[1]; + +const ECR_AUTH_RULES = Saider.saidify({ + d: '', + usageDisclaimer: { + l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', + }, + issuanceDisclaimer: { + l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', + }, + privacyDisclaimer: { + l: 'Privacy Considerations are applicable to QVI ECR AUTH vLEI Credentials. It is the sole responsibility of QVIs as Issuees of QVI ECR AUTH vLEI Credentials to present these Credentials in a privacy-preserving manner using the mechanisms provided in the Issuance and Presentation Exchange (IPEX) protocol specification and the Authentic Chained Data Container (ACDC) specification. https://github.com/WebOfTrust/IETF-IPEX and https://github.com/trustoverip/tswg-acdc-specification.', + }, +})[1]; + +const OOR_RULES = LE_RULES; +const OOR_AUTH_RULES = LE_RULES; + +interface Aid { + name: string; + prefix: string; + oobi: string; +} + +function createTimestamp() { + return new Date().toISOString().replace('Z', '000+00:00'); +} + +async function createAid(client: SignifyClient, name: string): Promise { + const [prefix, oobi] = await getOrCreateIdentifier(client, name); + return { name, prefix, oobi }; +} + +test('singlesig-vlei-issuance', async function run() { + const [gleifClient, qviClient, leClient, roleClient] = + await getOrCreateClients(4); + + const [gleifAid, qviAid, leAid, roleAid] = await Promise.all([ + createAid(gleifClient, 'gleif'), + createAid(qviClient, 'qvi'), + createAid(leClient, 'le'), + createAid(roleClient, 'role'), + ]); + + await Promise.all([ + getOrCreateContact(gleifClient, 'qvi', qviAid.oobi), + getOrCreateContact(qviClient, 'gleif', gleifAid.oobi), + getOrCreateContact(qviClient, 'le', leAid.oobi), + getOrCreateContact(qviClient, 'role', roleAid.oobi), + getOrCreateContact(leClient, 'gleif', gleifAid.oobi), + getOrCreateContact(leClient, 'qvi', qviAid.oobi), + getOrCreateContact(leClient, 'role', roleAid.oobi), + getOrCreateContact(roleClient, 'gleif', gleifAid.oobi), + getOrCreateContact(roleClient, 'qvi', qviAid.oobi), + getOrCreateContact(roleClient, 'le', leAid.oobi), + ]); + + await Promise.all([ + resolveOobi(gleifClient, QVI_SCHEMA_URL), + resolveOobi(qviClient, QVI_SCHEMA_URL), + resolveOobi(qviClient, LE_SCHEMA_URL), + resolveOobi(qviClient, ECR_AUTH_SCHEMA_URL), + resolveOobi(qviClient, ECR_SCHEMA_URL), + resolveOobi(qviClient, OOR_AUTH_SCHEMA_URL), + resolveOobi(qviClient, OOR_SCHEMA_URL), + resolveOobi(leClient, QVI_SCHEMA_URL), + resolveOobi(leClient, LE_SCHEMA_URL), + resolveOobi(leClient, ECR_AUTH_SCHEMA_URL), + resolveOobi(leClient, ECR_SCHEMA_URL), + resolveOobi(leClient, OOR_AUTH_SCHEMA_URL), + resolveOobi(leClient, OOR_SCHEMA_URL), + resolveOobi(roleClient, QVI_SCHEMA_URL), + resolveOobi(roleClient, LE_SCHEMA_URL), + resolveOobi(roleClient, ECR_AUTH_SCHEMA_URL), + resolveOobi(roleClient, ECR_SCHEMA_URL), + resolveOobi(roleClient, OOR_AUTH_SCHEMA_URL), + resolveOobi(roleClient, OOR_SCHEMA_URL), + ]); + + const [gleifRegistry, qviRegistry, leRegistry] = await Promise.all([ + getOrCreateRegistry(gleifClient, gleifAid, 'gleifRegistry'), + getOrCreateRegistry(qviClient, qviAid, 'qviRegistry'), + getOrCreateRegistry(leClient, leAid, 'leRegistry'), + ]); + + console.log('Issuing QVI vLEI Credential'); + const qviCred = await getOrIssueCredential( + gleifClient, + gleifAid, + qviAid, + gleifRegistry, + qviData, + QVI_SCHEMA_SAID + ); + + let qviCredHolder = await getGrantedCredential(qviClient, qviCred.sad.d); + + if (!qviCredHolder) { + await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); + await sendAdmitMessage(qviClient, qviAid, gleifAid); + + qviCredHolder = await retry(async () => { + const cred = await getGrantedCredential(qviClient, qviCred.sad.d); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(qviCredHolder.sad.d, qviCred.sad.d); + assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); + assert.equal(qviCredHolder.sad.i, gleifAid.prefix); + assert.equal(qviCredHolder.sad.a.i, qviAid.prefix); + assert.equal(qviCredHolder.status.s, '0'); + assert(qviCredHolder.atc !== undefined); + + console.log('Issuing LE vLEI Credential'); + const leCredSource = Saider.saidify({ + d: '', + qvi: { + n: qviCred.sad.d, + s: qviCred.sad.s, + }, + })[1]; + + const leCred = await getOrIssueCredential( + qviClient, + qviAid, + leAid, + qviRegistry, + leData, + LE_SCHEMA_SAID, + LE_RULES, + leCredSource + ); + + let leCredHolder = await getGrantedCredential(leClient, leCred.sad.d); + + if (!leCredHolder) { + await sendGrantMessage(qviClient, qviAid, leAid, leCred); + await sendAdmitMessage(leClient, leAid, qviAid); + + leCredHolder = await retry(async () => { + const cred = await getGrantedCredential(leClient, leCred.sad.d); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(leCredHolder.sad.d, leCred.sad.d); + assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); + assert.equal(leCredHolder.sad.i, qviAid.prefix); + assert.equal(leCredHolder.sad.a.i, leAid.prefix); + assert.equal(leCredHolder.sad.e.qvi.n, qviCred.sad.d); + assert.equal(leCredHolder.status.s, '0'); + assert(leCredHolder.atc !== undefined); + + console.log('Issuing ECR vLEI Credential from LE'); + const ecrCredSource = Saider.saidify({ + d: '', + le: { + n: leCred.sad.d, + s: leCred.sad.s, + }, + })[1]; + + const ecrCred = await getOrIssueCredential( + leClient, + leAid, + roleAid, + leRegistry, + ecrData, + ECR_SCHEMA_SAID, + ECR_RULES, + ecrCredSource, + true + ); + + let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); + + if (!ecrCredHolder) { + await sendGrantMessage(leClient, leAid, roleAid, ecrCred); + await sendAdmitMessage(roleClient, roleAid, leAid); + + ecrCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); + assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); + assert.equal(ecrCredHolder.sad.i, leAid.prefix); + assert.equal(ecrCredHolder.sad.a.i, roleAid.prefix); + assert.equal(ecrCredHolder.sad.e.le.n, leCred.sad.d); + assert.equal(ecrCredHolder.status.s, '0'); + assert(ecrCredHolder.atc !== undefined); + + console.log('Issuing ECR AUTH vLEI Credential'); + ecrAuthData.AID = roleAid.prefix; + const ecrAuthCredSource = Saider.saidify({ + d: '', + le: { + n: leCred.sad.d, + s: leCred.sad.s, + }, + })[1]; + + const ecrAuthCred = await getOrIssueCredential( + leClient, + leAid, + qviAid, + leRegistry, + ecrAuthData, + ECR_AUTH_SCHEMA_SAID, + ECR_AUTH_RULES, + ecrAuthCredSource + ); + + let ecrAuthCredHolder = await getGrantedCredential( + qviClient, + ecrAuthCred.sad.d + ); + + if (!ecrAuthCredHolder) { + await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + ecrAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + ecrAuthCred.sad.d + ); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); + assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); + assert.equal(ecrAuthCredHolder.sad.i, leAid.prefix); + assert.equal(ecrAuthCredHolder.sad.a.i, qviAid.prefix); + assert.equal(ecrAuthCredHolder.sad.a.AID, roleAid.prefix); + assert.equal(ecrAuthCredHolder.sad.e.le.n, leCred.sad.d); + assert.equal(ecrAuthCredHolder.status.s, '0'); + assert(ecrAuthCredHolder.atc !== undefined); + + console.log('Issuing ECR vLEI Credential from ECR AUTH'); + const ecrCredSource2 = Saider.saidify({ + d: '', + auth: { + n: ecrAuthCred.sad.d, + s: ecrAuthCred.sad.s, + o: 'I2I', + }, + })[1]; + + const ecrCred2 = await getOrIssueCredential( + qviClient, + qviAid, + roleAid, + qviRegistry, + ecrData, + ECR_SCHEMA_SAID, + ECR_RULES, + ecrCredSource2, + true + ); + + let ecrCredHolder2 = await getGrantedCredential(roleClient, ecrCred2.sad.d); + + if (!ecrCredHolder2) { + await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); + await sendAdmitMessage(roleClient, roleAid, qviAid); + + ecrCredHolder2 = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); + assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); + assert.equal(ecrCredHolder2.sad.i, qviAid.prefix); + assert.equal(ecrCredHolder2.sad.e.auth.n, ecrAuthCred.sad.d); + assert.equal(ecrCredHolder2.status.s, '0'); + assert(ecrCredHolder2.atc !== undefined); + + console.log('Issuing OOR AUTH vLEI Credential'); + oorAuthData.AID = roleAid.prefix; + const oorAuthCredSource = Saider.saidify({ + d: '', + le: { + n: leCred.sad.d, + s: leCred.sad.s, + }, + })[1]; + + const oorAuthCred = await getOrIssueCredential( + leClient, + leAid, + qviAid, + leRegistry, + oorAuthData, + OOR_AUTH_SCHEMA_SAID, + OOR_AUTH_RULES, + oorAuthCredSource + ); + + let oorAuthCredHolder = await getGrantedCredential( + qviClient, + oorAuthCred.sad.d + ); + + if (!oorAuthCredHolder) { + await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + oorAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + oorAuthCred.sad.d + ); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); + assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); + assert.equal(oorAuthCredHolder.sad.i, leAid.prefix); + assert.equal(oorAuthCredHolder.sad.a.i, qviAid.prefix); + assert.equal(oorAuthCredHolder.sad.a.AID, roleAid.prefix); + assert.equal(oorAuthCredHolder.sad.e.le.n, leCred.sad.d); + assert.equal(oorAuthCredHolder.status.s, '0'); + assert(oorAuthCredHolder.atc !== undefined); + + console.log('Issuing OOR vLEI Credential from OOR AUTH'); + const oorCredSource = Saider.saidify({ + d: '', + auth: { + n: oorAuthCred.sad.d, + s: oorAuthCred.sad.s, + o: 'I2I', + }, + })[1]; + + const oorCred = await getOrIssueCredential( + qviClient, + qviAid, + roleAid, + qviRegistry, + oorData, + OOR_SCHEMA_SAID, + OOR_RULES, + oorCredSource + ); + + let oorCredHolder = await getGrantedCredential(roleClient, oorCred.sad.d); + + if (!oorCredHolder) { + await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); + await sendAdmitMessage(roleClient, roleAid, qviAid); + + oorCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, oorCred.sad.d); + assert(cred !== undefined); + return cred; + }); + } + assert.equal(oorCredHolder.sad.d, oorCred.sad.d); + assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); + assert.equal(oorCredHolder.sad.i, qviAid.prefix); + assert.equal(oorCredHolder.sad.e.auth.n, oorAuthCred.sad.d); + assert.equal(oorCredHolder.status.s, '0'); + assert(oorCredHolder.atc !== undefined); + + await assertOperations(gleifClient, qviClient, leClient, roleClient); + await warnNotifications(gleifClient, qviClient, leClient, roleClient); +}, 360000); + +async function getOrCreateRegistry( + client: SignifyClient, + aid: Aid, + registryName: string +): Promise<{ name: string; regk: string }> { + let registries = await client.registries().list(aid.name); + if (registries.length > 0) { + assert.equal(registries.length, 1); + } else { + const regResult = await client + .registries() + .create({ name: aid.name, registryName: registryName }); + await waitOperation(client, await regResult.op()); + registries = await client.registries().list(aid.name); + } + return registries[0]; +} + +async function getOrIssueCredential( + issuerClient: SignifyClient, + issuerAid: Aid, + recipientAid: Aid, + issuerRegistry: { regk: string }, + credData: any, + schema: string, + rules?: any, + source?: any, + privacy = false +): Promise { + const credentialList = await issuerClient.credentials().list(); + + if (credentialList.length > 0) { + const credential = credentialList.find( + (cred: any) => + cred.sad.s === schema && + cred.sad.i === issuerAid.prefix && + cred.sad.a.i === recipientAid.prefix + ); + if (credential) return credential; + } + + const issResult = await issuerClient.credentials().issue(issuerAid.name, { + ri: issuerRegistry.regk, + s: schema, + u: privacy ? new Salter({}).qb64 : undefined, + a: { + i: recipientAid.prefix, + u: privacy ? new Salter({}).qb64 : undefined, + ...credData, + }, + r: rules, + e: source, + }); + + await waitOperation(issuerClient, issResult.op); + const credential = await issuerClient + .credentials() + .get(issResult.acdc.ked.d); + + return credential; +} + +async function getGrantedCredential( + client: SignifyClient, + credId: string +): Promise { + const credentialList = await client.credentials().list({ + filter: { '-d': credId }, + }); + let credential: any; + if (credentialList.length > 0) { + assert.equal(credentialList.length, 1); + credential = credentialList[0]; + } + return credential; +} + +async function sendGrantMessage( + senderClient: SignifyClient, + senderAid: Aid, + recipientAid: Aid, + credential: any +) { + const [grant, gsigs, gend] = await senderClient.ipex().grant({ + senderName: senderAid.name, + acdc: new Serder(credential.sad), + anc: new Serder(credential.anc), + iss: new Serder(credential.iss), + ancAttachment: credential.ancAttachment, + recipient: recipientAid.prefix, + datetime: createTimestamp(), + }); + + let op = await senderClient + .ipex() + .submitGrant(senderAid.name, grant, gsigs, gend, [recipientAid.prefix]); + op = await waitOperation(senderClient, op); +} + +async function sendAdmitMessage( + senderClient: SignifyClient, + senderAid: Aid, + recipientAid: Aid +) { + const notifications = await waitForNotifications( + senderClient, + '/exn/ipex/grant' + ); + assert.equal(notifications.length, 1); + const grantNotification = notifications[0]; + + const [admit, sigs, aend] = await senderClient + .ipex() + .admit(senderAid.name, '', grantNotification.a.d!, createTimestamp()); + + let op = await senderClient + .ipex() + .submitAdmit(senderAid.name, admit, sigs, aend, [recipientAid.prefix]); + op = await waitOperation(senderClient, op); + + await markAndRemoveNotification(senderClient, grantNotification); +} + +// This test assumes you have run a vlei test that sets up the glief, qvi, le, and +// role identifiers and Credentials. +test('vlei-verification', async function run() { + + // these come from a previous test + const bran = 'Ak_0QIVNz4DjRarVCPduI'; //look for SIGNIFY_SECRETS + const aidName = 'role'; + const [roleClient] = await getOrCreateClients(1,[bran]); + + try { + let resp = await roleClient.signedFetch( + 'http://localhost:7676', + '/health', + 'GET', + null, + aidName + ); + assert.equal(200,resp.status) + + + let ecrCreds = (await roleClient.credentials().list()); + let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); + let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); + assert(ecrCred !== undefined); + assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); + assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); + assert.equal(ecrCredHolder.status.s, '0'); + assert(ecrCredHolder.atc !== undefined); + + let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); + resp = await roleClient.signedFetch( + 'http://localhost:7676', + `/presentations/${ecrCred.sad.d}`, + 'PUT', + ecrCredCesr, + aidName, + true) + assert.equal(200,resp.status) + + // assert.equal(lastCall[0]!, 'http://example.com/test'); + // assert.equal(lastCall[1]!.method, 'POST'); + // lastBody = JSON.parse(lastCall[1]!.body!); + // assert.deepEqual(lastBody.foo, true); + // lastHeaders = new Headers(lastCall[1]!.headers!); + // assert.equal( + // lastHeaders.get('signify-resource'), + // 'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK' + // ); + } catch (e) { + if (e instanceof AggregateError) { + console.log(e.errors); + } else { + console.log(e); + } + fail(e); + } +}); \ No newline at end of file diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index de2e5986..0ed0406a 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -244,7 +244,8 @@ export class SignifyClient { path: string, method: string, data: any, - aidName: string + aidName: string, + cesr: boolean = false ): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -272,7 +273,11 @@ export class SignifyClient { path.split('?')[0] ); let _body = null; - if (method != 'GET') { + + if ((typeof data == 'string') && cesr) { + _body = data; + headers.set('Content-Type', 'application/cesr+json'); + } else if (method != 'GET') { if (data instanceof FormData) { _body = data; // do not set the content type, let the browser do it From ec214fecb60d110a695c022dbd330aebd8b9a606 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 13:15:09 -0400 Subject: [PATCH 02/23] Fixes for cd '/Users/meenyleeny/VSCode/signify-ts' Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 11 +- .../vlei-verification.test.ts | 626 +----------------- package-lock.json | 38 +- src/keri/app/clienting.ts | 2 +- src/keri/app/credentialing.ts | 4 +- 5 files changed, 60 insertions(+), 621 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index 6aacbc51..41979028 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -21,7 +21,7 @@ const { vleiServerUrl } = resolveEnvironment(); const QVI_SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; const LE_SCHEMA_SAID = 'ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY'; const ECR_AUTH_SCHEMA_SAID = 'EH6ekLjSr8V32WyFbGe1zXjTzFs9PkTYmupJ9H65O14g'; -const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; +export const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; const OOR_AUTH_SCHEMA_SAID = 'EKA57bKBKxr_kN7iN5i7lMUxpMG-s19dRcmov1iDxz-E'; const OOR_SCHEMA_SAID = 'EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy'; @@ -508,15 +508,14 @@ async function getOrIssueCredential( const issResult = await issuerClient.credentials().issue(issuerAid.name, { ri: issuerRegistry.regk, s: schema, - u: privacy ? new Salter({}).qb64 : undefined, a: { i: recipientAid.prefix, u: privacy ? new Salter({}).qb64 : undefined, ...credData, }, - r: rules, e: source, - }); + r: rules, + },privacy); await waitOperation(issuerClient, issResult.op); const credential = await issuerClient @@ -526,7 +525,7 @@ async function getOrIssueCredential( return credential; } -async function getGrantedCredential( +export async function getGrantedCredential( client: SignifyClient, credId: string ): Promise { @@ -585,4 +584,4 @@ async function sendAdmitMessage( op = await waitOperation(senderClient, op); await markAndRemoveNotification(senderClient, grantNotification); -} +} \ No newline at end of file diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts index 3c7a70d4..5bc22d92 100644 --- a/examples/integration-scripts/vlei-verification.test.ts +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -1,611 +1,27 @@ import { strict as assert } from 'assert'; -import { RotLabels, Saider, Salter, Serder, SignifyClient } from 'signify-ts'; -import { resolveEnvironment } from './utils/resolve-env'; -import { - assertOperations, - markAndRemoveNotification, - resolveOobi, - waitForNotifications, - waitOperation, - warnNotifications, -} from './utils/test-util'; -import { retry } from './utils/retry'; import { getOrCreateClients, - getOrCreateContact, - getOrCreateIdentifier, } from './utils/test-setup'; - -const { vleiServerUrl } = resolveEnvironment(); - -const QVI_SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; -const LE_SCHEMA_SAID = 'ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY'; -const ECR_AUTH_SCHEMA_SAID = 'EH6ekLjSr8V32WyFbGe1zXjTzFs9PkTYmupJ9H65O14g'; -const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; -const OOR_AUTH_SCHEMA_SAID = 'EKA57bKBKxr_kN7iN5i7lMUxpMG-s19dRcmov1iDxz-E'; -const OOR_SCHEMA_SAID = 'EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy'; - -const vLEIServerHostUrl = `${vleiServerUrl}/oobi`; -const QVI_SCHEMA_URL = `${vLEIServerHostUrl}/${QVI_SCHEMA_SAID}`; -const LE_SCHEMA_URL = `${vLEIServerHostUrl}/${LE_SCHEMA_SAID}`; -const ECR_AUTH_SCHEMA_URL = `${vLEIServerHostUrl}/${ECR_AUTH_SCHEMA_SAID}`; -const ECR_SCHEMA_URL = `${vLEIServerHostUrl}/${ECR_SCHEMA_SAID}`; -const OOR_AUTH_SCHEMA_URL = `${vLEIServerHostUrl}/${OOR_AUTH_SCHEMA_SAID}`; -const OOR_SCHEMA_URL = `${vLEIServerHostUrl}/${OOR_SCHEMA_SAID}`; - -const qviData = { - LEI: '254900OPPU84GM83MG36', -}; - -const leData = { - LEI: '875500ELOZEL05BVXV37', -}; - -const ecrData = { - LEI: leData.LEI, - personLegalName: 'John Doe', - engagementContextRole: 'EBA Data Submitter', -}; - -const ecrAuthData = { - AID: '', - LEI: ecrData.LEI, - personLegalName: ecrData.personLegalName, - engagementContextRole: ecrData.engagementContextRole, -}; - -const oorData = { - LEI: leData.LEI, - personLegalName: 'John Doe', - officialRole: 'HR Manager', -}; - -const oorAuthData = { - AID: '', - LEI: oorData.LEI, - personLegalName: oorData.personLegalName, - officialRole: oorData.officialRole, -}; - -const LE_RULES = Saider.saidify({ - d: '', - usageDisclaimer: { - l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', - }, - issuanceDisclaimer: { - l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', - }, -})[1]; - -const ECR_RULES = Saider.saidify({ - d: '', - usageDisclaimer: { - l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', - }, - issuanceDisclaimer: { - l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', - }, - privacyDisclaimer: { - l: 'It is the sole responsibility of Holders as Issuees of an ECR vLEI Credential to present that Credential in a privacy-preserving manner using the mechanisms provided in the Issuance and Presentation Exchange (IPEX) protocol specification and the Authentic Chained Data Container (ACDC) specification. https://github.com/WebOfTrust/IETF-IPEX and https://github.com/trustoverip/tswg-acdc-specification.', - }, -})[1]; - -const ECR_AUTH_RULES = Saider.saidify({ - d: '', - usageDisclaimer: { - l: 'Usage of a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, does not assert that the Legal Entity is trustworthy, honest, reputable in its business dealings, safe to do business with, or compliant with any laws or that an implied or expressly intended purpose will be fulfilled.', - }, - issuanceDisclaimer: { - l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.', - }, - privacyDisclaimer: { - l: 'Privacy Considerations are applicable to QVI ECR AUTH vLEI Credentials. It is the sole responsibility of QVIs as Issuees of QVI ECR AUTH vLEI Credentials to present these Credentials in a privacy-preserving manner using the mechanisms provided in the Issuance and Presentation Exchange (IPEX) protocol specification and the Authentic Chained Data Container (ACDC) specification. https://github.com/WebOfTrust/IETF-IPEX and https://github.com/trustoverip/tswg-acdc-specification.', - }, -})[1]; - -const OOR_RULES = LE_RULES; -const OOR_AUTH_RULES = LE_RULES; - -interface Aid { - name: string; - prefix: string; - oobi: string; -} - -function createTimestamp() { - return new Date().toISOString().replace('Z', '000+00:00'); -} - -async function createAid(client: SignifyClient, name: string): Promise { - const [prefix, oobi] = await getOrCreateIdentifier(client, name); - return { name, prefix, oobi }; -} - -test('singlesig-vlei-issuance', async function run() { - const [gleifClient, qviClient, leClient, roleClient] = - await getOrCreateClients(4); - - const [gleifAid, qviAid, leAid, roleAid] = await Promise.all([ - createAid(gleifClient, 'gleif'), - createAid(qviClient, 'qvi'), - createAid(leClient, 'le'), - createAid(roleClient, 'role'), - ]); - - await Promise.all([ - getOrCreateContact(gleifClient, 'qvi', qviAid.oobi), - getOrCreateContact(qviClient, 'gleif', gleifAid.oobi), - getOrCreateContact(qviClient, 'le', leAid.oobi), - getOrCreateContact(qviClient, 'role', roleAid.oobi), - getOrCreateContact(leClient, 'gleif', gleifAid.oobi), - getOrCreateContact(leClient, 'qvi', qviAid.oobi), - getOrCreateContact(leClient, 'role', roleAid.oobi), - getOrCreateContact(roleClient, 'gleif', gleifAid.oobi), - getOrCreateContact(roleClient, 'qvi', qviAid.oobi), - getOrCreateContact(roleClient, 'le', leAid.oobi), - ]); - - await Promise.all([ - resolveOobi(gleifClient, QVI_SCHEMA_URL), - resolveOobi(qviClient, QVI_SCHEMA_URL), - resolveOobi(qviClient, LE_SCHEMA_URL), - resolveOobi(qviClient, ECR_AUTH_SCHEMA_URL), - resolveOobi(qviClient, ECR_SCHEMA_URL), - resolveOobi(qviClient, OOR_AUTH_SCHEMA_URL), - resolveOobi(qviClient, OOR_SCHEMA_URL), - resolveOobi(leClient, QVI_SCHEMA_URL), - resolveOobi(leClient, LE_SCHEMA_URL), - resolveOobi(leClient, ECR_AUTH_SCHEMA_URL), - resolveOobi(leClient, ECR_SCHEMA_URL), - resolveOobi(leClient, OOR_AUTH_SCHEMA_URL), - resolveOobi(leClient, OOR_SCHEMA_URL), - resolveOobi(roleClient, QVI_SCHEMA_URL), - resolveOobi(roleClient, LE_SCHEMA_URL), - resolveOobi(roleClient, ECR_AUTH_SCHEMA_URL), - resolveOobi(roleClient, ECR_SCHEMA_URL), - resolveOobi(roleClient, OOR_AUTH_SCHEMA_URL), - resolveOobi(roleClient, OOR_SCHEMA_URL), - ]); - - const [gleifRegistry, qviRegistry, leRegistry] = await Promise.all([ - getOrCreateRegistry(gleifClient, gleifAid, 'gleifRegistry'), - getOrCreateRegistry(qviClient, qviAid, 'qviRegistry'), - getOrCreateRegistry(leClient, leAid, 'leRegistry'), - ]); - - console.log('Issuing QVI vLEI Credential'); - const qviCred = await getOrIssueCredential( - gleifClient, - gleifAid, - qviAid, - gleifRegistry, - qviData, - QVI_SCHEMA_SAID - ); - - let qviCredHolder = await getGrantedCredential(qviClient, qviCred.sad.d); - - if (!qviCredHolder) { - await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); - await sendAdmitMessage(qviClient, qviAid, gleifAid); - - qviCredHolder = await retry(async () => { - const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(qviCredHolder.sad.d, qviCred.sad.d); - assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); - assert.equal(qviCredHolder.sad.i, gleifAid.prefix); - assert.equal(qviCredHolder.sad.a.i, qviAid.prefix); - assert.equal(qviCredHolder.status.s, '0'); - assert(qviCredHolder.atc !== undefined); - - console.log('Issuing LE vLEI Credential'); - const leCredSource = Saider.saidify({ - d: '', - qvi: { - n: qviCred.sad.d, - s: qviCred.sad.s, - }, - })[1]; - - const leCred = await getOrIssueCredential( - qviClient, - qviAid, - leAid, - qviRegistry, - leData, - LE_SCHEMA_SAID, - LE_RULES, - leCredSource - ); - - let leCredHolder = await getGrantedCredential(leClient, leCred.sad.d); - - if (!leCredHolder) { - await sendGrantMessage(qviClient, qviAid, leAid, leCred); - await sendAdmitMessage(leClient, leAid, qviAid); - - leCredHolder = await retry(async () => { - const cred = await getGrantedCredential(leClient, leCred.sad.d); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(leCredHolder.sad.d, leCred.sad.d); - assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); - assert.equal(leCredHolder.sad.i, qviAid.prefix); - assert.equal(leCredHolder.sad.a.i, leAid.prefix); - assert.equal(leCredHolder.sad.e.qvi.n, qviCred.sad.d); - assert.equal(leCredHolder.status.s, '0'); - assert(leCredHolder.atc !== undefined); - - console.log('Issuing ECR vLEI Credential from LE'); - const ecrCredSource = Saider.saidify({ - d: '', - le: { - n: leCred.sad.d, - s: leCred.sad.s, - }, - })[1]; - - const ecrCred = await getOrIssueCredential( - leClient, - leAid, - roleAid, - leRegistry, - ecrData, - ECR_SCHEMA_SAID, - ECR_RULES, - ecrCredSource, - true - ); - - let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - - if (!ecrCredHolder) { - await sendGrantMessage(leClient, leAid, roleAid, ecrCred); - await sendAdmitMessage(roleClient, roleAid, leAid); - - ecrCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); - assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); - assert.equal(ecrCredHolder.sad.i, leAid.prefix); - assert.equal(ecrCredHolder.sad.a.i, roleAid.prefix); - assert.equal(ecrCredHolder.sad.e.le.n, leCred.sad.d); - assert.equal(ecrCredHolder.status.s, '0'); - assert(ecrCredHolder.atc !== undefined); - - console.log('Issuing ECR AUTH vLEI Credential'); - ecrAuthData.AID = roleAid.prefix; - const ecrAuthCredSource = Saider.saidify({ - d: '', - le: { - n: leCred.sad.d, - s: leCred.sad.s, - }, - })[1]; - - const ecrAuthCred = await getOrIssueCredential( - leClient, - leAid, - qviAid, - leRegistry, - ecrAuthData, - ECR_AUTH_SCHEMA_SAID, - ECR_AUTH_RULES, - ecrAuthCredSource - ); - - let ecrAuthCredHolder = await getGrantedCredential( - qviClient, - ecrAuthCred.sad.d - ); - - if (!ecrAuthCredHolder) { - await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - ecrAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - ecrAuthCred.sad.d - ); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); - assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); - assert.equal(ecrAuthCredHolder.sad.i, leAid.prefix); - assert.equal(ecrAuthCredHolder.sad.a.i, qviAid.prefix); - assert.equal(ecrAuthCredHolder.sad.a.AID, roleAid.prefix); - assert.equal(ecrAuthCredHolder.sad.e.le.n, leCred.sad.d); - assert.equal(ecrAuthCredHolder.status.s, '0'); - assert(ecrAuthCredHolder.atc !== undefined); - - console.log('Issuing ECR vLEI Credential from ECR AUTH'); - const ecrCredSource2 = Saider.saidify({ - d: '', - auth: { - n: ecrAuthCred.sad.d, - s: ecrAuthCred.sad.s, - o: 'I2I', - }, - })[1]; - - const ecrCred2 = await getOrIssueCredential( - qviClient, - qviAid, - roleAid, - qviRegistry, - ecrData, - ECR_SCHEMA_SAID, - ECR_RULES, - ecrCredSource2, - true - ); - - let ecrCredHolder2 = await getGrantedCredential(roleClient, ecrCred2.sad.d); - - if (!ecrCredHolder2) { - await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); - await sendAdmitMessage(roleClient, roleAid, qviAid); - - ecrCredHolder2 = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); - assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); - assert.equal(ecrCredHolder2.sad.i, qviAid.prefix); - assert.equal(ecrCredHolder2.sad.e.auth.n, ecrAuthCred.sad.d); - assert.equal(ecrCredHolder2.status.s, '0'); - assert(ecrCredHolder2.atc !== undefined); - - console.log('Issuing OOR AUTH vLEI Credential'); - oorAuthData.AID = roleAid.prefix; - const oorAuthCredSource = Saider.saidify({ - d: '', - le: { - n: leCred.sad.d, - s: leCred.sad.s, - }, - })[1]; - - const oorAuthCred = await getOrIssueCredential( - leClient, - leAid, - qviAid, - leRegistry, - oorAuthData, - OOR_AUTH_SCHEMA_SAID, - OOR_AUTH_RULES, - oorAuthCredSource - ); - - let oorAuthCredHolder = await getGrantedCredential( - qviClient, - oorAuthCred.sad.d - ); - - if (!oorAuthCredHolder) { - await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - oorAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - oorAuthCred.sad.d - ); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); - assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); - assert.equal(oorAuthCredHolder.sad.i, leAid.prefix); - assert.equal(oorAuthCredHolder.sad.a.i, qviAid.prefix); - assert.equal(oorAuthCredHolder.sad.a.AID, roleAid.prefix); - assert.equal(oorAuthCredHolder.sad.e.le.n, leCred.sad.d); - assert.equal(oorAuthCredHolder.status.s, '0'); - assert(oorAuthCredHolder.atc !== undefined); - - console.log('Issuing OOR vLEI Credential from OOR AUTH'); - const oorCredSource = Saider.saidify({ - d: '', - auth: { - n: oorAuthCred.sad.d, - s: oorAuthCred.sad.s, - o: 'I2I', - }, - })[1]; - - const oorCred = await getOrIssueCredential( - qviClient, - qviAid, - roleAid, - qviRegistry, - oorData, - OOR_SCHEMA_SAID, - OOR_RULES, - oorCredSource - ); - - let oorCredHolder = await getGrantedCredential(roleClient, oorCred.sad.d); - - if (!oorCredHolder) { - await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); - await sendAdmitMessage(roleClient, roleAid, qviAid); - - oorCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - assert(cred !== undefined); - return cred; - }); - } - assert.equal(oorCredHolder.sad.d, oorCred.sad.d); - assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); - assert.equal(oorCredHolder.sad.i, qviAid.prefix); - assert.equal(oorCredHolder.sad.e.auth.n, oorAuthCred.sad.d); - assert.equal(oorCredHolder.status.s, '0'); - assert(oorCredHolder.atc !== undefined); - - await assertOperations(gleifClient, qviClient, leClient, roleClient); - await warnNotifications(gleifClient, qviClient, leClient, roleClient); -}, 360000); - -async function getOrCreateRegistry( - client: SignifyClient, - aid: Aid, - registryName: string -): Promise<{ name: string; regk: string }> { - let registries = await client.registries().list(aid.name); - if (registries.length > 0) { - assert.equal(registries.length, 1); - } else { - const regResult = await client - .registries() - .create({ name: aid.name, registryName: registryName }); - await waitOperation(client, await regResult.op()); - registries = await client.registries().list(aid.name); - } - return registries[0]; -} - -async function getOrIssueCredential( - issuerClient: SignifyClient, - issuerAid: Aid, - recipientAid: Aid, - issuerRegistry: { regk: string }, - credData: any, - schema: string, - rules?: any, - source?: any, - privacy = false -): Promise { - const credentialList = await issuerClient.credentials().list(); - - if (credentialList.length > 0) { - const credential = credentialList.find( - (cred: any) => - cred.sad.s === schema && - cred.sad.i === issuerAid.prefix && - cred.sad.a.i === recipientAid.prefix - ); - if (credential) return credential; - } - - const issResult = await issuerClient.credentials().issue(issuerAid.name, { - ri: issuerRegistry.regk, - s: schema, - u: privacy ? new Salter({}).qb64 : undefined, - a: { - i: recipientAid.prefix, - u: privacy ? new Salter({}).qb64 : undefined, - ...credData, - }, - r: rules, - e: source, - }); - - await waitOperation(issuerClient, issResult.op); - const credential = await issuerClient - .credentials() - .get(issResult.acdc.ked.d); - - return credential; -} - -async function getGrantedCredential( - client: SignifyClient, - credId: string -): Promise { - const credentialList = await client.credentials().list({ - filter: { '-d': credId }, - }); - let credential: any; - if (credentialList.length > 0) { - assert.equal(credentialList.length, 1); - credential = credentialList[0]; - } - return credential; -} - -async function sendGrantMessage( - senderClient: SignifyClient, - senderAid: Aid, - recipientAid: Aid, - credential: any -) { - const [grant, gsigs, gend] = await senderClient.ipex().grant({ - senderName: senderAid.name, - acdc: new Serder(credential.sad), - anc: new Serder(credential.anc), - iss: new Serder(credential.iss), - ancAttachment: credential.ancAttachment, - recipient: recipientAid.prefix, - datetime: createTimestamp(), - }); - - let op = await senderClient - .ipex() - .submitGrant(senderAid.name, grant, gsigs, gend, [recipientAid.prefix]); - op = await waitOperation(senderClient, op); -} - -async function sendAdmitMessage( - senderClient: SignifyClient, - senderAid: Aid, - recipientAid: Aid -) { - const notifications = await waitForNotifications( - senderClient, - '/exn/ipex/grant' - ); - assert.equal(notifications.length, 1); - const grantNotification = notifications[0]; - - const [admit, sigs, aend] = await senderClient - .ipex() - .admit(senderAid.name, '', grantNotification.a.d!, createTimestamp()); - - let op = await senderClient - .ipex() - .submitAdmit(senderAid.name, admit, sigs, aend, [recipientAid.prefix]); - op = await waitOperation(senderClient, op); - - await markAndRemoveNotification(senderClient, grantNotification); -} +import {getGrantedCredential, ECR_SCHEMA_SAID} from './singlesig-vlei-issuance.test'; // This test assumes you have run a vlei test that sets up the glief, qvi, le, and // role identifiers and Credentials. test('vlei-verification', async function run() { - // these come from a previous test - const bran = 'Ak_0QIVNz4DjRarVCPduI'; //look for SIGNIFY_SECRETS + // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) + const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS const aidName = 'role'; const [roleClient] = await getOrCreateClients(1,[bran]); try { - let resp = await roleClient.signedFetch( - 'http://localhost:7676', - '/health', - 'GET', - null, - aidName - ); - assert.equal(200,resp.status) - + // let resp = await roleClient.signedFetch( + // 'http://localhost:7676', + // '/health', + // 'GET', + // null, + // aidName + // ); + // assert.equal(200,resp.status) let ecrCreds = (await roleClient.credentials().list()); let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); @@ -617,30 +33,16 @@ test('vlei-verification', async function run() { assert(ecrCredHolder.atc !== undefined); let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); - resp = await roleClient.signedFetch( + let resp = await roleClient.signedFetch( 'http://localhost:7676', `/presentations/${ecrCred.sad.d}`, 'PUT', ecrCredCesr, aidName, true) - assert.equal(200,resp.status) - - // assert.equal(lastCall[0]!, 'http://example.com/test'); - // assert.equal(lastCall[1]!.method, 'POST'); - // lastBody = JSON.parse(lastCall[1]!.body!); - // assert.deepEqual(lastBody.foo, true); - // lastHeaders = new Headers(lastCall[1]!.headers!); - // assert.equal( - // lastHeaders.get('signify-resource'), - // 'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK' - // ); + assert.equal(202,resp.status) } catch (e) { - if (e instanceof AggregateError) { - console.log(e.errors); - } else { - console.log(e); - } + console.log(e); fail(e); } }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e4f9dcd9..18a02720 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,6 @@ } }, "examples/scripts": { - "extraneous": true, "dependencies": { "prompt-sync": "^4.2.0", "signify-ts": "*" @@ -2153,6 +2152,12 @@ "optional": true, "peer": true }, + "node_modules/@types/prompt-sync": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@types/prompt-sync/-/prompt-sync-4.2.3.tgz", + "integrity": "sha512-Ox77gCSx0YyeakGt/qfOZUSFNSSi+sh3ABoGOiCwiO2KODx492BJnUm9oIXS+AHJtqp12iM4RduY6viTJ9bYwA==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.5.tgz", @@ -6850,6 +6855,33 @@ "integrity": "sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==", "dev": true }, + "node_modules/prompt-sync": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz", + "integrity": "sha512-BuEzzc5zptP5LsgV5MZETjDaKSWfchl5U9Luiu8SKp7iZWD5tZalOxvNcZRwv+d2phNFr8xlbxmFNcRKfJOzJw==", + "dependencies": { + "strip-ansi": "^5.0.0" + } + }, + "node_modules/prompt-sync/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "engines": { + "node": ">=6" + } + }, + "node_modules/prompt-sync/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -7209,6 +7241,10 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/signify-scripts-ts": { + "resolved": "examples/scripts", + "link": true + }, "node_modules/signify-ts": { "resolved": "", "link": true diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 0ed0406a..907224f5 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -276,7 +276,7 @@ export class SignifyClient { if ((typeof data == 'string') && cesr) { _body = data; - headers.set('Content-Type', 'application/cesr+json'); + headers.set('Content-Type', 'application/json+cesr'); } else if (method != 'GET') { if (data instanceof FormData) { _body = data; diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index ca08a9ab..18666384 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -188,7 +188,8 @@ export class Credentials { */ async issue( name: string, - args: CredentialData + args: CredentialData, + privacy:boolean = false ): Promise { const hab = await this.client.identifiers().get(name); const estOnly = hab.state.c !== undefined && hab.state.c.includes('EO'); @@ -211,6 +212,7 @@ export class Credentials { const [, acdc] = Saider.saidify({ v: versify(Ident.ACDC, undefined, Serials.JSON, 0), d: '', + u: privacy ? new Salter({}).qb64 : undefined, i: args.i ?? hab.prefix, ...args, a: subject, From 6e19a80e1276297c82290de0560d32efbc411c7d Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 14:08:51 -0400 Subject: [PATCH 03/23] make signedFetch generic so the caller can control contentType and data. This is a breaking change Signed-off-by: 2byrds <2byrds@gmail.com> --- src/keri/app/clienting.ts | 36 ++++++++++++++---------------------- test/app/clienting.test.ts | 5 +++-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 907224f5..d82dd417 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -235,7 +235,11 @@ export class SignifyClient { * @param {string} url URL of the resource * @param {string} path Path to the resource * @param {string} method HTTP method - * @param {any} data Data to be sent in the body of the resource + * @param {any} data Data to be sent in the body of the resource. + * If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr' + * If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data' + * If the data is an object then you should use JSON.stringify to convert it to a string and set the contentType to 'application/json' + * @param {string} contentType Content type of the request. * @param {string} aidName Name or alias of the AID to be used for signing * @returns {Promise} A promise to the result of the fetch */ @@ -243,9 +247,9 @@ export class SignifyClient { url: string, path: string, method: string, - data: any, + data: string, + contentType: string, aidName: string, - cesr: boolean = false ): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -262,37 +266,25 @@ export class SignifyClient { new Date().toISOString().replace('Z', '000+00:00') ); + if(contentType !== null) { + headers.set('Content-Type', contentType); + } + if (data !== null) { - headers.set('Content-Length', data.length); + headers.set('Content-Length', data.length.toString()); } else { headers.set('Content-Length', '0'); } + const signed_headers = authenticator.sign( headers, method, path.split('?')[0] ); - let _body = null; - - if ((typeof data == 'string') && cesr) { - _body = data; - headers.set('Content-Type', 'application/json+cesr'); - } else if (method != 'GET') { - if (data instanceof FormData) { - _body = data; - // do not set the content type, let the browser do it - // headers.set('Content-Type', 'multipart/form-data') - } else { - _body = JSON.stringify(data); - headers.set('Content-Type', 'application/json'); - } - } else { - headers.set('Content-Type', 'application/json'); - } return await fetch(url + path, { method: method, - body: _body, + body: data, headers: signed_headers, }); } diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index ede08d6f..ef197dfd 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -363,8 +363,9 @@ describe('SignifyClient', () => { 'http://example.com', '/test', 'POST', - { foo: true }, - 'aid1' + JSON.stringify({ foo: true }), + 'application/json', + 'aid1', ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, 'http://example.com/test'); From cbaafb6a2cc25a88fce92e79d8cc9f5380aa1bf0 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 14:14:06 -0400 Subject: [PATCH 04/23] CI/CD can't run the vlei verification integration test, so commenting out Signed-off-by: 2byrds <2byrds@gmail.com> --- .../vlei-verification.test.ts | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts index 5bc22d92..ae9841e4 100644 --- a/examples/integration-scripts/vlei-verification.test.ts +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -4,45 +4,45 @@ import { } from './utils/test-setup'; import {getGrantedCredential, ECR_SCHEMA_SAID} from './singlesig-vlei-issuance.test'; -// This test assumes you have run a vlei test that sets up the glief, qvi, le, and -// role identifiers and Credentials. -test('vlei-verification', async function run() { +// // This test assumes you have run a vlei test that sets up the glief, qvi, le, and +// // role identifiers and Credentials. +// test('vlei-verification', async function run() { - // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) - const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS - const aidName = 'role'; - const [roleClient] = await getOrCreateClients(1,[bran]); +// // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) +// const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS +// const aidName = 'role'; +// const [roleClient] = await getOrCreateClients(1,[bran]); - try { - // let resp = await roleClient.signedFetch( - // 'http://localhost:7676', - // '/health', - // 'GET', - // null, - // aidName - // ); - // assert.equal(200,resp.status) +// try { +// // let resp = await roleClient.signedFetch( +// // 'http://localhost:7676', +// // '/health', +// // 'GET', +// // null, +// // aidName +// // ); +// // assert.equal(200,resp.status) - let ecrCreds = (await roleClient.credentials().list()); - let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); - let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - assert(ecrCred !== undefined); - assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); - assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); - assert.equal(ecrCredHolder.status.s, '0'); - assert(ecrCredHolder.atc !== undefined); +// let ecrCreds = (await roleClient.credentials().list()); +// let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); +// let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); +// assert(ecrCred !== undefined); +// assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); +// assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); +// assert.equal(ecrCredHolder.status.s, '0'); +// assert(ecrCredHolder.atc !== undefined); - let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); - let resp = await roleClient.signedFetch( - 'http://localhost:7676', - `/presentations/${ecrCred.sad.d}`, - 'PUT', - ecrCredCesr, - aidName, - true) - assert.equal(202,resp.status) - } catch (e) { - console.log(e); - fail(e); - } -}); \ No newline at end of file +// let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); +// let resp = await roleClient.signedFetch( +// 'http://localhost:7676', +// `/presentations/${ecrCred.sad.d}`, +// 'PUT', +// ecrCredCesr, +// aidName, +// true) +// assert.equal(202,resp.status) +// } catch (e) { +// console.log(e); +// fail(e); +// } +// }); \ No newline at end of file From 05768f02252220e9bf1edddd3607730a01783cd3 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 14:41:14 -0400 Subject: [PATCH 05/23] CI/CD can't run the vlei verification integration test, so commenting out Signed-off-by: 2byrds <2byrds@gmail.com> --- examples/integration-scripts/vlei-verification.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts index ae9841e4..7c15432b 100644 --- a/examples/integration-scripts/vlei-verification.test.ts +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -4,9 +4,9 @@ import { } from './utils/test-setup'; import {getGrantedCredential, ECR_SCHEMA_SAID} from './singlesig-vlei-issuance.test'; -// // This test assumes you have run a vlei test that sets up the glief, qvi, le, and -// // role identifiers and Credentials. -// test('vlei-verification', async function run() { +// This test assumes you have run a vlei test that sets up the glief, qvi, le, and +// role identifiers and Credentials. +test('vlei-verification', async function run() { // // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) // const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS @@ -45,4 +45,4 @@ import {getGrantedCredential, ECR_SCHEMA_SAID} from './singlesig-vlei-issuance.t // console.log(e); // fail(e); // } -// }); \ No newline at end of file +}); \ No newline at end of file From 12fc3cfc9573141943eef7f96c8525b00b657c17 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 14:48:03 -0400 Subject: [PATCH 06/23] formatting fixes Signed-off-by: 2byrds <2byrds@gmail.com> --- .../vlei-verification.test.ts | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts index 7c15432b..5d35fe89 100644 --- a/examples/integration-scripts/vlei-verification.test.ts +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -2,47 +2,47 @@ import { strict as assert } from 'assert'; import { getOrCreateClients, } from './utils/test-setup'; -import {getGrantedCredential, ECR_SCHEMA_SAID} from './singlesig-vlei-issuance.test'; +import { getGrantedCredential, ECR_SCHEMA_SAID } from './singlesig-vlei-issuance.test'; // This test assumes you have run a vlei test that sets up the glief, qvi, le, and // role identifiers and Credentials. test('vlei-verification', async function run() { -// // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) -// const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS -// const aidName = 'role'; -// const [roleClient] = await getOrCreateClients(1,[bran]); + // // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) + // const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS + // const aidName = 'role'; + // const [roleClient] = await getOrCreateClients(1,[bran]); -// try { -// // let resp = await roleClient.signedFetch( -// // 'http://localhost:7676', -// // '/health', -// // 'GET', -// // null, -// // aidName -// // ); -// // assert.equal(200,resp.status) + // try { + // // let resp = await roleClient.signedFetch( + // // 'http://localhost:7676', + // // '/health', + // // 'GET', + // // null, + // // aidName + // // ); + // // assert.equal(200,resp.status) -// let ecrCreds = (await roleClient.credentials().list()); -// let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); -// let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); -// assert(ecrCred !== undefined); -// assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); -// assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); -// assert.equal(ecrCredHolder.status.s, '0'); -// assert(ecrCredHolder.atc !== undefined); + // let ecrCreds = (await roleClient.credentials().list()); + // let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); + // let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); + // assert(ecrCred !== undefined); + // assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); + // assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); + // assert.equal(ecrCredHolder.status.s, '0'); + // assert(ecrCredHolder.atc !== undefined); -// let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); -// let resp = await roleClient.signedFetch( -// 'http://localhost:7676', -// `/presentations/${ecrCred.sad.d}`, -// 'PUT', -// ecrCredCesr, -// aidName, -// true) -// assert.equal(202,resp.status) -// } catch (e) { -// console.log(e); -// fail(e); -// } + // let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); + // let resp = await roleClient.signedFetch( + // 'http://localhost:7676', + // `/presentations/${ecrCred.sad.d}`, + // 'PUT', + // ecrCredCesr, + // aidName, + // true) + // assert.equal(202,resp.status) + // } catch (e) { + // console.log(e); + // fail(e); + // } }); \ No newline at end of file From 9db0c6977e36063310e5ad048589eae80a9b87f6 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 29 Apr 2024 14:52:53 -0400 Subject: [PATCH 07/23] prettier formatting fixes Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 26 +++++++++++-------- .../vlei-verification.test.ts | 13 ++++------ src/keri/app/clienting.ts | 4 +-- src/keri/app/credentialing.ts | 2 +- test/app/clienting.test.ts | 2 +- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index 41979028..f6241aea 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -505,17 +505,21 @@ async function getOrIssueCredential( if (credential) return credential; } - const issResult = await issuerClient.credentials().issue(issuerAid.name, { - ri: issuerRegistry.regk, - s: schema, - a: { - i: recipientAid.prefix, - u: privacy ? new Salter({}).qb64 : undefined, - ...credData, + const issResult = await issuerClient.credentials().issue( + issuerAid.name, + { + ri: issuerRegistry.regk, + s: schema, + a: { + i: recipientAid.prefix, + u: privacy ? new Salter({}).qb64 : undefined, + ...credData, + }, + e: source, + r: rules, }, - e: source, - r: rules, - },privacy); + privacy + ); await waitOperation(issuerClient, issResult.op); const credential = await issuerClient @@ -584,4 +588,4 @@ async function sendAdmitMessage( op = await waitOperation(senderClient, op); await markAndRemoveNotification(senderClient, grantNotification); -} \ No newline at end of file +} diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts index 5d35fe89..bb31f17b 100644 --- a/examples/integration-scripts/vlei-verification.test.ts +++ b/examples/integration-scripts/vlei-verification.test.ts @@ -1,18 +1,17 @@ import { strict as assert } from 'assert'; +import { getOrCreateClients } from './utils/test-setup'; import { - getOrCreateClients, -} from './utils/test-setup'; -import { getGrantedCredential, ECR_SCHEMA_SAID } from './singlesig-vlei-issuance.test'; + getGrantedCredential, + ECR_SCHEMA_SAID, +} from './singlesig-vlei-issuance.test'; // This test assumes you have run a vlei test that sets up the glief, qvi, le, and // role identifiers and Credentials. test('vlei-verification', async function run() { - // // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) // const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS // const aidName = 'role'; // const [roleClient] = await getOrCreateClients(1,[bran]); - // try { // // let resp = await roleClient.signedFetch( // // 'http://localhost:7676', @@ -22,7 +21,6 @@ test('vlei-verification', async function run() { // // aidName // // ); // // assert.equal(200,resp.status) - // let ecrCreds = (await roleClient.credentials().list()); // let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); // let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); @@ -31,7 +29,6 @@ test('vlei-verification', async function run() { // assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); // assert.equal(ecrCredHolder.status.s, '0'); // assert(ecrCredHolder.atc !== undefined); - // let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); // let resp = await roleClient.signedFetch( // 'http://localhost:7676', @@ -45,4 +42,4 @@ test('vlei-verification', async function run() { // console.log(e); // fail(e); // } -}); \ No newline at end of file +}); diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index d82dd417..42b1757d 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -249,7 +249,7 @@ export class SignifyClient { method: string, data: string, contentType: string, - aidName: string, + aidName: string ): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -266,7 +266,7 @@ export class SignifyClient { new Date().toISOString().replace('Z', '000+00:00') ); - if(contentType !== null) { + if (contentType !== null) { headers.set('Content-Type', contentType); } diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 18666384..0eb93ee2 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -189,7 +189,7 @@ export class Credentials { async issue( name: string, args: CredentialData, - privacy:boolean = false + privacy: boolean = false ): Promise { const hab = await this.client.identifiers().get(name); const estOnly = hab.state.c !== undefined && hab.state.c.includes('EO'); diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index ef197dfd..149bcb41 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -365,7 +365,7 @@ describe('SignifyClient', () => { 'POST', JSON.stringify({ foo: true }), 'application/json', - 'aid1', + 'aid1' ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, 'http://example.com/test'); From 895a819cae18f573583af6e8a8eaebf07f8a67b2 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Tue, 30 Apr 2024 16:39:25 -0400 Subject: [PATCH 08/23] Align signedFetch with fetch api. Signed-off-by: 2byrds <2byrds@gmail.com> --- .../vlei-verification.test.ts | 45 ------------------- src/keri/app/clienting.ts | 41 +++++------------ test/app/clienting.test.ts | 13 +++--- 3 files changed, 17 insertions(+), 82 deletions(-) delete mode 100644 examples/integration-scripts/vlei-verification.test.ts diff --git a/examples/integration-scripts/vlei-verification.test.ts b/examples/integration-scripts/vlei-verification.test.ts deleted file mode 100644 index bb31f17b..00000000 --- a/examples/integration-scripts/vlei-verification.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { strict as assert } from 'assert'; -import { getOrCreateClients } from './utils/test-setup'; -import { - getGrantedCredential, - ECR_SCHEMA_SAID, -} from './singlesig-vlei-issuance.test'; - -// This test assumes you have run a vlei test that sets up the glief, qvi, le, and -// role identifiers and Credentials. -test('vlei-verification', async function run() { - // // these come from a previous test (ex. singlesig-vlei-issuance.test.ts) - // const bran = 'DbH7DF2uJgXg8gTRpM2ar'; //taken from SIGNIFY_SECRETS - // const aidName = 'role'; - // const [roleClient] = await getOrCreateClients(1,[bran]); - // try { - // // let resp = await roleClient.signedFetch( - // // 'http://localhost:7676', - // // '/health', - // // 'GET', - // // null, - // // aidName - // // ); - // // assert.equal(200,resp.status) - // let ecrCreds = (await roleClient.credentials().list()); - // let ecrCred = ecrCreds.find((cred: any) => cred.sad.s === ECR_SCHEMA_SAID); - // let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - // assert(ecrCred !== undefined); - // assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); - // assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); - // assert.equal(ecrCredHolder.status.s, '0'); - // assert(ecrCredHolder.atc !== undefined); - // let ecrCredCesr = (await roleClient.credentials().get(ecrCred.sad.d,true)); - // let resp = await roleClient.signedFetch( - // 'http://localhost:7676', - // `/presentations/${ecrCred.sad.d}`, - // 'PUT', - // ecrCredCesr, - // aidName, - // true) - // assert.equal(202,resp.status) - // } catch (e) { - // console.log(e); - // fail(e); - // } -}); diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 42b1757d..fc85aa2f 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -11,6 +11,7 @@ import { Notifications } from './notifying'; import { Escrows } from './escrowing'; import { Groups } from './grouping'; import { Exchanges } from './exchanging'; +import { Hab, Habery } from './habery'; const DEFAULT_BOOT_URL = 'http://localhost:3903'; @@ -243,14 +244,7 @@ export class SignifyClient { * @param {string} aidName Name or alias of the AID to be used for signing * @returns {Promise} A promise to the result of the fetch */ - async signedFetch( - url: string, - path: string, - method: string, - data: string, - contentType: string, - aidName: string - ): Promise { + async signedFetch(aidName: string, url: string, path: string, req: RequestInit): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -259,34 +253,23 @@ export class SignifyClient { keeper.signers[0].verfer ); - const headers = new Headers(); - headers.set('Signify-Resource', hab.prefix); - headers.set( - 'Signify-Timestamp', - new Date().toISOString().replace('Z', '000+00:00') - ); - - if (contentType !== null) { - headers.set('Content-Type', contentType); - } - - if (data !== null) { - headers.set('Content-Length', data.length.toString()); + let headers = req.headers; + if(headers == undefined) { + headers = new Headers(); } else { - headers.set('Content-Length', '0'); + headers = new Headers(headers); } + headers.set('Signify-Resource',hab['prefix']); + headers.set('Signify-Timestamp', new Date().toISOString().replace('Z', '000+00:00')); const signed_headers = authenticator.sign( - headers, - method, + new Headers(headers), + headers.get('method')!, path.split('?')[0] ); + req.headers = signed_headers; - return await fetch(url + path, { - method: method, - body: data, - headers: signed_headers, - }); + return await fetch(url + path, req); } /** diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index 149bcb41..cd5193ca 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -23,6 +23,7 @@ import { Salter, Tier } from '../../src/keri/core/salter'; import libsodium from 'libsodium-wrappers-sumo'; import fetchMock from 'jest-fetch-mock'; import 'whatwg-fetch'; +import { b } from '../../dist'; fetchMock.enableMocks(); @@ -359,14 +360,10 @@ describe('SignifyClient', () => { 'EGFi9pCcRaLK8dPh5S7JP9Em62fBMiR1l4gW1ZazuuAO' ); - resp = await client.signedFetch( - 'http://example.com', - '/test', - 'POST', - JSON.stringify({ foo: true }), - 'application/json', - 'aid1' - ); + let heads = new Headers(); + heads.set('Content-Type', 'application/json'); + let reqInit = {headers: heads, method: 'POST', body: JSON.stringify({foo: true})}; + resp = await client.signedFetch('aid1', 'http://example.com', '/test', reqInit); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, 'http://example.com/test'); assert.equal(lastCall[1]!.method, 'POST'); From 18b863bce5f4a07def0345b86bd682fb3a7b42ff Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 11:05:06 -0400 Subject: [PATCH 09/23] improved reliability of singlesig-vlei-issuance with retries Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 66 +++++++++++-------- src/keri/app/credentialing.ts | 12 ++-- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index f6241aea..441062ab 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -21,7 +21,7 @@ const { vleiServerUrl } = resolveEnvironment(); const QVI_SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; const LE_SCHEMA_SAID = 'ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY'; const ECR_AUTH_SCHEMA_SAID = 'EH6ekLjSr8V32WyFbGe1zXjTzFs9PkTYmupJ9H65O14g'; -export const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; +const ECR_SCHEMA_SAID = 'EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw'; const OOR_AUTH_SCHEMA_SAID = 'EKA57bKBKxr_kN7iN5i7lMUxpMG-s19dRcmov1iDxz-E'; const OOR_SCHEMA_SAID = 'EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy'; @@ -185,16 +185,18 @@ test('singlesig-vlei-issuance', async function run() { let qviCredHolder = await getGrantedCredential(qviClient, qviCred.sad.d); - if (!qviCredHolder) { + let qviRetry = 0; + while (!qviCredHolder && qviRetry < 5) { await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); await sendAdmitMessage(qviClient, qviAid, gleifAid); qviCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - assert(cred !== undefined); - return cred; + qviRetry += 1; + if (cred !== undefined) return cred; }); } + assert(qviCredHolder !== undefined); assert.equal(qviCredHolder.sad.d, qviCred.sad.d); assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); assert.equal(qviCredHolder.sad.i, gleifAid.prefix); @@ -224,16 +226,18 @@ test('singlesig-vlei-issuance', async function run() { let leCredHolder = await getGrantedCredential(leClient, leCred.sad.d); - if (!leCredHolder) { + let leRetry = 0; + while (!leCredHolder && leRetry < 5) { await sendGrantMessage(qviClient, qviAid, leAid, leCred); await sendAdmitMessage(leClient, leAid, qviAid); - + leRetry += 1; leCredHolder = await retry(async () => { const cred = await getGrantedCredential(leClient, leCred.sad.d); - assert(cred !== undefined); - return cred; + + if (cred !== undefined) return cred; }); } + assert(leCredHolder !== undefined); assert.equal(leCredHolder.sad.d, leCred.sad.d); assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); assert.equal(leCredHolder.sad.i, qviAid.prefix); @@ -265,16 +269,18 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - if (!ecrCredHolder) { + let ecrRetry = 0; + while (!ecrCredHolder && ecrRetry < 5) { await sendGrantMessage(leClient, leAid, roleAid, ecrCred); await sendAdmitMessage(roleClient, roleAid, leAid); ecrCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - assert(cred !== undefined); - return cred; + ecrRetry += 1; + if (cred !== undefined) return cred; }); } + assert(ecrCredHolder !== undefined); assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); assert.equal(ecrCredHolder.sad.i, leAid.prefix); @@ -309,7 +315,8 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCred.sad.d ); - if (!ecrAuthCredHolder) { + let ecrAuthRetry = 0; + while (!ecrAuthCredHolder && ecrAuthRetry < 5) { await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); await sendAdmitMessage(qviClient, qviAid, leAid); @@ -318,10 +325,11 @@ test('singlesig-vlei-issuance', async function run() { qviClient, ecrAuthCred.sad.d ); - assert(cred !== undefined); - return cred; + ecrAuthRetry += 1; + if(cred !== undefined) return cred; }); } + assert(ecrAuthCredHolder !== undefined); assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); assert.equal(ecrAuthCredHolder.sad.i, leAid.prefix); @@ -355,16 +363,18 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder2 = await getGrantedCredential(roleClient, ecrCred2.sad.d); - if (!ecrCredHolder2) { + let ecr2Retry = 0; + while (!ecrCredHolder2 && ecr2Retry < 5) { await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); await sendAdmitMessage(roleClient, roleAid, qviAid); ecrCredHolder2 = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - assert(cred !== undefined); - return cred; + ecr2Retry += 1; + if(cred !== undefined) return cred; }); } + assert(ecrCredHolder2 !== undefined); assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); assert.equal(ecrCredHolder2.sad.i, qviAid.prefix); @@ -398,7 +408,8 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCred.sad.d ); - if (!oorAuthCredHolder) { + let oorAuthRetry = 0; + while (!oorAuthCredHolder && oorAuthRetry < 5) { await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); await sendAdmitMessage(qviClient, qviAid, leAid); @@ -407,10 +418,11 @@ test('singlesig-vlei-issuance', async function run() { qviClient, oorAuthCred.sad.d ); - assert(cred !== undefined); - return cred; + oorAuthRetry += 1; + if(cred !== undefined) return cred; }); } + assert(oorAuthCredHolder !== undefined); assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); assert.equal(oorAuthCredHolder.sad.i, leAid.prefix); @@ -443,16 +455,18 @@ test('singlesig-vlei-issuance', async function run() { let oorCredHolder = await getGrantedCredential(roleClient, oorCred.sad.d); - if (!oorCredHolder) { + let oorRetry = 0; + while (!oorCredHolder && oorRetry < 5) { await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); await sendAdmitMessage(roleClient, roleAid, qviAid); oorCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - assert(cred !== undefined); - return cred; + oorRetry += 1; + if(cred !== undefined) return cred; }); } + assert(oorCredHolder !== undefined); assert.equal(oorCredHolder.sad.d, oorCred.sad.d); assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); assert.equal(oorCredHolder.sad.i, qviAid.prefix); @@ -508,6 +522,7 @@ async function getOrIssueCredential( const issResult = await issuerClient.credentials().issue( issuerAid.name, { + u: privacy ? new Salter({}).qb64 : undefined, ri: issuerRegistry.regk, s: schema, a: { @@ -517,8 +532,7 @@ async function getOrIssueCredential( }, e: source, r: rules, - }, - privacy + } ); await waitOperation(issuerClient, issResult.op); @@ -529,7 +543,7 @@ async function getOrIssueCredential( return credential; } -export async function getGrantedCredential( +async function getGrantedCredential( client: SignifyClient, credId: string ): Promise { diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 0eb93ee2..6ddca4ac 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -189,7 +189,6 @@ export class Credentials { async issue( name: string, args: CredentialData, - privacy: boolean = false ): Promise { const hab = await this.client.identifiers().get(name); const estOnly = hab.state.c !== undefined && hab.state.c.includes('EO'); @@ -212,11 +211,14 @@ export class Credentials { const [, acdc] = Saider.saidify({ v: versify(Ident.ACDC, undefined, Serials.JSON, 0), d: '', - u: privacy ? new Salter({}).qb64 : undefined, - i: args.i ?? hab.prefix, - ...args, + u: args.u, + i: args.i??hab.prefix, + ri: args.ri, + s: args.s, a: subject, - }); + e: args.e, + r: args.r, + }) const [, iss] = Saider.saidify({ v: versify(Ident.KERI, undefined, Serials.JSON, 0), From 96ec3c7101f6fa55411f5a09bbb68fb95b3707f4 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 11:07:41 -0400 Subject: [PATCH 10/23] restore original package-lock.json Signed-off-by: 2byrds <2byrds@gmail.com> --- package-lock.json | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 18a02720..e4f9dcd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,6 +51,7 @@ } }, "examples/scripts": { + "extraneous": true, "dependencies": { "prompt-sync": "^4.2.0", "signify-ts": "*" @@ -2152,12 +2153,6 @@ "optional": true, "peer": true }, - "node_modules/@types/prompt-sync": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/@types/prompt-sync/-/prompt-sync-4.2.3.tgz", - "integrity": "sha512-Ox77gCSx0YyeakGt/qfOZUSFNSSi+sh3ABoGOiCwiO2KODx492BJnUm9oIXS+AHJtqp12iM4RduY6viTJ9bYwA==", - "dev": true - }, "node_modules/@types/semver": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.5.tgz", @@ -6855,33 +6850,6 @@ "integrity": "sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==", "dev": true }, - "node_modules/prompt-sync": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz", - "integrity": "sha512-BuEzzc5zptP5LsgV5MZETjDaKSWfchl5U9Luiu8SKp7iZWD5tZalOxvNcZRwv+d2phNFr8xlbxmFNcRKfJOzJw==", - "dependencies": { - "strip-ansi": "^5.0.0" - } - }, - "node_modules/prompt-sync/node_modules/ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", - "engines": { - "node": ">=6" - } - }, - "node_modules/prompt-sync/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -7241,10 +7209,6 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, - "node_modules/signify-scripts-ts": { - "resolved": "examples/scripts", - "link": true - }, "node_modules/signify-ts": { "resolved": "", "link": true From 51422fceb83a5767872d1a5465a720de6db7b33c Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 11:09:36 -0400 Subject: [PATCH 11/23] prettier formatting Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 35 +++++++++---------- src/keri/app/credentialing.ts | 6 ++-- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index 441062ab..48f46bd4 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -233,7 +233,7 @@ test('singlesig-vlei-issuance', async function run() { leRetry += 1; leCredHolder = await retry(async () => { const cred = await getGrantedCredential(leClient, leCred.sad.d); - + if (cred !== undefined) return cred; }); } @@ -326,7 +326,7 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCred.sad.d ); ecrAuthRetry += 1; - if(cred !== undefined) return cred; + if (cred !== undefined) return cred; }); } assert(ecrAuthCredHolder !== undefined); @@ -371,7 +371,7 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder2 = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); ecr2Retry += 1; - if(cred !== undefined) return cred; + if (cred !== undefined) return cred; }); } assert(ecrCredHolder2 !== undefined); @@ -419,7 +419,7 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCred.sad.d ); oorAuthRetry += 1; - if(cred !== undefined) return cred; + if (cred !== undefined) return cred; }); } assert(oorAuthCredHolder !== undefined); @@ -463,7 +463,7 @@ test('singlesig-vlei-issuance', async function run() { oorCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); oorRetry += 1; - if(cred !== undefined) return cred; + if (cred !== undefined) return cred; }); } assert(oorCredHolder !== undefined); @@ -519,21 +519,18 @@ async function getOrIssueCredential( if (credential) return credential; } - const issResult = await issuerClient.credentials().issue( - issuerAid.name, - { + const issResult = await issuerClient.credentials().issue(issuerAid.name, { + u: privacy ? new Salter({}).qb64 : undefined, + ri: issuerRegistry.regk, + s: schema, + a: { + i: recipientAid.prefix, u: privacy ? new Salter({}).qb64 : undefined, - ri: issuerRegistry.regk, - s: schema, - a: { - i: recipientAid.prefix, - u: privacy ? new Salter({}).qb64 : undefined, - ...credData, - }, - e: source, - r: rules, - } - ); + ...credData, + }, + e: source, + r: rules, + }); await waitOperation(issuerClient, issResult.op); const credential = await issuerClient diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 6ddca4ac..44cd637f 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -188,7 +188,7 @@ export class Credentials { */ async issue( name: string, - args: CredentialData, + args: CredentialData ): Promise { const hab = await this.client.identifiers().get(name); const estOnly = hab.state.c !== undefined && hab.state.c.includes('EO'); @@ -212,13 +212,13 @@ export class Credentials { v: versify(Ident.ACDC, undefined, Serials.JSON, 0), d: '', u: args.u, - i: args.i??hab.prefix, + i: args.i ?? hab.prefix, ri: args.ri, s: args.s, a: subject, e: args.e, r: args.r, - }) + }); const [, iss] = Saider.saidify({ v: versify(Ident.KERI, undefined, Serials.JSON, 0), From 4058a4935c424bed1b69b24556845aefa25a0932 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 11:12:23 -0400 Subject: [PATCH 12/23] removed unnecessary imports Signed-off-by: 2byrds <2byrds@gmail.com> --- src/keri/app/clienting.ts | 1 - test/app/clienting.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index fc85aa2f..60d516d0 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -11,7 +11,6 @@ import { Notifications } from './notifying'; import { Escrows } from './escrowing'; import { Groups } from './grouping'; import { Exchanges } from './exchanging'; -import { Hab, Habery } from './habery'; const DEFAULT_BOOT_URL = 'http://localhost:3903'; diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index cd5193ca..ab955efb 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -23,7 +23,6 @@ import { Salter, Tier } from '../../src/keri/core/salter'; import libsodium from 'libsodium-wrappers-sumo'; import fetchMock from 'jest-fetch-mock'; import 'whatwg-fetch'; -import { b } from '../../dist'; fetchMock.enableMocks(); From 8245ed7b1557a8cd64a0f6f49f6819082250c661 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 11:17:43 -0400 Subject: [PATCH 13/23] even prettier formatting Signed-off-by: 2byrds <2byrds@gmail.com> --- src/keri/app/clienting.ts | 16 ++++++++++++---- test/app/clienting.test.ts | 13 +++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 60d516d0..7e24fc36 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -243,7 +243,12 @@ export class SignifyClient { * @param {string} aidName Name or alias of the AID to be used for signing * @returns {Promise} A promise to the result of the fetch */ - async signedFetch(aidName: string, url: string, path: string, req: RequestInit): Promise { + async signedFetch( + aidName: string, + url: string, + path: string, + req: RequestInit + ): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -253,13 +258,16 @@ export class SignifyClient { ); let headers = req.headers; - if(headers == undefined) { + if (headers == undefined) { headers = new Headers(); } else { headers = new Headers(headers); } - headers.set('Signify-Resource',hab['prefix']); - headers.set('Signify-Timestamp', new Date().toISOString().replace('Z', '000+00:00')); + headers.set('Signify-Resource', hab['prefix']); + headers.set( + 'Signify-Timestamp', + new Date().toISOString().replace('Z', '000+00:00') + ); const signed_headers = authenticator.sign( new Headers(headers), diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index ab955efb..122f0f3c 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -361,8 +361,17 @@ describe('SignifyClient', () => { let heads = new Headers(); heads.set('Content-Type', 'application/json'); - let reqInit = {headers: heads, method: 'POST', body: JSON.stringify({foo: true})}; - resp = await client.signedFetch('aid1', 'http://example.com', '/test', reqInit); + let reqInit = { + headers: heads, + method: 'POST', + body: JSON.stringify({ foo: true }), + }; + resp = await client.signedFetch( + 'aid1', + 'http://example.com', + '/test', + reqInit + ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, 'http://example.com/test'); assert.equal(lastCall[1]!.method, 'POST'); From c5914dbec7de78c6da39d2912c06a0e087a2c8c9 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 1 May 2024 12:12:42 -0400 Subject: [PATCH 14/23] fixed signedFetch documentation Signed-off-by: 2byrds <2byrds@gmail.com> --- src/keri/app/clienting.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 7e24fc36..736e2615 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -232,15 +232,16 @@ export class SignifyClient { /** * Fetch a resource from from an external URL with headers signed by an AID * @async + * @param {string} aidName Name or alias of the AID to be used for signing * @param {string} url URL of the resource * @param {string} path Path to the resource - * @param {string} method HTTP method - * @param {any} data Data to be sent in the body of the resource. + * @param {RequestInit} req Request options should include: + * - method: HTTP method + * - data Data to be sent in the body of the resource. * If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr' * If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data' * If the data is an object then you should use JSON.stringify to convert it to a string and set the contentType to 'application/json' - * @param {string} contentType Content type of the request. - * @param {string} aidName Name or alias of the AID to be used for signing + * - contentType Content type of the request. * @returns {Promise} A promise to the result of the fetch */ async signedFetch( From 6fe4061675473b2e971a5000b6e03e32f5e6d9bd Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 05:28:13 -0400 Subject: [PATCH 15/23] set retry options Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 137 ++++++++---------- 1 file changed, 59 insertions(+), 78 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index 48f46bd4..dce4b1ac 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -106,6 +106,8 @@ const ECR_AUTH_RULES = Saider.saidify({ const OOR_RULES = LE_RULES; const OOR_AUTH_RULES = LE_RULES; +const RETRY_DEFAULTS = {maxSleep: 1000, minSleep: 10, maxRetries: 5, timeout: 10000} + interface Aid { name: string; prefix: string; @@ -185,17 +187,14 @@ test('singlesig-vlei-issuance', async function run() { let qviCredHolder = await getGrantedCredential(qviClient, qviCred.sad.d); - let qviRetry = 0; - while (!qviCredHolder && qviRetry < 5) { - await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); - await sendAdmitMessage(qviClient, qviAid, gleifAid); + await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); + await sendAdmitMessage(qviClient, qviAid, gleifAid); + + qviCredHolder = await retry(async () => { + const cred = await getGrantedCredential(qviClient, qviCred.sad.d); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); - qviCredHolder = await retry(async () => { - const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - qviRetry += 1; - if (cred !== undefined) return cred; - }); - } assert(qviCredHolder !== undefined); assert.equal(qviCredHolder.sad.d, qviCred.sad.d); assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); @@ -226,17 +225,14 @@ test('singlesig-vlei-issuance', async function run() { let leCredHolder = await getGrantedCredential(leClient, leCred.sad.d); - let leRetry = 0; - while (!leCredHolder && leRetry < 5) { - await sendGrantMessage(qviClient, qviAid, leAid, leCred); - await sendAdmitMessage(leClient, leAid, qviAid); - leRetry += 1; - leCredHolder = await retry(async () => { - const cred = await getGrantedCredential(leClient, leCred.sad.d); + await sendGrantMessage(qviClient, qviAid, leAid, leCred); + await sendAdmitMessage(leClient, leAid, qviAid); + leCredHolder = await retry(async () => { + const cred = await getGrantedCredential(leClient, leCred.sad.d); + + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); - if (cred !== undefined) return cred; - }); - } assert(leCredHolder !== undefined); assert.equal(leCredHolder.sad.d, leCred.sad.d); assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); @@ -269,17 +265,14 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - let ecrRetry = 0; - while (!ecrCredHolder && ecrRetry < 5) { - await sendGrantMessage(leClient, leAid, roleAid, ecrCred); - await sendAdmitMessage(roleClient, roleAid, leAid); + await sendGrantMessage(leClient, leAid, roleAid, ecrCred); + await sendAdmitMessage(roleClient, roleAid, leAid); + + ecrCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); - ecrCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - ecrRetry += 1; - if (cred !== undefined) return cred; - }); - } assert(ecrCredHolder !== undefined); assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); @@ -315,20 +308,17 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCred.sad.d ); - let ecrAuthRetry = 0; - while (!ecrAuthCredHolder && ecrAuthRetry < 5) { - await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - ecrAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - ecrAuthCred.sad.d - ); - ecrAuthRetry += 1; - if (cred !== undefined) return cred; - }); - } + await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + ecrAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + ecrAuthCred.sad.d + ); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); + assert(ecrAuthCredHolder !== undefined); assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); @@ -363,17 +353,14 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder2 = await getGrantedCredential(roleClient, ecrCred2.sad.d); - let ecr2Retry = 0; - while (!ecrCredHolder2 && ecr2Retry < 5) { - await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); - await sendAdmitMessage(roleClient, roleAid, qviAid); + await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); + await sendAdmitMessage(roleClient, roleAid, qviAid); - ecrCredHolder2 = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - ecr2Retry += 1; - if (cred !== undefined) return cred; - }); - } + ecrCredHolder2 = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); + assert(ecrCredHolder2 !== undefined); assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); @@ -408,20 +395,17 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCred.sad.d ); - let oorAuthRetry = 0; - while (!oorAuthCredHolder && oorAuthRetry < 5) { - await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - oorAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - oorAuthCred.sad.d - ); - oorAuthRetry += 1; - if (cred !== undefined) return cred; - }); - } + await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + oorAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + oorAuthCred.sad.d + ); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); + assert(oorAuthCredHolder !== undefined); assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); @@ -455,17 +439,14 @@ test('singlesig-vlei-issuance', async function run() { let oorCredHolder = await getGrantedCredential(roleClient, oorCred.sad.d); - let oorRetry = 0; - while (!oorCredHolder && oorRetry < 5) { - await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); - await sendAdmitMessage(roleClient, roleAid, qviAid); + await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); + await sendAdmitMessage(roleClient, roleAid, qviAid); + + oorCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, oorCred.sad.d); + if (cred !== undefined) return cred; + },RETRY_DEFAULTS); - oorCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - oorRetry += 1; - if (cred !== undefined) return cred; - }); - } assert(oorCredHolder !== undefined); assert.equal(oorCredHolder.sad.d, oorCred.sad.d); assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); From df6f4f0993d45b7a5a53af562e2ea6c13c64caeb Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 05:29:15 -0400 Subject: [PATCH 16/23] format code Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index dce4b1ac..55d7fec9 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -106,7 +106,12 @@ const ECR_AUTH_RULES = Saider.saidify({ const OOR_RULES = LE_RULES; const OOR_AUTH_RULES = LE_RULES; -const RETRY_DEFAULTS = {maxSleep: 1000, minSleep: 10, maxRetries: 5, timeout: 10000} +const RETRY_DEFAULTS = { + maxSleep: 1000, + minSleep: 10, + maxRetries: 5, + timeout: 10000, +}; interface Aid { name: string; @@ -193,7 +198,7 @@ test('singlesig-vlei-issuance', async function run() { qviCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, qviCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(qviCredHolder !== undefined); assert.equal(qviCredHolder.sad.d, qviCred.sad.d); @@ -231,7 +236,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(leClient, leCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(leCredHolder !== undefined); assert.equal(leCredHolder.sad.d, leCred.sad.d); @@ -271,7 +276,7 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(ecrCredHolder !== undefined); assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); @@ -312,12 +317,9 @@ test('singlesig-vlei-issuance', async function run() { await sendAdmitMessage(qviClient, qviAid, leAid); ecrAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - ecrAuthCred.sad.d - ); + const cred = await getGrantedCredential(qviClient, ecrAuthCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(ecrAuthCredHolder !== undefined); assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); @@ -359,8 +361,8 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder2 = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); - + }, RETRY_DEFAULTS); + assert(ecrCredHolder2 !== undefined); assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); @@ -399,12 +401,9 @@ test('singlesig-vlei-issuance', async function run() { await sendAdmitMessage(qviClient, qviAid, leAid); oorAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential( - qviClient, - oorAuthCred.sad.d - ); + const cred = await getGrantedCredential(qviClient, oorAuthCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(oorAuthCredHolder !== undefined); assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); @@ -445,7 +444,7 @@ test('singlesig-vlei-issuance', async function run() { oorCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); if (cred !== undefined) return cred; - },RETRY_DEFAULTS); + }, RETRY_DEFAULTS); assert(oorCredHolder !== undefined); assert.equal(oorCredHolder.sad.d, oorCred.sad.d); From 355fcafce63d4d37712a2c8bc42aa0a2acd3b364 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 05:32:17 -0400 Subject: [PATCH 17/23] restore asserts Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index 55d7fec9..cd1b76d5 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -197,7 +197,8 @@ test('singlesig-vlei-issuance', async function run() { qviCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(qviCredHolder !== undefined); @@ -235,7 +236,8 @@ test('singlesig-vlei-issuance', async function run() { leCredHolder = await retry(async () => { const cred = await getGrantedCredential(leClient, leCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(leCredHolder !== undefined); @@ -275,7 +277,8 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(ecrCredHolder !== undefined); @@ -318,7 +321,8 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, ecrAuthCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(ecrAuthCredHolder !== undefined); @@ -360,7 +364,8 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder2 = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(ecrCredHolder2 !== undefined); @@ -402,7 +407,8 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, oorAuthCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(oorAuthCredHolder !== undefined); @@ -443,7 +449,8 @@ test('singlesig-vlei-issuance', async function run() { oorCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - if (cred !== undefined) return cred; + assert(cred !== undefined) + return cred; }, RETRY_DEFAULTS); assert(oorCredHolder !== undefined); From 54474641f341fbaf34313a0bf7b5308f12da6198 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 05:36:23 -0400 Subject: [PATCH 18/23] restore asserts Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index cd1b76d5..d83876f3 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -197,11 +197,10 @@ test('singlesig-vlei-issuance', async function run() { qviCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(qviCredHolder !== undefined); assert.equal(qviCredHolder.sad.d, qviCred.sad.d); assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); assert.equal(qviCredHolder.sad.i, gleifAid.prefix); @@ -235,12 +234,10 @@ test('singlesig-vlei-issuance', async function run() { await sendAdmitMessage(leClient, leAid, qviAid); leCredHolder = await retry(async () => { const cred = await getGrantedCredential(leClient, leCred.sad.d); - - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(leCredHolder !== undefined); assert.equal(leCredHolder.sad.d, leCred.sad.d); assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); assert.equal(leCredHolder.sad.i, qviAid.prefix); @@ -277,11 +274,10 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(ecrCredHolder !== undefined); assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); assert.equal(ecrCredHolder.sad.i, leAid.prefix); @@ -321,11 +317,10 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, ecrAuthCred.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(ecrAuthCredHolder !== undefined); assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); assert.equal(ecrAuthCredHolder.sad.i, leAid.prefix); @@ -364,11 +359,10 @@ test('singlesig-vlei-issuance', async function run() { ecrCredHolder2 = await retry(async () => { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(ecrCredHolder2 !== undefined); assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); assert.equal(ecrCredHolder2.sad.i, qviAid.prefix); @@ -407,11 +401,10 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCredHolder = await retry(async () => { const cred = await getGrantedCredential(qviClient, oorAuthCred.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(oorAuthCredHolder !== undefined); assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); assert.equal(oorAuthCredHolder.sad.i, leAid.prefix); @@ -449,11 +442,10 @@ test('singlesig-vlei-issuance', async function run() { oorCredHolder = await retry(async () => { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - assert(cred !== undefined) + assert(cred !== undefined); return cred; }, RETRY_DEFAULTS); - assert(oorCredHolder !== undefined); assert.equal(oorCredHolder.sad.d, oorCred.sad.d); assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); assert.equal(oorCredHolder.sad.i, qviAid.prefix); From c6b850a7f1989487916ac5e8861b669a45f13b6b Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 05:46:11 -0400 Subject: [PATCH 19/23] better naming Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index d83876f3..f518b56e 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -106,7 +106,7 @@ const ECR_AUTH_RULES = Saider.saidify({ const OOR_RULES = LE_RULES; const OOR_AUTH_RULES = LE_RULES; -const RETRY_DEFAULTS = { +const CRED_RETRY_DEFAULTS = { maxSleep: 1000, minSleep: 10, maxRetries: 5, @@ -199,7 +199,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(qviClient, qviCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(qviCredHolder.sad.d, qviCred.sad.d); assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); @@ -236,7 +236,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(leClient, leCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(leCredHolder.sad.d, leCred.sad.d); assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); @@ -276,7 +276,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); @@ -319,7 +319,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(qviClient, ecrAuthCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); @@ -361,7 +361,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); @@ -403,7 +403,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(qviClient, oorAuthCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); @@ -444,7 +444,7 @@ test('singlesig-vlei-issuance', async function run() { const cred = await getGrantedCredential(roleClient, oorCred.sad.d); assert(cred !== undefined); return cred; - }, RETRY_DEFAULTS); + }, CRED_RETRY_DEFAULTS); assert.equal(oorCredHolder.sad.d, oorCred.sad.d); assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); From 1cfe7a286c58c37f8ed85d06f964a4d52168c5e3 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 06:00:23 -0400 Subject: [PATCH 20/23] restore check Signed-off-by: 2byrds <2byrds@gmail.com> --- .../singlesig-vlei-issuance.test.ts | 124 +++++++++++------- 1 file changed, 73 insertions(+), 51 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index f518b56e..f1b5be40 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -15,6 +15,7 @@ import { getOrCreateContact, getOrCreateIdentifier, } from './utils/test-setup'; +import { i } from 'mathjs'; const { vleiServerUrl } = resolveEnvironment(); @@ -192,14 +193,16 @@ test('singlesig-vlei-issuance', async function run() { let qviCredHolder = await getGrantedCredential(qviClient, qviCred.sad.d); - await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); - await sendAdmitMessage(qviClient, qviAid, gleifAid); + if (!qviCredHolder) { + await sendGrantMessage(gleifClient, gleifAid, qviAid, qviCred); + await sendAdmitMessage(qviClient, qviAid, gleifAid); - qviCredHolder = await retry(async () => { - const cred = await getGrantedCredential(qviClient, qviCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + qviCredHolder = await retry(async () => { + const cred = await getGrantedCredential(qviClient, qviCred.sad.d); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(qviCredHolder.sad.d, qviCred.sad.d); assert.equal(qviCredHolder.sad.s, QVI_SCHEMA_SAID); @@ -230,13 +233,16 @@ test('singlesig-vlei-issuance', async function run() { let leCredHolder = await getGrantedCredential(leClient, leCred.sad.d); - await sendGrantMessage(qviClient, qviAid, leAid, leCred); - await sendAdmitMessage(leClient, leAid, qviAid); - leCredHolder = await retry(async () => { - const cred = await getGrantedCredential(leClient, leCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + if (!leCredHolder) { + await sendGrantMessage(qviClient, qviAid, leAid, leCred); + await sendAdmitMessage(leClient, leAid, qviAid); + + leCredHolder = await retry(async () => { + const cred = await getGrantedCredential(leClient, leCred.sad.d); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(leCredHolder.sad.d, leCred.sad.d); assert.equal(leCredHolder.sad.s, LE_SCHEMA_SAID); @@ -269,14 +275,16 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder = await getGrantedCredential(roleClient, ecrCred.sad.d); - await sendGrantMessage(leClient, leAid, roleAid, ecrCred); - await sendAdmitMessage(roleClient, roleAid, leAid); + if (!ecrCredHolder) { + await sendGrantMessage(leClient, leAid, roleAid, ecrCred); + await sendAdmitMessage(roleClient, roleAid, leAid); - ecrCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + ecrCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred.sad.d); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(ecrCredHolder.sad.d, ecrCred.sad.d); assert.equal(ecrCredHolder.sad.s, ECR_SCHEMA_SAID); @@ -312,14 +320,19 @@ test('singlesig-vlei-issuance', async function run() { ecrAuthCred.sad.d ); - await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - ecrAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential(qviClient, ecrAuthCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + if (!ecrAuthCredHolder) { + await sendGrantMessage(leClient, leAid, qviAid, ecrAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + ecrAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + ecrAuthCred.sad.d + ); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(ecrAuthCredHolder.sad.d, ecrAuthCred.sad.d); assert.equal(ecrAuthCredHolder.sad.s, ECR_AUTH_SCHEMA_SAID); @@ -354,14 +367,16 @@ test('singlesig-vlei-issuance', async function run() { let ecrCredHolder2 = await getGrantedCredential(roleClient, ecrCred2.sad.d); - await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); - await sendAdmitMessage(roleClient, roleAid, qviAid); + if (!ecrCredHolder2) { + await sendGrantMessage(qviClient, qviAid, roleAid, ecrCred2); + await sendAdmitMessage(roleClient, roleAid, qviAid); - ecrCredHolder2 = await retry(async () => { - const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + ecrCredHolder2 = await retry(async () => { + const cred = await getGrantedCredential(roleClient, ecrCred2.sad.d); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(ecrCredHolder2.sad.d, ecrCred2.sad.d); assert.equal(ecrCredHolder2.sad.s, ECR_SCHEMA_SAID); @@ -396,14 +411,19 @@ test('singlesig-vlei-issuance', async function run() { oorAuthCred.sad.d ); - await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); - await sendAdmitMessage(qviClient, qviAid, leAid); - - oorAuthCredHolder = await retry(async () => { - const cred = await getGrantedCredential(qviClient, oorAuthCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + if (!oorAuthCredHolder) { + await sendGrantMessage(leClient, leAid, qviAid, oorAuthCred); + await sendAdmitMessage(qviClient, qviAid, leAid); + + oorAuthCredHolder = await retry(async () => { + const cred = await getGrantedCredential( + qviClient, + oorAuthCred.sad.d + ); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(oorAuthCredHolder.sad.d, oorAuthCred.sad.d); assert.equal(oorAuthCredHolder.sad.s, OOR_AUTH_SCHEMA_SAID); @@ -437,14 +457,16 @@ test('singlesig-vlei-issuance', async function run() { let oorCredHolder = await getGrantedCredential(roleClient, oorCred.sad.d); - await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); - await sendAdmitMessage(roleClient, roleAid, qviAid); + if (!oorCredHolder) { + await sendGrantMessage(qviClient, qviAid, roleAid, oorCred); + await sendAdmitMessage(roleClient, roleAid, qviAid); - oorCredHolder = await retry(async () => { - const cred = await getGrantedCredential(roleClient, oorCred.sad.d); - assert(cred !== undefined); - return cred; - }, CRED_RETRY_DEFAULTS); + oorCredHolder = await retry(async () => { + const cred = await getGrantedCredential(roleClient, oorCred.sad.d); + assert(cred !== undefined); + return cred; + }, CRED_RETRY_DEFAULTS); + } assert.equal(oorCredHolder.sad.d, oorCred.sad.d); assert.equal(oorCredHolder.sad.s, OOR_SCHEMA_SAID); From 4c728f1762ea3695a05971fd14116dcd2bc56742 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 08:12:39 -0400 Subject: [PATCH 21/23] removed unnecessary re-ordering Signed-off-by: 2byrds <2byrds@gmail.com> --- .../integration-scripts/singlesig-vlei-issuance.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index f1b5be40..becc3be0 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -236,7 +236,7 @@ test('singlesig-vlei-issuance', async function run() { if (!leCredHolder) { await sendGrantMessage(qviClient, qviAid, leAid, leCred); await sendAdmitMessage(leClient, leAid, qviAid); - + leCredHolder = await retry(async () => { const cred = await getGrantedCredential(leClient, leCred.sad.d); assert(cred !== undefined); @@ -521,16 +521,16 @@ async function getOrIssueCredential( } const issResult = await issuerClient.credentials().issue(issuerAid.name, { - u: privacy ? new Salter({}).qb64 : undefined, ri: issuerRegistry.regk, s: schema, + u: privacy ? new Salter({}).qb64 : undefined, a: { i: recipientAid.prefix, u: privacy ? new Salter({}).qb64 : undefined, ...credData, }, - e: source, r: rules, + e: source, }); await waitOperation(issuerClient, issResult.op); From fdb9e3366954c98db28ac076da9051eaf172bf10 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 08:37:59 -0400 Subject: [PATCH 22/23] separating pr functionality Signed-off-by: 2byrds <2byrds@gmail.com> --- src/keri/app/clienting.ts | 54 +++++++++++++++++++++++--------------- test/app/clienting.test.ts | 12 +++------ 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 736e2615..de2e5986 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -232,23 +232,19 @@ export class SignifyClient { /** * Fetch a resource from from an external URL with headers signed by an AID * @async - * @param {string} aidName Name or alias of the AID to be used for signing * @param {string} url URL of the resource * @param {string} path Path to the resource - * @param {RequestInit} req Request options should include: - * - method: HTTP method - * - data Data to be sent in the body of the resource. - * If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr' - * If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data' - * If the data is an object then you should use JSON.stringify to convert it to a string and set the contentType to 'application/json' - * - contentType Content type of the request. + * @param {string} method HTTP method + * @param {any} data Data to be sent in the body of the resource + * @param {string} aidName Name or alias of the AID to be used for signing * @returns {Promise} A promise to the result of the fetch */ async signedFetch( - aidName: string, url: string, path: string, - req: RequestInit + method: string, + data: any, + aidName: string ): Promise { const hab = await this.identifiers().get(aidName); const keeper = this.manager!.get(hab); @@ -258,26 +254,42 @@ export class SignifyClient { keeper.signers[0].verfer ); - let headers = req.headers; - if (headers == undefined) { - headers = new Headers(); - } else { - headers = new Headers(headers); - } - headers.set('Signify-Resource', hab['prefix']); + const headers = new Headers(); + headers.set('Signify-Resource', hab.prefix); headers.set( 'Signify-Timestamp', new Date().toISOString().replace('Z', '000+00:00') ); + if (data !== null) { + headers.set('Content-Length', data.length); + } else { + headers.set('Content-Length', '0'); + } const signed_headers = authenticator.sign( - new Headers(headers), - headers.get('method')!, + headers, + method, path.split('?')[0] ); - req.headers = signed_headers; + let _body = null; + if (method != 'GET') { + if (data instanceof FormData) { + _body = data; + // do not set the content type, let the browser do it + // headers.set('Content-Type', 'multipart/form-data') + } else { + _body = JSON.stringify(data); + headers.set('Content-Type', 'application/json'); + } + } else { + headers.set('Content-Type', 'application/json'); + } - return await fetch(url + path, req); + return await fetch(url + path, { + method: method, + body: _body, + headers: signed_headers, + }); } /** diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index 122f0f3c..ede08d6f 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -359,18 +359,12 @@ describe('SignifyClient', () => { 'EGFi9pCcRaLK8dPh5S7JP9Em62fBMiR1l4gW1ZazuuAO' ); - let heads = new Headers(); - heads.set('Content-Type', 'application/json'); - let reqInit = { - headers: heads, - method: 'POST', - body: JSON.stringify({ foo: true }), - }; resp = await client.signedFetch( - 'aid1', 'http://example.com', '/test', - reqInit + 'POST', + { foo: true }, + 'aid1' ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, 'http://example.com/test'); From fc6d59b75ff3c25212824e63d0672fdc9b3b898b Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 8 May 2024 08:38:17 -0400 Subject: [PATCH 23/23] separating pr functionality Signed-off-by: 2byrds <2byrds@gmail.com> --- examples/integration-scripts/singlesig-vlei-issuance.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/integration-scripts/singlesig-vlei-issuance.test.ts b/examples/integration-scripts/singlesig-vlei-issuance.test.ts index becc3be0..6734d68a 100644 --- a/examples/integration-scripts/singlesig-vlei-issuance.test.ts +++ b/examples/integration-scripts/singlesig-vlei-issuance.test.ts @@ -15,7 +15,6 @@ import { getOrCreateContact, getOrCreateIdentifier, } from './utils/test-setup'; -import { i } from 'mathjs'; const { vleiServerUrl } = resolveEnvironment();