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

Using @nobles/hashes #162

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
- name: Build
run: npm run build
- name: Start dependencies
run: docker compose up deps
run: docker compose up deps --pull always
- name: Run integration test
run: npm run test:integration
- name: Print logs
run: docker compose logs
if: always()

17 changes: 0 additions & 17 deletions examples/integration-scripts/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import { strict as assert } from 'assert';
import signify, { Serder } from 'signify-ts';
import { resolveEnvironment } from './utils/resolve-env';
import { resolveOobi, waitOperation } from './utils/test-util';

const url = 'http://127.0.0.1:3901';
const boot_url = 'http://127.0.0.1:3903';
const { url, bootUrl } = resolveEnvironment();

await run();

async function run() {
test('challenge', async () => {
await signify.ready();
// Boot two clients
const bran1 = signify.randomPasscode();
const bran2 = signify.randomPasscode();
const client1 = new signify.SignifyClient(
url,
bran1,
signify.Tier.low,
boot_url
bootUrl
);
const client2 = new signify.SignifyClient(
url,
bran2,
signify.Tier.low,
boot_url
bootUrl
);
await client1.boot();
await client2.boot();
Expand Down Expand Up @@ -57,12 +55,10 @@ async function run() {
'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX',
],
});
let op1 = await icpResult1.op();
while (!op1['done']) {
op1 = await client1.operations().get(op1.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
const aid1 = op1['response'];
const { response: aid1 } = await waitOperation<{ i: string }>(
client1,
await icpResult1.op()
);
await client1
.identifiers()
.addEndRole('alice', 'agent', client1!.agent!.pre);
Expand All @@ -89,43 +85,39 @@ async function run() {
const oobi1 = await client1.oobis().get('alice', 'agent');
const oobi2 = await client2.oobis().get('bob', 'agent');

op1 = await client1.oobis().resolve(oobi2.oobis[0], 'bob');
while (!op1['done']) {
op1 = await client1.operations().get(op1.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await resolveOobi(client1, oobi2.oobis[0], 'bob');
console.log("Client 1 resolved Bob's OOBI");
op2 = await client2.oobis().resolve(oobi1.oobis[0], 'alice');
while (!op2['done']) {
op2 = await client2.operations().get(op2.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await resolveOobi(client2, oobi1.oobis[0], 'alice');
console.log("Client 2 resolved Alice's OOBI");

// List Client 1 contacts
let contacts1 = await client1.contacts().list();
assert.equal(contacts1[3].alias, 'bob');
expect(contacts1[0].alias).toEqual('bob');
expect(contacts1[0].challenges).toHaveLength(0);

// Bob responds to Alice challenge
await client2.challenges().respond('bob', aid1.i, challenge1_small.words);
console.log('Bob responded to Alice challenge with signed words');

// Alice verifies Bob's response
op1 = await client1
.challenges()
.verify('alice', aid2.i, challenge1_small.words);
while (!op1['done']) {
op1 = await client1.operations().get(op1.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
const verifyOperation = await waitOperation(
client1,
await client1
.challenges()
.verify('alice', aid2.i, challenge1_small.words)
);
console.log('Alice verified challenge response');

//Alice mark response as accepted
const exn = new Serder(op1.response.exn);
op1 = await client1.challenges().responded('alice', aid2.i, exn.ked.d);
const verifyResponse = verifyOperation.response as {
exn: Record<string, unknown>;
};
const exn = new Serder(verifyResponse.exn);

await client1.challenges().responded('alice', aid2.i, exn.ked.d);
console.log('Alice marked challenge response as accepted');

// Check Bob's challenge in conctats
contacts1 = await client1.contacts().list();
console.log('Challenge authenticated');
}
expect(contacts1[0].challenges[0].authenticated).toEqual(true);
}, 30000);
28 changes: 12 additions & 16 deletions examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { strict as assert } from 'assert';
import signify from 'signify-ts';

const url = 'http://127.0.0.1:3901';
const boot_url = 'http://127.0.0.1:3903';
const WAN_WITNESS_AID = 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha';
const WIL_WITNESS_AID = 'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM';
const WES_WITNESS_AID = 'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX';
const WITNESS_HOST = 'witness-demo';
import { resolveEnvironment } from './utils/resolve-env';
const { url, bootUrl, vleiServerUrl, witnessIds, witnessUrls } =
resolveEnvironment();

const boot_url = bootUrl;
const WAN_WITNESS_AID = witnessIds[0];
const WIL_WITNESS_AID = witnessIds[1];
const WES_WITNESS_AID = witnessIds[2];
const WITNESS_OOBIS = [
`http://${WITNESS_HOST}:5642/oobi/${WAN_WITNESS_AID}/controller?name=Wan&tag=witness`,
`http://${WITNESS_HOST}:5643/oobi/${WIL_WITNESS_AID}/controller?name=Wil&tag=witness`,
`http://${WITNESS_HOST}:5644/oobi/${WES_WITNESS_AID}/controller?name=Wes&tag=witness`,
`${witnessUrls[0]}/oobi/${WAN_WITNESS_AID}/controller?name=Wan&tag=witness`,
`${witnessUrls[1]}/oobi/${WIL_WITNESS_AID}/controller?name=Wil&tag=witness`,
`${witnessUrls[2]}/oobi/${WES_WITNESS_AID}/controller?name=Wes&tag=witness`,
];

const KLI_WITNESS_DEMO_PREFIXES = [
Expand All @@ -21,7 +22,7 @@

// Credential Schema discovery through credential schema OOBI resolution
const qviSchemaSAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao';
const vLEIServerHostUrl = 'http://vlei-server:7723/oobi';
const vLEIServerHostUrl = `${vleiServerUrl}/oobi`;
const schemaOobiUrl = `${vLEIServerHostUrl}/${qviSchemaSAID}`;

// Boots an agent and connects to it, returning the connected SignifyClient
Expand Down Expand Up @@ -56,7 +57,7 @@
route: string
): Promise<Notification[]> {
const awaitedNotifications = [];
while (true) {

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

View workflow job for this annotation

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

Unexpected constant condition

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

View workflow job for this annotation

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

Unexpected constant condition
const notifications = await client.notifications().list();
for (const note of notifications.notes) {
if (note.a.r === route) {
Expand All @@ -70,7 +71,7 @@
return awaitedNotifications;
}

async function resolveWitnesses(client: signify.SignifyClient) {

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

View workflow job for this annotation

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

'resolveWitnesses' is defined but never used

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

View workflow job for this annotation

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

'resolveWitnesses' is defined but never used
await Promise.all(
WITNESS_OOBIS.map((oobi) => client.oobis().resolve(oobi))
);
Expand All @@ -82,11 +83,6 @@
const issuerClient = await bootAndConnect(signify.randomPasscode());
const holderClient = await bootAndConnect(signify.randomPasscode());
const verifierClient = await bootAndConnect(signify.randomPasscode());
await Promise.all([
resolveWitnesses(issuerClient),
resolveWitnesses(holderClient),
resolveWitnesses(verifierClient),
]);

const state1 = await issuerClient.state();
const state2 = await holderClient.state();
Expand Down Expand Up @@ -349,7 +345,7 @@
await new Promise((resolve) => setTimeout(resolve, 250));
holderCreds = await holderClient.credentials().list();
}
const hldVleiAcdc: any = holderCreds[0];

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

View workflow job for this annotation

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

Unexpected any. Specify a different type

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

View workflow job for this annotation

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

Unexpected any. Specify a different type
assert.equal(holderCreds.length, 1);
assert.equal(hldVleiAcdc.sad.s, schemaSAID);
assert.equal(hldVleiAcdc.sad.i, issuerAID);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { strict as assert } from 'assert';
import signify from 'signify-ts';
import { resolveEnvironment } from './utils/resolve-env';
import { resolveOobi, waitOperation } from './utils/test-util';

const url = 'http://127.0.0.1:3901';
const boot_url = 'http://127.0.0.1:3903';
const { url, bootUrl } = resolveEnvironment();

await run();

async function run() {
test('delegation', async () => {
await signify.ready();
// Boot two clients
const bran1 = signify.randomPasscode();
Expand All @@ -15,13 +14,13 @@
url,
bran1,
signify.Tier.low,
boot_url
bootUrl
);
const client2 = new signify.SignifyClient(
url,
bran2,
signify.Tier.low,
boot_url
bootUrl
);
await client1.boot();
await client2.boot();
Expand Down Expand Up @@ -52,10 +51,7 @@
],
});
let op1 = await icpResult1.op();
while (!op1['done']) {
op1 = await client1.operations().get(op1.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await waitOperation(client1, op1);
const aid1 = await client1.identifiers().get('delegator');
await client1
.identifiers()
Expand All @@ -65,18 +61,14 @@
// Client 2 resolves delegator OOBI
console.log('Client 2 resolving delegator OOBI');
const oobi1 = await client1.oobis().get('delegator', 'agent');
let op2 = await client2.oobis().resolve(oobi1.oobis[0], 'delegator');
while (!op2['done']) {
op2 = await client2.operations().get(op2.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await resolveOobi(client2, oobi1.oobis[0], 'delegator');
console.log('OOBI resolved');

// Client 2 creates delegate AID
const icpResult2 = await client2
.identifiers()
.create('delegate', { delpre: aid1.prefix });
op2 = await icpResult2.op();
let op2 = await icpResult2.op();

Check warning on line 71 in examples/integration-scripts/delegation.test.ts

View workflow job for this annotation

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

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

Check warning on line 71 in examples/integration-scripts/delegation.test.ts

View workflow job for this annotation

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

'op2' is never reassigned. Use 'const' instead
const delegatePrefix = op2.name.split('.')[1];
console.log("Delegate's prefix:", delegatePrefix);
console.log('Delegate waiting for approval...');
Expand All @@ -91,11 +83,8 @@
console.log('Delegator approved delegation');

// Client 2 check approval
while (!op2['done']) {
op2 = await client2.operations().get(op2.name);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await waitOperation(client2, op2);
const aid2 = await client2.identifiers().get('delegate');
assert.equal(aid2.prefix, delegatePrefix);
console.log('Delegation approved for aid:', aid2.prefix);
}
}, 60000);
12 changes: 2 additions & 10 deletions examples/integration-scripts/multisig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
} from 'signify-ts';
import { resolveEnvironment } from './utils/resolve-env';

const { url, bootUrl, witnessUrls, vleiServerUrl } = resolveEnvironment();
const { url, bootUrl, vleiServerUrl } = resolveEnvironment();
const WITNESS_AIDS = [
'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha',
'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM',
'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX',
];

const WITNESS_OOBIS = witnessUrls.map((url) => `${url}/oobi`);
const SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao';
const SCHEMA_OOBI = `${vleiServerUrl}/oobi/${SCHEMA_SAID}`;

Expand All @@ -28,7 +27,7 @@
]);

// Create four identifiers, one for each client
let [aid1, aid2, aid3, aid4] = await Promise.all([

Check warning on line 30 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

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

Check warning on line 30 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

'aid4' is never reassigned. Use 'const' instead
createAID(client1, 'member1', WITNESS_AIDS),
createAID(client2, 'member2', WITNESS_AIDS),
createAID(client3, 'member3', WITNESS_AIDS),
Expand Down Expand Up @@ -133,7 +132,7 @@
let serder = icpResult1.serder;

let sigs = icpResult1.sigs;
let sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig }));

Check warning on line 135 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

Check warning on line 135 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

let ims = signify.d(signify.messagize(serder, sigers));
let atc = ims.substring(serder.size);
Expand Down Expand Up @@ -179,7 +178,7 @@
op2 = await icpResult2.op();
serder = icpResult2.serder;
sigs = icpResult2.sigs;
sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig }));

Check warning on line 181 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

Check warning on line 181 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

ims = signify.d(signify.messagize(serder, sigers));
atc = ims.substring(serder.size);
Expand Down Expand Up @@ -223,7 +222,7 @@
op3 = await icpResult3.op();
serder = icpResult3.serder;
sigs = icpResult3.sigs;
sigers = sigs.map((sig: any) => new signify.Siger({ qb64: sig }));

Check warning on line 225 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

Check warning on line 225 in examples/integration-scripts/multisig.test.ts

View workflow job for this annotation

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

Unexpected any. Specify a different type

ims = signify.d(signify.messagize(serder, sigers));
atc = ims.substring(serder.size);
Expand Down Expand Up @@ -1106,7 +1105,7 @@
console.log('Member1 received exchange message with the admit response');
const creds = await client4.credentials().list();
console.log(`Holder holds ${creds.length} credential`);
}, 240000);
}, 360000);

async function waitForOp(client: SignifyClient, op: any) {
while (!op['done']) {
Expand Down Expand Up @@ -1144,7 +1143,6 @@
state.agent.i
);

await resolveWitnesses(client);
return client;
}

Expand All @@ -1161,12 +1159,6 @@
return aid;
}

async function resolveWitnesses(client: SignifyClient) {
await Promise.all(
WITNESS_OOBIS.map((oobi) => client.oobis().resolve(oobi))
);
}

async function multisigIssue(
client: SignifyClient,
memberName: string,
Expand Down
Loading
Loading