@cheqd/did-provider-cheqd 3.6.9 → 3.6.10-develop.2

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 (94) hide show
  1. package/build/cjs/agent/ICheqd.d.ts +2 -2
  2. package/build/cjs/agent/ICheqd.d.ts.map +1 -1
  3. package/build/cjs/agent/ICheqd.js +1011 -783
  4. package/build/cjs/agent/ICheqd.js.map +1 -1
  5. package/build/cjs/agent/index.d.ts.map +1 -1
  6. package/build/cjs/agent/index.js.map +1 -1
  7. package/build/cjs/did-manager/cheqd-did-provider.d.ts +12 -12
  8. package/build/cjs/did-manager/cheqd-did-provider.d.ts.map +1 -1
  9. package/build/cjs/did-manager/cheqd-did-provider.js +56 -41
  10. package/build/cjs/did-manager/cheqd-did-provider.js.map +1 -1
  11. package/build/cjs/did-manager/cheqd-did-resolver.d.ts.map +1 -1
  12. package/build/cjs/did-manager/cheqd-did-resolver.js.map +1 -1
  13. package/build/cjs/did-manager/index.d.ts.map +1 -1
  14. package/build/cjs/did-manager/index.js.map +1 -1
  15. package/build/cjs/did-manager/resolver.d.ts.map +1 -1
  16. package/build/cjs/did-manager/resolver.js.map +1 -1
  17. package/build/cjs/dkg-threshold/index.d.ts.map +1 -1
  18. package/build/cjs/dkg-threshold/index.js.map +1 -1
  19. package/build/cjs/dkg-threshold/lit-protocol.d.ts +3 -3
  20. package/build/cjs/dkg-threshold/lit-protocol.d.ts.map +1 -1
  21. package/build/cjs/dkg-threshold/lit-protocol.js +30 -19
  22. package/build/cjs/dkg-threshold/lit-protocol.js.map +1 -1
  23. package/build/cjs/index.d.ts.map +1 -1
  24. package/build/cjs/index.js.map +1 -1
  25. package/build/cjs/utils/env.d.ts.map +1 -1
  26. package/build/cjs/utils/env.js +11 -2
  27. package/build/cjs/utils/env.js.map +1 -1
  28. package/build/cjs/utils/helpers.d.ts.map +1 -1
  29. package/build/cjs/utils/helpers.js.map +1 -1
  30. package/build/cjs/utils/index.d.ts.map +1 -1
  31. package/build/cjs/utils/index.js.map +1 -1
  32. package/build/esm/agent/ICheqd.d.ts +2 -2
  33. package/build/esm/agent/ICheqd.d.ts.map +1 -1
  34. package/build/esm/agent/ICheqd.js +1013 -785
  35. package/build/esm/agent/ICheqd.js.map +1 -1
  36. package/build/esm/agent/index.d.ts.map +1 -1
  37. package/build/esm/agent/index.js.map +1 -1
  38. package/build/esm/did-manager/cheqd-did-provider.d.ts +12 -12
  39. package/build/esm/did-manager/cheqd-did-provider.d.ts.map +1 -1
  40. package/build/esm/did-manager/cheqd-did-provider.js +58 -43
  41. package/build/esm/did-manager/cheqd-did-provider.js.map +1 -1
  42. package/build/esm/did-manager/cheqd-did-resolver.d.ts.map +1 -1
  43. package/build/esm/did-manager/cheqd-did-resolver.js.map +1 -1
  44. package/build/esm/did-manager/index.d.ts.map +1 -1
  45. package/build/esm/did-manager/index.js.map +1 -1
  46. package/build/esm/did-manager/resolver.d.ts.map +1 -1
  47. package/build/esm/did-manager/resolver.js.map +1 -1
  48. package/build/esm/dkg-threshold/index.d.ts.map +1 -1
  49. package/build/esm/dkg-threshold/index.js.map +1 -1
  50. package/build/esm/dkg-threshold/lit-protocol.d.ts +3 -3
  51. package/build/esm/dkg-threshold/lit-protocol.d.ts.map +1 -1
  52. package/build/esm/dkg-threshold/lit-protocol.js +31 -20
  53. package/build/esm/dkg-threshold/lit-protocol.js.map +1 -1
  54. package/build/esm/index.d.ts.map +1 -1
  55. package/build/esm/index.js.map +1 -1
  56. package/build/esm/utils/env.d.ts.map +1 -1
  57. package/build/esm/utils/env.js +11 -2
  58. package/build/esm/utils/env.js.map +1 -1
  59. package/build/esm/utils/helpers.d.ts.map +1 -1
  60. package/build/esm/utils/helpers.js.map +1 -1
  61. package/build/esm/utils/index.d.ts.map +1 -1
  62. package/build/esm/utils/index.js.map +1 -1
  63. package/build/tsconfig.cjs.tsbuildinfo +1 -1
  64. package/build/tsconfig.esm.tsbuildinfo +1 -1
  65. package/build/tsconfig.types.tsbuildinfo +1 -1
  66. package/build/types/agent/ICheqd.d.ts +2 -2
  67. package/build/types/agent/ICheqd.d.ts.map +1 -1
  68. package/build/types/agent/index.d.ts.map +1 -1
  69. package/build/types/did-manager/cheqd-did-provider.d.ts +12 -12
  70. package/build/types/did-manager/cheqd-did-provider.d.ts.map +1 -1
  71. package/build/types/did-manager/cheqd-did-resolver.d.ts.map +1 -1
  72. package/build/types/did-manager/index.d.ts.map +1 -1
  73. package/build/types/did-manager/resolver.d.ts.map +1 -1
  74. package/build/types/dkg-threshold/index.d.ts.map +1 -1
  75. package/build/types/dkg-threshold/lit-protocol.d.ts +3 -3
  76. package/build/types/dkg-threshold/lit-protocol.d.ts.map +1 -1
  77. package/build/types/index.d.ts.map +1 -1
  78. package/build/types/utils/env.d.ts.map +1 -1
  79. package/build/types/utils/helpers.d.ts.map +1 -1
  80. package/build/types/utils/index.d.ts.map +1 -1
  81. package/package.json +6 -5
  82. package/src/agent/ICheqd.ts +6506 -4727
  83. package/src/agent/index.ts +1 -1
  84. package/src/did-manager/cheqd-did-provider.ts +364 -325
  85. package/src/did-manager/cheqd-did-resolver.ts +34 -40
  86. package/src/did-manager/index.ts +3 -3
  87. package/src/did-manager/resolver.ts +30 -32
  88. package/src/dkg-threshold/index.ts +1 -1
  89. package/src/dkg-threshold/lit-protocol.ts +272 -240
  90. package/src/global.d.ts +1 -1
  91. package/src/index.ts +5 -5
  92. package/src/utils/env.ts +18 -6
  93. package/src/utils/helpers.ts +33 -38
  94. package/src/utils/index.ts +2 -2
@@ -20,8 +20,18 @@ const lit_protocol_js_1 = require("../dkg-threshold/lit-protocol.js");
20
20
  const helpers_js_1 = require("../utils/helpers.js");
21
21
  const cheqd_did_resolver_js_1 = require("../did-manager/cheqd-did-resolver.js");
22
22
  const debug = (0, debug_1.default)('veramo:did-provider-cheqd');
23
- exports.AccessControlConditionTypes = { timelockPayment: 'timelockPayment', memoNonce: 'memoNonce', balance: 'balance' };
24
- exports.AccessControlConditionReturnValueComparators = { lessThan: '<', greaterThan: '>', equalTo: '=', lessThanOrEqualTo: '<=', greaterThanOrEqualTo: '>=' };
23
+ exports.AccessControlConditionTypes = {
24
+ timelockPayment: 'timelockPayment',
25
+ memoNonce: 'memoNonce',
26
+ balance: 'balance',
27
+ };
28
+ exports.AccessControlConditionReturnValueComparators = {
29
+ lessThan: '<',
30
+ greaterThan: '>',
31
+ equalTo: '=',
32
+ lessThanOrEqualTo: '<=',
33
+ greaterThanOrEqualTo: '>=',
34
+ };
25
35
  exports.RemoteListPattern = /^(https:\/\/)?[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,}\/1\.0\/identifiers\/did:cheqd:[a-z]+:[a-zA-Z0-9-]+\?((resourceName=[^&]*)&(resourceType=[^&]*)|((resourceType=[^&]*)&(resourceName=[^&]*)))$/;
26
36
  exports.CreateIdentifierMethodName = 'cheqdCreateIdentifier';
27
37
  exports.UpdateIdentifierMethodName = 'cheqdUpdateIdentifier';
@@ -52,434 +62,392 @@ exports.CheqdDidMethod = 'cheqd';
52
62
  class Cheqd {
53
63
  methods;
54
64
  schema = {
55
- "components": {
56
- "schemas": {},
57
- "methods": {
58
- "cheqdCreateIdentifier": {
59
- "description": "Create a new identifier",
60
- "arguments": {
61
- "type": "object",
62
- "properties": {
63
- "args": {
64
- "type": "object",
65
- "description": "A cheqdCreateIdentifierArgs object as any for extensibility"
66
- }
65
+ components: {
66
+ schemas: {},
67
+ methods: {
68
+ cheqdCreateIdentifier: {
69
+ description: 'Create a new identifier',
70
+ arguments: {
71
+ type: 'object',
72
+ properties: {
73
+ args: {
74
+ type: 'object',
75
+ description: 'A cheqdCreateIdentifierArgs object as any for extensibility',
76
+ },
67
77
  },
68
- "required": [
69
- "args"
70
- ]
78
+ required: ['args'],
79
+ },
80
+ returnType: {
81
+ type: 'object',
71
82
  },
72
- "returnType": {
73
- "type": "object"
74
- }
75
83
  },
76
- "cheqdUpdateIdentifier": {
77
- "description": "Update an identifier",
78
- "arguments": {
79
- "type": "object",
80
- "properties": {
81
- "args": {
82
- "type": "object",
83
- "description": "A cheqdUpdateIdentifierArgs object as any for extensibility"
84
- }
84
+ cheqdUpdateIdentifier: {
85
+ description: 'Update an identifier',
86
+ arguments: {
87
+ type: 'object',
88
+ properties: {
89
+ args: {
90
+ type: 'object',
91
+ description: 'A cheqdUpdateIdentifierArgs object as any for extensibility',
92
+ },
85
93
  },
86
- "required": [
87
- "args"
88
- ]
94
+ required: ['args'],
95
+ },
96
+ returnType: {
97
+ type: 'object',
89
98
  },
90
- "returnType": {
91
- "type": "object"
92
- }
93
99
  },
94
- "cheqdDeactivateIdentifier": {
95
- "description": "Deactivate an identifier",
96
- "arguments": {
97
- "type": "object",
98
- "properties": {
99
- "args": {
100
- "type": "object",
101
- "description": "A cheqdDeactivateIdentifierArgs object as any for extensibility"
102
- }
100
+ cheqdDeactivateIdentifier: {
101
+ description: 'Deactivate an identifier',
102
+ arguments: {
103
+ type: 'object',
104
+ properties: {
105
+ args: {
106
+ type: 'object',
107
+ description: 'A cheqdDeactivateIdentifierArgs object as any for extensibility',
108
+ },
103
109
  },
104
- "required": [
105
- "args"
106
- ]
110
+ required: ['args'],
111
+ },
112
+ returnType: {
113
+ type: 'object',
107
114
  },
108
- "returnType": {
109
- "type": "object"
110
- }
111
115
  },
112
- "cheqdCreateLinkedResource": {
113
- "description": "Create a new resource",
114
- "arguments": {
115
- "type": "object",
116
- "properties": {
117
- "args": {
118
- "type": "object",
119
- "description": "A cheqdCreateLinkedResource object as any for extensibility"
120
- }
116
+ cheqdCreateLinkedResource: {
117
+ description: 'Create a new resource',
118
+ arguments: {
119
+ type: 'object',
120
+ properties: {
121
+ args: {
122
+ type: 'object',
123
+ description: 'A cheqdCreateLinkedResource object as any for extensibility',
124
+ },
121
125
  },
122
- "required": [
123
- "args"
124
- ]
126
+ required: ['args'],
127
+ },
128
+ returnType: {
129
+ type: 'boolean',
125
130
  },
126
- "returnType": {
127
- "type": "boolean"
128
- }
129
131
  },
130
- "cheqdCreateStatusList2021": {
131
- "description": "Create a new Status List 2021",
132
- "arguments": {
133
- "type": "object",
134
- "properties": {
135
- "args": {
136
- "type": "object",
137
- "description": "A cheqdCreateStatusList2021Args object as any for extensibility"
138
- }
132
+ cheqdCreateStatusList2021: {
133
+ description: 'Create a new Status List 2021',
134
+ arguments: {
135
+ type: 'object',
136
+ properties: {
137
+ args: {
138
+ type: 'object',
139
+ description: 'A cheqdCreateStatusList2021Args object as any for extensibility',
140
+ },
139
141
  },
140
- "required": [
141
- "args"
142
- ]
142
+ required: ['args'],
143
+ },
144
+ returnType: {
145
+ type: 'object',
143
146
  },
144
- "returnType": {
145
- "type": "object"
146
- }
147
147
  },
148
- "cheqdBroadcastStatusList2021": {
149
- "description": "Broadcast a Status List 2021 to cheqd ledger",
150
- "arguments": {
151
- "type": "object",
152
- "properties": {
153
- "args": {
154
- "type": "object",
155
- "description": "A cheqdBroadcastStatusList2021Args object as any for extensibility"
156
- }
148
+ cheqdBroadcastStatusList2021: {
149
+ description: 'Broadcast a Status List 2021 to cheqd ledger',
150
+ arguments: {
151
+ type: 'object',
152
+ properties: {
153
+ args: {
154
+ type: 'object',
155
+ description: 'A cheqdBroadcastStatusList2021Args object as any for extensibility',
156
+ },
157
157
  },
158
- "required": [
159
- "args"
160
- ]
158
+ required: ['args'],
159
+ },
160
+ returnType: {
161
+ type: 'object',
161
162
  },
162
- "returnType": {
163
- "type": "object"
164
- }
165
163
  },
166
- "cheqdGenerateDidDoc": {
167
- "description": "Generate a new DID document to use with `createIdentifier`",
168
- "arguments": {
169
- "type": "object",
170
- "properties": {
171
- "args": {
172
- "type": "object",
173
- "description": "A cheqdGenerateDidDocArgs object as any for extensibility"
174
- }
164
+ cheqdGenerateDidDoc: {
165
+ description: 'Generate a new DID document to use with `createIdentifier`',
166
+ arguments: {
167
+ type: 'object',
168
+ properties: {
169
+ args: {
170
+ type: 'object',
171
+ description: 'A cheqdGenerateDidDocArgs object as any for extensibility',
172
+ },
175
173
  },
176
- "required": [
177
- "args"
178
- ]
174
+ required: ['args'],
175
+ },
176
+ returnType: {
177
+ type: 'object',
179
178
  },
180
- "returnType": {
181
- "type": "object"
182
- }
183
179
  },
184
- "cheqdGenerateDidDocWithLinkedResource": {
185
- "description": "Generate a new DID document to use with `createIdentifier` and / or `createResource`",
186
- "arguments": {
187
- "type": "object",
188
- "properties": {
189
- "args": {
190
- "type": "object",
191
- "description": "A cheqdGenerateDidDocWithLinkedResourceArgs object as any for extensibility"
192
- }
180
+ cheqdGenerateDidDocWithLinkedResource: {
181
+ description: 'Generate a new DID document to use with `createIdentifier` and / or `createResource`',
182
+ arguments: {
183
+ type: 'object',
184
+ properties: {
185
+ args: {
186
+ type: 'object',
187
+ description: 'A cheqdGenerateDidDocWithLinkedResourceArgs object as any for extensibility',
188
+ },
193
189
  },
194
- "required": [
195
- "args"
196
- ]
190
+ required: ['args'],
191
+ },
192
+ returnType: {
193
+ type: 'object',
197
194
  },
198
- "returnType": {
199
- "type": "object"
200
- }
201
195
  },
202
- "cheqdGenerateIdentityKeys": {
203
- "description": "Generate a new key pair in hex to use with `createIdentifier`",
204
- "arguments": {
205
- "type": "object",
206
- "properties": {
207
- "args": {
208
- "type": "object",
209
- "description": "A cheqdGenerateIdentityKeysArgs object as any for extensibility"
210
- }
211
- }
196
+ cheqdGenerateIdentityKeys: {
197
+ description: 'Generate a new key pair in hex to use with `createIdentifier`',
198
+ arguments: {
199
+ type: 'object',
200
+ properties: {
201
+ args: {
202
+ type: 'object',
203
+ description: 'A cheqdGenerateIdentityKeysArgs object as any for extensibility',
204
+ },
205
+ },
206
+ },
207
+ returnType: {
208
+ type: 'object',
212
209
  },
213
- "returnType": {
214
- "type": "object"
215
- }
216
210
  },
217
- "cheqdGenerateVersionId": {
218
- "description": "Generate a random uuid",
219
- "arguments": {
220
- "type": "object",
221
- "properties": {
222
- "args": {
223
- "type": "object",
224
- "description": "A cheqdGenerateVersionIdArgs object as any for extensibility"
225
- }
211
+ cheqdGenerateVersionId: {
212
+ description: 'Generate a random uuid',
213
+ arguments: {
214
+ type: 'object',
215
+ properties: {
216
+ args: {
217
+ type: 'object',
218
+ description: 'A cheqdGenerateVersionIdArgs object as any for extensibility',
219
+ },
226
220
  },
227
221
  },
228
- "returnType": {
229
- "type": "object"
230
- }
222
+ returnType: {
223
+ type: 'object',
224
+ },
231
225
  },
232
- "cheqdGenerateStatusList2021": {
233
- "description": "Generate a new Status List 2021",
234
- "arguments": {
235
- "type": "object",
236
- "properties": {
237
- "args": {
238
- "type": "object",
239
- "description": "A cheqdGenerateStatusList2021Args object as any for extensibility"
240
- }
226
+ cheqdGenerateStatusList2021: {
227
+ description: 'Generate a new Status List 2021',
228
+ arguments: {
229
+ type: 'object',
230
+ properties: {
231
+ args: {
232
+ type: 'object',
233
+ description: 'A cheqdGenerateStatusList2021Args object as any for extensibility',
234
+ },
241
235
  },
242
236
  },
243
- "returnType": {
244
- "type": "string"
245
- }
237
+ returnType: {
238
+ type: 'string',
239
+ },
246
240
  },
247
- "cheqdIssueRevocableCredentialWithStatusList2021": {
248
- "description": "Issue a revocable credential with a Status List 2021 as credential status registry",
249
- "arguments": {
250
- "type": "object",
251
- "properties": {
252
- "args": {
253
- "type": "object",
254
- "description": "A cheqdIssueCredentialWithStatusList2021Args object as any for extensibility"
255
- }
241
+ cheqdIssueRevocableCredentialWithStatusList2021: {
242
+ description: 'Issue a revocable credential with a Status List 2021 as credential status registry',
243
+ arguments: {
244
+ type: 'object',
245
+ properties: {
246
+ args: {
247
+ type: 'object',
248
+ description: 'A cheqdIssueCredentialWithStatusList2021Args object as any for extensibility',
249
+ },
256
250
  },
257
- "required": [
258
- "args"
259
- ]
251
+ required: ['args'],
252
+ },
253
+ returnType: {
254
+ type: 'object',
260
255
  },
261
- "returnType": {
262
- "type": "object"
263
- }
264
256
  },
265
- "cheqdIssueSuspendableCredentialWithStatusList2021": {
266
- "description": "Issue a suspendable credential with a Status List 2021 as credential status registry",
267
- "arguments": {
268
- "type": "object",
269
- "properties": {
270
- "args": {
271
- "type": "object",
272
- "description": "A cheqdIssueCredentialWithStatusList2021Args object as any for extensibility"
273
- }
257
+ cheqdIssueSuspendableCredentialWithStatusList2021: {
258
+ description: 'Issue a suspendable credential with a Status List 2021 as credential status registry',
259
+ arguments: {
260
+ type: 'object',
261
+ properties: {
262
+ args: {
263
+ type: 'object',
264
+ description: 'A cheqdIssueCredentialWithStatusList2021Args object as any for extensibility',
265
+ },
274
266
  },
275
- "required": [
276
- "args"
277
- ]
267
+ required: ['args'],
268
+ },
269
+ returnType: {
270
+ type: 'object',
278
271
  },
279
- "returnType": {
280
- "type": "object"
281
- }
282
272
  },
283
- "cheqdVerifyCredential": {
284
- "description": "Verify a credential, enhanced by revocation / suspension check with a Status List 2021 as credential status registry",
285
- "arguments": {
286
- "type": "object",
287
- "properties": {
288
- "args": {
289
- "type": "object",
290
- "description": "A cheqdVerifyCredentialWithStatusList2021Args object as any for extensibility"
291
- }
273
+ cheqdVerifyCredential: {
274
+ description: 'Verify a credential, enhanced by revocation / suspension check with a Status List 2021 as credential status registry',
275
+ arguments: {
276
+ type: 'object',
277
+ properties: {
278
+ args: {
279
+ type: 'object',
280
+ description: 'A cheqdVerifyCredentialWithStatusList2021Args object as any for extensibility',
281
+ },
292
282
  },
293
- "required": [
294
- "args"
295
- ]
283
+ required: ['args'],
284
+ },
285
+ returnType: {
286
+ type: 'object',
296
287
  },
297
- "returnType": {
298
- "type": "object"
299
- }
300
288
  },
301
- "cheqdVerifyPresentation": {
302
- "description": "Verify a presentation, enhanced by revocation / suspension check with a Status List 2021 as credential status registry",
303
- "arguments": {
304
- "type": "object",
305
- "properties": {
306
- "args": {
307
- "type": "object",
308
- "description": "A cheqdVerifyPresentationWithStatusList2021Args object as any for extensibility"
309
- }
289
+ cheqdVerifyPresentation: {
290
+ description: 'Verify a presentation, enhanced by revocation / suspension check with a Status List 2021 as credential status registry',
291
+ arguments: {
292
+ type: 'object',
293
+ properties: {
294
+ args: {
295
+ type: 'object',
296
+ description: 'A cheqdVerifyPresentationWithStatusList2021Args object as any for extensibility',
297
+ },
310
298
  },
311
- "required": [
312
- "args"
313
- ]
299
+ required: ['args'],
300
+ },
301
+ returnType: {
302
+ type: 'object',
314
303
  },
315
- "returnType": {
316
- "type": "object"
317
- }
318
304
  },
319
- "cheqdCheckCredentialStatus": {
320
- "description": "Check the revocation / suspension status of a credential with a Status List 2021 as credential status registry",
321
- "arguments": {
322
- "type": "object",
323
- "properties": {
324
- "args": {
325
- "type": "object",
326
- "description": "A cheqdCheckCredentialStatusWithStatusList2021Args object as any for extensibility"
327
- }
305
+ cheqdCheckCredentialStatus: {
306
+ description: 'Check the revocation / suspension status of a credential with a Status List 2021 as credential status registry',
307
+ arguments: {
308
+ type: 'object',
309
+ properties: {
310
+ args: {
311
+ type: 'object',
312
+ description: 'A cheqdCheckCredentialStatusWithStatusList2021Args object as any for extensibility',
313
+ },
328
314
  },
329
- "required": [
330
- "args"
331
- ]
315
+ required: ['args'],
316
+ },
317
+ returnType: {
318
+ type: 'object',
332
319
  },
333
- "returnType": {
334
- "type": "object"
335
- }
336
320
  },
337
- "cheqdRevokeCredential": {
338
- "description": "Revoke a credential against a Status List 2021 as credential status registry",
339
- "arguments": {
340
- "type": "object",
341
- "properties": {
342
- "args": {
343
- "type": "object",
344
- "description": "A cheqdRevokeCredentialWithStatusList2021Args object as any for extensibility"
345
- }
321
+ cheqdRevokeCredential: {
322
+ description: 'Revoke a credential against a Status List 2021 as credential status registry',
323
+ arguments: {
324
+ type: 'object',
325
+ properties: {
326
+ args: {
327
+ type: 'object',
328
+ description: 'A cheqdRevokeCredentialWithStatusList2021Args object as any for extensibility',
329
+ },
346
330
  },
347
- "required": [
348
- "args"
349
- ]
331
+ required: ['args'],
332
+ },
333
+ returnType: {
334
+ type: 'object',
350
335
  },
351
- "returnType": {
352
- "type": "object"
353
- }
354
336
  },
355
- "cheqdRevokeCredentials": {
356
- "description": "Revoke multiple credentials against a Status List 2021 as credential status registry",
357
- "arguments": {
358
- "type": "object",
359
- "properties": {
360
- "args": {
361
- "type": "object",
362
- "description": "A cheqdRevokeBulkCredentialsWithStatusList2021Args object as any for extensibility"
363
- }
337
+ cheqdRevokeCredentials: {
338
+ description: 'Revoke multiple credentials against a Status List 2021 as credential status registry',
339
+ arguments: {
340
+ type: 'object',
341
+ properties: {
342
+ args: {
343
+ type: 'object',
344
+ description: 'A cheqdRevokeBulkCredentialsWithStatusList2021Args object as any for extensibility',
345
+ },
364
346
  },
365
- "required": [
366
- "args"
367
- ]
347
+ required: ['args'],
348
+ },
349
+ returnType: {
350
+ type: 'array',
368
351
  },
369
- "returnType": {
370
- "type": "array"
371
- }
372
352
  },
373
- "cheqdSuspendCredential": {
374
- "description": "Suspend a credential against a Status List 2021 as credential status registry",
375
- "arguments": {
376
- "type": "object",
377
- "properties": {
378
- "args": {
379
- "type": "object",
380
- "description": "A cheqdSuspendCredentialWithStatusList2021Args object as any for extensibility"
381
- }
353
+ cheqdSuspendCredential: {
354
+ description: 'Suspend a credential against a Status List 2021 as credential status registry',
355
+ arguments: {
356
+ type: 'object',
357
+ properties: {
358
+ args: {
359
+ type: 'object',
360
+ description: 'A cheqdSuspendCredentialWithStatusList2021Args object as any for extensibility',
361
+ },
382
362
  },
383
- "required": [
384
- "args"
385
- ]
363
+ required: ['args'],
364
+ },
365
+ returnType: {
366
+ type: 'object',
386
367
  },
387
- "returnType": {
388
- "type": "object"
389
- }
390
368
  },
391
- "cheqdSuspendCredentials": {
392
- "description": "Suspend multiple credentials against a Status List 2021 as credential status registry",
393
- "arguments": {
394
- "type": "object",
395
- "properties": {
396
- "args": {
397
- "type": "object",
398
- "description": "A cheqdSuspendBulkCredentialsWithStatusList2021Args object as any for extensibility"
399
- }
369
+ cheqdSuspendCredentials: {
370
+ description: 'Suspend multiple credentials against a Status List 2021 as credential status registry',
371
+ arguments: {
372
+ type: 'object',
373
+ properties: {
374
+ args: {
375
+ type: 'object',
376
+ description: 'A cheqdSuspendBulkCredentialsWithStatusList2021Args object as any for extensibility',
377
+ },
400
378
  },
401
- "required": [
402
- "args"
403
- ]
379
+ required: ['args'],
380
+ },
381
+ returnType: {
382
+ type: 'array',
404
383
  },
405
- "returnType": {
406
- "type": "array"
407
- }
408
384
  },
409
- "cheqdUnsuspendCredential": {
410
- "description": "Unsuspend a credential against a Status List 2021 as credential status registry",
411
- "arguments": {
412
- "type": "object",
413
- "properties": {
414
- "args": {
415
- "type": "object",
416
- "description": "cheqdUnsuspendCredentialWithStatusList2021Args object as any for extensibility"
417
- }
385
+ cheqdUnsuspendCredential: {
386
+ description: 'Unsuspend a credential against a Status List 2021 as credential status registry',
387
+ arguments: {
388
+ type: 'object',
389
+ properties: {
390
+ args: {
391
+ type: 'object',
392
+ description: 'cheqdUnsuspendCredentialWithStatusList2021Args object as any for extensibility',
393
+ },
418
394
  },
419
- "required": [
420
- "args"
421
- ]
395
+ required: ['args'],
396
+ },
397
+ returnType: {
398
+ type: 'object',
422
399
  },
423
- "returnType": {
424
- "type": "object"
425
- }
426
400
  },
427
- "cheqdUnsuspendCredentials": {
428
- "description": "Unsuspend multiple credentials against a Status List 2021 as credential status registry",
429
- "arguments": {
430
- "type": "object",
431
- "properties": {
432
- "args": {
433
- "type": "object",
434
- "description": "A cheqdUnsuspendBulkCredentialsWithStatusList2021Args object as any for extensibility"
435
- }
401
+ cheqdUnsuspendCredentials: {
402
+ description: 'Unsuspend multiple credentials against a Status List 2021 as credential status registry',
403
+ arguments: {
404
+ type: 'object',
405
+ properties: {
406
+ args: {
407
+ type: 'object',
408
+ description: 'A cheqdUnsuspendBulkCredentialsWithStatusList2021Args object as any for extensibility',
409
+ },
436
410
  },
437
- "required": [
438
- "args"
439
- ]
411
+ required: ['args'],
412
+ },
413
+ returnType: {
414
+ type: 'array',
440
415
  },
441
- "returnType": {
442
- "type": "array"
443
- }
444
416
  },
445
- "cheqdTransactSendTokens": {
446
- "description": "Send tokens from one account to another",
447
- "arguments": {
448
- "type": "object",
449
- "properties": {
450
- "args": {
451
- "type": "object",
452
- "description": "A cheqdTransactSendTokensArgs object as any for extensibility"
453
- }
417
+ cheqdTransactSendTokens: {
418
+ description: 'Send tokens from one account to another',
419
+ arguments: {
420
+ type: 'object',
421
+ properties: {
422
+ args: {
423
+ type: 'object',
424
+ description: 'A cheqdTransactSendTokensArgs object as any for extensibility',
425
+ },
454
426
  },
455
- "required": [
456
- "args"
457
- ]
427
+ required: ['args'],
428
+ },
429
+ returnType: {
430
+ type: 'object',
458
431
  },
459
- "returnType": {
460
- "type": "object"
461
- }
462
432
  },
463
- "cheqdObservePaymentCondition": {
464
- "description": "Observe payment conditions for a given set of payment conditions",
465
- "arguments": {
466
- "type": "object",
467
- "properties": {
468
- "args": {
469
- "type": "object",
470
- "description": "cheqdObservePaymentConditionArgs object as any for extensibility"
471
- }
433
+ cheqdObservePaymentCondition: {
434
+ description: 'Observe payment conditions for a given set of payment conditions',
435
+ arguments: {
436
+ type: 'object',
437
+ properties: {
438
+ args: {
439
+ type: 'object',
440
+ description: 'cheqdObservePaymentConditionArgs object as any for extensibility',
441
+ },
472
442
  },
473
- "required": [
474
- "args"
475
- ]
443
+ required: ['args'],
476
444
  },
477
- "returnType": {
478
- "type": "object"
479
- }
480
- }
481
- }
482
- }
445
+ returnType: {
446
+ type: 'object',
447
+ },
448
+ },
449
+ },
450
+ },
483
451
  };
484
452
  supportedDidProviders;
485
453
  didProvider;
@@ -542,8 +510,8 @@ class Cheqd {
542
510
  document: args.document,
543
511
  keys: args.keys,
544
512
  versionId: args?.versionId,
545
- fee: args?.fee
546
- }
513
+ fee: args?.fee,
514
+ },
547
515
  });
548
516
  }
549
517
  async UpdateIdentifier(args, context) {
@@ -563,8 +531,8 @@ class Cheqd {
563
531
  kms: args.kms,
564
532
  keys: args.keys,
565
533
  versionId: args?.versionId,
566
- fee: args?.fee
567
- }
534
+ fee: args?.fee,
535
+ },
568
536
  });
569
537
  }
570
538
  async DeactivateIdentifier(args, context) {
@@ -582,8 +550,8 @@ class Cheqd {
582
550
  document: args.document,
583
551
  options: {
584
552
  keys: args.keys,
585
- fee: args?.fee
586
- }
553
+ fee: args?.fee,
554
+ },
587
555
  }, context);
588
556
  }
589
557
  async CreateResource(args, context) {
@@ -609,8 +577,8 @@ class Cheqd {
609
577
  kms: args.kms,
610
578
  payload: args.payload,
611
579
  signInputs: args.signInputs,
612
- fee: args?.fee
613
- }
580
+ fee: args?.fee,
581
+ },
614
582
  }, context);
615
583
  }
616
584
  async CreateStatusList2021(args, context) {
@@ -663,13 +631,18 @@ class Cheqd {
663
631
  // validate args in pairs - case: encrypted
664
632
  if (args.encrypted) {
665
633
  // validate paymentConditions
666
- if (!args?.paymentConditions || !args?.paymentConditions?.length || !Array.isArray(args?.paymentConditions) || args?.paymentConditions.length === 0) {
634
+ if (!args?.paymentConditions ||
635
+ !args?.paymentConditions?.length ||
636
+ !Array.isArray(args?.paymentConditions) ||
637
+ args?.paymentConditions.length === 0) {
667
638
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
668
639
  }
669
640
  if (!args?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
670
641
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
671
642
  }
672
- if (!args?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
643
+ if (!args?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
644
+ typeof condition.feePaymentAmount === 'string' &&
645
+ typeof condition.intervalInSeconds === 'number')) {
673
646
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
674
647
  }
675
648
  if (!args?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -679,10 +652,13 @@ class Cheqd {
679
652
  // get network
680
653
  const network = args.issuerDid.split(':')[2];
681
654
  // generate bitstring
682
- const bitstring = await context.agent[exports.GenerateStatusList2021MethodName]({ length: args?.statusListLength || Cheqd.defaultStatusList2021Length, bitstringEncoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url });
655
+ const bitstring = await context.agent[exports.GenerateStatusList2021MethodName]({
656
+ length: args?.statusListLength || Cheqd.defaultStatusList2021Length,
657
+ bitstringEncoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url,
658
+ });
683
659
  // construct data and metadata tuple
684
660
  const data = args.encrypted
685
- ? (await (async function (that) {
661
+ ? await (async function (that) {
686
662
  // instantiate dkg-threshold client, in which case lit-protocol is used
687
663
  const lit = await lit_protocol_js_1.LitProtocol.create({
688
664
  chain: args?.dkgOptions?.chain || that.didProvider.dkgOptions.chain,
@@ -706,89 +682,95 @@ class Cheqd {
706
682
  // return result tuple
707
683
  switch (args.statusPurpose) {
708
684
  case cheqd_did_provider_js_1.DefaultStatusList2021StatusPurposeTypes.revocation:
709
- return [{
685
+ return [
686
+ {
710
687
  StatusList2021: {
711
688
  statusPurpose: args.statusPurpose,
712
689
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
713
690
  validFrom: new Date().toISOString(),
714
- validUntil: args?.validUntil
691
+ validUntil: args?.validUntil,
715
692
  },
716
693
  metadata: {
717
694
  type: cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes.revocation,
718
695
  encrypted: true,
719
696
  encoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url,
720
697
  encryptedSymmetricKey,
721
- paymentConditions: args.paymentConditions
722
- }
698
+ paymentConditions: args.paymentConditions,
699
+ },
723
700
  },
724
701
  {
725
702
  symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
726
703
  encryptedSymmetricKey,
727
704
  encryptedString: await (0, helpers_js_1.blobToHexString)(encryptedString),
728
- }
705
+ },
729
706
  ];
730
707
  case cheqd_did_provider_js_1.DefaultStatusList2021StatusPurposeTypes.suspension:
731
- return [{
708
+ return [
709
+ {
732
710
  StatusList2021: {
733
711
  statusPurpose: args.statusPurpose,
734
712
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
735
713
  validFrom: new Date().toISOString(),
736
- validUntil: args?.validUntil
714
+ validUntil: args?.validUntil,
737
715
  },
738
716
  metadata: {
739
717
  type: cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes.suspension,
740
718
  encrypted: true,
741
719
  encoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url,
742
720
  encryptedSymmetricKey,
743
- paymentConditions: args.paymentConditions
744
- }
721
+ paymentConditions: args.paymentConditions,
722
+ },
745
723
  },
746
724
  {
747
725
  symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
748
726
  encryptedSymmetricKey,
749
727
  encryptedString: await (0, helpers_js_1.blobToHexString)(encryptedString),
750
- }
728
+ },
751
729
  ];
752
730
  default:
753
731
  throw new Error(`[did-provider-cheqd]: status purpose is not valid ${args.statusPurpose}`);
754
732
  }
755
- }(this)))
756
- : (await (async function () {
733
+ })(this)
734
+ : await (async function () {
757
735
  switch (args.statusPurpose) {
758
736
  case cheqd_did_provider_js_1.DefaultStatusList2021StatusPurposeTypes.revocation:
759
- return [{
737
+ return [
738
+ {
760
739
  StatusList2021: {
761
740
  statusPurpose: args.statusPurpose,
762
741
  encodedList: bitstring,
763
742
  validFrom: new Date().toISOString(),
764
- validUntil: args?.validUntil
743
+ validUntil: args?.validUntil,
765
744
  },
766
745
  metadata: {
767
746
  type: cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes.revocation,
768
747
  encrypted: false,
769
748
  encoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url,
770
- }
749
+ },
771
750
  },
772
- undefined];
751
+ undefined,
752
+ ];
773
753
  case cheqd_did_provider_js_1.DefaultStatusList2021StatusPurposeTypes.suspension:
774
- return [{
754
+ return [
755
+ {
775
756
  StatusList2021: {
776
757
  statusPurpose: args.statusPurpose,
777
758
  encodedList: bitstring,
778
759
  validFrom: new Date().toISOString(),
779
- validUntil: args?.validUntil
760
+ validUntil: args?.validUntil,
780
761
  },
781
762
  metadata: {
782
763
  type: cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes.suspension,
783
764
  encrypted: false,
784
765
  encoding: args?.statusListEncoding || cheqd_did_provider_js_1.DefaultStatusList2021Encodings.base64url,
785
- }
766
+ },
786
767
  },
787
- undefined];
768
+ undefined,
769
+ ];
788
770
  default:
789
771
  throw new Error('[did-provider-cheqd]: statusPurpose is not valid');
790
772
  }
791
- }()));
773
+ })();
792
774
  // construct payload
793
775
  const payload = {
794
776
  id: (0, uuid_1.v4)(),
@@ -801,9 +783,18 @@ class Cheqd {
801
783
  };
802
784
  // return result
803
785
  return {
804
- created: await context.agent[exports.BroadcastStatusList2021MethodName]({ kms: args.kms, payload, network: network }),
786
+ created: await context.agent[exports.BroadcastStatusList2021MethodName]({
787
+ kms: args.kms,
788
+ payload,
789
+ network: network,
790
+ }),
805
791
  resource: data[0],
806
- resourceMetadata: await Cheqd.fetchStatusList2021Metadata({ credentialStatus: { id: `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.issuerDid}?resourceName=${args.statusListName}&resourceType=${cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes[args.statusPurpose]}`, type: 'StatusList2021Entry' } }),
792
+ resourceMetadata: await Cheqd.fetchStatusList2021Metadata({
793
+ credentialStatus: {
794
+ id: `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.issuerDid}?resourceName=${args.statusListName}&resourceType=${cheqd_did_provider_js_1.DefaultStatusList2021ResourceTypes[args.statusPurpose]}`,
795
+ type: 'StatusList2021Entry',
796
+ },
797
+ }),
807
798
  encrypted: args.encrypted,
808
799
  symmetricKey: args?.returnSymmetricKey ? data[1]?.symmetricKey : undefined,
809
800
  };
@@ -836,8 +827,9 @@ class Cheqd {
836
827
  kms: args.kms,
837
828
  payload: args.payload,
838
829
  signInputs: args.signInputs,
839
- fee: args?.fee || await sdk_1.ResourceModule.generateCreateResourceJsonFees((await this.didProvider.getWalletAccounts())[0].address)
840
- }
830
+ fee: args?.fee ||
831
+ (await sdk_1.ResourceModule.generateCreateResourceJsonFees((await this.didProvider.getWalletAccounts())[0].address)),
832
+ },
841
833
  }, context);
842
834
  }
843
835
  async GenerateDidDoc(args, context) {
@@ -851,7 +843,10 @@ class Cheqd {
851
843
  throw new Error('[did-provider-cheqd]: network is required');
852
844
  }
853
845
  const keyPair = (0, sdk_1.createKeyPairBase64)();
854
- const keyPairHex = { publicKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.publicKey, 'base64'), 'hex'), privateKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.privateKey, 'base64'), 'hex') };
846
+ const keyPairHex = {
847
+ publicKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.publicKey, 'base64'), 'hex'),
848
+ privateKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.privateKey, 'base64'), 'hex'),
849
+ };
855
850
  const verificationKeys = (0, sdk_1.createVerificationKeys)(keyPair.publicKey, args.methodSpecificIdAlgo, 'key-1', args.network);
856
851
  const verificationMethods = (0, sdk_1.createDidVerificationMethod)([args.verificationMethod], [verificationKeys]);
857
852
  return {
@@ -862,9 +857,9 @@ class Cheqd {
862
857
  publicKeyHex: keyPairHex.publicKey,
863
858
  privateKeyHex: keyPairHex.privateKey,
864
859
  kid: keyPairHex.publicKey,
865
- type: 'Ed25519'
866
- }
867
- ]
860
+ type: 'Ed25519',
861
+ },
862
+ ],
868
863
  };
869
864
  }
870
865
  async GenerateDidDocWithLinkedResource(args, context) {
@@ -878,7 +873,10 @@ class Cheqd {
878
873
  throw new Error('[did-provider-cheqd]: network is required');
879
874
  }
880
875
  const keyPair = (0, sdk_1.createKeyPairBase64)();
881
- const keyPairHex = { publicKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.publicKey, 'base64'), 'hex'), privateKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.privateKey, 'base64'), 'hex') };
876
+ const keyPairHex = {
877
+ publicKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.publicKey, 'base64'), 'hex'),
878
+ privateKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.privateKey, 'base64'), 'hex'),
879
+ };
882
880
  const verificationKeys = (0, sdk_1.createVerificationKeys)(keyPair.publicKey, args.methodSpecificIdAlgo, 'key-1', args.network);
883
881
  const verificationMethods = (0, sdk_1.createDidVerificationMethod)([args.verificationMethod], [verificationKeys]);
884
882
  const payload = (0, sdk_1.createDidPayload)(verificationMethods, [verificationKeys]);
@@ -890,8 +888,8 @@ class Cheqd {
890
888
  publicKeyHex: keyPairHex.publicKey,
891
889
  privateKeyHex: keyPairHex.privateKey,
892
890
  kid: keyPairHex.publicKey,
893
- type: 'Ed25519'
894
- }
891
+ type: 'Ed25519',
892
+ },
895
893
  ],
896
894
  linkedResource: {
897
895
  id: (0, uuid_1.v4)(),
@@ -901,7 +899,7 @@ class Cheqd {
901
899
  resourceType: 'SampleResource',
902
900
  alsoKnownAs: [],
903
901
  data: (0, uint8arrays_1.toString)(new TextEncoder().encode(JSON.stringify({ sample: 'json' })), 'base64'),
904
- }
902
+ },
905
903
  };
906
904
  }
907
905
  async GenerateIdentityKeys(args, context) {
@@ -910,7 +908,7 @@ class Cheqd {
910
908
  publicKeyHex: keyPair.publicKey,
911
909
  privateKeyHex: keyPair.privateKey,
912
910
  kid: keyPair.publicKey,
913
- type: 'Ed25519'
911
+ type: 'Ed25519',
914
912
  };
915
913
  }
916
914
  async GenerateVersionId(args, context) {
@@ -920,7 +918,7 @@ class Cheqd {
920
918
  const statusList = args?.buffer
921
919
  ? new vc_status_list_1.StatusList({ buffer: args.buffer })
922
920
  : new vc_status_list_1.StatusList({ length: args?.length || Cheqd.defaultStatusList2021Length });
923
- const encoded = await statusList.encode();
921
+ const encoded = (await statusList.encode());
924
922
  switch (args?.bitstringEncoding) {
925
923
  case 'base64url':
926
924
  return encoded;
@@ -934,9 +932,10 @@ class Cheqd {
934
932
  }
935
933
  async IssueRevocableCredentialWithStatusList2021(args, context) {
936
934
  // generate index
937
- const statusListIndex = args.statusOptions.statusListIndex || await (0, helpers_js_1.randomFromRange)(args.statusOptions.statusListRangeStart || 0, (args.statusOptions.statusListRangeEnd || Cheqd.defaultStatusList2021Length) - 1, args.statusOptions.indexNotIn || []);
935
+ const statusListIndex = args.statusOptions.statusListIndex ||
936
+ (await (0, helpers_js_1.randomFromRange)(args.statusOptions.statusListRangeStart || 0, (args.statusOptions.statusListRangeEnd || Cheqd.defaultStatusList2021Length) - 1, args.statusOptions.indexNotIn || []));
938
937
  // construct issuer
939
- const issuer = (args.issuanceOptions.credential.issuer.id)
938
+ const issuer = args.issuanceOptions.credential.issuer.id
940
939
  ? args.issuanceOptions.credential.issuer.id
941
940
  : args.issuanceOptions.credential.issuer;
942
941
  // generate status list credential
@@ -951,7 +950,7 @@ class Cheqd {
951
950
  // add credential status to credential
952
951
  args.issuanceOptions.credential.credentialStatus = credentialStatus;
953
952
  // add relevant context
954
- args.issuanceOptions.credential['@context'] = function () {
953
+ args.issuanceOptions.credential['@context'] = (function () {
955
954
  // if no context is provided, add default context
956
955
  if (!args.issuanceOptions.credential['@context']) {
957
956
  return [Cheqd.defaultContextV1, Cheqd.statusList2021Context];
@@ -968,16 +967,17 @@ class Cheqd {
968
967
  // if context is provided as a string, add default context if it is not already present
969
968
  if (typeof args.issuanceOptions.credential['@context'] === 'string')
970
969
  return [Cheqd.defaultContextV1, Cheqd.statusList2021Context];
971
- }();
970
+ })();
972
971
  // create a credential
973
972
  const credential = await context.agent.createVerifiableCredential(args.issuanceOptions);
974
973
  return credential;
975
974
  }
976
975
  async IssueSuspendableCredentialWithStatusList2021(args, context) {
977
976
  // generate index
978
- const statusListIndex = args.statusOptions.statusListIndex || await (0, helpers_js_1.randomFromRange)(args.statusOptions.statusListRangeStart || 0, (args.statusOptions.statusListRangeEnd || Cheqd.defaultStatusList2021Length) - 1, args.statusOptions.indexNotIn || []);
977
+ const statusListIndex = args.statusOptions.statusListIndex ||
978
+ (await (0, helpers_js_1.randomFromRange)(args.statusOptions.statusListRangeStart || 0, (args.statusOptions.statusListRangeEnd || Cheqd.defaultStatusList2021Length) - 1, args.statusOptions.indexNotIn || []));
979
979
  // construct issuer
980
- const issuer = (args.issuanceOptions.credential.issuer.id)
980
+ const issuer = args.issuanceOptions.credential.issuer.id
981
981
  ? args.issuanceOptions.credential.issuer.id
982
982
  : args.issuanceOptions.credential.issuer;
983
983
  // generate status list credential
@@ -992,7 +992,7 @@ class Cheqd {
992
992
  // add credential status to credential
993
993
  args.issuanceOptions.credential.credentialStatus = credentialStatus;
994
994
  // add relevant context
995
- args.issuanceOptions.credential['@context'] = function () {
995
+ args.issuanceOptions.credential['@context'] = (function () {
996
996
  // if no context is provided, add default context
997
997
  if (!args.issuanceOptions.credential['@context']) {
998
998
  return [Cheqd.defaultContextV1, Cheqd.statusList2021Context];
@@ -1009,7 +1009,7 @@ class Cheqd {
1009
1009
  // if context is provided as a string, add default context if it is not already present
1010
1010
  if (typeof args.issuanceOptions.credential['@context'] === 'string')
1011
1011
  return [Cheqd.defaultContextV1, Cheqd.statusList2021Context];
1012
- }();
1012
+ })();
1013
1013
  // create a credential
1014
1014
  const credential = await context.agent.createVerifiableCredential(args.issuanceOptions);
1015
1015
  return credential;
@@ -1021,7 +1021,7 @@ class Cheqd {
1021
1021
  credential: args.credential,
1022
1022
  policies: {
1023
1023
  ...args?.verificationArgs?.policies,
1024
- credentialStatus: false
1024
+ credentialStatus: false,
1025
1025
  },
1026
1026
  });
1027
1027
  // early return if verification failed
@@ -1031,9 +1031,7 @@ class Cheqd {
1031
1031
  // if jwt credential, decode it
1032
1032
  const credential = typeof args.credential === 'string' ? await Cheqd.decodeCredentialJWT(args.credential) : args.credential;
1033
1033
  // define issuer
1034
- const issuer = typeof credential.issuer === 'string'
1035
- ? credential.issuer
1036
- : credential.issuer.id;
1034
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1037
1035
  // define provider, if applicable
1038
1036
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1039
1037
  // define provider id, if applicable
@@ -1061,7 +1059,7 @@ class Cheqd {
1061
1059
  presentation: args.presentation,
1062
1060
  policies: {
1063
1061
  ...args?.verificationArgs?.policies,
1064
- credentialStatus: false
1062
+ credentialStatus: false,
1065
1063
  },
1066
1064
  });
1067
1065
  // early return if verification failed
@@ -1077,9 +1075,7 @@ class Cheqd {
1077
1075
  if (typeof credential === 'string')
1078
1076
  credential = await Cheqd.decodeCredentialJWT(credential);
1079
1077
  // define issuer
1080
- const issuer = typeof credential.issuer === 'string'
1081
- ? credential.issuer
1082
- : credential.issuer.id;
1078
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1083
1079
  // define provider, if applicable
1084
1080
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1085
1081
  // define provider id, if applicable
@@ -1107,8 +1103,8 @@ class Cheqd {
1107
1103
  const verificationResult = await context.agent.verifyCredential({
1108
1104
  credential: args.credential,
1109
1105
  policies: {
1110
- credentialStatus: false
1111
- }
1106
+ credentialStatus: false,
1107
+ },
1112
1108
  });
1113
1109
  // early return if verification failed
1114
1110
  if (!verificationResult.verified) {
@@ -1130,7 +1126,9 @@ class Cheqd {
1130
1126
  if (!args.statusOptions.statusListIndex)
1131
1127
  throw new Error('[did-provider-cheqd]: check status: statusOptions.statusListIndex is required');
1132
1128
  // generate resource type
1133
- const resourceType = args.statusOptions.statusPurpose === 'revocation' ? 'StatusList2021Revocation' : 'StatusList2021Suspension';
1129
+ const resourceType = args.statusOptions.statusPurpose === 'revocation'
1130
+ ? 'StatusList2021Revocation'
1131
+ : 'StatusList2021Suspension';
1134
1132
  // construct status list credential
1135
1133
  const statusListCredential = `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.statusOptions.issuerDid}?resourceName=${args.statusOptions.statusListName}&resourceType=${resourceType}`;
1136
1134
  // construct credential status
@@ -1145,7 +1143,7 @@ class Cheqd {
1145
1143
  statusListIndex: `${args.statusOptions.statusListIndex}`,
1146
1144
  },
1147
1145
  issuanceDate: '',
1148
- proof: {}
1146
+ proof: {},
1149
1147
  };
1150
1148
  }
1151
1149
  // validate args - case: credential
@@ -1154,9 +1152,7 @@ class Cheqd {
1154
1152
  // if jwt credential, decode it
1155
1153
  const credential = typeof args.credential === 'string' ? await Cheqd.decodeCredentialJWT(args.credential) : args.credential;
1156
1154
  // define issuer
1157
- const issuer = typeof credential.issuer === 'string'
1158
- ? credential.issuer
1159
- : credential.issuer.id;
1155
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1160
1156
  // define provider, if applicable
1161
1157
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1162
1158
  // define provider id, if applicable
@@ -1182,8 +1178,8 @@ class Cheqd {
1182
1178
  const verificationResult = await context.agent.verifyCredential({
1183
1179
  credential: args.credential,
1184
1180
  policies: {
1185
- credentialStatus: false
1186
- }
1181
+ credentialStatus: false,
1182
+ },
1187
1183
  });
1188
1184
  // early return if verification failed
1189
1185
  if (!verificationResult.verified) {
@@ -1215,7 +1211,7 @@ class Cheqd {
1215
1211
  statusListIndex: `${args.revocationOptions.statusListIndex}`,
1216
1212
  },
1217
1213
  issuanceDate: '',
1218
- proof: {}
1214
+ proof: {},
1219
1215
  };
1220
1216
  }
1221
1217
  // validate args - case: credential
@@ -1244,9 +1240,7 @@ class Cheqd {
1244
1240
  throw new Error('[did-provider-cheqd]: revocation: publish requires statusListFile or statusList, if fetchList is disabled');
1245
1241
  }
1246
1242
  // define issuer
1247
- const issuer = typeof credential.issuer === 'string'
1248
- ? credential.issuer
1249
- : credential.issuer.id;
1243
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1250
1244
  // define provider, if applicable
1251
1245
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1252
1246
  // define provider id, if applicable
@@ -1265,8 +1259,8 @@ class Cheqd {
1265
1259
  resourceVersion: args?.options?.resourceVersion,
1266
1260
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1267
1261
  signInputs: args?.options?.signInputs,
1268
- fee: args?.options?.fee
1269
- }
1262
+ fee: args?.options?.fee,
1263
+ },
1270
1264
  });
1271
1265
  }
1272
1266
  async RevokeBulkCredentialsWithStatusList2021(args, context) {
@@ -1276,14 +1270,19 @@ class Cheqd {
1276
1270
  return await context.agent.verifyCredential({
1277
1271
  credential,
1278
1272
  policies: {
1279
- credentialStatus: false
1280
- }
1273
+ credentialStatus: false,
1274
+ },
1281
1275
  });
1282
1276
  }));
1283
1277
  // early return if verification failed for any credential
1284
- if (verificationResult.some(result => !result.verified)) {
1278
+ if (verificationResult.some((result) => !result.verified)) {
1285
1279
  // define verified
1286
- return { revoked: Array(args.credentials.length).fill(false), error: verificationResult.find(result => !result.verified).error || { message: 'verification: could not verify credential' } };
1280
+ return {
1281
+ revoked: Array(args.credentials.length).fill(false),
1282
+ error: verificationResult.find((result) => !result.verified).error || {
1283
+ message: 'verification: could not verify credential',
1284
+ },
1285
+ };
1287
1286
  }
1288
1287
  }
1289
1288
  // if revocation options are provided, give precedence
@@ -1295,12 +1294,15 @@ class Cheqd {
1295
1294
  if (!args.revocationOptions.statusListName)
1296
1295
  throw new Error('[did-provider-cheqd]: revocation: revocationOptions.statusListName is required');
1297
1296
  // validate revocation options - case: revocationOptions.statusListIndices
1298
- if (!args.revocationOptions.statusListIndices || !args.revocationOptions.statusListIndices.length || args.revocationOptions.statusListIndices.length === 0 || !args.revocationOptions.statusListIndices.every(index => !isNaN(+index)))
1297
+ if (!args.revocationOptions.statusListIndices ||
1298
+ !args.revocationOptions.statusListIndices.length ||
1299
+ args.revocationOptions.statusListIndices.length === 0 ||
1300
+ !args.revocationOptions.statusListIndices.every((index) => !isNaN(+index)))
1299
1301
  throw new Error('[did-provider-cheqd]: revocation: revocationOptions.statusListIndex is required and must be an array of indices');
1300
1302
  // construct status list credential
1301
1303
  const statusListCredential = `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.revocationOptions.issuerDid}?resourceName=${args.revocationOptions.statusListName}&resourceType=StatusList2021Revocation`;
1302
1304
  // construct credential status
1303
- args.credentials = args.revocationOptions.statusListIndices.map(index => ({
1305
+ args.credentials = args.revocationOptions.statusListIndices.map((index) => ({
1304
1306
  '@context': [],
1305
1307
  issuer: args.revocationOptions.issuerDid,
1306
1308
  credentialSubject: {},
@@ -1311,7 +1313,7 @@ class Cheqd {
1311
1313
  statusListIndex: `${index}`,
1312
1314
  },
1313
1315
  issuanceDate: '',
1314
- proof: {}
1316
+ proof: {},
1315
1317
  }));
1316
1318
  }
1317
1319
  // validate args - case: credentials
@@ -1355,8 +1357,8 @@ class Cheqd {
1355
1357
  resourceVersion: args?.options?.resourceVersion,
1356
1358
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1357
1359
  signInputs: args?.options?.signInputs,
1358
- fee: args?.options?.fee
1359
- }
1360
+ fee: args?.options?.fee,
1361
+ },
1360
1362
  });
1361
1363
  }
1362
1364
  async SuspendCredentialWithStatusList2021(args, context) {
@@ -1365,8 +1367,8 @@ class Cheqd {
1365
1367
  const verificationResult = await context.agent.verifyCredential({
1366
1368
  credential: args.credential,
1367
1369
  policies: {
1368
- credentialStatus: false
1369
- }
1370
+ credentialStatus: false,
1371
+ },
1370
1372
  });
1371
1373
  // early return if verification failed
1372
1374
  if (!verificationResult.verified) {
@@ -1398,7 +1400,7 @@ class Cheqd {
1398
1400
  statusListIndex: `${args.suspensionOptions.statusListIndex}`,
1399
1401
  },
1400
1402
  issuanceDate: '',
1401
- proof: {}
1403
+ proof: {},
1402
1404
  };
1403
1405
  }
1404
1406
  // validate args - case: credential
@@ -1427,9 +1429,7 @@ class Cheqd {
1427
1429
  throw new Error('[did-provider-cheqd]: suspension: publish requires statusListFile or statusList, if fetchList is disabled');
1428
1430
  }
1429
1431
  // define issuer
1430
- const issuer = typeof credential.issuer === 'string'
1431
- ? credential.issuer
1432
- : credential.issuer.id;
1432
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1433
1433
  // define provider, if applicable
1434
1434
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1435
1435
  // define provider id, if applicable
@@ -1448,8 +1448,8 @@ class Cheqd {
1448
1448
  resourceVersion: args?.options?.resourceVersion,
1449
1449
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1450
1450
  signInputs: args?.options?.signInputs,
1451
- fee: args?.options?.fee
1452
- }
1451
+ fee: args?.options?.fee,
1452
+ },
1453
1453
  });
1454
1454
  }
1455
1455
  async SuspendBulkCredentialsWithStatusList2021(args, context) {
@@ -1459,14 +1459,19 @@ class Cheqd {
1459
1459
  return await context.agent.verifyCredential({
1460
1460
  credential,
1461
1461
  policies: {
1462
- credentialStatus: false
1463
- }
1462
+ credentialStatus: false,
1463
+ },
1464
1464
  });
1465
1465
  }));
1466
1466
  // early return if verification failed for any credential
1467
- if (verificationResult.some(result => !result.verified)) {
1467
+ if (verificationResult.some((result) => !result.verified)) {
1468
1468
  // define verified
1469
- return { suspended: Array(args.credentials.length).fill(false), error: verificationResult.find(result => !result.verified).error || { message: 'verification: could not verify credential' } };
1469
+ return {
1470
+ suspended: Array(args.credentials.length).fill(false),
1471
+ error: verificationResult.find((result) => !result.verified).error || {
1472
+ message: 'verification: could not verify credential',
1473
+ },
1474
+ };
1470
1475
  }
1471
1476
  }
1472
1477
  // if suspension options are provided, give precedence
@@ -1478,12 +1483,15 @@ class Cheqd {
1478
1483
  if (!args.suspensionOptions.statusListName)
1479
1484
  throw new Error('[did-provider-cheqd]: suspension: suspensionOptions.statusListName is required');
1480
1485
  // validate suspension options - case: suspensionOptions.statusListIndices
1481
- if (!args.suspensionOptions.statusListIndices || !args.suspensionOptions.statusListIndices.length || args.suspensionOptions.statusListIndices.length === 0 || !args.suspensionOptions.statusListIndices.every(index => !isNaN(+index)))
1486
+ if (!args.suspensionOptions.statusListIndices ||
1487
+ !args.suspensionOptions.statusListIndices.length ||
1488
+ args.suspensionOptions.statusListIndices.length === 0 ||
1489
+ !args.suspensionOptions.statusListIndices.every((index) => !isNaN(+index)))
1482
1490
  throw new Error('[did-provider-cheqd]: suspension: suspensionOptions.statusListIndex is required and must be an array of indices');
1483
1491
  // construct status list credential
1484
1492
  const statusListCredential = `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.suspensionOptions.issuerDid}?resourceName=${args.suspensionOptions.statusListName}&resourceType=StatusList2021Suspension`;
1485
1493
  // construct credential status
1486
- args.credentials = args.suspensionOptions.statusListIndices.map(index => ({
1494
+ args.credentials = args.suspensionOptions.statusListIndices.map((index) => ({
1487
1495
  '@context': [],
1488
1496
  issuer: args.suspensionOptions.issuerDid,
1489
1497
  credentialSubject: {},
@@ -1494,7 +1502,7 @@ class Cheqd {
1494
1502
  statusListIndex: `${index}`,
1495
1503
  },
1496
1504
  issuanceDate: '',
1497
- proof: {}
1505
+ proof: {},
1498
1506
  }));
1499
1507
  }
1500
1508
  // validate args - case: credentials
@@ -1538,8 +1546,8 @@ class Cheqd {
1538
1546
  resourceVersion: args?.options?.resourceVersion,
1539
1547
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1540
1548
  signInputs: args?.options?.signInputs,
1541
- fee: args?.options?.fee
1542
- }
1549
+ fee: args?.options?.fee,
1550
+ },
1543
1551
  });
1544
1552
  }
1545
1553
  async UnsuspendCredentialWithStatusList2021(args, context) {
@@ -1548,8 +1556,8 @@ class Cheqd {
1548
1556
  const verificationResult = await context.agent.verifyCredential({
1549
1557
  credential: args.credential,
1550
1558
  policies: {
1551
- credentialStatus: false
1552
- }
1559
+ credentialStatus: false,
1560
+ },
1553
1561
  });
1554
1562
  // early return if verification failed
1555
1563
  if (!verificationResult.verified) {
@@ -1581,7 +1589,7 @@ class Cheqd {
1581
1589
  statusListIndex: `${args.unsuspensionOptions.statusListIndex}`,
1582
1590
  },
1583
1591
  issuanceDate: '',
1584
- proof: {}
1592
+ proof: {},
1585
1593
  };
1586
1594
  }
1587
1595
  // validate args - case: credential
@@ -1610,9 +1618,7 @@ class Cheqd {
1610
1618
  throw new Error('[did-provider-cheqd]: suspension: publish requires statusListFile or statusList, if fetchList is disabled');
1611
1619
  }
1612
1620
  // define issuer
1613
- const issuer = typeof credential.issuer === 'string'
1614
- ? credential.issuer
1615
- : credential.issuer.id;
1621
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : credential.issuer.id;
1616
1622
  // define provider, if applicable
1617
1623
  this.didProvider = await Cheqd.loadProvider(issuer, this.supportedDidProviders);
1618
1624
  // define provider id, if applicable
@@ -1631,8 +1637,8 @@ class Cheqd {
1631
1637
  resourceVersion: args?.options?.resourceVersion,
1632
1638
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1633
1639
  signInputs: args?.options?.signInputs,
1634
- fee: args?.options?.fee
1635
- }
1640
+ fee: args?.options?.fee,
1641
+ },
1636
1642
  });
1637
1643
  }
1638
1644
  async UnsuspendBulkCredentialsWithStatusList2021(args, context) {
@@ -1642,14 +1648,19 @@ class Cheqd {
1642
1648
  return await context.agent.verifyCredential({
1643
1649
  credential,
1644
1650
  policies: {
1645
- credentialStatus: false
1646
- }
1651
+ credentialStatus: false,
1652
+ },
1647
1653
  });
1648
1654
  }));
1649
1655
  // early return if verification failed for any credential
1650
- if (verificationResult.some(result => !result.verified)) {
1656
+ if (verificationResult.some((result) => !result.verified)) {
1651
1657
  // define verified
1652
- return { unsuspended: Array(args.credentials.length).fill(false), error: verificationResult.find(result => !result.verified).error || { message: 'verification: could not verify credential' } };
1658
+ return {
1659
+ unsuspended: Array(args.credentials.length).fill(false),
1660
+ error: verificationResult.find((result) => !result.verified).error || {
1661
+ message: 'verification: could not verify credential',
1662
+ },
1663
+ };
1653
1664
  }
1654
1665
  }
1655
1666
  // if unsuspension options are provided, give precedence
@@ -1661,12 +1672,15 @@ class Cheqd {
1661
1672
  if (!args.unsuspensionOptions.statusListName)
1662
1673
  throw new Error('[did-provider-cheqd]: unsuspension: unsuspensionOptions.statusListName is required');
1663
1674
  // validate unsuspension options - case: unsuspensionOptions.statusListIndices
1664
- if (!args.unsuspensionOptions.statusListIndices || !args.unsuspensionOptions.statusListIndices.length || args.unsuspensionOptions.statusListIndices.length === 0 || !args.unsuspensionOptions.statusListIndices.every(index => !isNaN(+index)))
1675
+ if (!args.unsuspensionOptions.statusListIndices ||
1676
+ !args.unsuspensionOptions.statusListIndices.length ||
1677
+ args.unsuspensionOptions.statusListIndices.length === 0 ||
1678
+ !args.unsuspensionOptions.statusListIndices.every((index) => !isNaN(+index)))
1665
1679
  throw new Error('[did-provider-cheqd]: unsuspension: unsuspensionOptions.statusListIndex is required and must be an array of indices');
1666
1680
  // construct status list credential
1667
1681
  const statusListCredential = `${cheqd_did_resolver_js_1.DefaultResolverUrl}${args.unsuspensionOptions.issuerDid}?resourceName=${args.unsuspensionOptions.statusListName}&resourceType=StatusList2021Suspension`;
1668
1682
  // construct credential status
1669
- args.credentials = args.unsuspensionOptions.statusListIndices.map(index => ({
1683
+ args.credentials = args.unsuspensionOptions.statusListIndices.map((index) => ({
1670
1684
  '@context': [],
1671
1685
  issuer: args.unsuspensionOptions.issuerDid,
1672
1686
  credentialSubject: {},
@@ -1677,7 +1691,7 @@ class Cheqd {
1677
1691
  statusListIndex: `${index}`,
1678
1692
  },
1679
1693
  issuanceDate: '',
1680
- proof: {}
1694
+ proof: {},
1681
1695
  }));
1682
1696
  }
1683
1697
  // validate args - case: credentials
@@ -1721,16 +1735,19 @@ class Cheqd {
1721
1735
  resourceVersion: args?.options?.resourceVersion,
1722
1736
  resourceAlsoKnownAs: args?.options?.alsoKnownAs,
1723
1737
  signInputs: args?.options?.signInputs,
1724
- fee: args?.options?.fee
1725
- }
1738
+ fee: args?.options?.fee,
1739
+ },
1726
1740
  });
1727
1741
  }
1728
1742
  async TransactSendTokens(args, context) {
1729
1743
  // define provider
1730
- const provider = function (that) {
1744
+ const provider = (function (that) {
1731
1745
  // switch on network
1732
- return that.supportedDidProviders.find(provider => provider.network === args.network) || (function () { throw new Error(`[did-provider-cheqd]: transact: no relevant providers found`); }());
1733
- }(this);
1746
+ return (that.supportedDidProviders.find((provider) => provider.network === args.network) ||
1747
+ (function () {
1748
+ throw new Error(`[did-provider-cheqd]: transact: no relevant providers found`);
1749
+ })());
1750
+ })(this);
1734
1751
  try {
1735
1752
  // delegate to provider
1736
1753
  const transactionResult = await provider.transactSendTokens({
@@ -1745,14 +1762,14 @@ class Cheqd {
1745
1762
  transactionHash: transactionResult.transactionHash,
1746
1763
  events: transactionResult.events,
1747
1764
  rawLog: transactionResult.rawLog,
1748
- txResponse: args?.returnTxResponse ? transactionResult : undefined
1765
+ txResponse: args?.returnTxResponse ? transactionResult : undefined,
1749
1766
  };
1750
1767
  }
1751
1768
  catch (error) {
1752
1769
  // return error
1753
1770
  return {
1754
1771
  successful: false,
1755
- error: error
1772
+ error: error,
1756
1773
  };
1757
1774
  }
1758
1775
  }
@@ -1760,7 +1777,8 @@ class Cheqd {
1760
1777
  // verify with raw unified access control condition, if any
1761
1778
  if (args?.unifiedAccessControlCondition) {
1762
1779
  // validate args - case: unifiedAccessControlCondition.chain
1763
- if (!args.unifiedAccessControlCondition.chain || !Object.values(lit_protocol_js_1.LitCompatibleCosmosChains).includes(args.unifiedAccessControlCondition.chain))
1780
+ if (!args.unifiedAccessControlCondition.chain ||
1781
+ !Object.values(lit_protocol_js_1.LitCompatibleCosmosChains).includes(args.unifiedAccessControlCondition.chain))
1764
1782
  throw new Error('[did-provider-cheqd]: observe: unifiedAccessControlCondition.chain is required and must be a valid Lit-compatible chain');
1765
1783
  // validate args - case: unifiedAccessControlCondition.path
1766
1784
  if (!args.unifiedAccessControlCondition.path)
@@ -1772,10 +1790,16 @@ class Cheqd {
1772
1790
  if (args.unifiedAccessControlCondition.method !== 'timelock')
1773
1791
  throw new Error('[did-provider-cheqd]: observe: unifiedAccessControlCondition.method must be timelock');
1774
1792
  // validate args - case: unifiedAccessControlCondition.parameters
1775
- if (!args.unifiedAccessControlCondition.parameters || !Array.isArray(args.unifiedAccessControlCondition.parameters) || args.unifiedAccessControlCondition.parameters.length === 0 || args.unifiedAccessControlCondition.parameters.length > 1)
1793
+ if (!args.unifiedAccessControlCondition.parameters ||
1794
+ !Array.isArray(args.unifiedAccessControlCondition.parameters) ||
1795
+ args.unifiedAccessControlCondition.parameters.length === 0 ||
1796
+ args.unifiedAccessControlCondition.parameters.length > 1)
1776
1797
  throw new Error('[did-provider-cheqd]: observe: unifiedAccessControlCondition.parameters is required and must be an array of length 1 of type string content');
1777
1798
  // validate args - case: unifiedAccessControlCondition.returnValueTest
1778
- if (!args.unifiedAccessControlCondition.returnValueTest || !args.unifiedAccessControlCondition.returnValueTest.comparator || !args.unifiedAccessControlCondition.returnValueTest.key || !args.unifiedAccessControlCondition.returnValueTest.value)
1799
+ if (!args.unifiedAccessControlCondition.returnValueTest ||
1800
+ !args.unifiedAccessControlCondition.returnValueTest.comparator ||
1801
+ !args.unifiedAccessControlCondition.returnValueTest.key ||
1802
+ !args.unifiedAccessControlCondition.returnValueTest.value)
1779
1803
  throw new Error('[did-provider-cheqd]: observe: unifiedAccessControlCondition.returnValueTest is required');
1780
1804
  try {
1781
1805
  // define network
@@ -1788,24 +1812,24 @@ class Cheqd {
1788
1812
  default:
1789
1813
  throw new Error(`[did-provider-cheqd]: observe: Unsupported chain: ${args.unifiedAccessControlCondition.chain}`);
1790
1814
  }
1791
- }());
1815
+ })();
1792
1816
  // get block height url
1793
- const blockHeightUrl = function () {
1817
+ const blockHeightUrl = (function () {
1794
1818
  switch (args.unifiedAccessControlCondition.parameters[0]) {
1795
1819
  case 'latest':
1796
1820
  return `${cheqd_did_provider_js_1.DefaultRESTUrls[network]}/cosmos/base/tendermint/v1beta1/blocks/latest`;
1797
1821
  default:
1798
1822
  return `${cheqd_did_provider_js_1.DefaultRESTUrls[network]}/cosmos/base/tendermint/v1beta1/blocks/${args.unifiedAccessControlCondition.parameters[0]}`;
1799
1823
  }
1800
- }();
1824
+ })();
1801
1825
  // fetch block response
1802
- const blockHeightResponse = await (await fetch(blockHeightUrl)).json();
1826
+ const blockHeightResponse = (await (await fetch(blockHeightUrl)).json());
1803
1827
  // get timestamp from block response
1804
1828
  const blockTimestamp = Date.parse(blockHeightResponse.block.header.time);
1805
1829
  // construct url
1806
1830
  const url = `${cheqd_did_provider_js_1.DefaultRESTUrls[network]}${args.unifiedAccessControlCondition.path}`;
1807
1831
  // fetch relevant txs
1808
- const txs = await (await fetch(url)).json();
1832
+ const txs = (await (await fetch(url)).json());
1809
1833
  // skim through txs for relevant events, in which case the transaction timestamp is within the defined interval in seconds, from the block timestamp
1810
1834
  const meetsConditionTxIndex = txs?.tx_responses?.findIndex((tx) => {
1811
1835
  // get tx timestamp
@@ -1823,7 +1847,7 @@ class Cheqd {
1823
1847
  }
1824
1848
  });
1825
1849
  // define meetsCondition
1826
- const meetsCondition = (typeof meetsConditionTxIndex !== 'undefined' && meetsConditionTxIndex !== -1);
1850
+ const meetsCondition = typeof meetsConditionTxIndex !== 'undefined' && meetsConditionTxIndex !== -1;
1827
1851
  // return observation result
1828
1852
  return {
1829
1853
  subscribed: true,
@@ -1831,7 +1855,11 @@ class Cheqd {
1831
1855
  transactionHash: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].txhash : undefined,
1832
1856
  events: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].events : undefined,
1833
1857
  rawLog: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].raw_log : undefined,
1834
- txResponse: meetsCondition ? (args?.returnTxResponse ? txs.tx_responses[meetsConditionTxIndex] : undefined) : undefined
1858
+ txResponse: meetsCondition
1859
+ ? args?.returnTxResponse
1860
+ ? txs.tx_responses[meetsConditionTxIndex]
1861
+ : undefined
1862
+ : undefined,
1835
1863
  };
1836
1864
  }
1837
1865
  catch (error) {
@@ -1839,7 +1867,7 @@ class Cheqd {
1839
1867
  return {
1840
1868
  subscribed: false,
1841
1869
  meetsCondition: false,
1842
- error: error
1870
+ error: error,
1843
1871
  };
1844
1872
  }
1845
1873
  }
@@ -1867,22 +1895,22 @@ class Cheqd {
1867
1895
  args.blockHeight ||= 'latest';
1868
1896
  try {
1869
1897
  // get block height url
1870
- const blockHeightUrl = function () {
1898
+ const blockHeightUrl = (function () {
1871
1899
  switch (args.blockHeight) {
1872
1900
  case 'latest':
1873
1901
  return `${cheqd_did_provider_js_1.DefaultRESTUrls[args.network]}/cosmos/base/tendermint/v1beta1/blocks/latest`;
1874
1902
  default:
1875
1903
  return `${cheqd_did_provider_js_1.DefaultRESTUrls[args.network]}/cosmos/base/tendermint/v1beta1/blocks/${args.blockHeight}`;
1876
1904
  }
1877
- }();
1905
+ })();
1878
1906
  // fetch block response
1879
- const blockHeightResponse = await (await fetch(blockHeightUrl)).json();
1907
+ const blockHeightResponse = (await (await fetch(blockHeightUrl)).json());
1880
1908
  // get timestamp from block response
1881
1909
  const blockTimestamp = Date.parse(blockHeightResponse.block.header.time);
1882
1910
  // otherwise, construct url, as per components
1883
1911
  const url = `${cheqd_did_provider_js_1.DefaultRESTUrls[args.network]}/cosmos/tx/v1beta1/txs?events=transfer.recipient='${args.recipientAddress}'&events=transfer.amount='${args.amount.amount}${args.amount.denom}'&order_by=2&pagination.limit=1`;
1884
1912
  // fetch relevant txs
1885
- const txs = await (await fetch(url)).json();
1913
+ const txs = (await (await fetch(url)).json());
1886
1914
  // skim through txs for relevant events, in which case the transaction timestamp is within the defined interval in seconds, from the block timestamp
1887
1915
  const meetsConditionTxIndex = txs?.tx_responses?.findIndex((tx) => {
1888
1916
  // get tx timestamp
@@ -1900,7 +1928,7 @@ class Cheqd {
1900
1928
  }
1901
1929
  });
1902
1930
  // define meetsCondition
1903
- const meetsCondition = (typeof meetsConditionTxIndex !== 'undefined' && meetsConditionTxIndex !== -1);
1931
+ const meetsCondition = typeof meetsConditionTxIndex !== 'undefined' && meetsConditionTxIndex !== -1;
1904
1932
  // return observation result
1905
1933
  return {
1906
1934
  subscribed: true,
@@ -1908,7 +1936,11 @@ class Cheqd {
1908
1936
  transactionHash: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].txhash : undefined,
1909
1937
  events: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].events : undefined,
1910
1938
  rawLog: meetsCondition ? txs.tx_responses[meetsConditionTxIndex].raw_log : undefined,
1911
- txResponse: meetsCondition ? (args?.returnTxResponse ? txs.tx_responses[meetsConditionTxIndex] : undefined) : undefined
1939
+ txResponse: meetsCondition
1940
+ ? args?.returnTxResponse
1941
+ ? txs.tx_responses[meetsConditionTxIndex]
1942
+ : undefined
1943
+ : undefined,
1912
1944
  };
1913
1945
  }
1914
1946
  catch (error) {
@@ -1916,7 +1948,7 @@ class Cheqd {
1916
1948
  return {
1917
1949
  subscribed: false,
1918
1950
  meetsCondition: false,
1919
- error: error
1951
+ error: error,
1920
1952
  };
1921
1953
  }
1922
1954
  }
@@ -1932,7 +1964,7 @@ class Cheqd {
1932
1964
  throw new Error('[did-provider-cheqd]: revocation: symmetricKey is required, if status list 2021 is encrypted');
1933
1965
  // fetch status list 2021 inscribed in credential
1934
1966
  const statusList2021 = options?.topArgs?.fetchList
1935
- ? (await async function () {
1967
+ ? await (async function () {
1936
1968
  // if not encrypted, return bitstring
1937
1969
  if (!publishedList.metadata.encrypted)
1938
1970
  return publishedList.metadata.encoding === 'base64url'
@@ -1942,8 +1974,8 @@ class Cheqd {
1942
1974
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
1943
1975
  // decrypt
1944
1976
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
1945
- }())
1946
- : (await async function () {
1977
+ })()
1978
+ : await (async function () {
1947
1979
  // transcode to base64url, if needed
1948
1980
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
1949
1981
  ? publishedList.StatusList2021.encodedList
@@ -1953,7 +1985,9 @@ class Cheqd {
1953
1985
  // if not encrypted, return bitstring
1954
1986
  if (!publishedList.metadata.encrypted) {
1955
1987
  // construct encoded status list
1956
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
1988
+ const encoded = new vc_status_list_1.StatusList({
1989
+ buffer: await Cheqd.getFile(options.statusListFile),
1990
+ }).encode();
1957
1991
  // validate against published list
1958
1992
  if (encoded !== publishedListTranscoded)
1959
1993
  throw new Error('[did-provider-cheqd]: revocation: statusListFile does not match published status list 2021');
@@ -1977,7 +2011,7 @@ class Cheqd {
1977
2011
  throw new Error('[did-provider-cheqd]: revocation: statusListInlineBitstring does not match published status list 2021');
1978
2012
  // otherwise, read from inline bitstring
1979
2013
  return options?.statusListInlineBitstring;
1980
- }());
2014
+ })();
1981
2015
  // parse status list 2021
1982
2016
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
1983
2017
  // early exit, if credential is already revoked
@@ -1986,7 +2020,7 @@ class Cheqd {
1986
2020
  // update revocation status
1987
2021
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), true);
1988
2022
  // set in-memory status list ref
1989
- const bitstring = await statusList.encode();
2023
+ const bitstring = (await statusList.encode());
1990
2024
  // cast top-level args
1991
2025
  const topArgs = options?.topArgs;
1992
2026
  // write status list 2021 to file, if provided
@@ -1995,14 +2029,15 @@ class Cheqd {
1995
2029
  }
1996
2030
  // publish status list 2021, if provided
1997
2031
  const published = topArgs?.publish
1998
- ? (await async function () {
2032
+ ? await (async function () {
1999
2033
  // fetch status list 2021 metadata
2000
2034
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credential);
2001
2035
  // publish status list 2021 as new version
2002
2036
  const scoped = topArgs.publishEncrypted
2003
- ? (await async function () {
2037
+ ? await (async function () {
2004
2038
  // validate encoding, if provided
2005
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2039
+ if (options?.publishOptions?.statusListEncoding &&
2040
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2006
2041
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list encoding');
2007
2042
  }
2008
2043
  // validate validUntil, if provided
@@ -2017,15 +2052,20 @@ class Cheqd {
2017
2052
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2018
2053
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be future date)');
2019
2054
  // validate validUntil towards validFrom
2020
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2055
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2056
+ new Date(publishedList.StatusList2021.validFrom))
2021
2057
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be after validFrom)');
2022
2058
  }
2023
2059
  // validate paymentConditions, if provided
2024
2060
  if (topArgs?.paymentConditions) {
2025
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
2061
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
2062
+ condition.feePaymentAmount &&
2063
+ condition.intervalInSeconds)) {
2026
2064
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
2027
2065
  }
2028
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
2066
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
2067
+ typeof condition.feePaymentAmount === 'string' &&
2068
+ typeof condition.intervalInSeconds === 'number')) {
2029
2069
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
2030
2070
  }
2031
2071
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -2033,19 +2073,22 @@ class Cheqd {
2033
2073
  }
2034
2074
  }
2035
2075
  // validate dkgOptions
2036
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
2076
+ if (!topArgs?.dkgOptions ||
2077
+ !topArgs?.dkgOptions?.chain ||
2078
+ !topArgs?.dkgOptions?.network) {
2037
2079
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
2038
2080
  }
2039
2081
  // instantiate dkg-threshold client, in which case lit-protocol is used
2040
2082
  const lit = await lit_protocol_js_1.LitProtocol.create({
2041
2083
  chain: topArgs?.dkgOptions?.chain,
2042
- litNetwork: topArgs?.dkgOptions?.network
2084
+ litNetwork: topArgs?.dkgOptions?.network,
2043
2085
  });
2044
2086
  // construct access control conditions and payment conditions tuple
2045
2087
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
2046
- ? (await (async function () {
2088
+ ? await (async function () {
2047
2089
  // define payment conditions, give precedence to top-level args
2048
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
2090
+ const paymentConditions = topArgs?.paymentConditions ||
2091
+ publishedList.metadata.paymentConditions;
2049
2092
  // return access control conditions and payment conditions tuple
2050
2093
  return [
2051
2094
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -2060,10 +2103,10 @@ class Cheqd {
2060
2103
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2061
2104
  }
2062
2105
  })),
2063
- paymentConditions
2106
+ paymentConditions,
2064
2107
  ];
2065
- }()))
2066
- : (await (async function () {
2108
+ })()
2109
+ : await (async function () {
2067
2110
  // validate paymentConditions
2068
2111
  if (!topArgs?.paymentConditions) {
2069
2112
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -2082,9 +2125,9 @@ class Cheqd {
2082
2125
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2083
2126
  }
2084
2127
  })),
2085
- topArgs.paymentConditions
2128
+ topArgs.paymentConditions,
2086
2129
  ];
2087
- }()));
2130
+ })();
2088
2131
  // encrypt bitstring
2089
2132
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
2090
2133
  // define status list content
@@ -2093,25 +2136,31 @@ class Cheqd {
2093
2136
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2094
2137
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
2095
2138
  validFrom: publishedList.StatusList2021.validFrom,
2096
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2139
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2140
+ publishedList.StatusList2021.validUntil,
2097
2141
  },
2098
2142
  metadata: {
2099
2143
  type: publishedList.metadata.type,
2100
2144
  encrypted: true,
2101
2145
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2102
2146
  encryptedSymmetricKey,
2103
- paymentConditions: unifiedAccessControlConditionsTuple[1]
2104
- }
2147
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
2148
+ },
2105
2149
  };
2106
2150
  // return tuple of publish result and encryption relevant metadata
2107
2151
  return [
2108
2152
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2109
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
2153
+ {
2154
+ encryptedString,
2155
+ encryptedSymmetricKey,
2156
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
2157
+ },
2110
2158
  ];
2111
- }())
2112
- : (await async function () {
2159
+ })()
2160
+ : await (async function () {
2113
2161
  // validate encoding, if provided
2114
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2162
+ if (options?.publishOptions?.statusListEncoding &&
2163
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2115
2164
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list encoding');
2116
2165
  }
2117
2166
  // validate validUntil, if provided
@@ -2126,42 +2175,53 @@ class Cheqd {
2126
2175
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2127
2176
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be future date)');
2128
2177
  // validate validUntil towards validFrom
2129
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2178
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2179
+ new Date(publishedList.StatusList2021.validFrom))
2130
2180
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be after validFrom)');
2131
2181
  }
2132
2182
  // define status list content
2133
2183
  const content = {
2134
2184
  StatusList2021: {
2135
2185
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2136
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
2186
+ encodedList: publishedList.metadata.encoding === 'base64url'
2187
+ ? bitstring
2188
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
2189
+ .statusListEncoding),
2137
2190
  validFrom: publishedList.StatusList2021.validFrom,
2138
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2191
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2192
+ publishedList.StatusList2021.validUntil,
2139
2193
  },
2140
2194
  metadata: {
2141
2195
  type: publishedList.metadata.type,
2142
2196
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2143
2197
  encrypted: false,
2144
- }
2198
+ },
2145
2199
  };
2146
2200
  // return tuple of publish result and encryption relevant metadata
2147
2201
  return [
2148
2202
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2149
- undefined
2203
+ undefined,
2150
2204
  ];
2151
- }());
2205
+ })();
2152
2206
  // early exit, if publish failed
2153
2207
  if (!scoped[0])
2154
2208
  throw new Error('[did-provider-cheqd]: revocation: Failed to publish status list 2021');
2155
2209
  // return publish result
2156
2210
  return scoped;
2157
- }())
2211
+ })()
2158
2212
  : undefined;
2159
2213
  return {
2160
2214
  revoked: true,
2161
2215
  published: topArgs?.publish ? true : undefined,
2162
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credential) : undefined,
2163
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
2164
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credential) : undefined
2216
+ statusList: topArgs?.returnUpdatedStatusList
2217
+ ? (await Cheqd.fetchStatusList2021(credential))
2218
+ : undefined,
2219
+ symmetricKey: topArgs?.returnSymmetricKey
2220
+ ? published?.[1]?.symmetricKey
2221
+ : undefined,
2222
+ resourceMetadata: topArgs?.returnStatusListMetadata
2223
+ ? await Cheqd.fetchStatusList2021Metadata(credential)
2224
+ : undefined,
2165
2225
  };
2166
2226
  }
2167
2227
  catch (error) {
@@ -2175,14 +2235,18 @@ class Cheqd {
2175
2235
  if (!credentials.length || credentials.length === 0)
2176
2236
  throw new Error('[did-provider-cheqd]: revocation: No credentials provided');
2177
2237
  // validate credentials - case: consistent issuer
2178
- if (credentials.map((credential) => {
2179
- return (credential.issuer.id)
2238
+ if (credentials
2239
+ .map((credential) => {
2240
+ return credential.issuer.id
2180
2241
  ? credential.issuer.id
2181
2242
  : credential.issuer;
2182
- }).filter((value, _, self) => value && value !== self[0]).length > 0)
2243
+ })
2244
+ .filter((value, _, self) => value && value !== self[0]).length > 0)
2183
2245
  throw new Error('[did-provider-cheqd]: revocation: Credentials must be issued by the same issuer');
2184
2246
  // validate credentials - case: status list index
2185
- if (credentials.map((credential) => credential.credentialStatus.statusListIndex).filter((value, index, self) => self.indexOf(value) !== index).length > 0)
2247
+ if (credentials
2248
+ .map((credential) => credential.credentialStatus.statusListIndex)
2249
+ .filter((value, index, self) => self.indexOf(value) !== index).length > 0)
2186
2250
  throw new Error('[did-provider-cheqd]: revocation: Credentials must have unique status list index');
2187
2251
  // validate credentials - case: status purpose
2188
2252
  if (!credentials.every((credential) => credential.credentialStatus?.statusPurpose === 'revocation'))
@@ -2192,7 +2256,7 @@ class Cheqd {
2192
2256
  ? credentials[0].credentialStatus.id.split('#')[0]
2193
2257
  : (function () {
2194
2258
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list id');
2195
- }());
2259
+ })();
2196
2260
  // validate credentials - case: status list id format
2197
2261
  if (!exports.RemoteListPattern.test(remote))
2198
2262
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list id format: expected: https://<optional_subdomain>.<sld>.<tld>/1.0/identifiers/<did:cheqd:<namespace>:<method_specific_id>>?resourceName=<resource_name>&resourceType=<resource_type>');
@@ -2211,7 +2275,7 @@ class Cheqd {
2211
2275
  throw new Error('[did-provider-cheqd]: revocation: symmetricKey is required, if status list 2021 is encrypted');
2212
2276
  // fetch status list 2021 inscribed in credential
2213
2277
  const statusList2021 = options?.topArgs?.fetchList
2214
- ? (await async function () {
2278
+ ? await (async function () {
2215
2279
  // if not encrypted, return bitstring
2216
2280
  if (!publishedList.metadata.encrypted)
2217
2281
  return publishedList.metadata.encoding === 'base64url'
@@ -2221,8 +2285,8 @@ class Cheqd {
2221
2285
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
2222
2286
  // decrypt
2223
2287
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
2224
- }())
2225
- : (await async function () {
2288
+ })()
2289
+ : await (async function () {
2226
2290
  // transcode to base64url, if needed
2227
2291
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
2228
2292
  ? publishedList.StatusList2021.encodedList
@@ -2232,7 +2296,9 @@ class Cheqd {
2232
2296
  // if not encrypted, return bitstring
2233
2297
  if (!publishedList.metadata.encrypted) {
2234
2298
  // construct encoded status list
2235
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
2299
+ const encoded = new vc_status_list_1.StatusList({
2300
+ buffer: await Cheqd.getFile(options.statusListFile),
2301
+ }).encode();
2236
2302
  // validate against published list
2237
2303
  if (encoded !== publishedListTranscoded)
2238
2304
  throw new Error('[did-provider-cheqd]: revocation: statusListFile does not match published status list 2021');
@@ -2256,12 +2322,12 @@ class Cheqd {
2256
2322
  throw new Error('[did-provider-cheqd]: revocation: statusListInlineBitstring does not match published status list 2021');
2257
2323
  // otherwise, read from inline bitstring
2258
2324
  return options?.statusListInlineBitstring;
2259
- }());
2325
+ })();
2260
2326
  // parse status list 2021
2261
2327
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
2262
2328
  // initiate bulk revocation
2263
- const revoked = await Promise.allSettled(credentials.map((credential) => {
2264
- return async function () {
2329
+ const revoked = (await Promise.allSettled(credentials.map((credential) => {
2330
+ return (async function () {
2265
2331
  // early return, if no credential status
2266
2332
  if (!credential.credentialStatus)
2267
2333
  return { revoked: false };
@@ -2272,13 +2338,15 @@ class Cheqd {
2272
2338
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), true);
2273
2339
  // return revocation status
2274
2340
  return { revoked: true };
2275
- }();
2276
- }));
2341
+ })();
2342
+ })));
2277
2343
  // revert bulk ops, if some failed
2278
2344
  if (revoked.some((result) => result.status === 'fulfilled' && !result.value.revoked))
2279
- throw new Error(`[did-provider-cheqd]: revocation: Bulk revocation failed: already revoked credentials in revocation bundle: raw log: ${JSON.stringify(revoked.map((result) => ({ revoked: result.status === 'fulfilled' ? result.value.revoked : false })))}`);
2345
+ throw new Error(`[did-provider-cheqd]: revocation: Bulk revocation failed: already revoked credentials in revocation bundle: raw log: ${JSON.stringify(revoked.map((result) => ({
2346
+ revoked: result.status === 'fulfilled' ? result.value.revoked : false,
2347
+ })))}`);
2280
2348
  // set in-memory status list ref
2281
- const bitstring = await statusList.encode();
2349
+ const bitstring = (await statusList.encode());
2282
2350
  // cast top-level args
2283
2351
  const topArgs = options?.topArgs;
2284
2352
  // write status list 2021 to file, if provided
@@ -2287,14 +2355,15 @@ class Cheqd {
2287
2355
  }
2288
2356
  // publish status list 2021, if provided
2289
2357
  const published = topArgs?.publish
2290
- ? (await async function () {
2358
+ ? await (async function () {
2291
2359
  // fetch status list 2021 metadata
2292
2360
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credentials[0]);
2293
2361
  // publish status list 2021 as new version
2294
2362
  const scoped = topArgs.publishEncrypted
2295
- ? (await async function () {
2363
+ ? await (async function () {
2296
2364
  // validate encoding, if provided
2297
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2365
+ if (options?.publishOptions?.statusListEncoding &&
2366
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2298
2367
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list encoding');
2299
2368
  }
2300
2369
  // validate validUntil, if provided
@@ -2309,15 +2378,20 @@ class Cheqd {
2309
2378
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2310
2379
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be future date)');
2311
2380
  // validate validUntil towards validFrom
2312
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2381
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2382
+ new Date(publishedList.StatusList2021.validFrom))
2313
2383
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be after validFrom)');
2314
2384
  }
2315
2385
  // validate paymentConditions, if provided
2316
2386
  if (topArgs?.paymentConditions) {
2317
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
2387
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
2388
+ condition.feePaymentAmount &&
2389
+ condition.intervalInSeconds)) {
2318
2390
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
2319
2391
  }
2320
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
2392
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
2393
+ typeof condition.feePaymentAmount === 'string' &&
2394
+ typeof condition.intervalInSeconds === 'number')) {
2321
2395
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
2322
2396
  }
2323
2397
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -2325,19 +2399,22 @@ class Cheqd {
2325
2399
  }
2326
2400
  }
2327
2401
  // validate dkgOptions
2328
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
2402
+ if (!topArgs?.dkgOptions ||
2403
+ !topArgs?.dkgOptions?.chain ||
2404
+ !topArgs?.dkgOptions?.network) {
2329
2405
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
2330
2406
  }
2331
2407
  // instantiate dkg-threshold client, in which case lit-protocol is used
2332
2408
  const lit = await lit_protocol_js_1.LitProtocol.create({
2333
2409
  chain: topArgs?.dkgOptions?.chain,
2334
- litNetwork: topArgs?.dkgOptions?.network
2410
+ litNetwork: topArgs?.dkgOptions?.network,
2335
2411
  });
2336
2412
  // construct access control conditions and payment conditions tuple
2337
2413
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
2338
- ? (await (async function () {
2414
+ ? await (async function () {
2339
2415
  // define payment conditions, give precedence to top-level args
2340
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
2416
+ const paymentConditions = topArgs?.paymentConditions ||
2417
+ publishedList.metadata.paymentConditions;
2341
2418
  // return access control conditions and payment conditions tuple
2342
2419
  return [
2343
2420
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -2352,10 +2429,10 @@ class Cheqd {
2352
2429
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2353
2430
  }
2354
2431
  })),
2355
- paymentConditions
2432
+ paymentConditions,
2356
2433
  ];
2357
- }()))
2358
- : (await (async function () {
2434
+ })()
2435
+ : await (async function () {
2359
2436
  // validate paymentConditions
2360
2437
  if (!topArgs?.paymentConditions) {
2361
2438
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -2374,9 +2451,9 @@ class Cheqd {
2374
2451
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2375
2452
  }
2376
2453
  })),
2377
- topArgs.paymentConditions
2454
+ topArgs.paymentConditions,
2378
2455
  ];
2379
- }()));
2456
+ })();
2380
2457
  // encrypt bitstring
2381
2458
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
2382
2459
  // define status list content
@@ -2385,25 +2462,31 @@ class Cheqd {
2385
2462
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2386
2463
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
2387
2464
  validFrom: publishedList.StatusList2021.validFrom,
2388
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2465
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2466
+ publishedList.StatusList2021.validUntil,
2389
2467
  },
2390
2468
  metadata: {
2391
2469
  type: publishedList.metadata.type,
2392
2470
  encrypted: true,
2393
2471
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2394
2472
  encryptedSymmetricKey,
2395
- paymentConditions: unifiedAccessControlConditionsTuple[1]
2396
- }
2473
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
2474
+ },
2397
2475
  };
2398
2476
  // return tuple of publish result and encryption relevant metadata
2399
2477
  return [
2400
2478
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2401
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
2479
+ {
2480
+ encryptedString,
2481
+ encryptedSymmetricKey,
2482
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
2483
+ },
2402
2484
  ];
2403
- }())
2404
- : (await async function () {
2485
+ })()
2486
+ : await (async function () {
2405
2487
  // validate encoding, if provided
2406
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2488
+ if (options?.publishOptions?.statusListEncoding &&
2489
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2407
2490
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list encoding');
2408
2491
  }
2409
2492
  // validate validUntil, if provided
@@ -2418,42 +2501,53 @@ class Cheqd {
2418
2501
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2419
2502
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be future date)');
2420
2503
  // validate validUntil towards validFrom
2421
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2504
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2505
+ new Date(publishedList.StatusList2021.validFrom))
2422
2506
  throw new Error('[did-provider-cheqd]: revocation: Invalid status list validUntil (must be after validFrom)');
2423
2507
  }
2424
2508
  // define status list content
2425
2509
  const content = {
2426
2510
  StatusList2021: {
2427
2511
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2428
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
2512
+ encodedList: publishedList.metadata.encoding === 'base64url'
2513
+ ? bitstring
2514
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
2515
+ .statusListEncoding),
2429
2516
  validFrom: publishedList.StatusList2021.validFrom,
2430
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2517
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2518
+ publishedList.StatusList2021.validUntil,
2431
2519
  },
2432
2520
  metadata: {
2433
2521
  type: publishedList.metadata.type,
2434
2522
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2435
2523
  encrypted: false,
2436
- }
2524
+ },
2437
2525
  };
2438
2526
  // return tuple of publish result and encryption relevant metadata
2439
2527
  return [
2440
2528
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2441
- undefined
2529
+ undefined,
2442
2530
  ];
2443
- }());
2531
+ })();
2444
2532
  // early exit, if publish failed
2445
2533
  if (!scoped[0])
2446
2534
  throw new Error('[did-provider-cheqd]: revocation: Failed to publish status list 2021');
2447
2535
  // return publish result
2448
2536
  return scoped;
2449
- }())
2537
+ })()
2450
2538
  : undefined;
2451
2539
  return {
2452
- revoked: revoked.map((result) => result.status === 'fulfilled' ? result.value.revoked : false),
2540
+ revoked: revoked.map((result) => (result.status === 'fulfilled' ? result.value.revoked : false)),
2453
2541
  published: topArgs?.publish ? true : undefined,
2454
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credentials[0]) : undefined,
2455
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
2456
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credentials[0]) : undefined
2542
+ statusList: topArgs?.returnUpdatedStatusList
2543
+ ? (await Cheqd.fetchStatusList2021(credentials[0]))
2544
+ : undefined,
2545
+ symmetricKey: topArgs?.returnSymmetricKey
2546
+ ? published?.[1]?.symmetricKey
2547
+ : undefined,
2548
+ resourceMetadata: topArgs?.returnStatusListMetadata
2549
+ ? await Cheqd.fetchStatusList2021Metadata(credentials[0])
2550
+ : undefined,
2457
2551
  };
2458
2552
  }
2459
2553
  catch (error) {
@@ -2474,7 +2568,7 @@ class Cheqd {
2474
2568
  throw new Error('[did-provider-cheqd]: suspension: symmetricKey is required, if status list 2021 is encrypted');
2475
2569
  // fetch status list 2021 inscribed in credential
2476
2570
  const statusList2021 = options?.topArgs?.fetchList
2477
- ? (await async function () {
2571
+ ? await (async function () {
2478
2572
  // if not encrypted, return bitstring
2479
2573
  if (!publishedList.metadata.encrypted)
2480
2574
  return publishedList.metadata.encoding === 'base64url'
@@ -2484,8 +2578,8 @@ class Cheqd {
2484
2578
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
2485
2579
  // decrypt
2486
2580
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
2487
- }())
2488
- : (await async function () {
2581
+ })()
2582
+ : await (async function () {
2489
2583
  // transcode to base64url, if needed
2490
2584
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
2491
2585
  ? publishedList.StatusList2021.encodedList
@@ -2495,7 +2589,9 @@ class Cheqd {
2495
2589
  // if not encrypted, return bitstring
2496
2590
  if (!publishedList.metadata.encrypted) {
2497
2591
  // construct encoded status list
2498
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
2592
+ const encoded = new vc_status_list_1.StatusList({
2593
+ buffer: await Cheqd.getFile(options.statusListFile),
2594
+ }).encode();
2499
2595
  // validate against published list
2500
2596
  if (encoded !== publishedListTranscoded)
2501
2597
  throw new Error('[did-provider-cheqd]: suspension: statusListFile does not match published status list 2021');
@@ -2519,7 +2615,7 @@ class Cheqd {
2519
2615
  throw new Error('[did-provider-cheqd]: suspension: statusListInlineBitstring does not match published status list 2021');
2520
2616
  // otherwise, read from inline bitstring
2521
2617
  return options?.statusListInlineBitstring;
2522
- }());
2618
+ })();
2523
2619
  // parse status list 2021
2524
2620
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
2525
2621
  // early exit, if already suspended
@@ -2528,7 +2624,7 @@ class Cheqd {
2528
2624
  // update suspension status
2529
2625
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), true);
2530
2626
  // set in-memory status list ref
2531
- const bitstring = await statusList.encode();
2627
+ const bitstring = (await statusList.encode());
2532
2628
  // cast top-level args
2533
2629
  const topArgs = options?.topArgs;
2534
2630
  // write status list 2021 to file, if provided
@@ -2537,14 +2633,15 @@ class Cheqd {
2537
2633
  }
2538
2634
  // publish status list 2021, if provided
2539
2635
  const published = topArgs?.publish
2540
- ? (await async function () {
2636
+ ? await (async function () {
2541
2637
  // fetch status list 2021 metadata
2542
2638
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credential);
2543
2639
  // publish status list 2021 as new version
2544
2640
  const scoped = topArgs.publishEncrypted
2545
- ? (await async function () {
2641
+ ? await (async function () {
2546
2642
  // validate encoding, if provided
2547
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2643
+ if (options?.publishOptions?.statusListEncoding &&
2644
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2548
2645
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list encoding');
2549
2646
  }
2550
2647
  // validate validUntil, if provided
@@ -2559,15 +2656,20 @@ class Cheqd {
2559
2656
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2560
2657
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be future date)');
2561
2658
  // validate validUntil towards validFrom
2562
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2659
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2660
+ new Date(publishedList.StatusList2021.validFrom))
2563
2661
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be after validFrom)');
2564
2662
  }
2565
2663
  // validate paymentConditions, if provided
2566
2664
  if (topArgs?.paymentConditions) {
2567
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
2665
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
2666
+ condition.feePaymentAmount &&
2667
+ condition.intervalInSeconds)) {
2568
2668
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
2569
2669
  }
2570
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
2670
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
2671
+ typeof condition.feePaymentAmount === 'string' &&
2672
+ typeof condition.intervalInSeconds === 'number')) {
2571
2673
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
2572
2674
  }
2573
2675
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -2575,19 +2677,22 @@ class Cheqd {
2575
2677
  }
2576
2678
  }
2577
2679
  // validate dkgOptions
2578
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
2680
+ if (!topArgs?.dkgOptions ||
2681
+ !topArgs?.dkgOptions?.chain ||
2682
+ !topArgs?.dkgOptions?.network) {
2579
2683
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
2580
2684
  }
2581
2685
  // instantiate dkg-threshold client, in which case lit-protocol is used
2582
2686
  const lit = await lit_protocol_js_1.LitProtocol.create({
2583
2687
  chain: topArgs?.dkgOptions?.chain,
2584
- litNetwork: topArgs?.dkgOptions?.network
2688
+ litNetwork: topArgs?.dkgOptions?.network,
2585
2689
  });
2586
2690
  // construct access control conditions and payment conditions tuple
2587
2691
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
2588
- ? (await (async function () {
2692
+ ? await (async function () {
2589
2693
  // define payment conditions, give precedence to top-level args
2590
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
2694
+ const paymentConditions = topArgs?.paymentConditions ||
2695
+ publishedList.metadata.paymentConditions;
2591
2696
  // return access control conditions and payment conditions tuple
2592
2697
  return [
2593
2698
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -2602,10 +2707,10 @@ class Cheqd {
2602
2707
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2603
2708
  }
2604
2709
  })),
2605
- paymentConditions
2710
+ paymentConditions,
2606
2711
  ];
2607
- }()))
2608
- : (await (async function () {
2712
+ })()
2713
+ : await (async function () {
2609
2714
  // validate paymentConditions
2610
2715
  if (!topArgs?.paymentConditions) {
2611
2716
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -2624,9 +2729,9 @@ class Cheqd {
2624
2729
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2625
2730
  }
2626
2731
  })),
2627
- topArgs.paymentConditions
2732
+ topArgs.paymentConditions,
2628
2733
  ];
2629
- }()));
2734
+ })();
2630
2735
  // encrypt bitstring
2631
2736
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
2632
2737
  // define status list content
@@ -2635,25 +2740,31 @@ class Cheqd {
2635
2740
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2636
2741
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
2637
2742
  validFrom: publishedList.StatusList2021.validFrom,
2638
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2743
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2744
+ publishedList.StatusList2021.validUntil,
2639
2745
  },
2640
2746
  metadata: {
2641
2747
  type: publishedList.metadata.type,
2642
2748
  encrypted: true,
2643
2749
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2644
2750
  encryptedSymmetricKey,
2645
- paymentConditions: unifiedAccessControlConditionsTuple[1]
2646
- }
2751
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
2752
+ },
2647
2753
  };
2648
2754
  // return tuple of publish result and encryption relevant metadata
2649
2755
  return [
2650
2756
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2651
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
2757
+ {
2758
+ encryptedString,
2759
+ encryptedSymmetricKey,
2760
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
2761
+ },
2652
2762
  ];
2653
- }())
2654
- : (await async function () {
2763
+ })()
2764
+ : await (async function () {
2655
2765
  // validate encoding, if provided
2656
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2766
+ if (options?.publishOptions?.statusListEncoding &&
2767
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2657
2768
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list encoding');
2658
2769
  }
2659
2770
  // validate validUntil, if provided
@@ -2668,42 +2779,53 @@ class Cheqd {
2668
2779
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2669
2780
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be future date)');
2670
2781
  // validate validUntil towards validFrom
2671
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2782
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2783
+ new Date(publishedList.StatusList2021.validFrom))
2672
2784
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be after validFrom)');
2673
2785
  }
2674
2786
  // define status list content
2675
2787
  const content = {
2676
2788
  StatusList2021: {
2677
2789
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2678
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
2790
+ encodedList: publishedList.metadata.encoding === 'base64url'
2791
+ ? bitstring
2792
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
2793
+ .statusListEncoding),
2679
2794
  validFrom: publishedList.StatusList2021.validFrom,
2680
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
2795
+ validUntil: options?.publishOptions?.statusListValidUntil ||
2796
+ publishedList.StatusList2021.validUntil,
2681
2797
  },
2682
2798
  metadata: {
2683
2799
  type: publishedList.metadata.type,
2684
2800
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2685
2801
  encrypted: false,
2686
- }
2802
+ },
2687
2803
  };
2688
2804
  // return tuple of publish result and encryption relevant metadata
2689
2805
  return [
2690
2806
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2691
- undefined
2807
+ undefined,
2692
2808
  ];
2693
- }());
2809
+ })();
2694
2810
  // early exit, if publish failed
2695
2811
  if (!scoped[0])
2696
2812
  throw new Error('[did-provider-cheqd]: suspension: Failed to publish status list 2021');
2697
2813
  // return publish result
2698
2814
  return scoped;
2699
- }())
2815
+ })()
2700
2816
  : undefined;
2701
2817
  return {
2702
2818
  suspended: true,
2703
2819
  published: topArgs?.publish ? true : undefined,
2704
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credential) : undefined,
2705
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
2706
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credential) : undefined
2820
+ statusList: topArgs?.returnUpdatedStatusList
2821
+ ? (await Cheqd.fetchStatusList2021(credential))
2822
+ : undefined,
2823
+ symmetricKey: topArgs?.returnSymmetricKey
2824
+ ? published?.[1]?.symmetricKey
2825
+ : undefined,
2826
+ resourceMetadata: topArgs?.returnStatusListMetadata
2827
+ ? await Cheqd.fetchStatusList2021Metadata(credential)
2828
+ : undefined,
2707
2829
  };
2708
2830
  }
2709
2831
  catch (error) {
@@ -2717,14 +2839,18 @@ class Cheqd {
2717
2839
  if (!credentials.length || credentials.length === 0)
2718
2840
  throw new Error('[did-provider-cheqd]: suspension: No credentials provided');
2719
2841
  // validate credentials - case: consistent issuer
2720
- if (credentials.map((credential) => {
2721
- return (credential.issuer.id)
2842
+ if (credentials
2843
+ .map((credential) => {
2844
+ return credential.issuer.id
2722
2845
  ? credential.issuer.id
2723
2846
  : credential.issuer;
2724
- }).filter((value, _, self) => value && value !== self[0]).length > 0)
2847
+ })
2848
+ .filter((value, _, self) => value && value !== self[0]).length > 0)
2725
2849
  throw new Error('[did-provider-cheqd]: suspension: Credentials must be issued by the same issuer');
2726
2850
  // validate credentials - case: status list index
2727
- if (credentials.map((credential) => credential.credentialStatus.statusListIndex).filter((value, index, self) => self.indexOf(value) !== index).length > 0)
2851
+ if (credentials
2852
+ .map((credential) => credential.credentialStatus.statusListIndex)
2853
+ .filter((value, index, self) => self.indexOf(value) !== index).length > 0)
2728
2854
  throw new Error('[did-provider-cheqd]: suspension: Credentials must have unique status list index');
2729
2855
  // validate credentials - case: status purpose
2730
2856
  if (!credentials.every((credential) => credential.credentialStatus?.statusPurpose === 'suspension'))
@@ -2734,7 +2860,7 @@ class Cheqd {
2734
2860
  ? credentials[0].credentialStatus.id.split('#')[0]
2735
2861
  : (function () {
2736
2862
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list id');
2737
- }());
2863
+ })();
2738
2864
  // validate credentials - case: status list id format
2739
2865
  if (!exports.RemoteListPattern.test(remote))
2740
2866
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list id format: expected: https://<optional_subdomain>.<sld>.<tld>/1.0/identifiers/<did:cheqd:<namespace>:<method_specific_id>>?resourceName=<resource_name>&resourceType=<resource_type>');
@@ -2753,7 +2879,7 @@ class Cheqd {
2753
2879
  throw new Error('[did-provider-cheqd]: suspension: symmetricKey is required, if status list 2021 is encrypted');
2754
2880
  // fetch status list 2021 inscribed in credential
2755
2881
  const statusList2021 = options?.topArgs?.fetchList
2756
- ? (await async function () {
2882
+ ? await (async function () {
2757
2883
  // if not encrypted, return bitstring
2758
2884
  if (!publishedList.metadata.encrypted)
2759
2885
  return publishedList.metadata.encoding === 'base64url'
@@ -2763,8 +2889,8 @@ class Cheqd {
2763
2889
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
2764
2890
  // decrypt
2765
2891
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
2766
- }())
2767
- : (await async function () {
2892
+ })()
2893
+ : await (async function () {
2768
2894
  // transcode to base64url, if needed
2769
2895
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
2770
2896
  ? publishedList.StatusList2021.encodedList
@@ -2774,7 +2900,9 @@ class Cheqd {
2774
2900
  // if not encrypted, return bitstring
2775
2901
  if (!publishedList.metadata.encrypted) {
2776
2902
  // construct encoded status list
2777
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
2903
+ const encoded = new vc_status_list_1.StatusList({
2904
+ buffer: await Cheqd.getFile(options.statusListFile),
2905
+ }).encode();
2778
2906
  // validate against published list
2779
2907
  if (encoded !== publishedListTranscoded)
2780
2908
  throw new Error('[did-provider-cheqd]: suspension: statusListFile does not match published status list 2021');
@@ -2798,12 +2926,12 @@ class Cheqd {
2798
2926
  throw new Error('[did-provider-cheqd]: suspension: statusListInlineBitstring does not match published status list 2021');
2799
2927
  // otherwise, read from inline bitstring
2800
2928
  return options?.statusListInlineBitstring;
2801
- }());
2929
+ })();
2802
2930
  // parse status list 2021
2803
2931
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
2804
2932
  // initiate bulk suspension
2805
- const suspended = await Promise.allSettled(credentials.map((credential) => {
2806
- return async function () {
2933
+ const suspended = (await Promise.allSettled(credentials.map((credential) => {
2934
+ return (async function () {
2807
2935
  // early return, if no credential status
2808
2936
  if (!credential.credentialStatus)
2809
2937
  return { suspended: false };
@@ -2814,13 +2942,15 @@ class Cheqd {
2814
2942
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), true);
2815
2943
  // return suspension status
2816
2944
  return { suspended: true };
2817
- }();
2818
- }));
2945
+ })();
2946
+ })));
2819
2947
  // revert bulk ops, if some failed
2820
2948
  if (suspended.some((result) => result.status === 'fulfilled' && !result.value.suspended))
2821
- throw new Error(`[did-provider-cheqd]: suspension: Bulk suspension failed: already suspended credentials in suspension bundle: raw log: ${JSON.stringify(suspended.map((result) => ({ suspended: result.status === 'fulfilled' ? result.value.suspended : false })))}`);
2949
+ throw new Error(`[did-provider-cheqd]: suspension: Bulk suspension failed: already suspended credentials in suspension bundle: raw log: ${JSON.stringify(suspended.map((result) => ({
2950
+ suspended: result.status === 'fulfilled' ? result.value.suspended : false,
2951
+ })))}`);
2822
2952
  // set in-memory status list ref
2823
- const bitstring = await statusList.encode();
2953
+ const bitstring = (await statusList.encode());
2824
2954
  // cast top-level args
2825
2955
  const topArgs = options?.topArgs;
2826
2956
  // write status list 2021 to file, if provided
@@ -2829,14 +2959,15 @@ class Cheqd {
2829
2959
  }
2830
2960
  // publish status list 2021, if provided
2831
2961
  const published = topArgs?.publish
2832
- ? (await async function () {
2962
+ ? await (async function () {
2833
2963
  // fetch status list 2021 metadata
2834
2964
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credentials[0]);
2835
2965
  // publish status list 2021 as new version
2836
2966
  const scoped = topArgs.publishEncrypted
2837
- ? (await async function () {
2967
+ ? await (async function () {
2838
2968
  // validate encoding, if provided
2839
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2969
+ if (options?.publishOptions?.statusListEncoding &&
2970
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2840
2971
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list encoding');
2841
2972
  }
2842
2973
  // validate validUntil, if provided
@@ -2851,15 +2982,20 @@ class Cheqd {
2851
2982
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2852
2983
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be future date)');
2853
2984
  // validate validUntil towards validFrom
2854
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
2985
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
2986
+ new Date(publishedList.StatusList2021.validFrom))
2855
2987
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be after validFrom)');
2856
2988
  }
2857
2989
  // validate paymentConditions, if provided
2858
2990
  if (topArgs?.paymentConditions) {
2859
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
2991
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
2992
+ condition.feePaymentAmount &&
2993
+ condition.intervalInSeconds)) {
2860
2994
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
2861
2995
  }
2862
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
2996
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
2997
+ typeof condition.feePaymentAmount === 'string' &&
2998
+ typeof condition.intervalInSeconds === 'number')) {
2863
2999
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
2864
3000
  }
2865
3001
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -2867,19 +3003,22 @@ class Cheqd {
2867
3003
  }
2868
3004
  }
2869
3005
  // validate dkgOptions
2870
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
3006
+ if (!topArgs?.dkgOptions ||
3007
+ !topArgs?.dkgOptions?.chain ||
3008
+ !topArgs?.dkgOptions?.network) {
2871
3009
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
2872
3010
  }
2873
3011
  // instantiate dkg-threshold client, in which case lit-protocol is used
2874
3012
  const lit = await lit_protocol_js_1.LitProtocol.create({
2875
3013
  chain: topArgs?.dkgOptions?.chain,
2876
- litNetwork: topArgs?.dkgOptions?.network
3014
+ litNetwork: topArgs?.dkgOptions?.network,
2877
3015
  });
2878
3016
  // construct access control conditions and payment conditions tuple
2879
3017
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
2880
- ? (await (async function () {
3018
+ ? await (async function () {
2881
3019
  // define payment conditions, give precedence to top-level args
2882
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
3020
+ const paymentConditions = topArgs?.paymentConditions ||
3021
+ publishedList.metadata.paymentConditions;
2883
3022
  // return access control conditions and payment conditions tuple
2884
3023
  return [
2885
3024
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -2894,10 +3033,10 @@ class Cheqd {
2894
3033
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2895
3034
  }
2896
3035
  })),
2897
- paymentConditions
3036
+ paymentConditions,
2898
3037
  ];
2899
- }()))
2900
- : (await (async function () {
3038
+ })()
3039
+ : await (async function () {
2901
3040
  // validate paymentConditions
2902
3041
  if (!topArgs?.paymentConditions) {
2903
3042
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -2916,9 +3055,9 @@ class Cheqd {
2916
3055
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
2917
3056
  }
2918
3057
  })),
2919
- topArgs.paymentConditions
3058
+ topArgs.paymentConditions,
2920
3059
  ];
2921
- }()));
3060
+ })();
2922
3061
  // encrypt bitstring
2923
3062
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
2924
3063
  // define status list content
@@ -2927,25 +3066,31 @@ class Cheqd {
2927
3066
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2928
3067
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
2929
3068
  validFrom: publishedList.StatusList2021.validFrom,
2930
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3069
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3070
+ publishedList.StatusList2021.validUntil,
2931
3071
  },
2932
3072
  metadata: {
2933
3073
  type: publishedList.metadata.type,
2934
3074
  encrypted: true,
2935
3075
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2936
3076
  encryptedSymmetricKey,
2937
- paymentConditions: unifiedAccessControlConditionsTuple[1]
2938
- }
3077
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
3078
+ },
2939
3079
  };
2940
3080
  // return tuple of publish result and encryption relevant metadata
2941
3081
  return [
2942
3082
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2943
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
3083
+ {
3084
+ encryptedString,
3085
+ encryptedSymmetricKey,
3086
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
3087
+ },
2944
3088
  ];
2945
- }())
2946
- : (await async function () {
3089
+ })()
3090
+ : await (async function () {
2947
3091
  // validate encoding, if provided
2948
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3092
+ if (options?.publishOptions?.statusListEncoding &&
3093
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
2949
3094
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list encoding');
2950
3095
  }
2951
3096
  // validate validUntil, if provided
@@ -2960,42 +3105,53 @@ class Cheqd {
2960
3105
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
2961
3106
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be future date)');
2962
3107
  // validate validUntil towards validFrom
2963
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
3108
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
3109
+ new Date(publishedList.StatusList2021.validFrom))
2964
3110
  throw new Error('[did-provider-cheqd]: suspension: Invalid status list validUntil (must be after validFrom)');
2965
3111
  }
2966
3112
  // define status list content
2967
3113
  const content = {
2968
3114
  StatusList2021: {
2969
3115
  statusPurpose: publishedList.StatusList2021.statusPurpose,
2970
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
3116
+ encodedList: publishedList.metadata.encoding === 'base64url'
3117
+ ? bitstring
3118
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
3119
+ .statusListEncoding),
2971
3120
  validFrom: publishedList.StatusList2021.validFrom,
2972
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3121
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3122
+ publishedList.StatusList2021.validUntil,
2973
3123
  },
2974
3124
  metadata: {
2975
3125
  type: publishedList.metadata.type,
2976
3126
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
2977
3127
  encrypted: false,
2978
- }
3128
+ },
2979
3129
  };
2980
3130
  // return tuple of publish result and encryption relevant metadata
2981
3131
  return [
2982
3132
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
2983
- undefined
3133
+ undefined,
2984
3134
  ];
2985
- }());
3135
+ })();
2986
3136
  // early exit, if publish failed
2987
3137
  if (!scoped[0])
2988
3138
  throw new Error('[did-provider-cheqd]: suspension: Failed to publish status list 2021');
2989
3139
  // return publish result
2990
3140
  return scoped;
2991
- }())
3141
+ })()
2992
3142
  : undefined;
2993
3143
  return {
2994
- suspended: suspended.map((result) => result.status === 'fulfilled' ? result.value.suspended : false),
3144
+ suspended: suspended.map((result) => (result.status === 'fulfilled' ? result.value.suspended : false)),
2995
3145
  published: topArgs?.publish ? true : undefined,
2996
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credentials[0]) : undefined,
2997
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
2998
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credentials[0]) : undefined
3146
+ statusList: topArgs?.returnUpdatedStatusList
3147
+ ? (await Cheqd.fetchStatusList2021(credentials[0]))
3148
+ : undefined,
3149
+ symmetricKey: topArgs?.returnSymmetricKey
3150
+ ? published?.[1]?.symmetricKey
3151
+ : undefined,
3152
+ resourceMetadata: topArgs?.returnStatusListMetadata
3153
+ ? await Cheqd.fetchStatusList2021Metadata(credentials[0])
3154
+ : undefined,
2999
3155
  };
3000
3156
  }
3001
3157
  catch (error) {
@@ -3016,7 +3172,7 @@ class Cheqd {
3016
3172
  throw new Error('[did-provider-cheqd]: unsuspension: symmetricKey is required, if status list 2021 is encrypted');
3017
3173
  // fetch status list 2021 inscribed in credential
3018
3174
  const statusList2021 = options?.topArgs?.fetchList
3019
- ? (await async function () {
3175
+ ? await (async function () {
3020
3176
  // if not encrypted, return bitstring
3021
3177
  if (!publishedList.metadata.encrypted)
3022
3178
  return publishedList.metadata.encoding === 'base64url'
@@ -3026,8 +3182,8 @@ class Cheqd {
3026
3182
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
3027
3183
  // decrypt
3028
3184
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
3029
- }())
3030
- : (await async function () {
3185
+ })()
3186
+ : await (async function () {
3031
3187
  // transcode to base64url, if needed
3032
3188
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
3033
3189
  ? publishedList.StatusList2021.encodedList
@@ -3037,7 +3193,9 @@ class Cheqd {
3037
3193
  // if not encrypted, return bitstring
3038
3194
  if (!publishedList.metadata.encrypted) {
3039
3195
  // construct encoded status list
3040
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
3196
+ const encoded = new vc_status_list_1.StatusList({
3197
+ buffer: await Cheqd.getFile(options.statusListFile),
3198
+ }).encode();
3041
3199
  // validate against published list
3042
3200
  if (encoded !== publishedListTranscoded)
3043
3201
  throw new Error('[did-provider-cheqd]: unsuspension: statusListFile does not match published status list 2021');
@@ -3061,7 +3219,7 @@ class Cheqd {
3061
3219
  throw new Error('[did-provider-cheqd]: unsuspension: statusListInlineBitstring does not match published status list 2021');
3062
3220
  // otherwise, read from inline bitstring
3063
3221
  return options?.statusListInlineBitstring;
3064
- }());
3222
+ })();
3065
3223
  // parse status list 2021
3066
3224
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
3067
3225
  // early exit, if already unsuspended
@@ -3070,7 +3228,7 @@ class Cheqd {
3070
3228
  // update suspension status
3071
3229
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), false);
3072
3230
  // set in-memory status list ref
3073
- const bitstring = await statusList.encode();
3231
+ const bitstring = (await statusList.encode());
3074
3232
  // cast top-level args
3075
3233
  const topArgs = options?.topArgs;
3076
3234
  // write status list 2021 to file, if provided
@@ -3079,14 +3237,15 @@ class Cheqd {
3079
3237
  }
3080
3238
  // publish status list 2021, if provided
3081
3239
  const published = topArgs?.publish
3082
- ? (await async function () {
3240
+ ? await (async function () {
3083
3241
  // fetch status list 2021 metadata
3084
3242
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credential);
3085
3243
  // publish status list 2021 as new version
3086
3244
  const scoped = topArgs.publishEncrypted
3087
- ? (await async function () {
3245
+ ? await (async function () {
3088
3246
  // validate encoding, if provided
3089
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3247
+ if (options?.publishOptions?.statusListEncoding &&
3248
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3090
3249
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list encoding');
3091
3250
  }
3092
3251
  // validate validUntil, if provided
@@ -3101,15 +3260,20 @@ class Cheqd {
3101
3260
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
3102
3261
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be future date)');
3103
3262
  // validate validUntil towards validFrom
3104
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
3263
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
3264
+ new Date(publishedList.StatusList2021.validFrom))
3105
3265
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be after validFrom)');
3106
3266
  }
3107
3267
  // validate paymentConditions, if provided
3108
3268
  if (topArgs?.paymentConditions) {
3109
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
3269
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
3270
+ condition.feePaymentAmount &&
3271
+ condition.intervalInSeconds)) {
3110
3272
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
3111
3273
  }
3112
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
3274
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
3275
+ typeof condition.feePaymentAmount === 'string' &&
3276
+ typeof condition.intervalInSeconds === 'number')) {
3113
3277
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
3114
3278
  }
3115
3279
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -3117,19 +3281,22 @@ class Cheqd {
3117
3281
  }
3118
3282
  }
3119
3283
  // validate dkgOptions
3120
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
3284
+ if (!topArgs?.dkgOptions ||
3285
+ !topArgs?.dkgOptions?.chain ||
3286
+ !topArgs?.dkgOptions?.network) {
3121
3287
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
3122
3288
  }
3123
3289
  // instantiate dkg-threshold client, in which case lit-protocol is used
3124
3290
  const lit = await lit_protocol_js_1.LitProtocol.create({
3125
3291
  chain: topArgs?.dkgOptions?.chain,
3126
- litNetwork: topArgs?.dkgOptions?.network
3292
+ litNetwork: topArgs?.dkgOptions?.network,
3127
3293
  });
3128
3294
  // construct access control conditions and payment conditions tuple
3129
3295
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
3130
- ? (await (async function () {
3296
+ ? await (async function () {
3131
3297
  // define payment conditions, give precedence to top-level args
3132
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
3298
+ const paymentConditions = topArgs?.paymentConditions ||
3299
+ publishedList.metadata.paymentConditions;
3133
3300
  // return access control conditions and payment conditions tuple
3134
3301
  return [
3135
3302
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -3144,10 +3311,10 @@ class Cheqd {
3144
3311
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
3145
3312
  }
3146
3313
  })),
3147
- paymentConditions
3314
+ paymentConditions,
3148
3315
  ];
3149
- }()))
3150
- : (await (async function () {
3316
+ })()
3317
+ : await (async function () {
3151
3318
  // validate paymentConditions
3152
3319
  if (!topArgs?.paymentConditions) {
3153
3320
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -3166,9 +3333,9 @@ class Cheqd {
3166
3333
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
3167
3334
  }
3168
3335
  })),
3169
- topArgs.paymentConditions
3336
+ topArgs.paymentConditions,
3170
3337
  ];
3171
- }()));
3338
+ })();
3172
3339
  // encrypt bitstring
3173
3340
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
3174
3341
  // define status list content
@@ -3177,25 +3344,31 @@ class Cheqd {
3177
3344
  statusPurpose: publishedList.StatusList2021.statusPurpose,
3178
3345
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
3179
3346
  validFrom: publishedList.StatusList2021.validFrom,
3180
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3347
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3348
+ publishedList.StatusList2021.validUntil,
3181
3349
  },
3182
3350
  metadata: {
3183
3351
  type: publishedList.metadata.type,
3184
3352
  encrypted: true,
3185
3353
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
3186
3354
  encryptedSymmetricKey,
3187
- paymentConditions: unifiedAccessControlConditionsTuple[1]
3188
- }
3355
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
3356
+ },
3189
3357
  };
3190
3358
  // return tuple of publish result and encryption relevant metadata
3191
3359
  return [
3192
3360
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
3193
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
3361
+ {
3362
+ encryptedString,
3363
+ encryptedSymmetricKey,
3364
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
3365
+ },
3194
3366
  ];
3195
- }())
3196
- : (await async function () {
3367
+ })()
3368
+ : await (async function () {
3197
3369
  // validate encoding, if provided
3198
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3370
+ if (options?.publishOptions?.statusListEncoding &&
3371
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3199
3372
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list encoding');
3200
3373
  }
3201
3374
  // validate validUntil, if provided
@@ -3210,42 +3383,53 @@ class Cheqd {
3210
3383
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
3211
3384
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be future date)');
3212
3385
  // validate validUntil towards validFrom
3213
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
3386
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
3387
+ new Date(publishedList.StatusList2021.validFrom))
3214
3388
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be after validFrom)');
3215
3389
  }
3216
3390
  // define status list content
3217
3391
  const content = {
3218
3392
  StatusList2021: {
3219
3393
  statusPurpose: publishedList.StatusList2021.statusPurpose,
3220
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
3394
+ encodedList: publishedList.metadata.encoding === 'base64url'
3395
+ ? bitstring
3396
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
3397
+ .statusListEncoding),
3221
3398
  validFrom: publishedList.StatusList2021.validFrom,
3222
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3399
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3400
+ publishedList.StatusList2021.validUntil,
3223
3401
  },
3224
3402
  metadata: {
3225
3403
  type: publishedList.metadata.type,
3226
3404
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
3227
3405
  encrypted: false,
3228
- }
3406
+ },
3229
3407
  };
3230
3408
  // return tuple of publish result and encryption relevant metadata
3231
3409
  return [
3232
3410
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
3233
- undefined
3411
+ undefined,
3234
3412
  ];
3235
- }());
3413
+ })();
3236
3414
  // early exit, if publish failed
3237
3415
  if (!scoped[0])
3238
3416
  throw new Error('[did-provider-cheqd]: unsuspension: Failed to publish status list 2021');
3239
3417
  // return publish result
3240
3418
  return scoped;
3241
- }())
3419
+ })()
3242
3420
  : undefined;
3243
3421
  return {
3244
3422
  unsuspended: true,
3245
3423
  published: topArgs?.publish ? true : undefined,
3246
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credential) : undefined,
3247
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
3248
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credential) : undefined
3424
+ statusList: topArgs?.returnUpdatedStatusList
3425
+ ? (await Cheqd.fetchStatusList2021(credential))
3426
+ : undefined,
3427
+ symmetricKey: topArgs?.returnSymmetricKey
3428
+ ? published?.[1]?.symmetricKey
3429
+ : undefined,
3430
+ resourceMetadata: topArgs?.returnStatusListMetadata
3431
+ ? await Cheqd.fetchStatusList2021Metadata(credential)
3432
+ : undefined,
3249
3433
  };
3250
3434
  }
3251
3435
  catch (error) {
@@ -3259,14 +3443,18 @@ class Cheqd {
3259
3443
  if (!credentials.length || credentials.length === 0)
3260
3444
  throw new Error('[did-provider-cheqd]: unsuspension: No credentials provided');
3261
3445
  // validate credentials - case: consistent issuer
3262
- if (credentials.map((credential) => {
3263
- return (credential.issuer.id)
3446
+ if (credentials
3447
+ .map((credential) => {
3448
+ return credential.issuer.id
3264
3449
  ? credential.issuer.id
3265
3450
  : credential.issuer;
3266
- }).filter((value, _, self) => value && value !== self[0]).length > 0)
3451
+ })
3452
+ .filter((value, _, self) => value && value !== self[0]).length > 0)
3267
3453
  throw new Error('[did-provider-cheqd]: unsuspension: Credentials must be issued by the same issuer');
3268
3454
  // validate credentials - case: status list index
3269
- if (credentials.map((credential) => credential.credentialStatus.statusListIndex).filter((value, index, self) => self.indexOf(value) !== index).length > 0)
3455
+ if (credentials
3456
+ .map((credential) => credential.credentialStatus.statusListIndex)
3457
+ .filter((value, index, self) => self.indexOf(value) !== index).length > 0)
3270
3458
  throw new Error('[did-provider-cheqd]: unsuspension: Credentials must have unique status list index');
3271
3459
  // validate credentials - case: status purpose
3272
3460
  if (!credentials.every((credential) => credential.credentialStatus?.statusPurpose === 'suspension'))
@@ -3276,7 +3464,7 @@ class Cheqd {
3276
3464
  ? credentials[0].credentialStatus.id.split('#')[0]
3277
3465
  : (function () {
3278
3466
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list id');
3279
- }());
3467
+ })();
3280
3468
  // validate credentials - case: status list id format
3281
3469
  if (!exports.RemoteListPattern.test(remote))
3282
3470
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list id format: expected: https://<optional_subdomain>.<sld>.<tld>/1.0/identifiers/<did:cheqd:<namespace>:<method_specific_id>>?resourceName=<resource_name>&resourceType=<resource_type>');
@@ -3295,7 +3483,7 @@ class Cheqd {
3295
3483
  throw new Error('[did-provider-cheqd]: unsuspension: symmetricKey is required, if status list 2021 is encrypted');
3296
3484
  // fetch status list 2021 inscribed in credential
3297
3485
  const statusList2021 = options?.topArgs?.fetchList
3298
- ? (await async function () {
3486
+ ? await (async function () {
3299
3487
  // if not encrypted, return bitstring
3300
3488
  if (!publishedList.metadata.encrypted)
3301
3489
  return publishedList.metadata.encoding === 'base64url'
@@ -3305,8 +3493,8 @@ class Cheqd {
3305
3493
  const scopedRawBlob = await (0, helpers_js_1.toBlob)((0, uint8arrays_1.fromString)(publishedList.StatusList2021.encodedList, 'hex'));
3306
3494
  // decrypt
3307
3495
  return await lit_protocol_js_1.LitProtocol.decryptDirect(scopedRawBlob, (0, uint8arrays_1.fromString)(options?.topArgs?.symmetricKey, 'hex'));
3308
- }())
3309
- : (await async function () {
3496
+ })()
3497
+ : await (async function () {
3310
3498
  // transcode to base64url, if needed
3311
3499
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
3312
3500
  ? publishedList.StatusList2021.encodedList
@@ -3316,7 +3504,9 @@ class Cheqd {
3316
3504
  // if not encrypted, return bitstring
3317
3505
  if (!publishedList.metadata.encrypted) {
3318
3506
  // construct encoded status list
3319
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
3507
+ const encoded = new vc_status_list_1.StatusList({
3508
+ buffer: await Cheqd.getFile(options.statusListFile),
3509
+ }).encode();
3320
3510
  // validate against published list
3321
3511
  if (encoded !== publishedListTranscoded)
3322
3512
  throw new Error('[did-provider-cheqd]: unsuspension: statusListFile does not match published status list 2021');
@@ -3340,12 +3530,12 @@ class Cheqd {
3340
3530
  throw new Error('[did-provider-cheqd]: unsuspension: statusListInlineBitstring does not match published status list 2021');
3341
3531
  // otherwise, read from inline bitstring
3342
3532
  return options?.statusListInlineBitstring;
3343
- }());
3533
+ })();
3344
3534
  // parse status list 2021
3345
3535
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
3346
3536
  // initiate bulk unsuspension
3347
- const unsuspended = await Promise.allSettled(credentials.map((credential) => {
3348
- return async function () {
3537
+ const unsuspended = (await Promise.allSettled(credentials.map((credential) => {
3538
+ return (async function () {
3349
3539
  // early return, if no credential status
3350
3540
  if (!credential.credentialStatus)
3351
3541
  return { unsuspended: false };
@@ -3356,13 +3546,15 @@ class Cheqd {
3356
3546
  statusList.setStatus(Number(credential.credentialStatus.statusListIndex), false);
3357
3547
  // return unsuspension status
3358
3548
  return { unsuspended: true };
3359
- }();
3360
- }));
3549
+ })();
3550
+ })));
3361
3551
  // revert bulk ops, if some failed
3362
3552
  if (unsuspended.some((result) => result.status === 'fulfilled' && !result.value.unsuspended))
3363
- throw new Error(`[did-provider-cheqd]: unsuspension: Bulk unsuspension failed: already unsuspended credentials in unsuspension bundle: raw log: ${JSON.stringify(unsuspended.map((result) => ({ unsuspended: result.status === 'fulfilled' ? result.value.unsuspended : false })))}`);
3553
+ throw new Error(`[did-provider-cheqd]: unsuspension: Bulk unsuspension failed: already unsuspended credentials in unsuspension bundle: raw log: ${JSON.stringify(unsuspended.map((result) => ({
3554
+ unsuspended: result.status === 'fulfilled' ? result.value.unsuspended : false,
3555
+ })))}`);
3364
3556
  // set in-memory status list ref
3365
- const bitstring = await statusList.encode();
3557
+ const bitstring = (await statusList.encode());
3366
3558
  // cast top-level args
3367
3559
  const topArgs = options?.topArgs;
3368
3560
  // write status list 2021 to file, if provided
@@ -3371,14 +3563,15 @@ class Cheqd {
3371
3563
  }
3372
3564
  // publish status list 2021, if provided
3373
3565
  const published = topArgs?.publish
3374
- ? (await async function () {
3566
+ ? await (async function () {
3375
3567
  // fetch status list 2021 metadata
3376
3568
  const statusListMetadata = await Cheqd.fetchStatusList2021Metadata(credentials[0]);
3377
3569
  // publish status list 2021 as new version
3378
3570
  const scoped = topArgs.publishEncrypted
3379
- ? (await async function () {
3571
+ ? await (async function () {
3380
3572
  // validate encoding, if provided
3381
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3573
+ if (options?.publishOptions?.statusListEncoding &&
3574
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3382
3575
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list encoding');
3383
3576
  }
3384
3577
  // validate validUntil, if provided
@@ -3393,15 +3586,20 @@ class Cheqd {
3393
3586
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
3394
3587
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be future date)');
3395
3588
  // validate validUntil towards validFrom
3396
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
3589
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
3590
+ new Date(publishedList.StatusList2021.validFrom))
3397
3591
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be after validFrom)');
3398
3592
  }
3399
3593
  // validate paymentConditions, if provided
3400
3594
  if (topArgs?.paymentConditions) {
3401
- if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress && condition.feePaymentAmount && condition.intervalInSeconds)) {
3595
+ if (!topArgs?.paymentConditions?.every((condition) => condition.feePaymentAddress &&
3596
+ condition.feePaymentAmount &&
3597
+ condition.intervalInSeconds)) {
3402
3598
  throw new Error('[did-provider-cheqd]: paymentConditions must contain feePaymentAddress and feeAmount and intervalInSeconds');
3403
3599
  }
3404
- if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' && typeof condition.feePaymentAmount === 'string' && typeof condition.intervalInSeconds === 'number')) {
3600
+ if (!topArgs?.paymentConditions?.every((condition) => typeof condition.feePaymentAddress === 'string' &&
3601
+ typeof condition.feePaymentAmount === 'string' &&
3602
+ typeof condition.intervalInSeconds === 'number')) {
3405
3603
  throw new Error('[did-provider-cheqd]: feePaymentAddress and feePaymentAmount must be string and intervalInSeconds must be number');
3406
3604
  }
3407
3605
  if (!topArgs?.paymentConditions?.every((condition) => condition.type === exports.AccessControlConditionTypes.timelockPayment)) {
@@ -3409,19 +3607,22 @@ class Cheqd {
3409
3607
  }
3410
3608
  }
3411
3609
  // validate dkgOptions
3412
- if (!topArgs?.dkgOptions || !topArgs?.dkgOptions?.chain || !topArgs?.dkgOptions?.network) {
3610
+ if (!topArgs?.dkgOptions ||
3611
+ !topArgs?.dkgOptions?.chain ||
3612
+ !topArgs?.dkgOptions?.network) {
3413
3613
  throw new Error('[did-provider-cheqd]: dkgOptions is required');
3414
3614
  }
3415
3615
  // instantiate dkg-threshold client, in which case lit-protocol is used
3416
3616
  const lit = await lit_protocol_js_1.LitProtocol.create({
3417
3617
  chain: topArgs?.dkgOptions?.chain,
3418
- litNetwork: topArgs?.dkgOptions?.network
3618
+ litNetwork: topArgs?.dkgOptions?.network,
3419
3619
  });
3420
3620
  // construct access control conditions and payment conditions tuple
3421
3621
  const unifiedAccessControlConditionsTuple = publishedList.metadata.encrypted
3422
- ? (await (async function () {
3622
+ ? await (async function () {
3423
3623
  // define payment conditions, give precedence to top-level args
3424
- const paymentConditions = topArgs?.paymentConditions || publishedList.metadata.paymentConditions;
3624
+ const paymentConditions = topArgs?.paymentConditions ||
3625
+ publishedList.metadata.paymentConditions;
3425
3626
  // return access control conditions and payment conditions tuple
3426
3627
  return [
3427
3628
  await Promise.all(paymentConditions.map(async (condition) => {
@@ -3436,10 +3637,10 @@ class Cheqd {
3436
3637
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
3437
3638
  }
3438
3639
  })),
3439
- paymentConditions
3640
+ paymentConditions,
3440
3641
  ];
3441
- }()))
3442
- : (await (async function () {
3642
+ })()
3643
+ : await (async function () {
3443
3644
  // validate paymentConditions
3444
3645
  if (!topArgs?.paymentConditions) {
3445
3646
  throw new Error('[did-provider-cheqd]: paymentConditions is required');
@@ -3458,9 +3659,9 @@ class Cheqd {
3458
3659
  throw new Error(`[did-provider-cheqd]: unsupported access control condition type ${condition.type}`);
3459
3660
  }
3460
3661
  })),
3461
- topArgs.paymentConditions
3662
+ topArgs.paymentConditions,
3462
3663
  ];
3463
- }()));
3664
+ })();
3464
3665
  // encrypt bitstring
3465
3666
  const { encryptedString, encryptedSymmetricKey, symmetricKey } = await lit.encrypt(bitstring, unifiedAccessControlConditionsTuple[0], true);
3466
3667
  // define status list content
@@ -3469,25 +3670,31 @@ class Cheqd {
3469
3670
  statusPurpose: publishedList.StatusList2021.statusPurpose,
3470
3671
  encodedList: await (0, helpers_js_1.blobToHexString)(encryptedString),
3471
3672
  validFrom: publishedList.StatusList2021.validFrom,
3472
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3673
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3674
+ publishedList.StatusList2021.validUntil,
3473
3675
  },
3474
3676
  metadata: {
3475
3677
  type: publishedList.metadata.type,
3476
3678
  encrypted: true,
3477
3679
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
3478
3680
  encryptedSymmetricKey,
3479
- paymentConditions: unifiedAccessControlConditionsTuple[1]
3480
- }
3681
+ paymentConditions: unifiedAccessControlConditionsTuple[1],
3682
+ },
3481
3683
  };
3482
3684
  // return tuple of publish result and encryption relevant metadata
3483
3685
  return [
3484
3686
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
3485
- { encryptedString, encryptedSymmetricKey, symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex') }
3687
+ {
3688
+ encryptedString,
3689
+ encryptedSymmetricKey,
3690
+ symmetricKey: (0, uint8arrays_1.toString)(symmetricKey, 'hex'),
3691
+ },
3486
3692
  ];
3487
- }())
3488
- : (await async function () {
3693
+ })()
3694
+ : await (async function () {
3489
3695
  // validate encoding, if provided
3490
- if (options?.publishOptions?.statusListEncoding && !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3696
+ if (options?.publishOptions?.statusListEncoding &&
3697
+ !Object.values(cheqd_did_provider_js_1.DefaultStatusList2021Encodings).includes(options?.publishOptions?.statusListEncoding)) {
3491
3698
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list encoding');
3492
3699
  }
3493
3700
  // validate validUntil, if provided
@@ -3502,42 +3709,53 @@ class Cheqd {
3502
3709
  if (new Date(options?.publishOptions?.statusListValidUntil) < new Date())
3503
3710
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be future date)');
3504
3711
  // validate validUntil towards validFrom
3505
- if (new Date(options?.publishOptions?.statusListValidUntil) <= new Date(publishedList.StatusList2021.validFrom))
3712
+ if (new Date(options?.publishOptions?.statusListValidUntil) <=
3713
+ new Date(publishedList.StatusList2021.validFrom))
3506
3714
  throw new Error('[did-provider-cheqd]: unsuspension: Invalid status list validUntil (must be after validFrom)');
3507
3715
  }
3508
3716
  // define status list content
3509
3717
  const content = {
3510
3718
  StatusList2021: {
3511
3719
  statusPurpose: publishedList.StatusList2021.statusPurpose,
3512
- encodedList: publishedList.metadata.encoding === 'base64url' ? bitstring : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions.statusListEncoding),
3720
+ encodedList: publishedList.metadata.encoding === 'base64url'
3721
+ ? bitstring
3722
+ : (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(bitstring, 'base64url'), options.publishOptions
3723
+ .statusListEncoding),
3513
3724
  validFrom: publishedList.StatusList2021.validFrom,
3514
- validUntil: options?.publishOptions?.statusListValidUntil || publishedList.StatusList2021.validUntil
3725
+ validUntil: options?.publishOptions?.statusListValidUntil ||
3726
+ publishedList.StatusList2021.validUntil,
3515
3727
  },
3516
3728
  metadata: {
3517
3729
  type: publishedList.metadata.type,
3518
3730
  encoding: options?.publishOptions?.statusListEncoding || publishedList.metadata.encoding,
3519
3731
  encrypted: false,
3520
- }
3732
+ },
3521
3733
  };
3522
3734
  // return tuple of publish result and encryption relevant metadata
3523
3735
  return [
3524
3736
  await Cheqd.publishStatusList2021((0, uint8arrays_1.fromString)(JSON.stringify(content), 'utf-8'), statusListMetadata, options?.publishOptions),
3525
- undefined
3737
+ undefined,
3526
3738
  ];
3527
- }());
3739
+ })();
3528
3740
  // early exit, if publish failed
3529
3741
  if (!scoped[0])
3530
3742
  throw new Error('[did-provider-cheqd]: unsuspension: Failed to publish status list 2021');
3531
3743
  // return publish result
3532
3744
  return scoped;
3533
- }())
3745
+ })()
3534
3746
  : undefined;
3535
3747
  return {
3536
3748
  unsuspended: unsuspended.map((result) => result.status === 'fulfilled' ? result.value.unsuspended : false),
3537
3749
  published: topArgs?.publish ? true : undefined,
3538
- statusList: topArgs?.returnUpdatedStatusList ? await Cheqd.fetchStatusList2021(credentials[0]) : undefined,
3539
- symmetricKey: topArgs?.returnSymmetricKey ? published?.[1]?.symmetricKey : undefined,
3540
- resourceMetadata: topArgs?.returnStatusListMetadata ? await Cheqd.fetchStatusList2021Metadata(credentials[0]) : undefined
3750
+ statusList: topArgs?.returnUpdatedStatusList
3751
+ ? (await Cheqd.fetchStatusList2021(credentials[0]))
3752
+ : undefined,
3753
+ symmetricKey: topArgs?.returnSymmetricKey
3754
+ ? published?.[1]?.symmetricKey
3755
+ : undefined,
3756
+ resourceMetadata: topArgs?.returnStatusListMetadata
3757
+ ? await Cheqd.fetchStatusList2021Metadata(credentials[0])
3758
+ : undefined,
3541
3759
  };
3542
3760
  }
3543
3761
  catch (error) {
@@ -3555,7 +3773,7 @@ class Cheqd {
3555
3773
  const publishedList = (await Cheqd.fetchStatusList2021(credential));
3556
3774
  // fetch status list 2021 inscribed in credential
3557
3775
  const statusList2021 = options?.topArgs?.fetchList
3558
- ? (await async function () {
3776
+ ? await (async function () {
3559
3777
  // if not encrypted, return bitstring
3560
3778
  if (!publishedList.metadata.encrypted)
3561
3779
  return publishedList.metadata.encoding === 'base64url'
@@ -3566,7 +3784,7 @@ class Cheqd {
3566
3784
  // instantiate dkg-threshold client, in which case lit-protocol is used
3567
3785
  const lit = await lit_protocol_js_1.LitProtocol.create({
3568
3786
  chain: options?.topArgs?.dkgOptions?.chain,
3569
- litNetwork: options?.topArgs?.dkgOptions?.network
3787
+ litNetwork: options?.topArgs?.dkgOptions?.network,
3570
3788
  });
3571
3789
  // construct access control conditions
3572
3790
  const unifiedAccessControlConditions = await Promise.all(publishedList.metadata.paymentConditions.map(async (condition) => {
@@ -3583,8 +3801,8 @@ class Cheqd {
3583
3801
  }));
3584
3802
  // decrypt
3585
3803
  return await lit.decrypt(scopedRawBlob, publishedList.metadata.encryptedSymmetricKey, unifiedAccessControlConditions);
3586
- }())
3587
- : (await async function () {
3804
+ })()
3805
+ : await (async function () {
3588
3806
  // transcode to base64url, if needed
3589
3807
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
3590
3808
  ? publishedList.StatusList2021.encodedList
@@ -3594,7 +3812,9 @@ class Cheqd {
3594
3812
  // if not encrypted, return bitstring
3595
3813
  if (!publishedList.metadata.encrypted) {
3596
3814
  // construct encoded status list
3597
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
3815
+ const encoded = new vc_status_list_1.StatusList({
3816
+ buffer: await Cheqd.getFile(options.statusListFile),
3817
+ }).encode();
3598
3818
  // validate against published list
3599
3819
  if (encoded !== publishedListTranscoded)
3600
3820
  throw new Error('[did-provider-cheqd]: check: revocation: statusListFile does not match published status list 2021');
@@ -3618,7 +3838,7 @@ class Cheqd {
3618
3838
  throw new Error('[did-provider-cheqd]: check: revocation: statusListInlineBitstring does not match published status list 2021');
3619
3839
  // otherwise, read from inline bitstring
3620
3840
  return options?.statusListInlineBitstring;
3621
- }());
3841
+ })();
3622
3842
  // transcode, if needed
3623
3843
  const transcodedStatusList2021 = publishedList.metadata.encoding === 'base64url'
3624
3844
  ? statusList2021
@@ -3637,7 +3857,7 @@ class Cheqd {
3637
3857
  const publishedList = (await Cheqd.fetchStatusList2021(credential));
3638
3858
  // fetch status list 2021 inscribed in credential
3639
3859
  const statusList2021 = options?.topArgs?.fetchList
3640
- ? (await async function () {
3860
+ ? await (async function () {
3641
3861
  // if not encrypted, return bitstring
3642
3862
  if (!publishedList.metadata.encrypted)
3643
3863
  return publishedList.metadata.encoding === 'base64url'
@@ -3648,7 +3868,7 @@ class Cheqd {
3648
3868
  // instantiate dkg-threshold client, in which case lit-protocol is used
3649
3869
  const lit = await lit_protocol_js_1.LitProtocol.create({
3650
3870
  chain: options?.topArgs?.dkgOptions?.chain,
3651
- litNetwork: options?.topArgs?.dkgOptions?.network
3871
+ litNetwork: options?.topArgs?.dkgOptions?.network,
3652
3872
  });
3653
3873
  // construct access control conditions
3654
3874
  const unifiedAccessControlConditions = await Promise.all(publishedList.metadata.paymentConditions.map(async (condition) => {
@@ -3665,8 +3885,8 @@ class Cheqd {
3665
3885
  }));
3666
3886
  // decrypt
3667
3887
  return await lit.decrypt(scopedRawBlob, publishedList.metadata.encryptedSymmetricKey, unifiedAccessControlConditions);
3668
- }())
3669
- : (await async function () {
3888
+ })()
3889
+ : await (async function () {
3670
3890
  // transcode to base64url, if needed
3671
3891
  const publishedListTranscoded = publishedList.metadata.encoding === 'base64url'
3672
3892
  ? publishedList.StatusList2021.encodedList
@@ -3676,7 +3896,9 @@ class Cheqd {
3676
3896
  // if not encrypted, return bitstring
3677
3897
  if (!publishedList.metadata.encrypted) {
3678
3898
  // construct encoded status list
3679
- const encoded = new vc_status_list_1.StatusList({ buffer: await Cheqd.getFile(options.statusListFile) }).encode();
3899
+ const encoded = new vc_status_list_1.StatusList({
3900
+ buffer: await Cheqd.getFile(options.statusListFile),
3901
+ }).encode();
3680
3902
  // validate against published list
3681
3903
  if (encoded !== publishedListTranscoded)
3682
3904
  throw new Error('[did-provider-cheqd]: check: suspension: statusListFile does not match published status list 2021');
@@ -3700,7 +3922,7 @@ class Cheqd {
3700
3922
  throw new Error('[did-provider-cheqd]: check: suspension: statusListInlineBitstring does not match published status list 2021');
3701
3923
  // otherwise, read from inline bitstring
3702
3924
  return options?.statusListInlineBitstring;
3703
- }());
3925
+ })();
3704
3926
  // parse status list 2021
3705
3927
  const statusList = await vc_status_list_1.StatusList.decode({ encodedList: statusList2021 });
3706
3928
  // get status by index
@@ -3715,14 +3937,14 @@ class Cheqd {
3715
3937
  version: options?.resourceVersion || new Date().toISOString(),
3716
3938
  alsoKnownAs: options?.resourceAlsoKnownAs || [],
3717
3939
  resourceType: statusList2021Metadata.resourceType,
3718
- data: statusList2021Raw
3940
+ data: statusList2021Raw,
3719
3941
  };
3720
3942
  return await options.context.agent[exports.BroadcastStatusList2021MethodName]({
3721
3943
  kms: (await options.context.agent.keyManagerGetKeyManagementSystems())[0],
3722
3944
  payload,
3723
3945
  network: statusList2021Metadata.resourceURI.split(':')[2],
3724
3946
  signInputs: options?.signInputs,
3725
- fee: options?.fee
3947
+ fee: options?.fee,
3726
3948
  });
3727
3949
  }
3728
3950
  static async fetchStatusList2021(credential, returnRaw = false) {
@@ -3733,11 +3955,16 @@ class Cheqd {
3733
3955
  if (credential.credentialStatus.type !== 'StatusList2021Entry')
3734
3956
  throw new Error('[did-provider-cheqd]: fetch status list: Credential status type is not valid');
3735
3957
  // validate credential status list status purpose
3736
- if (credential.credentialStatus.statusPurpose !== 'revocation' && credential.credentialStatus.statusPurpose !== 'suspension')
3958
+ if (credential.credentialStatus.statusPurpose !== 'revocation' &&
3959
+ credential.credentialStatus.statusPurpose !== 'suspension')
3737
3960
  throw new Error('[did-provider-cheqd]: fetch status list: Credential status purpose is not valid');
3738
3961
  // fetch status list 2021
3739
- const content = await (await fetch(credential.credentialStatus.id.split('#')[0])).json();
3740
- if (!(content.StatusList2021 && content.metadata && content.StatusList2021.encodedList && content.StatusList2021.statusPurpose && content.metadata.encoding)) {
3962
+ const content = (await (await fetch(credential.credentialStatus.id.split('#')[0])).json());
3963
+ if (!(content.StatusList2021 &&
3964
+ content.metadata &&
3965
+ content.StatusList2021.encodedList &&
3966
+ content.StatusList2021.statusPurpose &&
3967
+ content.metadata.encoding)) {
3741
3968
  throw new Error(`'[did-provider-cheqd]: fetch status list: Status List resource content is not valid'`);
3742
3969
  }
3743
3970
  // return raw if requested
@@ -3761,7 +3988,7 @@ class Cheqd {
3761
3988
  // construct metadata url
3762
3989
  const metadataUrl = `${baseUrl.toString()}/metadata`;
3763
3990
  // fetch collection metadata
3764
- const collectionMetadata = await (await fetch(metadataUrl)).json();
3991
+ const collectionMetadata = (await (await fetch(metadataUrl)).json());
3765
3992
  // early exit if no linked resources
3766
3993
  if (!collectionMetadata?.contentStream?.linkedResourceMetadata)
3767
3994
  throw new Error('[did-provider-cheqd]: fetch status list metadata: No linked resources found');
@@ -3771,7 +3998,8 @@ class Cheqd {
3771
3998
  if (!resourceVersioning.length || resourceVersioning.length === 0)
3772
3999
  throw new Error(`[did-provider-cheqd]: fetch status list metadata: No relevant resources found by resource name ${resourceName}`);
3773
4000
  // get latest resource version by nextVersionId null pointer, or by latest created date as fallback
3774
- return resourceVersioning.find((resource) => !resource.nextVersionId) || resourceVersioning.sort((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime())[0];
4001
+ return (resourceVersioning.find((resource) => !resource.nextVersionId) ||
4002
+ resourceVersioning.sort((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime())[0]);
3775
4003
  }
3776
4004
  static async loadProvider(didUrl, providers) {
3777
4005
  const provider = providers.find((provider) => didUrl.includes(`${exports.DidPrefix}:${exports.CheqdDidMethod}:${provider.network}`));