@cheqd/studio 3.7.0-develop.1 → 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.
Files changed (98) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +3 -3
  3. package/dist/app.js.map +1 -1
  4. package/dist/controllers/api/accreditation.d.ts +6 -6
  5. package/dist/controllers/api/accreditation.d.ts.map +1 -1
  6. package/dist/controllers/api/accreditation.js +20 -16
  7. package/dist/controllers/api/accreditation.js.map +1 -1
  8. package/dist/controllers/api/credential-status.d.ts +103 -16
  9. package/dist/controllers/api/credential-status.d.ts.map +1 -1
  10. package/dist/controllers/api/credential-status.js +321 -61
  11. package/dist/controllers/api/credential-status.js.map +1 -1
  12. package/dist/controllers/api/credential.d.ts +33 -8
  13. package/dist/controllers/api/credential.d.ts.map +1 -1
  14. package/dist/controllers/api/credential.js +53 -30
  15. package/dist/controllers/api/credential.js.map +1 -1
  16. package/dist/controllers/api/did.d.ts.map +1 -1
  17. package/dist/controllers/api/did.js +8 -0
  18. package/dist/controllers/api/did.js.map +1 -1
  19. package/dist/controllers/validator/credential-status.d.ts.map +1 -1
  20. package/dist/controllers/validator/credential-status.js +19 -5
  21. package/dist/controllers/validator/credential-status.js.map +1 -1
  22. package/dist/controllers/validator/service-create-request.d.ts.map +1 -1
  23. package/dist/controllers/validator/service-create-request.js +16 -0
  24. package/dist/controllers/validator/service-create-request.js.map +1 -1
  25. package/dist/controllers/validator/service.d.ts.map +1 -1
  26. package/dist/controllers/validator/service.js +16 -0
  27. package/dist/controllers/validator/service.js.map +1 -1
  28. package/dist/database/entities/api.key.entity.js +1 -1
  29. package/dist/database/entities/payment.entity.d.ts.map +1 -1
  30. package/dist/database/entities/payment.entity.js +4 -1
  31. package/dist/database/entities/payment.entity.js.map +1 -1
  32. package/dist/database/entities/resource.entity.js.map +1 -1
  33. package/dist/database/entities/subscription.entity.js.map +1 -1
  34. package/dist/database/migrations/1750427001486-studio-migrations.d.ts +1 -1
  35. package/dist/database/migrations/1750427001486-studio-migrations.d.ts.map +1 -1
  36. package/dist/database/migrations/1750427001486-studio-migrations.js +0 -2
  37. package/dist/database/migrations/1750427001486-studio-migrations.js.map +1 -1
  38. package/dist/database/migrations/custom/1748331341024-Cleanup.d.ts +1 -1
  39. package/dist/database/migrations/custom/1748331341024-Cleanup.d.ts.map +1 -1
  40. package/dist/database/migrations/custom/1748331341024-Cleanup.js +1 -1
  41. package/dist/database/migrations/custom/1748331341024-Cleanup.js.map +1 -1
  42. package/dist/database/scripts/add-migration-to-types.js +6 -5
  43. package/dist/database/scripts/add-migration-to-types.js.map +1 -1
  44. package/dist/middleware/auth/auth-gaurd.js +1 -1
  45. package/dist/middleware/auth/auth-gaurd.js.map +1 -1
  46. package/dist/services/identity/abstract.d.ts +11 -8
  47. package/dist/services/identity/abstract.d.ts.map +1 -1
  48. package/dist/services/identity/abstract.js +15 -6
  49. package/dist/services/identity/abstract.js.map +1 -1
  50. package/dist/services/identity/agent.d.ts +10 -7
  51. package/dist/services/identity/agent.d.ts.map +1 -1
  52. package/dist/services/identity/agent.js +370 -139
  53. package/dist/services/identity/agent.js.map +1 -1
  54. package/dist/services/identity/default.d.ts +1 -1
  55. package/dist/services/identity/default.d.ts.map +1 -1
  56. package/dist/services/identity/default.js +2 -2
  57. package/dist/services/identity/default.js.map +1 -1
  58. package/dist/services/identity/index.d.ts +11 -8
  59. package/dist/services/identity/index.d.ts.map +1 -1
  60. package/dist/services/identity/index.js.map +1 -1
  61. package/dist/services/identity/local.d.ts +9 -6
  62. package/dist/services/identity/local.d.ts.map +1 -1
  63. package/dist/services/identity/local.js +18 -10
  64. package/dist/services/identity/local.js.map +1 -1
  65. package/dist/services/identity/postgres.d.ts +9 -6
  66. package/dist/services/identity/postgres.d.ts.map +1 -1
  67. package/dist/services/identity/postgres.js +24 -10
  68. package/dist/services/identity/postgres.js.map +1 -1
  69. package/dist/services/track/operation-subscriber.d.ts.map +1 -1
  70. package/dist/services/track/operation-subscriber.js +18 -16
  71. package/dist/services/track/operation-subscriber.js.map +1 -1
  72. package/dist/services/w3c-credential.d.ts +2 -2
  73. package/dist/services/w3c-credential.d.ts.map +1 -1
  74. package/dist/services/w3c-credential.js +2 -1
  75. package/dist/services/w3c-credential.js.map +1 -1
  76. package/dist/static/swagger-api.json +289 -43
  77. package/dist/types/accreditation.d.ts +11 -14
  78. package/dist/types/accreditation.d.ts.map +1 -1
  79. package/dist/types/accreditation.js +6 -0
  80. package/dist/types/accreditation.js.map +1 -1
  81. package/dist/types/constants.d.ts +1 -0
  82. package/dist/types/constants.d.ts.map +1 -1
  83. package/dist/types/constants.js +1 -0
  84. package/dist/types/constants.js.map +1 -1
  85. package/dist/types/credential-status.d.ts +40 -8
  86. package/dist/types/credential-status.d.ts.map +1 -1
  87. package/dist/types/credential-status.js +11 -0
  88. package/dist/types/credential-status.js.map +1 -1
  89. package/dist/types/credential.d.ts +7 -10
  90. package/dist/types/credential.d.ts.map +1 -1
  91. package/dist/types/credential.js.map +1 -1
  92. package/dist/types/swagger-api-types.d.ts +62 -12
  93. package/dist/types/swagger-api-types.d.ts.map +1 -1
  94. package/dist/types/swagger-api-types.js +62 -12
  95. package/dist/types/swagger-api-types.js.map +1 -1
  96. package/dist/types/validation.d.ts +4 -0
  97. package/dist/types/validation.d.ts.map +1 -1
  98. 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, DefaultStatusList2021ResourceTypes, DefaultStatusList2021StatusPurposeTypes, DefaultStatusList2021Encodings, } from '@cheqd/did-provider-cheqd';
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
- verifiable_credential =
199
- statusListOptions.statusPurpose == 'revocation'
200
- ? await agent.cheqdIssueRevocableCredentialWithStatusList2021({
201
- issuanceOptions,
202
- statusOptions: statusListOptions,
203
- })
204
- : await agent.cheqdIssueSuspendableCredentialWithStatusList2021({
205
- issuanceOptions,
206
- statusOptions: statusListOptions,
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
- result = await agent.cheqdVerifyCredential({
222
- credential: credential,
223
- fetchList: true,
224
- verificationArgs: {
225
- ...verificationOptions,
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
- result = await agent.cheqdVerifyPresentation({
281
- presentation: presentation,
282
- fetchList: true,
283
- verificationArgs: {
284
- ...verificationOptions,
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 || DefaultStatusList2021Encodings.base64url,
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 || DefaultStatusList2021Encodings.base64url,
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 === 'revocation'
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 updateUnencryptedStatusList2021(agent, did, statusOptions) {
444
- switch (statusOptions.statusAction) {
445
- case DefaultStatusActions.revoke:
446
- return await agent.cheqdRevokeCredentials({
447
- revocationOptions: {
448
- issuerDid: did,
449
- statusListIndices: statusOptions.indices,
450
- statusListName: statusOptions.statusListName,
451
- statusListVersion: statusOptions.statusListVersion,
452
- },
453
- fetchList: true,
454
- publish: true,
455
- publishEncrypted: false,
456
- returnUpdatedStatusList: true,
457
- returnStatusListMetadata: true,
458
- });
459
- case DefaultStatusActions.suspend:
460
- return await agent.cheqdSuspendCredentials({
461
- suspensionOptions: {
462
- issuerDid: did,
463
- statusListIndices: statusOptions.indices,
464
- statusListName: statusOptions.statusListName,
465
- statusListVersion: statusOptions.statusListVersion,
466
- },
467
- fetchList: true,
468
- publish: true,
469
- publishEncrypted: false,
470
- returnUpdatedStatusList: true,
471
- returnStatusListMetadata: true,
472
- });
473
- case DefaultStatusActions.reinstate:
474
- return await agent.cheqdUnsuspendCredentials({
475
- unsuspensionOptions: {
476
- issuerDid: did,
477
- statusListIndices: statusOptions.indices,
478
- statusListName: statusOptions.statusListName,
479
- statusListVersion: statusOptions.statusListVersion,
480
- },
481
- fetchList: true,
482
- publish: true,
483
- publishEncrypted: false,
484
- returnUpdatedStatusList: true,
485
- returnStatusListMetadata: true,
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 updateEncryptedStatusList2021(agent, did, statusOptions) {
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('updateEncryptedStatusList2021: feePaymentAddress is required');
710
+ throw new Error('updateEncryptedStatusList: feePaymentAddress is required');
509
711
  // validate relevant components - case: feePaymentAmount
510
712
  if (!statusOptions.feePaymentAmount)
511
- throw new Error('updateEncryptedStatusList2021: feePaymentAmount is required');
713
+ throw new Error('updateEncryptedStatusList: feePaymentAmount is required');
512
714
  // validate relevant components - case: feePaymentWindow
513
715
  if (!statusOptions.feePaymentWindow)
514
- throw new Error('updateEncryptedStatusList2021: feePaymentWindow is required');
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
- switch (statusOptions.statusAction) {
525
- case DefaultStatusActions.revoke:
526
- return await agent.cheqdRevokeCredentials({
527
- revocationOptions: {
528
- issuerDid: did,
529
- statusListIndices: statusOptions.indices,
530
- statusListName: statusOptions.statusListName,
531
- statusListVersion: statusOptions.statusListVersion,
532
- },
533
- symmetricKey: statusOptions.symmetricKey,
534
- paymentConditions,
535
- fetchList: true,
536
- publish: true,
537
- publishEncrypted: true,
538
- returnSymmetricKey: true,
539
- returnUpdatedStatusList: true,
540
- returnStatusListMetadata: true,
541
- dkgOptions: toDefaultDkg(did),
542
- });
543
- case DefaultStatusActions.suspend:
544
- return await agent.cheqdSuspendCredentials({
545
- suspensionOptions: {
546
- issuerDid: did,
547
- statusListIndices: statusOptions.indices,
548
- statusListName: statusOptions.statusListName,
549
- statusListVersion: statusOptions.statusListVersion,
550
- },
551
- symmetricKey: statusOptions.symmetricKey,
552
- paymentConditions,
553
- fetchList: true,
554
- publish: true,
555
- publishEncrypted: true,
556
- returnSymmetricKey: true,
557
- returnUpdatedStatusList: true,
558
- returnStatusListMetadata: true,
559
- dkgOptions: toDefaultDkg(did),
560
- });
561
- case DefaultStatusActions.reinstate:
562
- return await agent.cheqdUnsuspendCredentials({
563
- unsuspensionOptions: {
564
- issuerDid: did,
565
- statusListIndices: statusOptions.indices,
566
- statusListName: statusOptions.statusListName,
567
- statusListVersion: statusOptions.statusListVersion,
568
- },
569
- symmetricKey: statusOptions.symmetricKey,
570
- paymentConditions,
571
- fetchList: true,
572
- publish: true,
573
- publishEncrypted: true,
574
- returnSymmetricKey: true,
575
- returnUpdatedStatusList: true,
576
- returnStatusListMetadata: true,
577
- dkgOptions: toDefaultDkg(did),
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 searchStatusList2021(did, statusListName, statusPurpose) {
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=${DefaultStatusList2021ResourceTypes[statusPurpose]}`);
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(`searchStatusList2021: fetch: failed: ${error}`);
860
+ console.error(`searchStatusList: fetch: failed: ${error}`);
630
861
  // return result
631
862
  return {
632
863
  found: false,