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: single-sig IPEX apply, offer, agree #234

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 @@ -55,7 +55,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
keria-version: ['latest']
keria-version: ['0.2.0-dev1']
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:-latest}
image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev1}
environment:
- KERI_AGENT_CORS=1
- KERI_URL=http://keria:3902
Expand Down
112 changes: 111 additions & 1 deletion examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ let holderAid: Aid;
let verifierAid: Aid;
let legalEntityAid: Aid;

let applySaid: string;
let offerSaid: string;
let agreeSaid: string;

beforeAll(async () => {
[issuerClient, holderClient, verifierClient, legalEntityClient] =
await getOrCreateClients(4);
Expand Down Expand Up @@ -296,7 +300,107 @@ test('single signature credentials', async () => {
assert(holderCredential.atc !== undefined);
});

await step('holder IPEX present', async () => {
await step('verifier IPEX apply', async () => {
const [apply, sigs, _] = await verifierClient.ipex().apply({
senderName: verifierAid.name,
schema: QVI_SCHEMA_SAID,
attributes: { LEI: '5493001KJTIIGC8Y1R17' },
recipient: holderAid.prefix,
datetime: createTimestamp(),
});

const op = await verifierClient
.ipex()
.submitApply(verifierAid.name, apply, sigs, [holderAid.prefix]);
await waitOperation(verifierClient, op);
});

await step('holder IPEX apply receive and offer', async () => {
const holderNotifications = await waitForNotifications(
holderClient,
'/exn/ipex/apply'
);

const holderApplyNote = holderNotifications[0];
assert(holderApplyNote.a.d);

const apply = await holderClient.exchanges().get(holderApplyNote.a.d);
applySaid = apply.exn.d;

let filter: { [x: string]: any } = { '-s': apply.exn.a.s };
for (const key in apply.exn.a.a) {
filter[`-a-${key}`] = apply.exn.a.a[key];
}

const matchingCreds = await holderClient.credentials().list({ filter });
expect(matchingCreds).toHaveLength(1);

await markAndRemoveNotification(holderClient, holderNotifications[0]);

const [offer, sigs, end] = await holderClient.ipex().offer({
senderName: holderAid.name,
recipient: verifierAid.prefix,
acdc: new Serder(matchingCreds[0].sad),
apply: applySaid,
datetime: createTimestamp(),
});

const op = await holderClient
.ipex()
.submitOffer(holderAid.name, offer, sigs, end, [
verifierAid.prefix,
]);
await waitOperation(holderClient, op);
});

await step('verifier receive offer and agree', async () => {
const verifierNotifications = await waitForNotifications(
verifierClient,
'/exn/ipex/offer'
);

const verifierOfferNote = verifierNotifications[0];
assert(verifierOfferNote.a.d);

const offer = await verifierClient
.exchanges()
.get(verifierOfferNote.a.d);
offerSaid = offer.exn.d;

expect(offer.exn.p).toBe(applySaid);
expect(offer.exn.e.acdc.a.LEI).toBe('5493001KJTIIGC8Y1R17');

await markAndRemoveNotification(verifierClient, verifierOfferNote);

const [agree, sigs, _] = await verifierClient.ipex().agree({
senderName: verifierAid.name,
recipient: holderAid.prefix,
offer: offerSaid,
datetime: createTimestamp(),
});

const op = await verifierClient
.ipex()
.submitAgree(verifierAid.name, agree, sigs, [holderAid.prefix]);
await waitOperation(verifierClient, op);
});

await step('holder IPEX receive agree and grant/present', async () => {
const holderNotifications = await waitForNotifications(
holderClient,
'/exn/ipex/agree'
);

const holderAgreeNote = holderNotifications[0];
assert(holderAgreeNote.a.d);

const agree = await holderClient.exchanges().get(holderAgreeNote.a.d);
agreeSaid = agree.exn.d;

expect(agree.exn.p).toBe(offerSaid);

await markAndRemoveNotification(holderClient, holderAgreeNote);

const holderCredential = await holderClient
.credentials()
.get(qviCredentialId);
Expand All @@ -310,6 +414,7 @@ test('single signature credentials', async () => {
acdcAttachment: holderCredential.atc,
ancAttachment: holderCredential.ancatc,
issAttachment: holderCredential.issAtc,
agree: agreeSaid,
datetime: createTimestamp(),
});

Expand All @@ -328,6 +433,10 @@ test('single signature credentials', async () => {
);

const verifierGrantNote = verifierNotifications[0];
assert(verifierGrantNote.a.d);

const grant = await holderClient.exchanges().get(verifierGrantNote.a.d);
expect(grant.exn.p).toBe(agreeSaid);

const [admit3, sigs3, aend3] = await verifierClient
.ipex()
Expand Down Expand Up @@ -361,6 +470,7 @@ test('single signature credentials', async () => {
holderClient,
'/exn/ipex/admit'
);

await markAndRemoveNotification(holderClient, holderNotifications[0]);
});

Expand Down
6 changes: 3 additions & 3 deletions examples/integration-scripts/salty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ test('salty', async () => {
const events = client1.keyEvents();
const log = await events.get(aid['prefix']);
assert.equal(log.length, 3);
let serder = new signify.Serder(log[0]);
let serder = new signify.Serder(log[0].ked);
assert.equal(serder.pre, icp.pre);
assert.equal(serder.ked['d'], icp.ked['d']);
serder = new signify.Serder(log[1]);
serder = new signify.Serder(log[1].ked);
assert.equal(serder.pre, rot.pre);
assert.equal(serder.ked['d'], rot.ked['d']);
serder = new signify.Serder(log[2]);
serder = new signify.Serder(log[2].ked);
assert.equal(serder.pre, ixn.pre);
assert.equal(serder.ked['d'], ixn.ked['d']);

Expand Down
7 changes: 2 additions & 5 deletions examples/integration-scripts/test-setup-single-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ afterAll(async () => {

describe('test-setup-single-client', () => {
test('step1', async () => {
expect(client.agent?.pre).toEqual(
'EC60ue9GOpQGrLBlS9T0dO6JkBTbv3V05Y4O730QBBoc'
);
expect(client.controller?.pre).toEqual(
'EB3UGWwIMq7ppzcQ697ImQIuXlBG5jzh-baSx-YG3-tY'
);
Expand All @@ -33,7 +30,7 @@ describe('test-setup-single-client', () => {
switch (env.preset) {
case 'local':
expect(name1_oobi).toEqual(
`http://127.0.0.1:3902/oobi/${name1_id}/agent/EC60ue9GOpQGrLBlS9T0dO6JkBTbv3V05Y4O730QBBoc`
`http://127.0.0.1:3902/oobi/${name1_id}/agent/${client.agent?.pre}`
);
expect(oobi.oobis[0]).toEqual(
`http://127.0.0.1:5642/oobi/${name1_id}/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha`
Expand All @@ -47,7 +44,7 @@ describe('test-setup-single-client', () => {
break;
case 'docker':
expect(name1_oobi).toEqual(
`http://keria:3902/oobi/${name1_id}/agent/EC60ue9GOpQGrLBlS9T0dO6JkBTbv3V05Y4O730QBBoc`
`http://keria:3902/oobi/${name1_id}/agent/${client.agent?.pre}`
);
expect(oobi.oobis[0]).toEqual(
`http://witness-demo:5642/oobi/${name1_id}/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha`
Expand Down
18 changes: 6 additions & 12 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,8 @@ export class Identifier {
icp: serder.ked,
sigs: sigs,
proxy: proxy,
smids:
states != undefined
? states.map((state) => state.i)
: undefined,
rmids:
rstates != undefined
? rstates.map((state) => state.i)
: undefined,
smids: states,
rmids: rstates,
};
jsondata[algo] = keeper.params();

Expand Down Expand Up @@ -278,8 +272,8 @@ export class Identifier {
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name + '?type=ixn',
'PUT',
'/identifiers/' + name + '/events',
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down Expand Up @@ -376,8 +370,8 @@ export class Identifier {
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name,
'PUT',
'/identifiers/' + name + '/events',
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down
Loading