Skip to content

Commit

Permalink
fix: cannot set salts for credential creation (suggestion) (WebOfTrus…
Browse files Browse the repository at this point in the history
…t#222)

* fix: cannot set different salts for credential

* fix types

* add comments

* fix dt for issuance event
  • Loading branch information
lenkan authored and daviddm committed May 8, 2024
1 parent c3ea695 commit eb4030b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 138 deletions.
66 changes: 35 additions & 31 deletions examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,16 @@ test('single signature credentials', async () => {
LEI: '5493001KJTIIGC8Y1R17',
};

const issResult = await issuerClient.credentials().issue({
issuerName: issuerAid.name,
registryId: registry.regk,
schemaId: QVI_SCHEMA_SAID,
recipient: holderAid.prefix,
data: vcdata,
});
const issResult = await issuerClient
.credentials()
.issue(issuerAid.name, {
ri: registry.regk,
s: QVI_SCHEMA_SAID,
a: {
i: holderAid.prefix,
...vcdata,
},
});

await waitOperation(issuerClient, issResult.op);
return issResult.acdc.ked.d as string;
Expand Down Expand Up @@ -385,31 +388,32 @@ test('single signature credentials', async () => {
.credentials()
.get(qviCredentialId);

const result = await holderClient.credentials().issue({
issuerName: holderAid.name,
recipient: legalEntityAid.prefix,
registryId: holderRegistry.regk,
schemaId: LE_SCHEMA_SAID,
data: {
LEI: '5493001KJTIIGC8Y1R17',
},
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],
source: Saider.saidify({
d: '',
qvi: {
n: qviCredential.sad.d,
s: qviCredential.sad.s,
const result = await holderClient
.credentials()
.issue(holderAid.name, {
a: {
i: legalEntityAid.prefix,
LEI: '5493001KJTIIGC8Y1R17',
},
})[1],
});
ri: holderRegistry.regk,
s: LE_SCHEMA_SAID,
r: 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],
e: Saider.saidify({
d: '',
qvi: {
n: qviCredential.sad.d,
s: qviCredential.sad.s,
},
})[1],
});

await waitOperation(holderClient, result.op);
return result.acdc.ked.d;
Expand Down
32 changes: 14 additions & 18 deletions examples/integration-scripts/multisig-holder.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { strict as assert } from 'assert';
import signify, {
SignifyClient,
IssueCredentialArgs,
Operation,
} from 'signify-ts';
import signify, { SignifyClient, Operation, CredentialData } from 'signify-ts';
import { resolveEnvironment } from './utils/resolve-env';
import {
assertOperations,
Expand Down Expand Up @@ -354,12 +350,11 @@ test('multisig', async function run() {

console.log(`Issuer starting credential issuance to holder...`);
const registires = await client3.registries().list('issuer');
await issueCredential(client3, {
issuerName: 'issuer',
registryId: registires[0].regk,
schemaId: SCHEMA_SAID,
recipient: holderAid['prefix'],
data: {
await issueCredential(client3, 'issuer', {
ri: registires[0].regk,
s: SCHEMA_SAID,
a: {
i: holderAid['prefix'],
LEI: '5493001KJTIIGC8Y1R17',
},
});
Expand Down Expand Up @@ -476,23 +471,24 @@ async function createRegistry(

async function issueCredential(
client: SignifyClient,
args: IssueCredentialArgs
name: string,
data: CredentialData
) {
const result = await client.credentials().issue(args);
const result = await client.credentials().issue(name, data);

await waitOperation(client, result.op);

const creds = await client.credentials().list();
assert.equal(creds.length, 1);
assert.equal(creds[0].sad.s, args.schemaId);
assert.equal(creds[0].sad.s, data.s);
assert.equal(creds[0].status.s, '0');

const dt = createTimestamp();

if (args.recipient) {
if (data.a.i) {
const [grant, gsigs, end] = await client.ipex().grant({
senderName: args.issuerName,
recipient: args.recipient,
senderName: name,
recipient: data.a.i,
datetime: dt,
acdc: result.acdc,
anc: result.anc,
Expand All @@ -501,7 +497,7 @@ async function issueCredential(

let op = await client
.ipex()
.submitGrant(args.issuerName, grant, gsigs, end, [args.recipient]);
.submitGrant(name, grant, gsigs, end, [data.a.i]);
op = await waitOperation(client, op);
}

Expand Down
36 changes: 10 additions & 26 deletions examples/integration-scripts/multisig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ test('multisig', async function run() {
});
op2 = await vcpRes2.op();
serder = vcpRes2.regser;
const regk2 = serder.pre;
anc = vcpRes2.serder;
sigs = vcpRes2.sigs;

Expand Down Expand Up @@ -840,7 +839,6 @@ test('multisig', async function run() {
});
op3 = await vcpRes3.op();
serder = vcpRes3.regser;
const regk3 = serder.pre;
anc = vcpRes3.serder;
sigs = vcpRes3.sigs;

Expand Down Expand Up @@ -881,13 +879,14 @@ test('multisig', async function run() {
const holder = aid4.prefix;

const TIME = new Date().toISOString().replace('Z', '000+00:00');
const credRes = await client1.credentials().issue({
issuerName: 'multisig',
registryId: regk,
schemaId: SCHEMA_SAID,
data: vcdata,
recipient: holder,
datetime: TIME,
const credRes = await client1.credentials().issue('multisig', {
ri: regk,
s: SCHEMA_SAID,
a: {
i: holder,
dt: TIME,
...vcdata,
},
});
op1 = credRes.op;
await multisigIssue(client1, 'member1', 'multisig', credRes);
Expand All @@ -905,15 +904,7 @@ test('multisig', async function run() {
exn = res[0].exn;

const credentialSaid = exn.e.acdc.d;

const credRes2 = await client2.credentials().issue({
issuerName: 'multisig',
registryId: regk2,
schemaId: SCHEMA_SAID,
data: vcdata,
datetime: exn.e.acdc.a.dt,
recipient: holder,
});
const credRes2 = await client2.credentials().issue('multisig', exn.e.acdc);

op2 = credRes2.op;
await multisigIssue(client2, 'member2', 'multisig', credRes2);
Expand All @@ -927,14 +918,7 @@ test('multisig', async function run() {
res = await client3.groups().getRequest(msgSaid);
exn = res[0].exn;

const credRes3 = await client3.credentials().issue({
issuerName: 'multisig',
registryId: regk3,
schemaId: SCHEMA_SAID,
recipient: holder,
data: vcdata,
datetime: exn.e.acdc.a.dt,
});
const credRes3 = await client3.credentials().issue('multisig', exn.e.acdc);

op3 = credRes3.op;
await multisigIssue(client3, 'member3', 'multisig', credRes3);
Expand Down
24 changes: 13 additions & 11 deletions examples/integration-scripts/singlesig-vlei-issuance.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 { Saider, Salter, Serder, SignifyClient } from 'signify-ts';
import { resolveEnvironment } from './utils/resolve-env';
import {
assertOperations,
Expand Down Expand Up @@ -491,7 +491,7 @@ async function getOrIssueCredential(
schema: string,
rules?: any,
source?: any,
privacy: boolean = false
privacy = false
): Promise<any> {
const credentialList = await issuerClient.credentials().list();

Expand All @@ -507,15 +507,17 @@ async function getOrIssueCredential(
if (credential) return credential;
}

const issResult = await issuerClient.credentials().issue({
issuerName: issuerAid.name,
registryId: issuerRegistry.regk,
schemaId: schema,
recipient: recipientAid.prefix,
data: credData,
rules: rules,
source: source,
privacy: privacy,
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);
Expand Down
Loading

0 comments on commit eb4030b

Please sign in to comment.