Skip to content

Commit eb4030b

Browse files
lenkandaviddm
authored andcommitted
fix: cannot set salts for credential creation (suggestion) (WebOfTrust#222)
* fix: cannot set different salts for credential * fix types * add comments * fix dt for issuance event
1 parent c3ea695 commit eb4030b

File tree

6 files changed

+115
-138
lines changed

6 files changed

+115
-138
lines changed

examples/integration-scripts/credentials.test.ts

+35-31
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,16 @@ test('single signature credentials', async () => {
154154
LEI: '5493001KJTIIGC8Y1R17',
155155
};
156156

157-
const issResult = await issuerClient.credentials().issue({
158-
issuerName: issuerAid.name,
159-
registryId: registry.regk,
160-
schemaId: QVI_SCHEMA_SAID,
161-
recipient: holderAid.prefix,
162-
data: vcdata,
163-
});
157+
const issResult = await issuerClient
158+
.credentials()
159+
.issue(issuerAid.name, {
160+
ri: registry.regk,
161+
s: QVI_SCHEMA_SAID,
162+
a: {
163+
i: holderAid.prefix,
164+
...vcdata,
165+
},
166+
});
164167

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

388-
const result = await holderClient.credentials().issue({
389-
issuerName: holderAid.name,
390-
recipient: legalEntityAid.prefix,
391-
registryId: holderRegistry.regk,
392-
schemaId: LE_SCHEMA_SAID,
393-
data: {
394-
LEI: '5493001KJTIIGC8Y1R17',
395-
},
396-
rules: Saider.saidify({
397-
d: '',
398-
usageDisclaimer: {
399-
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.',
400-
},
401-
issuanceDisclaimer: {
402-
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.',
403-
},
404-
})[1],
405-
source: Saider.saidify({
406-
d: '',
407-
qvi: {
408-
n: qviCredential.sad.d,
409-
s: qviCredential.sad.s,
391+
const result = await holderClient
392+
.credentials()
393+
.issue(holderAid.name, {
394+
a: {
395+
i: legalEntityAid.prefix,
396+
LEI: '5493001KJTIIGC8Y1R17',
410397
},
411-
})[1],
412-
});
398+
ri: holderRegistry.regk,
399+
s: LE_SCHEMA_SAID,
400+
r: Saider.saidify({
401+
d: '',
402+
usageDisclaimer: {
403+
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.',
404+
},
405+
issuanceDisclaimer: {
406+
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.',
407+
},
408+
})[1],
409+
e: Saider.saidify({
410+
d: '',
411+
qvi: {
412+
n: qviCredential.sad.d,
413+
s: qviCredential.sad.s,
414+
},
415+
})[1],
416+
});
413417

414418
await waitOperation(holderClient, result.op);
415419
return result.acdc.ked.d;

examples/integration-scripts/multisig-holder.test.ts

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { strict as assert } from 'assert';
2-
import signify, {
3-
SignifyClient,
4-
IssueCredentialArgs,
5-
Operation,
6-
} from 'signify-ts';
2+
import signify, { SignifyClient, Operation, CredentialData } from 'signify-ts';
73
import { resolveEnvironment } from './utils/resolve-env';
84
import {
95
assertOperations,
@@ -354,12 +350,11 @@ test('multisig', async function run() {
354350

355351
console.log(`Issuer starting credential issuance to holder...`);
356352
const registires = await client3.registries().list('issuer');
357-
await issueCredential(client3, {
358-
issuerName: 'issuer',
359-
registryId: registires[0].regk,
360-
schemaId: SCHEMA_SAID,
361-
recipient: holderAid['prefix'],
362-
data: {
353+
await issueCredential(client3, 'issuer', {
354+
ri: registires[0].regk,
355+
s: SCHEMA_SAID,
356+
a: {
357+
i: holderAid['prefix'],
363358
LEI: '5493001KJTIIGC8Y1R17',
364359
},
365360
});
@@ -476,23 +471,24 @@ async function createRegistry(
476471

477472
async function issueCredential(
478473
client: SignifyClient,
479-
args: IssueCredentialArgs
474+
name: string,
475+
data: CredentialData
480476
) {
481-
const result = await client.credentials().issue(args);
477+
const result = await client.credentials().issue(name, data);
482478

483479
await waitOperation(client, result.op);
484480

485481
const creds = await client.credentials().list();
486482
assert.equal(creds.length, 1);
487-
assert.equal(creds[0].sad.s, args.schemaId);
483+
assert.equal(creds[0].sad.s, data.s);
488484
assert.equal(creds[0].status.s, '0');
489485

490486
const dt = createTimestamp();
491487

492-
if (args.recipient) {
488+
if (data.a.i) {
493489
const [grant, gsigs, end] = await client.ipex().grant({
494-
senderName: args.issuerName,
495-
recipient: args.recipient,
490+
senderName: name,
491+
recipient: data.a.i,
496492
datetime: dt,
497493
acdc: result.acdc,
498494
anc: result.anc,
@@ -501,7 +497,7 @@ async function issueCredential(
501497

502498
let op = await client
503499
.ipex()
504-
.submitGrant(args.issuerName, grant, gsigs, end, [args.recipient]);
500+
.submitGrant(name, grant, gsigs, end, [data.a.i]);
505501
op = await waitOperation(client, op);
506502
}
507503

examples/integration-scripts/multisig.test.ts

+10-26
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ test('multisig', async function run() {
797797
});
798798
op2 = await vcpRes2.op();
799799
serder = vcpRes2.regser;
800-
const regk2 = serder.pre;
801800
anc = vcpRes2.serder;
802801
sigs = vcpRes2.sigs;
803802

@@ -840,7 +839,6 @@ test('multisig', async function run() {
840839
});
841840
op3 = await vcpRes3.op();
842841
serder = vcpRes3.regser;
843-
const regk3 = serder.pre;
844842
anc = vcpRes3.serder;
845843
sigs = vcpRes3.sigs;
846844

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

883881
const TIME = new Date().toISOString().replace('Z', '000+00:00');
884-
const credRes = await client1.credentials().issue({
885-
issuerName: 'multisig',
886-
registryId: regk,
887-
schemaId: SCHEMA_SAID,
888-
data: vcdata,
889-
recipient: holder,
890-
datetime: TIME,
882+
const credRes = await client1.credentials().issue('multisig', {
883+
ri: regk,
884+
s: SCHEMA_SAID,
885+
a: {
886+
i: holder,
887+
dt: TIME,
888+
...vcdata,
889+
},
891890
});
892891
op1 = credRes.op;
893892
await multisigIssue(client1, 'member1', 'multisig', credRes);
@@ -905,15 +904,7 @@ test('multisig', async function run() {
905904
exn = res[0].exn;
906905

907906
const credentialSaid = exn.e.acdc.d;
908-
909-
const credRes2 = await client2.credentials().issue({
910-
issuerName: 'multisig',
911-
registryId: regk2,
912-
schemaId: SCHEMA_SAID,
913-
data: vcdata,
914-
datetime: exn.e.acdc.a.dt,
915-
recipient: holder,
916-
});
907+
const credRes2 = await client2.credentials().issue('multisig', exn.e.acdc);
917908

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

930-
const credRes3 = await client3.credentials().issue({
931-
issuerName: 'multisig',
932-
registryId: regk3,
933-
schemaId: SCHEMA_SAID,
934-
recipient: holder,
935-
data: vcdata,
936-
datetime: exn.e.acdc.a.dt,
937-
});
921+
const credRes3 = await client3.credentials().issue('multisig', exn.e.acdc);
938922

939923
op3 = credRes3.op;
940924
await multisigIssue(client3, 'member3', 'multisig', credRes3);

examples/integration-scripts/singlesig-vlei-issuance.test.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { strict as assert } from 'assert';
2-
import { Saider, Serder, SignifyClient } from 'signify-ts';
2+
import { Saider, Salter, Serder, SignifyClient } from 'signify-ts';
33
import { resolveEnvironment } from './utils/resolve-env';
44
import {
55
assertOperations,
@@ -491,7 +491,7 @@ async function getOrIssueCredential(
491491
schema: string,
492492
rules?: any,
493493
source?: any,
494-
privacy: boolean = false
494+
privacy = false
495495
): Promise<any> {
496496
const credentialList = await issuerClient.credentials().list();
497497

@@ -507,15 +507,17 @@ async function getOrIssueCredential(
507507
if (credential) return credential;
508508
}
509509

510-
const issResult = await issuerClient.credentials().issue({
511-
issuerName: issuerAid.name,
512-
registryId: issuerRegistry.regk,
513-
schemaId: schema,
514-
recipient: recipientAid.prefix,
515-
data: credData,
516-
rules: rules,
517-
source: source,
518-
privacy: privacy,
510+
const issResult = await issuerClient.credentials().issue(issuerAid.name, {
511+
ri: issuerRegistry.regk,
512+
s: schema,
513+
u: privacy ? new Salter({}).qb64 : undefined,
514+
a: {
515+
i: recipientAid.prefix,
516+
u: privacy ? new Salter({}).qb64 : undefined,
517+
...credData,
518+
},
519+
r: rules,
520+
e: source,
519521
});
520522

521523
await waitOperation(issuerClient, issResult.op);

0 commit comments

Comments
 (0)