@cheqd/studio 3.7.0 → 3.8.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -3
- package/dist/app.js.map +1 -1
- package/dist/controllers/api/accreditation.d.ts +6 -6
- package/dist/controllers/api/accreditation.d.ts.map +1 -1
- package/dist/controllers/api/accreditation.js +20 -16
- package/dist/controllers/api/accreditation.js.map +1 -1
- package/dist/controllers/api/credential-status.d.ts +103 -16
- package/dist/controllers/api/credential-status.d.ts.map +1 -1
- package/dist/controllers/api/credential-status.js +321 -61
- package/dist/controllers/api/credential-status.js.map +1 -1
- package/dist/controllers/api/credential.d.ts +33 -8
- package/dist/controllers/api/credential.d.ts.map +1 -1
- package/dist/controllers/api/credential.js +53 -30
- package/dist/controllers/api/credential.js.map +1 -1
- package/dist/controllers/api/did.d.ts.map +1 -1
- package/dist/controllers/api/did.js +8 -0
- package/dist/controllers/api/did.js.map +1 -1
- package/dist/controllers/validator/credential-status.d.ts.map +1 -1
- package/dist/controllers/validator/credential-status.js +19 -5
- package/dist/controllers/validator/credential-status.js.map +1 -1
- package/dist/controllers/validator/service-create-request.d.ts.map +1 -1
- package/dist/controllers/validator/service-create-request.js +16 -0
- package/dist/controllers/validator/service-create-request.js.map +1 -1
- package/dist/controllers/validator/service.d.ts.map +1 -1
- package/dist/controllers/validator/service.js +16 -0
- package/dist/controllers/validator/service.js.map +1 -1
- package/dist/database/entities/api.key.entity.js +1 -1
- package/dist/database/entities/payment.entity.d.ts.map +1 -1
- package/dist/database/entities/payment.entity.js +4 -1
- package/dist/database/entities/payment.entity.js.map +1 -1
- package/dist/database/entities/resource.entity.js.map +1 -1
- package/dist/database/entities/subscription.entity.js.map +1 -1
- package/dist/database/migrations/1750427001486-studio-migrations.d.ts +1 -1
- package/dist/database/migrations/1750427001486-studio-migrations.d.ts.map +1 -1
- package/dist/database/migrations/1750427001486-studio-migrations.js.map +1 -1
- package/dist/database/migrations/custom/1748331341024-Cleanup.d.ts +1 -1
- package/dist/database/migrations/custom/1748331341024-Cleanup.d.ts.map +1 -1
- package/dist/database/migrations/custom/1748331341024-Cleanup.js +1 -1
- package/dist/database/migrations/custom/1748331341024-Cleanup.js.map +1 -1
- package/dist/database/scripts/add-migration-to-types.js +6 -5
- package/dist/database/scripts/add-migration-to-types.js.map +1 -1
- package/dist/middleware/auth/auth-gaurd.js +1 -1
- package/dist/middleware/auth/auth-gaurd.js.map +1 -1
- package/dist/services/identity/abstract.d.ts +11 -8
- package/dist/services/identity/abstract.d.ts.map +1 -1
- package/dist/services/identity/abstract.js +15 -6
- package/dist/services/identity/abstract.js.map +1 -1
- package/dist/services/identity/agent.d.ts +10 -7
- package/dist/services/identity/agent.d.ts.map +1 -1
- package/dist/services/identity/agent.js +370 -139
- package/dist/services/identity/agent.js.map +1 -1
- package/dist/services/identity/default.d.ts +1 -1
- package/dist/services/identity/default.d.ts.map +1 -1
- package/dist/services/identity/default.js +2 -2
- package/dist/services/identity/default.js.map +1 -1
- package/dist/services/identity/index.d.ts +11 -8
- package/dist/services/identity/index.d.ts.map +1 -1
- package/dist/services/identity/index.js.map +1 -1
- package/dist/services/identity/local.d.ts +9 -6
- package/dist/services/identity/local.d.ts.map +1 -1
- package/dist/services/identity/local.js +18 -10
- package/dist/services/identity/local.js.map +1 -1
- package/dist/services/identity/postgres.d.ts +9 -6
- package/dist/services/identity/postgres.d.ts.map +1 -1
- package/dist/services/identity/postgres.js +24 -10
- package/dist/services/identity/postgres.js.map +1 -1
- package/dist/services/track/operation-subscriber.d.ts.map +1 -1
- package/dist/services/track/operation-subscriber.js +18 -16
- package/dist/services/track/operation-subscriber.js.map +1 -1
- package/dist/services/w3c-credential.d.ts +2 -2
- package/dist/services/w3c-credential.d.ts.map +1 -1
- package/dist/services/w3c-credential.js +2 -1
- package/dist/services/w3c-credential.js.map +1 -1
- package/dist/static/swagger-api.json +289 -43
- package/dist/types/accreditation.d.ts +11 -14
- package/dist/types/accreditation.d.ts.map +1 -1
- package/dist/types/accreditation.js +6 -0
- package/dist/types/accreditation.js.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/constants.js +1 -0
- package/dist/types/constants.js.map +1 -1
- package/dist/types/credential-status.d.ts +40 -8
- package/dist/types/credential-status.d.ts.map +1 -1
- package/dist/types/credential-status.js +11 -0
- package/dist/types/credential-status.js.map +1 -1
- package/dist/types/credential.d.ts +7 -10
- package/dist/types/credential.d.ts.map +1 -1
- package/dist/types/credential.js.map +1 -1
- package/dist/types/swagger-api-types.d.ts +62 -12
- package/dist/types/swagger-api-types.d.ts.map +1 -1
- package/dist/types/swagger-api-types.js +62 -12
- package/dist/types/swagger-api-types.js.map +1 -1
- package/dist/types/validation.d.ts +4 -0
- package/dist/types/validation.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -5,13 +5,13 @@ import { DIDManager } from '@veramo/did-manager';
|
|
|
5
5
|
import { DIDResolverPlugin, getUniversalResolver as UniversalResolver } from '@veramo/did-resolver';
|
|
6
6
|
import { CredentialPlugin } from '@veramo/credential-w3c';
|
|
7
7
|
import { CredentialIssuerLD, LdDefaultContexts, VeramoEd25519Signature2018, VeramoEd25519Signature2020, VeramoJsonWebSignature2020, } from '@veramo/credential-ld';
|
|
8
|
-
import { Cheqd, getResolver as CheqdDidResolver, DefaultResolverUrl,
|
|
8
|
+
import { Cheqd, getResolver as CheqdDidResolver, DefaultResolverUrl, BitstringStatusListResourceType, DefaultStatusList2021StatusPurposeTypes, DefaultStatusListEncodings, BitstringStatusPurposeTypes, DefaultStatusList2021ResourceTypes, } from '@cheqd/did-provider-cheqd';
|
|
9
9
|
import { ResourceModule } from '@cheqd/sdk';
|
|
10
10
|
import { getDidKeyResolver as KeyDidResolver } from '@veramo/did-provider-key';
|
|
11
11
|
import { Resolver } from 'did-resolver';
|
|
12
12
|
import { DefaultDidUrlPattern } from '../../types/shared.js';
|
|
13
|
-
import { DefaultStatusActions } from '../../types/credential-status.js';
|
|
14
|
-
import { MINIMAL_DENOM, VC_PROOF_FORMAT, VC_REMOVE_ORIGINAL_FIELDS } from '../../types/constants.js';
|
|
13
|
+
import { BitstringStatusActions, DefaultStatusActions, StatusListType } from '../../types/credential-status.js';
|
|
14
|
+
import { BitstringStatusListEntry, MINIMAL_DENOM, VC_PROOF_FORMAT, VC_REMOVE_ORIGINAL_FIELDS, } from '../../types/constants.js';
|
|
15
15
|
import { toCoin, toDefaultDkg, toMinimalDenom } from '../../helpers/helpers.js';
|
|
16
16
|
import { jwtDecode } from 'jwt-decode';
|
|
17
17
|
import { SupportedKeyTypes } from '@veramo/utils';
|
|
@@ -195,16 +195,26 @@ export class Veramo {
|
|
|
195
195
|
try {
|
|
196
196
|
let verifiable_credential;
|
|
197
197
|
if (statusListOptions) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
198
|
+
const { statusListType, ...statusOptions } = statusListOptions;
|
|
199
|
+
if (statusListType == StatusListType.StatusList2021) {
|
|
200
|
+
// TODO: remove this check when we remove StatusList2021
|
|
201
|
+
verifiable_credential =
|
|
202
|
+
statusListOptions.statusPurpose == DefaultStatusList2021StatusPurposeTypes.revocation
|
|
203
|
+
? await agent.cheqdIssueRevocableCredentialWithStatusList2021({
|
|
204
|
+
issuanceOptions,
|
|
205
|
+
statusOptions: statusOptions,
|
|
206
|
+
})
|
|
207
|
+
: await agent.cheqdIssueSuspendableCredentialWithStatusList2021({
|
|
208
|
+
issuanceOptions,
|
|
209
|
+
statusOptions: statusOptions,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
verifiable_credential = await agent.cheqdIssueCredentialWithStatusList({
|
|
214
|
+
issuanceOptions,
|
|
215
|
+
statusOptions: statusOptions,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
else {
|
|
210
220
|
verifiable_credential = await agent.createVerifiableCredential(issuanceOptions);
|
|
@@ -218,13 +228,25 @@ export class Veramo {
|
|
|
218
228
|
async verifyCredential(agent, credential, verificationOptions = {}) {
|
|
219
229
|
let result;
|
|
220
230
|
if (verificationOptions.verifyStatus) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
231
|
+
const cred = credential;
|
|
232
|
+
if (cred.credentialStatus?.type === BitstringStatusListEntry) {
|
|
233
|
+
result = await agent.cheqdVerifyCredentialWithStatusList({
|
|
234
|
+
credential: cred,
|
|
235
|
+
fetchList: true,
|
|
236
|
+
verificationArgs: {
|
|
237
|
+
...verificationOptions,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
result = await agent.cheqdVerifyCredential({
|
|
243
|
+
credential: cred,
|
|
244
|
+
fetchList: true,
|
|
245
|
+
verificationArgs: {
|
|
246
|
+
...verificationOptions,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
228
250
|
}
|
|
229
251
|
else {
|
|
230
252
|
result = await agent.verifyCredential({
|
|
@@ -277,13 +299,27 @@ export class Veramo {
|
|
|
277
299
|
});
|
|
278
300
|
}
|
|
279
301
|
if (verificationOptions.verifyStatus) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
302
|
+
const firstCredential = typeof presentation.verifiableCredential?.[0] === 'string'
|
|
303
|
+
? jwtDecode(presentation.verifiableCredential[0])
|
|
304
|
+
: presentation.verifiableCredential?.[0];
|
|
305
|
+
if (firstCredential?.credentialStatus?.type === BitstringStatusListEntry) {
|
|
306
|
+
result = await agent.cheqdVerifyPresentationWithStatusList({
|
|
307
|
+
presentation: presentation,
|
|
308
|
+
fetchList: true,
|
|
309
|
+
verificationArgs: {
|
|
310
|
+
...verificationOptions,
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
result = await agent.cheqdVerifyPresentation({
|
|
316
|
+
presentation: presentation,
|
|
317
|
+
fetchList: true,
|
|
318
|
+
verificationArgs: {
|
|
319
|
+
...verificationOptions,
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}
|
|
287
323
|
}
|
|
288
324
|
else {
|
|
289
325
|
result = await agent.verifyPresentation({
|
|
@@ -319,9 +355,29 @@ export class Veramo {
|
|
|
319
355
|
issuerDid: did,
|
|
320
356
|
statusListName: resourceOptions.name,
|
|
321
357
|
statusPurpose: statusOptions.statusPurpose || DefaultStatusList2021StatusPurposeTypes.revocation,
|
|
322
|
-
statusListEncoding: statusOptions.encoding ||
|
|
358
|
+
statusListEncoding: statusOptions.encoding || DefaultStatusListEncodings.base64url,
|
|
359
|
+
statusListLength: statusOptions.length,
|
|
360
|
+
resourceVersion: resourceOptions.version,
|
|
361
|
+
encrypted: false,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
async createUnencryptedBitstringStatusList(agent, did, resourceOptions, statusOptions) {
|
|
365
|
+
const [kms] = await agent.keyManagerGetKeyManagementSystems();
|
|
366
|
+
if (!resourceOptions.name) {
|
|
367
|
+
throw new Error(`createUnencryptedBitstringStatusList: status list name is required`);
|
|
368
|
+
}
|
|
369
|
+
return await agent.cheqdCreateStatusList({
|
|
370
|
+
kms,
|
|
371
|
+
issuerDid: did,
|
|
372
|
+
statusListName: resourceOptions.name,
|
|
373
|
+
statusPurpose: statusOptions.statusPurpose || BitstringStatusPurposeTypes.message,
|
|
374
|
+
statusSize: statusOptions.size || 1,
|
|
375
|
+
statusMessages: statusOptions.statusMessages,
|
|
376
|
+
ttl: statusOptions.ttl,
|
|
377
|
+
statusListEncoding: statusOptions.encoding || DefaultStatusListEncodings.base64url,
|
|
323
378
|
statusListLength: statusOptions.length,
|
|
324
379
|
resourceVersion: resourceOptions.version,
|
|
380
|
+
alsoKnownAs: resourceOptions.alsoKnownAs,
|
|
325
381
|
encrypted: false,
|
|
326
382
|
});
|
|
327
383
|
}
|
|
@@ -364,7 +420,7 @@ export class Veramo {
|
|
|
364
420
|
issuerDid: did,
|
|
365
421
|
statusListName: resourceOptions.name,
|
|
366
422
|
statusPurpose: statusOptions.statusPurpose || DefaultStatusList2021StatusPurposeTypes.revocation,
|
|
367
|
-
statusListEncoding: statusOptions.encoding ||
|
|
423
|
+
statusListEncoding: statusOptions.encoding || DefaultStatusListEncodings.base64url,
|
|
368
424
|
statusListLength: statusOptions.length,
|
|
369
425
|
resourceVersion: resourceOptions.version,
|
|
370
426
|
encrypted: true,
|
|
@@ -373,6 +429,58 @@ export class Veramo {
|
|
|
373
429
|
dkgOptions: toDefaultDkg(did),
|
|
374
430
|
});
|
|
375
431
|
}
|
|
432
|
+
async createEncryptedBitstringStatusList(agent, did, resourceOptions, statusOptions) {
|
|
433
|
+
const [kms] = await agent.keyManagerGetKeyManagementSystems();
|
|
434
|
+
if (!resourceOptions.name) {
|
|
435
|
+
throw new Error(`createEncryptedBitstringStatusList: status list name is required`);
|
|
436
|
+
}
|
|
437
|
+
// construct payment conditions
|
|
438
|
+
const paymentConditions = (statusOptions?.paymentConditions
|
|
439
|
+
? statusOptions.paymentConditions.map((condition) => {
|
|
440
|
+
return {
|
|
441
|
+
type: 'timelockPayment',
|
|
442
|
+
feePaymentAddress: condition.feePaymentAddress,
|
|
443
|
+
feePaymentAmount: `${toMinimalDenom(condition.feePaymentAmount)}${MINIMAL_DENOM}`,
|
|
444
|
+
intervalInSeconds: condition.feePaymentWindow * 60,
|
|
445
|
+
};
|
|
446
|
+
})
|
|
447
|
+
: (function () {
|
|
448
|
+
// validate relevant components - case: feePaymentAddress
|
|
449
|
+
if (!statusOptions.feePaymentAddress)
|
|
450
|
+
throw new Error('createEncryptedBitstringStatusList: feePaymentAddress is required');
|
|
451
|
+
// validate relevant components - case: feePaymentAmount
|
|
452
|
+
if (!statusOptions.feePaymentAmount)
|
|
453
|
+
throw new Error('createEncryptedBitstringStatusList: feePaymentAmount is required');
|
|
454
|
+
// validate relevant components - case: feePaymentWindow
|
|
455
|
+
if (!statusOptions.feePaymentWindow)
|
|
456
|
+
throw new Error('createEncryptedBitstringStatusList: feePaymentWindow is required');
|
|
457
|
+
return [
|
|
458
|
+
{
|
|
459
|
+
type: 'timelockPayment',
|
|
460
|
+
feePaymentAddress: statusOptions.feePaymentAddress,
|
|
461
|
+
feePaymentAmount: `${toMinimalDenom(statusOptions.feePaymentAmount)}${MINIMAL_DENOM}`,
|
|
462
|
+
intervalInSeconds: statusOptions.feePaymentWindow * 60,
|
|
463
|
+
},
|
|
464
|
+
];
|
|
465
|
+
})());
|
|
466
|
+
return await agent.cheqdCreateStatusList({
|
|
467
|
+
kms,
|
|
468
|
+
issuerDid: did,
|
|
469
|
+
statusListName: resourceOptions.name,
|
|
470
|
+
statusPurpose: statusOptions.statusPurpose || BitstringStatusPurposeTypes.message,
|
|
471
|
+
statusSize: statusOptions.size || 1,
|
|
472
|
+
statusMessages: statusOptions.statusMessages,
|
|
473
|
+
ttl: statusOptions.ttl,
|
|
474
|
+
statusListEncoding: statusOptions.encoding || DefaultStatusListEncodings.base64url,
|
|
475
|
+
statusListLength: statusOptions.length,
|
|
476
|
+
resourceVersion: resourceOptions.version,
|
|
477
|
+
alsoKnownAs: resourceOptions.alsoKnownAs,
|
|
478
|
+
encrypted: true,
|
|
479
|
+
paymentConditions,
|
|
480
|
+
returnSymmetricKey: true,
|
|
481
|
+
dkgOptions: toDefaultDkg(did),
|
|
482
|
+
});
|
|
483
|
+
}
|
|
376
484
|
async broadcastStatusList2021(agent, did, resourceOptions, statusOptions) {
|
|
377
485
|
const [kms] = await agent.keyManagerGetKeyManagementSystems();
|
|
378
486
|
if (!resourceOptions.data) {
|
|
@@ -384,13 +492,29 @@ export class Veramo {
|
|
|
384
492
|
...resourceOptions,
|
|
385
493
|
collectionId: did.split(':')[3],
|
|
386
494
|
data: resourceOptions.data,
|
|
387
|
-
resourceType: statusOptions.statusPurpose ===
|
|
495
|
+
resourceType: statusOptions.statusPurpose === DefaultStatusList2021StatusPurposeTypes.revocation
|
|
388
496
|
? DefaultStatusList2021ResourceTypes.revocation
|
|
389
497
|
: DefaultStatusList2021ResourceTypes.suspension,
|
|
390
498
|
},
|
|
391
499
|
network: did.split(':')[2],
|
|
392
500
|
});
|
|
393
501
|
}
|
|
502
|
+
async broadcastBitstringStatusList(agent, did, resourceOptions) {
|
|
503
|
+
const [kms] = await agent.keyManagerGetKeyManagementSystems();
|
|
504
|
+
if (!resourceOptions.data) {
|
|
505
|
+
throw new Error(`StatusList data is required`);
|
|
506
|
+
}
|
|
507
|
+
return await agent.cheqdBroadcastStatusList({
|
|
508
|
+
kms,
|
|
509
|
+
payload: {
|
|
510
|
+
...resourceOptions,
|
|
511
|
+
collectionId: did.split(':')[3],
|
|
512
|
+
data: resourceOptions.data,
|
|
513
|
+
resourceType: BitstringStatusListResourceType,
|
|
514
|
+
},
|
|
515
|
+
network: did.split(':')[2],
|
|
516
|
+
});
|
|
517
|
+
}
|
|
394
518
|
async remunerateStatusList2021(agent, feePaymentOptions) {
|
|
395
519
|
return await agent.cheqdTransactSendTokens({
|
|
396
520
|
recipientAddress: feePaymentOptions.feePaymentAddress,
|
|
@@ -400,7 +524,27 @@ export class Veramo {
|
|
|
400
524
|
returnTxResponse: true,
|
|
401
525
|
});
|
|
402
526
|
}
|
|
403
|
-
async revokeCredentials(agent, credentials, publish = true, symmetricKey = '') {
|
|
527
|
+
async revokeCredentials(agent, credentials, listType, publish = true, symmetricKey = '') {
|
|
528
|
+
if (listType === StatusListType.Bitstring) {
|
|
529
|
+
if (Array.isArray(credentials)) {
|
|
530
|
+
return await agent.cheqdBulkUpdateCredentialsWithStatusList({
|
|
531
|
+
credentials,
|
|
532
|
+
newStatus: BitstringStatusActions.revoke,
|
|
533
|
+
fetchList: true,
|
|
534
|
+
publish,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
return await agent.cheqdUpdateCredentialWithStatusList({
|
|
538
|
+
credential: credentials,
|
|
539
|
+
newStatus: BitstringStatusActions.revoke,
|
|
540
|
+
fetchList: true,
|
|
541
|
+
publish,
|
|
542
|
+
symmetricKey,
|
|
543
|
+
returnStatusListMetadata: true,
|
|
544
|
+
returnUpdatedStatusList: true,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
// default to StatusList2021
|
|
404
548
|
if (Array.isArray(credentials))
|
|
405
549
|
return await agent.cheqdRevokeCredentials({
|
|
406
550
|
credentials,
|
|
@@ -416,7 +560,27 @@ export class Veramo {
|
|
|
416
560
|
returnUpdatedStatusList: true,
|
|
417
561
|
});
|
|
418
562
|
}
|
|
419
|
-
async suspendCredentials(agent, credentials, publish = true, symmetricKey = '') {
|
|
563
|
+
async suspendCredentials(agent, credentials, listType, publish = true, symmetricKey = '') {
|
|
564
|
+
if (listType === StatusListType.Bitstring) {
|
|
565
|
+
if (Array.isArray(credentials)) {
|
|
566
|
+
return await agent.cheqdBulkUpdateCredentialsWithStatusList({
|
|
567
|
+
credentials,
|
|
568
|
+
newStatus: BitstringStatusActions.suspend,
|
|
569
|
+
fetchList: true,
|
|
570
|
+
publish,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return await agent.cheqdUpdateCredentialWithStatusList({
|
|
574
|
+
credential: credentials,
|
|
575
|
+
newStatus: BitstringStatusActions.suspend,
|
|
576
|
+
fetchList: true,
|
|
577
|
+
publish,
|
|
578
|
+
symmetricKey,
|
|
579
|
+
returnStatusListMetadata: true,
|
|
580
|
+
returnUpdatedStatusList: true,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
// default to StatusList2021
|
|
420
584
|
if (Array.isArray(credentials))
|
|
421
585
|
return await agent.cheqdSuspendCredentials({ credentials, fetchList: true, publish });
|
|
422
586
|
return await agent.cheqdSuspendCredential({
|
|
@@ -428,7 +592,27 @@ export class Veramo {
|
|
|
428
592
|
returnUpdatedStatusList: true,
|
|
429
593
|
});
|
|
430
594
|
}
|
|
431
|
-
async unsuspendCredentials(agent, credentials, publish = true, symmetricKey = '') {
|
|
595
|
+
async unsuspendCredentials(agent, credentials, listType, publish = true, symmetricKey = '') {
|
|
596
|
+
if (listType === StatusListType.Bitstring) {
|
|
597
|
+
if (Array.isArray(credentials)) {
|
|
598
|
+
return await agent.cheqdBulkUpdateCredentialsWithStatusList({
|
|
599
|
+
credentials,
|
|
600
|
+
newStatus: BitstringStatusActions.reinstate,
|
|
601
|
+
fetchList: true,
|
|
602
|
+
publish,
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
return await agent.cheqdUpdateCredentialWithStatusList({
|
|
606
|
+
credential: credentials,
|
|
607
|
+
newStatus: BitstringStatusActions.reinstate,
|
|
608
|
+
fetchList: true,
|
|
609
|
+
publish,
|
|
610
|
+
symmetricKey,
|
|
611
|
+
returnStatusListMetadata: true,
|
|
612
|
+
returnUpdatedStatusList: true,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
// default to StatusList2021
|
|
432
616
|
if (Array.isArray(credentials))
|
|
433
617
|
return await agent.cheqdUnsuspendCredentials({ credentials, fetchList: true, publish });
|
|
434
618
|
return await agent.cheqdUnsuspendCredential({
|
|
@@ -440,53 +624,71 @@ export class Veramo {
|
|
|
440
624
|
returnUpdatedStatusList: true,
|
|
441
625
|
});
|
|
442
626
|
}
|
|
443
|
-
async
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
627
|
+
async updateUnencryptedStatusList(agent, did, listType, statusOptions) {
|
|
628
|
+
if (listType === StatusListType.Bitstring) {
|
|
629
|
+
return await agent.cheqdBulkUpdateCredentialsWithStatusList({
|
|
630
|
+
newStatus: BitstringStatusActions[statusOptions.statusAction],
|
|
631
|
+
updateOptions: {
|
|
632
|
+
issuerDid: did,
|
|
633
|
+
statusListIndices: statusOptions.indices,
|
|
634
|
+
statusListName: statusOptions.statusListName,
|
|
635
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
636
|
+
},
|
|
637
|
+
fetchList: true,
|
|
638
|
+
publish: true,
|
|
639
|
+
publishEncrypted: false,
|
|
640
|
+
returnUpdatedStatusList: true,
|
|
641
|
+
returnStatusListMetadata: true,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
switch (statusOptions.statusAction) {
|
|
646
|
+
case DefaultStatusActions.revoke:
|
|
647
|
+
return await agent.cheqdRevokeCredentials({
|
|
648
|
+
revocationOptions: {
|
|
649
|
+
issuerDid: did,
|
|
650
|
+
statusListIndices: statusOptions.indices,
|
|
651
|
+
statusListName: statusOptions.statusListName,
|
|
652
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
653
|
+
},
|
|
654
|
+
fetchList: true,
|
|
655
|
+
publish: true,
|
|
656
|
+
publishEncrypted: false,
|
|
657
|
+
returnUpdatedStatusList: true,
|
|
658
|
+
returnStatusListMetadata: true,
|
|
659
|
+
});
|
|
660
|
+
case DefaultStatusActions.suspend:
|
|
661
|
+
return await agent.cheqdSuspendCredentials({
|
|
662
|
+
suspensionOptions: {
|
|
663
|
+
issuerDid: did,
|
|
664
|
+
statusListIndices: statusOptions.indices,
|
|
665
|
+
statusListName: statusOptions.statusListName,
|
|
666
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
667
|
+
},
|
|
668
|
+
fetchList: true,
|
|
669
|
+
publish: true,
|
|
670
|
+
publishEncrypted: false,
|
|
671
|
+
returnUpdatedStatusList: true,
|
|
672
|
+
returnStatusListMetadata: true,
|
|
673
|
+
});
|
|
674
|
+
case DefaultStatusActions.reinstate:
|
|
675
|
+
return await agent.cheqdUnsuspendCredentials({
|
|
676
|
+
unsuspensionOptions: {
|
|
677
|
+
issuerDid: did,
|
|
678
|
+
statusListIndices: statusOptions.indices,
|
|
679
|
+
statusListName: statusOptions.statusListName,
|
|
680
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
681
|
+
},
|
|
682
|
+
fetchList: true,
|
|
683
|
+
publish: true,
|
|
684
|
+
publishEncrypted: false,
|
|
685
|
+
returnUpdatedStatusList: true,
|
|
686
|
+
returnStatusListMetadata: true,
|
|
687
|
+
});
|
|
688
|
+
}
|
|
487
689
|
}
|
|
488
690
|
}
|
|
489
|
-
async
|
|
691
|
+
async updateEncryptedStatusList(agent, did, listType, statusOptions) {
|
|
490
692
|
// construct payment conditions
|
|
491
693
|
const paymentConditions = (statusOptions?.paymentConditions
|
|
492
694
|
? statusOptions.paymentConditions.map((condition) => {
|
|
@@ -505,13 +707,13 @@ export class Veramo {
|
|
|
505
707
|
return undefined;
|
|
506
708
|
// validate relevant components - case: feePaymentAddress
|
|
507
709
|
if (!statusOptions.feePaymentAddress)
|
|
508
|
-
throw new Error('
|
|
710
|
+
throw new Error('updateEncryptedStatusList: feePaymentAddress is required');
|
|
509
711
|
// validate relevant components - case: feePaymentAmount
|
|
510
712
|
if (!statusOptions.feePaymentAmount)
|
|
511
|
-
throw new Error('
|
|
713
|
+
throw new Error('updateEncryptedStatusList: feePaymentAmount is required');
|
|
512
714
|
// validate relevant components - case: feePaymentWindow
|
|
513
715
|
if (!statusOptions.feePaymentWindow)
|
|
514
|
-
throw new Error('
|
|
716
|
+
throw new Error('updateEncryptedStatusList: feePaymentWindow is required');
|
|
515
717
|
return [
|
|
516
718
|
{
|
|
517
719
|
feePaymentAddress: statusOptions.feePaymentAddress,
|
|
@@ -521,61 +723,83 @@ export class Veramo {
|
|
|
521
723
|
},
|
|
522
724
|
];
|
|
523
725
|
})());
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
726
|
+
if (listType === StatusListType.Bitstring) {
|
|
727
|
+
return await agent.cheqdBulkUpdateCredentialsWithStatusList({
|
|
728
|
+
newStatus: BitstringStatusActions[statusOptions.statusAction],
|
|
729
|
+
updateOptions: {
|
|
730
|
+
issuerDid: did,
|
|
731
|
+
statusListIndices: statusOptions.indices,
|
|
732
|
+
statusListName: statusOptions.statusListName,
|
|
733
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
734
|
+
},
|
|
735
|
+
symmetricKey: statusOptions.symmetricKey,
|
|
736
|
+
paymentConditions,
|
|
737
|
+
fetchList: true,
|
|
738
|
+
publish: true,
|
|
739
|
+
publishEncrypted: true,
|
|
740
|
+
returnSymmetricKey: true,
|
|
741
|
+
returnUpdatedStatusList: true,
|
|
742
|
+
returnStatusListMetadata: true,
|
|
743
|
+
dkgOptions: toDefaultDkg(did),
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
switch (statusOptions.statusAction) {
|
|
748
|
+
case DefaultStatusActions.revoke:
|
|
749
|
+
return await agent.cheqdRevokeCredentials({
|
|
750
|
+
revocationOptions: {
|
|
751
|
+
issuerDid: did,
|
|
752
|
+
statusListIndices: statusOptions.indices,
|
|
753
|
+
statusListName: statusOptions.statusListName,
|
|
754
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
755
|
+
},
|
|
756
|
+
symmetricKey: statusOptions.symmetricKey,
|
|
757
|
+
paymentConditions,
|
|
758
|
+
fetchList: true,
|
|
759
|
+
publish: true,
|
|
760
|
+
publishEncrypted: true,
|
|
761
|
+
returnSymmetricKey: true,
|
|
762
|
+
returnUpdatedStatusList: true,
|
|
763
|
+
returnStatusListMetadata: true,
|
|
764
|
+
dkgOptions: toDefaultDkg(did),
|
|
765
|
+
});
|
|
766
|
+
case DefaultStatusActions.suspend:
|
|
767
|
+
return await agent.cheqdSuspendCredentials({
|
|
768
|
+
suspensionOptions: {
|
|
769
|
+
issuerDid: did,
|
|
770
|
+
statusListIndices: statusOptions.indices,
|
|
771
|
+
statusListName: statusOptions.statusListName,
|
|
772
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
773
|
+
},
|
|
774
|
+
symmetricKey: statusOptions.symmetricKey,
|
|
775
|
+
paymentConditions,
|
|
776
|
+
fetchList: true,
|
|
777
|
+
publish: true,
|
|
778
|
+
publishEncrypted: true,
|
|
779
|
+
returnSymmetricKey: true,
|
|
780
|
+
returnUpdatedStatusList: true,
|
|
781
|
+
returnStatusListMetadata: true,
|
|
782
|
+
dkgOptions: toDefaultDkg(did),
|
|
783
|
+
});
|
|
784
|
+
case DefaultStatusActions.reinstate:
|
|
785
|
+
return await agent.cheqdUnsuspendCredentials({
|
|
786
|
+
unsuspensionOptions: {
|
|
787
|
+
issuerDid: did,
|
|
788
|
+
statusListIndices: statusOptions.indices,
|
|
789
|
+
statusListName: statusOptions.statusListName,
|
|
790
|
+
statusListVersion: statusOptions.statusListVersion,
|
|
791
|
+
},
|
|
792
|
+
symmetricKey: statusOptions.symmetricKey,
|
|
793
|
+
paymentConditions,
|
|
794
|
+
fetchList: true,
|
|
795
|
+
publish: true,
|
|
796
|
+
publishEncrypted: true,
|
|
797
|
+
returnSymmetricKey: true,
|
|
798
|
+
returnUpdatedStatusList: true,
|
|
799
|
+
returnStatusListMetadata: true,
|
|
800
|
+
dkgOptions: toDefaultDkg(did),
|
|
801
|
+
});
|
|
802
|
+
}
|
|
579
803
|
}
|
|
580
804
|
}
|
|
581
805
|
async checkStatusList2021(agent, did, statusOptions) {
|
|
@@ -588,9 +812,16 @@ export class Veramo {
|
|
|
588
812
|
dkgOptions: toDefaultDkg(did),
|
|
589
813
|
});
|
|
590
814
|
}
|
|
591
|
-
async
|
|
815
|
+
async searchStatusList(did, statusListName, listType, statusPurpose) {
|
|
816
|
+
let resourceType;
|
|
817
|
+
if (listType === StatusListType.Bitstring) {
|
|
818
|
+
resourceType = BitstringStatusListResourceType;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
resourceType = DefaultStatusList2021ResourceTypes[statusPurpose];
|
|
822
|
+
}
|
|
592
823
|
// construct url
|
|
593
|
-
const url = new URL(`${process.env.RESOLVER_URL || DefaultResolverUrl}${did}?resourceName=${statusListName}&resourceType=${
|
|
824
|
+
const url = new URL(`${process.env.RESOLVER_URL || DefaultResolverUrl}${did}?resourceName=${statusListName}&resourceType=${resourceType}`);
|
|
594
825
|
try {
|
|
595
826
|
// fetch resource metadata
|
|
596
827
|
const resourceMetadataVersioned = (await (await fetch(url, {
|
|
@@ -626,7 +857,7 @@ export class Veramo {
|
|
|
626
857
|
}
|
|
627
858
|
catch (error) {
|
|
628
859
|
// silent fail
|
|
629
|
-
console.error(`
|
|
860
|
+
console.error(`searchStatusList: fetch: failed: ${error}`);
|
|
630
861
|
// return result
|
|
631
862
|
return {
|
|
632
863
|
found: false,
|