Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get credential registry state (tever vcstate) #282

Merged
merged 8 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
keria-version: ['0.2.0-dev3']
keria-version: ['0.2.0-dev4']
node-version: ['20']
env:
KERIA_IMAGE_TAG: ${{ matrix.keria-version }}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- 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-dev4}
environment:
- KERI_AGENT_CORS=1
- KERI_URL=http://keria:3902
Expand Down
14 changes: 13 additions & 1 deletion examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -248,6 +248,18 @@
await waitOperation(issuerClient, op);
});

await step(
'holder can get the credential status before or without holding',
lenkan marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand Down Expand Up @@ -293,7 +305,7 @@
});

await step('verifier IPEX apply', async () => {
const [apply, sigs, _] = await verifierClient.ipex().apply({

Check warning on line 308 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'_' is assigned a value but never used

Check warning on line 308 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'_' is assigned a value but never used

Check warning on line 308 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'_' is assigned a value but never used

Check warning on line 308 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'_' is assigned a value but never used
senderName: verifierAid.name,
schemaSaid: QVI_SCHEMA_SAID,
attributes: { LEI: '5493001KJTIIGC8Y1R17' },
Expand All @@ -319,7 +331,7 @@
const apply = await holderClient.exchanges().get(holderApplyNote.a.d);
applySaid = apply.exn.d;

let filter: { [x: string]: any } = { '-s': apply.exn.a.s };

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'filter' is never reassigned. Use 'const' instead

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

Unexpected any. Specify a different type

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'filter' is never reassigned. Use 'const' instead

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

Unexpected any. Specify a different type

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'filter' is never reassigned. Use 'const' instead

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

Unexpected any. Specify a different type

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'filter' is never reassigned. Use 'const' instead

Check warning on line 334 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

Unexpected any. Specify a different type
for (const key in apply.exn.a.a) {
filter[`-a-${key}`] = apply.exn.a.a[key];
}
Expand Down Expand Up @@ -364,7 +376,7 @@

await markAndRemoveNotification(verifierClient, verifierOfferNote);

const [agree, sigs, _] = await verifierClient.ipex().agree({

Check warning on line 379 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'_' is assigned a value but never used

Check warning on line 379 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'_' is assigned a value but never used

Check warning on line 379 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'_' is assigned a value but never used

Check warning on line 379 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'_' is assigned a value but never used
senderName: verifierAid.name,
recipient: holderAid.prefix,
offerSaid: offerSaid,
Expand Down
2 changes: 1 addition & 1 deletion examples/integration-scripts/singlesig-drt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/keri/app/credentialing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, never>;
}
| {
et: 'bis' | 'brv';
ra: { i: string; s: string; d: string };
}
);

/**
* Credentials
*/
Expand Down Expand Up @@ -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<CredentialState>} A promise to the credential registry state
*/
async state(ri: string, said: string): Promise<CredentialState> {
const path = `/registries/${ri}/${said}`;
const method = 'GET';
const res = await this.client.fetch(path, method, null);
return res.json();
}

/**
* Issue a credential
*/
Expand Down
2 changes: 2 additions & 0 deletions src/keri/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const Ilks = {
vcp: 'vcp',
iss: 'iss',
rev: 'rev',
bis: 'bis',
brv: 'brv',
};

export const IcpLabels = [
Expand Down
10 changes: 10 additions & 0 deletions test/app/credentialing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ describe('Credentialing', () => {
);
assert.equal(lastBody.sigs[0].substring(0, 2), 'AA');
assert.equal(lastBody.sigs[0].length, 88);

await credentials.state(mockCredential.sad.ri, mockCredential.sad.d);
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
assert.equal(
lastCall[0]!,
url +
'/registries/EGK216v1yguLfex4YRFnG7k1sXRjh3OKY7QqzdKsx7df/EMwcsEMUEruPXVwPCW7zmqmN8m0I3CihxolBm-RDrsJo'
);
assert.equal(lastCall[1]!.method, 'GET');
assert.equal(lastCall[1]!.body, null);
});
});

Expand Down
Loading