diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 00000000..3deaa5be --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,34 @@ +name: "Bug report" +description: Bug report template +title: "Bug: short description" +labels: ["bug", "triage"] +body: + - type: input + id: version + attributes: + label: Version + validations: + required: true + - type: input + id: Evnironment + attributes: + label: Environment + description: (OS, Node.js version) + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + validations: + required: true + - type: textarea + id: actual-behavior + attributes: + label: Actual behavior + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml new file mode 100644 index 00000000..99110a3d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -0,0 +1,11 @@ +name: "Feature request" +description: Feature request template +title: "Feature request: short description" +labels: ["feature request", "triage"] +body: + - type: textarea + id: desired-behavior + attributes: + label: Feature request description/rationale + validations: + required: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61ad49d1..e3fed1da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: strategy: matrix: os: ['ubuntu-latest'] - keria-version: ['0.2.0-dev3'] + keria-version: ['0.2.0-dev5'] node-version: ['20'] env: KERIA_IMAGE_TAG: ${{ matrix.keria-version }} @@ -76,7 +76,7 @@ jobs: - name: Print docker compose config run: docker compose config - name: Start dependencies - run: docker compose up deps --pull always + run: docker compose up --wait --pull always - name: Run integration test run: npm run test:integration - name: Print logs diff --git a/README.md b/README.md index 0ca1bf72..0320e545 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,31 @@ The code is built using Typescript and running code locally requires a Mac or Li Typescript source files needs to be transpiled before running scripts or integration tests - Build: + ```bash npm run build ``` +- ready() must be called before library is useable. Example minimum viable client code. + + ```javascript + import { randomPasscode, ready, SignifyClient, Tier } from 'signify-ts'; + + await ready(); + + const bran = randomPasscode(); + const url = 'http://127.0.0.1:3901'; + const boot_url = 'http://127.0.0.1:3903'; + const actualSignifyClient = new SignifyClient( + url, + bran, + Tier.low, + boot_url + ); + + console.log(actualSignifyClient); + ``` + ### Unit testing To run unit tests @@ -57,22 +78,18 @@ npm test The integration tests depends on a local instance of KERIA, vLEI-Server and Witness Demo. These are specified in the [Docker Compose](./docker-compose.yaml) file. To start the dependencies, use docker compose: ```bash -docker compose up deps +docker compose up --wait ``` If successful, it should print someting like this: ```bash -$ docker compose up deps -[+] Running 5/4 +$ docker compose up --wait +[+] Running 4/4 ✔ Network signify-ts_default Created 0.0s - ✔ Container signify-ts-vlei-server-1 Created 0.1s - ✔ Container signify-ts-keria-1 Created 0.1s - ✔ Container signify-ts-witness-demo-1 Created 0.1s - ✔ Container signify-ts-deps-1 Created 0.0s -Attaching to signify-ts-deps-1 -signify-ts-deps-1 | Dependencies running -signify-ts-deps-1 exited with code 0 + ✔ Container signify-ts-vlei-server-1 Healthy 5.7s + ✔ Container signify-ts-keria-1 Healthy 6.2s + ✔ Container signify-ts-witness-demo-1 Healthy 6.2s ``` It is possible to change the keria image by using environment variables. For example, to use weboftrust/keria:0.1.3, do: @@ -80,7 +97,7 @@ It is possible to change the keria image by using environment variables. For exa ```bash export KERIA_IMAGE_TAG=0.1.3 docker compose pull -docker compose up deps +docker compose up --wait ``` To use another repository, you can do: @@ -88,7 +105,7 @@ To use another repository, you can do: ```bash export KERIA_IMAGE=gleif/keria docker compose pull -docker compose up deps +docker compose up --wait ``` **Important!** The integration tests runs on the build output in `dist/` directory. Make sure to run build before running the integration tests. diff --git a/docker-compose.yaml b/docker-compose.yaml index 25d0dd40..1900fea1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,56 +1,36 @@ +x-healthcheck: &healthcheck + interval: 2s + timeout: 3s + retries: 5 + start_period: 2s + +x-python-env: &python-env + PYTHONUNBUFFERED: 1 + PYTHONIOENCODING: UTF-8 + services: vlei-server: image: gleif/vlei environment: - - PYTHONUNBUFFERED=1 - - PYTHONIOENCODING=UTF-8 - command: - - vLEI-server - - -s - - ./schema/acdc - - -c - - ./samples/acdc/ - - -o - - ./samples/oobis/ + <<: *python-env + command: vLEI-server -s ./schema/acdc -c ./samples/acdc/ -o ./samples/oobis/ healthcheck: - test: - - CMD - - curl - - -f - - http://localhost:7723/oobi/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao - interval: 2s - timeout: 3s - retries: 5 - start_period: 2s + test: curl -f http://localhost:7723/oobi/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao + <<: *healthcheck ports: - 7723:7723 keria: - image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev3} + image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev5} environment: - - KERI_AGENT_CORS=1 - - KERI_URL=http://keria:3902 - - PYTHONUNBUFFERED=1 - - PYTHONIOENCODING=UTF-8 + KERI_AGENT_CORS: 1 + <<: *python-env volumes: - ./config/keria.json:/keria/config/keri/cf/keria.json - entrypoint: - [ - 'keria', - 'start', - '--config-dir', - '/keria/config', - '--config-file', - 'keria', - '--name', - 'agent', - ] + command: --config-dir /keria/config --config-file keria --name agent healthcheck: - test: ['CMD', 'wget', '--spider', 'http://keria:3902/spec.yaml'] - interval: 2s - timeout: 3s - retries: 5 - start_period: 2s + test: wget --spider http://keria:3902/spec.yaml + <<: *healthcheck ports: - 3901:3901 - 3902:3902 @@ -59,28 +39,13 @@ services: witness-demo: image: weboftrust/keri-witness-demo:1.1.0 environment: - - PYTHONUNBUFFERED=1 - - PYTHONIOENCODING=UTF-8 + <<: *python-env healthcheck: - test: ['CMD', 'curl', '-f', 'http://localhost:5642/oobi'] - interval: 2s - timeout: 3s - retries: 5 - start_period: 2s + test: curl -f http://localhost:5642/oobi + <<: *healthcheck volumes: - ./config/witness-demo:/keripy/scripts/keri/cf/main ports: - 5642:5642 - 5643:5643 - 5644:5644 - - deps: - image: alpine - command: ['echo', 'Dependencies running'] - depends_on: - vlei-server: - condition: service_healthy - keria: - condition: service_healthy - witness-demo: - condition: service_healthy diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index 3ae1f6d4..e9dc4174 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { Saider, Serder, SignifyClient } from 'signify-ts'; +import { Ilks, Saider, Serder, SignifyClient } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env'; import { assertNotifications, @@ -248,6 +248,18 @@ test('single signature credentials', async () => { await waitOperation(issuerClient, op); }); + await step( + 'holder can get the credential status before or without holding', + async () => { + const state = await retry(async () => + holderClient.credentials().state(registry.regk, qviCredentialId) + ); + assert.equal(state.i, qviCredentialId); + assert.equal(state.ri, registry.regk); + assert.equal(state.et, Ilks.iss); + } + ); + await step('holder IPEX admit', async () => { const holderNotifications = await waitForNotifications( holderClient, diff --git a/examples/integration-scripts/salty.test.ts b/examples/integration-scripts/salty.test.ts index 5c460796..b74833dc 100644 --- a/examples/integration-scripts/salty.test.ts +++ b/examples/integration-scripts/salty.test.ts @@ -168,5 +168,14 @@ test('salty', async () => { await assertOperations(client1); + aid = await client1.identifiers().update('aid3', { name: 'aid4' }); + assert.equal(aid.name, 'aid4'); + aid = await client1.identifiers().get('aid4'); + assert.equal(aid.name, 'aid4'); + aids = await client1.identifiers().list(2, 2); + assert.equal(aids.aids.length, 1); + aid = aids.aids[0]; + assert.equal(aid.name, 'aid4'); + console.log('Salty test passed'); }, 30000); diff --git a/examples/integration-scripts/singlesig-drt.test.ts b/examples/integration-scripts/singlesig-drt.test.ts index bb1c714f..2f099a9c 100644 --- a/examples/integration-scripts/singlesig-drt.test.ts +++ b/examples/integration-scripts/singlesig-drt.test.ts @@ -55,7 +55,7 @@ describe('singlesig-drt', () => { kargs = {}; result = await delegate.identifiers().rotate('delegate1', kargs); op = await result.op(); - expect(op.name).toEqual(`delegation.${delegate1.prefix}`); + expect(op.name).toEqual(`delegation.${result.serder.ked.d}`); // delegator approves delegate delegate1 = await delegate.identifiers().get('delegate1'); diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index fecf61c7..bd957743 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -27,6 +27,7 @@ describe('test-setup-single-client', () => { 'EB3UGWwIMq7ppzcQ697ImQIuXlBG5jzh-baSx-YG3-tY' ); }); + test('step2', async () => { const env = resolveEnvironment(); const oobi = await client.oobis().get('name1', 'witness'); @@ -62,4 +63,32 @@ describe('test-setup-single-client', () => { break; } }); + + test('validate config', async () => { + const env = resolveEnvironment(); + const config = await client.config().get(); + switch (env.preset) { + case 'local': + expect(config).toEqual({ + iurls: [ + 'http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller?name=Wan&tag=witness', + 'http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller?name=Wes&tag=witness', + 'http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller?name=Wil&tag=witness', + ], + }); + break; + case 'docker': + expect(config).toEqual({ + iurls: [ + 'http://witness-demo:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller', + 'http://witness-demo:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller', + 'http://witness-demo:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller', + 'http://witness-demo:5645/oobi/BM35JN8XeJSEfpxopjn5jr7tAHCE5749f0OobhMLCorE/controller', + 'http://witness-demo:5646/oobi/BIj15u5V11bkbtAxMA7gcNJZcax-7TgaBMLsQnMHpYHP/controller', + 'http://witness-demo:5647/oobi/BF2rZTW79z4IXocYRQnjjsOuvFUQv-ptCf8Yltd7PfsM/controller', + ], + }); + break; + } + }); }); diff --git a/package-lock.json b/package-lock.json index c0c5d42e..a5f65c5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3368,10 +3368,11 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -7102,9 +7103,9 @@ } }, "node_modules/mermaid": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-10.9.1.tgz", - "integrity": "sha512-Mx45Obds5W1UkW1nv/7dHRsbfMM1aOKA2+Pxs/IGHNonygDHwmng8xTHyS9z4KWVi0rbko8gjiBmuwwXQ7tiNA==", + "version": "10.9.3", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-10.9.3.tgz", + "integrity": "sha512-V80X1isSEvAewIL3xhmz/rVmc27CVljcsbWxkxlWJWY/1kQa4XOABqpDl2qQLGKzpKm6WbTfUEKImBlUfFYArw==", "dev": true, "dependencies": { "@braintree/sanitize-url": "^6.0.1", @@ -7116,7 +7117,7 @@ "d3-sankey": "^0.12.3", "dagre-d3-es": "7.0.10", "dayjs": "^1.11.7", - "dompurify": "^3.0.5", + "dompurify": "^3.0.5 <3.1.7", "elkjs": "^0.9.0", "katex": "^0.16.9", "khroma": "^2.0.0", diff --git a/src/keri/app/aiding.ts b/src/keri/app/aiding.ts index 7bab1c48..a0863748 100644 --- a/src/keri/app/aiding.ts +++ b/src/keri/app/aiding.ts @@ -7,7 +7,6 @@ import { MtrDex } from '../core/matter'; import { Serder } from '../core/serder'; import { parseRangeHeaders } from '../core/httping'; import { KeyManager } from '../core/keeping'; -import { Operation } from './coring'; import { HabState } from '../core/state'; /** Arguments required to create an identfier */ @@ -67,6 +66,13 @@ export interface IdentifierDeps { manager: KeyManager | null; } +/** + * Updatable information for a managed identifier + */ +export interface IdentifierInfo { + name: string; +} + /** Identifier */ export class Identifier { public client: IdentifierDeps; @@ -110,8 +116,8 @@ export class Identifier { /** * Get information for a managed identifier * @async - * @param {string} name Name or alias of the identifier - * @returns {Promise} A promise to the identifier information + * @param {string} name Prefix or alias of the identifier + * @returns {Promise} A promise to the identifier information */ async get(name: string): Promise { const path = `/identifiers/${encodeURIComponent(name)}`; @@ -121,6 +127,20 @@ export class Identifier { return await res.json(); } + /** + * Update managed identifier + * @async + * @param {string} name Prefix or alias of the identifier + * @param {IdentifierInfo} info Information to update for the given identifier + * @returns {Promise} A promise to the identifier information after updating + */ + async update(name: string, info: IdentifierInfo): Promise { + const path = `/identifiers/${name}`; + const method = 'PUT'; + const res = await this.client.fetch(path, method, info); + return await res.json(); + } + /** * Create a managed identifier * @async @@ -253,7 +273,7 @@ export class Identifier { /** * Generate an interaction event in a managed identifier * @async - * @param {string} name Name or alias of the identifier + * @param {string} name Prefix or alias of the identifier * @param {any} [data] Option data to be anchored in the interaction event * @returns {Promise} A promise to the interaction event result */ diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 9da24ecd..df1d7356 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -6,7 +6,7 @@ import { Tier } from '../core/salter'; import { Identifier } from './aiding'; import { Contacts, Challenges } from './contacting'; import { Agent, Controller } from './controller'; -import { Oobis, Operations, KeyEvents, KeyStates } from './coring'; +import { Oobis, Operations, KeyEvents, KeyStates, Config } from './coring'; import { Credentials, Ipex, Registries, Schemas } from './credentialing'; import { Delegations } from './delegating'; import { Escrows } from './escrowing'; @@ -478,4 +478,12 @@ export class SignifyClient { delegations(): Delegations { return new Delegations(this); } + + /** + * Get agent config resource + * @returns {Config} + */ + config(): Config { + return new Config(this); + } } diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index fd5a1161..9a0eb3f9 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -81,6 +81,10 @@ export interface OperationsDeps { ): Promise; } +export interface AgentConfig { + iurls?: string[]; +} + /** * Operations * @remarks @@ -278,3 +282,22 @@ export class KeyStates { return await res.json(); } } + +export class Config { + public client: SignifyClient; + + /** + * Config + * @param {SignifyClient} client + */ + constructor(client: SignifyClient) { + this.client = client; + } + + async get(): Promise { + const path = `/config`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); + return await res.json(); + } +} diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index a13ddba3..a48928c2 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -229,6 +229,26 @@ export interface IpexAdmitArgs { datetime?: string; } +export type CredentialState = { + vn: [number, number]; + i: string; + s: string; + d: string; + ri: string; + a: { s: number; d: string }; + dt: string; + et: string; +} & ( + | { + et: 'iss' | 'rev'; + ra: Record; + } + | { + et: 'bis' | 'brv'; + ra: { i: string; s: string; d: string }; + } +); + /** * Credentials */ @@ -285,6 +305,20 @@ export class Credentials { return includeCESR ? await res.text() : await res.json(); } + /** + * Get the state of a credential + * @async + * @param {string} ri - management registry identifier + * @param {string} said - SAID of the credential + * @returns {Promise} A promise to the credential registry state + */ + async state(ri: string, said: string): Promise { + const path = `/registries/${ri}/${said}`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); + return res.json(); + } + /** * Issue a credential */ @@ -472,133 +506,6 @@ export class Credentials { op, }; } - - /** - * Present a credential - * @async - * @param {string} name Name or alias of the identifier - * @param {string} said SAID of the credential - * @param {string} recipient Identifier prefix of the receiver of the presentation - * @param {boolean} [include=true] Flag to indicate whether to stream credential alongside presentation exchange message - * @returns {Promise} A promise to the long-running operation - */ - async present( - name: string, - said: string, - recipient: string, - include: boolean = true - ): Promise { - const hab = await this.client.identifiers().get(name); - const pre: string = hab.prefix; - - const cred = await this.get(said); - const data = { - i: cred.sad.i, - s: cred.sad.s, - n: said, - }; - - const vs = versify(Ident.KERI, undefined, Serials.JSON, 0); - - const _sad = { - v: vs, - t: Ilks.exn, - d: '', - dt: new Date().toISOString().replace('Z', '000+00:00'), - r: '/presentation', - q: {}, - a: data, - }; - const [, sad] = Saider.saidify(_sad); - const exn = new Serder(sad); - - const keeper = this.client!.manager!.get(hab); - - const sig = await keeper.sign(b(exn.raw), true); - - const siger = new Siger({ qb64: sig[0] }); - const seal = ['SealLast', { i: pre }]; - let ims = messagize(exn, [siger], seal, undefined, undefined, true); - ims = ims.slice(JSON.stringify(exn.ked).length); - - const body = { - exn: exn.ked, - sig: new TextDecoder().decode(ims), - recipient: recipient, - include: include, - }; - - const path = `/identifiers/${name}/credentials/${said}/presentations`; - const method = 'POST'; - const headers = new Headers({ - Accept: 'application/json+cesr', - }); - const res = await this.client.fetch(path, method, body, headers); - return await res.text(); - } - - /** - * Request a presentation of a credential - * @async - * @param {string} name Name or alias of the identifier - * @param {string} recipient Identifier prefix of the receiver of the presentation - * @param {string} schema SAID of the schema - * @param {string} [issuer] Optional prefix of the issuer of the credential - * @returns {Promise} A promise to the long-running operation - */ - async request( - name: string, - recipient: string, - schema: string, - issuer?: string - ): Promise { - const hab = await this.client.identifiers().get(name); - const pre: string = hab.prefix; - - const data: any = { - s: schema, - }; - if (issuer !== undefined) { - data['i'] = issuer; - } - - const vs = versify(Ident.KERI, undefined, Serials.JSON, 0); - - const _sad = { - v: vs, - t: Ilks.exn, - d: '', - dt: new Date().toISOString().replace('Z', '000+00:00'), - r: '/presentation/request', - q: {}, - a: data, - }; - const [, sad] = Saider.saidify(_sad); - const exn = new Serder(sad); - - const keeper = this.client!.manager!.get(hab); - - const sig = await keeper.sign(b(exn.raw), true); - - const siger = new Siger({ qb64: sig[0] }); - const seal = ['SealLast', { i: pre }]; - let ims = messagize(exn, [siger], seal, undefined, undefined, true); - ims = ims.slice(JSON.stringify(exn.ked).length); - - const body = { - exn: exn.ked, - sig: new TextDecoder().decode(ims), - recipient: recipient, - }; - - const path = `/identifiers/${name}/requests`; - const method = 'POST'; - const headers = new Headers({ - Accept: 'application/json+cesr', - }); - const res = await this.client.fetch(path, method, body, headers); - return await res.text(); - } } export interface CreateRegistryArgs { diff --git a/src/keri/core/core.ts b/src/keri/core/core.ts index 6d4d148f..ee75d997 100644 --- a/src/keri/core/core.ts +++ b/src/keri/core/core.ts @@ -32,6 +32,8 @@ export const Ilks = { vcp: 'vcp', iss: 'iss', rev: 'rev', + bis: 'bis', + brv: 'brv', }; export const IcpLabels = [ diff --git a/test/app/aiding.test.ts b/test/app/aiding.test.ts index fbb885ac..bbe910c7 100644 --- a/test/app/aiding.test.ts +++ b/test/app/aiding.test.ts @@ -369,6 +369,15 @@ describe('Aiding', () => { assert.deepEqual(lastCall.body.randy.transferable, true); }); + it('Can rename identifier', async () => { + client.fetch.mockResolvedValue(Response.json({})); + await client.identifiers().update('aid1', { name: 'aid2' }); + const lastCall = client.getLastMockRequest(); + assert.equal(lastCall.path, '/identifiers/aid1'); + assert.equal(lastCall.method, 'PUT'); + assert.equal(lastCall.body.name, 'aid2'); + }); + describe('Group identifiers', () => { it('Can Rotate group', async () => { const member1 = await createMockIdentifierState( diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index f25c8be0..1325b945 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -267,6 +267,23 @@ describe('Coring', () => { 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao' ); }); + + it('Agent configuration', async () => { + await libsodium.ready; + const bran = '0123456789abcdefghijk'; + + const client = new SignifyClient(url, bran, Tier.low, boot_url); + + await client.boot(); + await client.connect(); + + const config = client.config(); + + await config.get(); + const lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal(lastCall[0]!, url + '/config'); + assert.equal(lastCall[1]!.method, 'GET'); + }); }); describe('Operations', () => { diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index 99f36dcc..a293a36a 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -316,58 +316,15 @@ describe('Credentialing', () => { assert.equal(lastBody.sigs[0].substring(0, 2), 'AA'); assert.equal(lastBody.sigs[0].length, 88); - await credentials.present( - 'aid1', - credential, - 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX', - false - ); + await credentials.state(mockCredential.sad.ri, mockCredential.sad.d); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - lastBody = JSON.parse(lastCall[1]!.body!.toString()); assert.equal( lastCall[0]!, url + - '/identifiers/aid1/credentials/' + - credential + - '/presentations' - ); - assert.equal(lastCall[1]!.method, 'POST'); - assert.equal(lastBody.exn.t, 'exn'); - assert.equal(lastBody.exn.r, '/presentation'); - assert.equal( - lastBody.exn.a.n, - 'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK' - ); - assert.equal(lastBody.exn.a.s, schema); - assert.equal(lastBody.sig.length, 144); - assert.equal( - lastBody.recipient, - 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' - ); - assert.equal(lastBody.include, false); - - await credentials.request( - 'aid1', - 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX', - credential, - 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' - ); - lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - lastBody = JSON.parse(lastCall[1]!.body!.toString()); - assert.equal(lastCall[0]!, url + '/identifiers/aid1/requests'); - assert.equal(lastCall[1]!.method, 'POST'); - assert.equal(lastBody.exn.t, 'exn'); - assert.equal(lastBody.exn.r, '/presentation/request'); - assert.equal(lastBody.exn.a.i, registry); - assert.equal( - lastBody.exn.a.s, - 'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK' - ); - assert.equal(lastBody.sig.length, 144); - assert.equal( - lastBody.recipient, - 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' + '/registries/EGK216v1yguLfex4YRFnG7k1sXRjh3OKY7QqzdKsx7df/EMwcsEMUEruPXVwPCW7zmqmN8m0I3CihxolBm-RDrsJo' ); + assert.equal(lastCall[1]!.method, 'GET'); + assert.equal(lastCall[1]!.body, null); }); });