@sphereon/ssi-sdk.vc-status-list 0.34.1-next.7 → 0.34.1-next.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +695 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -37
- package/dist/index.d.ts +163 -37
- package/dist/index.js +698 -125
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
- package/src/functions.ts +126 -47
- package/src/impl/BitstringStatusListImplementation.ts +496 -0
- package/src/impl/IStatusList.ts +102 -8
- package/src/impl/OAuthStatusList.ts +133 -38
- package/src/impl/StatusList2021.ts +114 -34
- package/src/impl/StatusListFactory.ts +2 -0
- package/src/impl/encoding/cbor.ts +14 -12
- package/src/index.ts +1 -0
- package/src/types/BitstringStatusList.ts +4 -0
- package/src/types/index.ts +56 -35
- package/src/utils.ts +82 -20
package/src/functions.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
2
|
+
import { CredentialMapper, type CredentialProofFormat, type StatusListCredential, StatusListType, type StatusPurpose2021 } from '@sphereon/ssi-types'
|
|
3
|
+
import type { CredentialStatus, DIDDocument, IAgentContext, ProofFormat as VeramoProofFormat } from '@veramo/core'
|
|
4
|
+
|
|
2
5
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
StatusListType,
|
|
9
|
-
type StatusPurpose2021,
|
|
10
|
-
} from '@sphereon/ssi-types'
|
|
11
|
-
import type { CredentialStatus, DIDDocument, IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'
|
|
6
|
+
BitstringStatusListEntryCredentialStatus,
|
|
7
|
+
IBitstringStatusListEntryEntity,
|
|
8
|
+
IStatusListEntryEntity,
|
|
9
|
+
StatusListEntity,
|
|
10
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
12
11
|
|
|
13
12
|
import { checkStatus } from '@sphereon/vc-status-list'
|
|
14
13
|
|
|
@@ -16,8 +15,12 @@ import { checkStatus } from '@sphereon/vc-status-list'
|
|
|
16
15
|
import { CredentialJwtOrJSON, StatusMethod } from 'credential-status'
|
|
17
16
|
import {
|
|
18
17
|
CreateNewStatusListFuncArgs,
|
|
18
|
+
IMergeDetailsWithEntityArgs,
|
|
19
|
+
IToDetailsFromCredentialArgs,
|
|
19
20
|
Status2021,
|
|
21
|
+
StatusList2021EntryCredentialStatus,
|
|
20
22
|
StatusList2021ToVerifiableCredentialArgs,
|
|
23
|
+
StatusListOAuthEntryCredentialStatus,
|
|
21
24
|
StatusListResult,
|
|
22
25
|
StatusOAuth,
|
|
23
26
|
UpdateStatusListFromEncodedListArgs,
|
|
@@ -25,7 +28,19 @@ import {
|
|
|
25
28
|
} from './types'
|
|
26
29
|
import { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'
|
|
27
30
|
import { getStatusListImplementation } from './impl/StatusListFactory'
|
|
31
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
32
|
+
import {
|
|
33
|
+
IBitstringStatusListImplementationResult,
|
|
34
|
+
IExtractedCredentialDetails,
|
|
35
|
+
IOAuthStatusListImplementationResult,
|
|
36
|
+
IStatusList2021ImplementationResult,
|
|
37
|
+
} from './impl/IStatusList'
|
|
28
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Fetches a status list credential from a URL
|
|
41
|
+
* @param args - Object containing the status list credential URL
|
|
42
|
+
* @returns Promise resolving to the fetched StatusListCredential
|
|
43
|
+
*/
|
|
29
44
|
export async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {
|
|
30
45
|
const url = getAssertedValue('statusListCredential', args.statusListCredential)
|
|
31
46
|
try {
|
|
@@ -44,6 +59,11 @@ export async function fetchStatusListCredential(args: { statusListCredential: st
|
|
|
44
59
|
}
|
|
45
60
|
}
|
|
46
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Creates a status checking function for credential-status plugin
|
|
64
|
+
* @param args - Configuration options for status verification
|
|
65
|
+
* @returns StatusMethod function for checking credential status
|
|
66
|
+
*/
|
|
47
67
|
export function statusPluginStatusFunction(args: {
|
|
48
68
|
documentLoader: any
|
|
49
69
|
suite: any
|
|
@@ -69,7 +89,8 @@ export function statusPluginStatusFunction(args: {
|
|
|
69
89
|
|
|
70
90
|
/**
|
|
71
91
|
* Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc
|
|
72
|
-
* @param args
|
|
92
|
+
* @param args - Configuration options for status verification
|
|
93
|
+
* @returns Function for checking credential status
|
|
73
94
|
*/
|
|
74
95
|
export function vcLibCheckStatusFunction(args: {
|
|
75
96
|
mandatoryCredentialStatus?: boolean
|
|
@@ -96,6 +117,11 @@ export function vcLibCheckStatusFunction(args: {
|
|
|
96
117
|
}
|
|
97
118
|
}
|
|
98
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Checks the status of a credential using its credential status information
|
|
122
|
+
* @param args - Parameters for credential status verification
|
|
123
|
+
* @returns Promise resolving to verification result with error details if any
|
|
124
|
+
*/
|
|
99
125
|
export async function checkStatusForCredential(args: {
|
|
100
126
|
credential: StatusListCredential
|
|
101
127
|
documentLoader: any
|
|
@@ -117,7 +143,7 @@ export async function checkStatusForCredential(args: {
|
|
|
117
143
|
return { verified: true }
|
|
118
144
|
}
|
|
119
145
|
if ('credentialStatus' in uniform && uniform.credentialStatus) {
|
|
120
|
-
if (uniform.credentialStatus.type === 'StatusList2021Entry') {
|
|
146
|
+
if (uniform.credentialStatus.type === 'StatusList2021Entry' || uniform.credentialStatus.type === 'BitstringStatusListEntry') {
|
|
121
147
|
return checkStatus({ ...args, verifyStatusListCredential, verifyMatchingIssuers })
|
|
122
148
|
} else if (args?.errorUnknownListType) {
|
|
123
149
|
const error = `Credential status type ${uniform.credentialStatus.type} is not supported, and check status has been configured to not allow for that`
|
|
@@ -143,12 +169,18 @@ export async function simpleCheckStatusFromStatusListUrl(args: {
|
|
|
143
169
|
})
|
|
144
170
|
}
|
|
145
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Checks the status at a specific index in a status list credential
|
|
174
|
+
* @param args - Parameters including credential and index to check
|
|
175
|
+
* @returns Promise resolving to status value at the specified index
|
|
176
|
+
*/
|
|
146
177
|
export async function checkStatusIndexFromStatusListCredential(args: {
|
|
147
178
|
statusListCredential: StatusListCredential
|
|
148
|
-
statusPurpose?: StatusPurpose2021
|
|
149
|
-
type?: StatusListType | 'StatusList2021Entry'
|
|
179
|
+
statusPurpose?: StatusPurpose2021 | string | string[]
|
|
180
|
+
type?: StatusListType | 'StatusList2021Entry' | 'BitstringStatusListEntry'
|
|
150
181
|
id?: string
|
|
151
182
|
statusListIndex: string | number
|
|
183
|
+
bitsPerStatus?: number
|
|
152
184
|
}): Promise<number | Status2021 | StatusOAuth> {
|
|
153
185
|
const statusListType: StatusListType = determineStatusListType(args.statusListCredential)
|
|
154
186
|
const implementation = getStatusListImplementation(statusListType)
|
|
@@ -157,16 +189,22 @@ export async function checkStatusIndexFromStatusListCredential(args: {
|
|
|
157
189
|
|
|
158
190
|
export async function createNewStatusList(
|
|
159
191
|
args: CreateNewStatusListFuncArgs,
|
|
160
|
-
context: IAgentContext<(
|
|
192
|
+
context: IAgentContext<(IVcdmCredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
|
|
161
193
|
): Promise<StatusListResult> {
|
|
162
194
|
const { type } = getAssertedValues(args)
|
|
163
195
|
const implementation = getStatusListImplementation(type)
|
|
164
196
|
return implementation.createNewStatusList(args, context)
|
|
165
197
|
}
|
|
166
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Updates a status index in a status list credential
|
|
201
|
+
* @param args - Parameters for status update including credential and new value
|
|
202
|
+
* @param context - Agent context with required plugins
|
|
203
|
+
* @returns Promise resolving to updated status list details
|
|
204
|
+
*/
|
|
167
205
|
export async function updateStatusIndexFromStatusListCredential(
|
|
168
206
|
args: UpdateStatusListIndexArgs,
|
|
169
|
-
context: IAgentContext<
|
|
207
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
170
208
|
): Promise<StatusListResult> {
|
|
171
209
|
const credential = getAssertedValue('statusListCredential', args.statusListCredential)
|
|
172
210
|
const statusListType: StatusListType = determineStatusListType(credential)
|
|
@@ -174,56 +212,97 @@ export async function updateStatusIndexFromStatusListCredential(
|
|
|
174
212
|
return implementation.updateStatusListIndex(args, context)
|
|
175
213
|
}
|
|
176
214
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
215
|
+
/**
|
|
216
|
+
* Extracts credential details from a status list credential
|
|
217
|
+
* @param statusListCredential - The status list credential to extract from
|
|
218
|
+
* @returns Promise resolving to extracted credential details
|
|
219
|
+
*/
|
|
220
|
+
export async function extractCredentialDetails(statusListCredential: StatusListCredential): Promise<IExtractedCredentialDetails> {
|
|
221
|
+
const statusListType = determineStatusListType(statusListCredential)
|
|
222
|
+
const implementation = getStatusListImplementation(statusListType)
|
|
223
|
+
return implementation.extractCredentialDetails(statusListCredential)
|
|
224
|
+
}
|
|
184
225
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const [header] = credential.split('.')
|
|
189
|
-
const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())
|
|
226
|
+
export async function toStatusListDetails(
|
|
227
|
+
args: IToDetailsFromCredentialArgs,
|
|
228
|
+
): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
|
|
190
229
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
230
|
+
export async function toStatusListDetails(
|
|
231
|
+
args: IMergeDetailsWithEntityArgs,
|
|
232
|
+
): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Converts credential and metadata into detailed status list information
|
|
236
|
+
* Handles both CREATE/READ and UPDATE contexts based on input arguments
|
|
237
|
+
* @param args - Either credential-based args or entity-based args for merging
|
|
238
|
+
* @returns Promise resolving to complete status list details
|
|
239
|
+
*/
|
|
240
|
+
export async function toStatusListDetails(
|
|
241
|
+
args: IToDetailsFromCredentialArgs | IMergeDetailsWithEntityArgs,
|
|
242
|
+
): Promise<
|
|
243
|
+
StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)
|
|
244
|
+
> {
|
|
245
|
+
if ('statusListCredential' in args) {
|
|
246
|
+
// CREATE/READ context
|
|
247
|
+
const statusListType = args.statusListType
|
|
248
|
+
const implementation = getStatusListImplementation(statusListType)
|
|
249
|
+
return implementation.toStatusListDetails(args)
|
|
250
|
+
} else {
|
|
251
|
+
// UPDATE context
|
|
252
|
+
const statusListType = args.statusListEntity.type
|
|
253
|
+
const implementation = getStatusListImplementation(statusListType)
|
|
254
|
+
return implementation.toStatusListDetails(args)
|
|
205
255
|
}
|
|
256
|
+
}
|
|
206
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Creates a credential status object from status list and entry information
|
|
260
|
+
* @param args - Parameters including status list, entry, and index
|
|
261
|
+
* @returns Promise resolving to appropriate credential status type
|
|
262
|
+
*/
|
|
263
|
+
export async function createCredentialStatusFromStatusList(args: {
|
|
264
|
+
statusList: StatusListEntity
|
|
265
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
266
|
+
statusListIndex: number
|
|
267
|
+
}): Promise<StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus> {
|
|
268
|
+
const { statusList, statusListEntry, statusListIndex } = args
|
|
269
|
+
|
|
270
|
+
// Determine the status list type and delegate to appropriate implementation
|
|
271
|
+
const statusListType = determineStatusListType(statusList.statusListCredential!)
|
|
207
272
|
const implementation = getStatusListImplementation(statusListType)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
273
|
+
|
|
274
|
+
// Each implementation should have a method to create credential status
|
|
275
|
+
return implementation.createCredentialStatus({
|
|
276
|
+
statusList,
|
|
277
|
+
statusListEntry,
|
|
278
|
+
statusListIndex,
|
|
212
279
|
})
|
|
213
280
|
}
|
|
214
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Updates a status list using a base64 encoded list of statuses
|
|
284
|
+
* @param args - Parameters including encoded list and update details
|
|
285
|
+
* @param context - Agent context with required plugins
|
|
286
|
+
* @returns Promise resolving to updated status list details
|
|
287
|
+
*/
|
|
215
288
|
export async function updateStatusListIndexFromEncodedList(
|
|
216
289
|
args: UpdateStatusListFromEncodedListArgs,
|
|
217
|
-
context: IAgentContext<
|
|
290
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
218
291
|
): Promise<StatusListResult> {
|
|
219
292
|
const { type } = getAssertedValue('type', args)
|
|
220
293
|
const implementation = getStatusListImplementation(type!)
|
|
221
294
|
return implementation.updateStatusListFromEncodedList(args, context)
|
|
222
295
|
}
|
|
223
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Converts a StatusList2021 to a verifiable credential
|
|
299
|
+
* @param args - Parameters for credential creation including issuer and encoded list
|
|
300
|
+
* @param context - Agent context with required plugins
|
|
301
|
+
* @returns Promise resolving to signed status list credential
|
|
302
|
+
*/
|
|
224
303
|
export async function statusList2021ToVerifiableCredential(
|
|
225
304
|
args: StatusList2021ToVerifiableCredentialArgs,
|
|
226
|
-
context: IAgentContext<
|
|
305
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
227
306
|
): Promise<StatusListCredential> {
|
|
228
307
|
const { issuer, id, type } = getAssertedValues(args)
|
|
229
308
|
const identifier = await context.agent.identifierManagedGet({
|