@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.9 → 0.34.1-next.29

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.vc-status-list",
3
3
  "description": "Sphereon SSI-SDK plugin for Status List management, like StatusList2021.",
4
- "version": "0.34.1-feature.SSISDK.17.bitstring.sl.9+a052acba",
4
+ "version": "0.34.1-next.29+2593a430",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -27,11 +27,13 @@
27
27
  "@sd-jwt/jwt-status-list": "^0.9.1",
28
28
  "@sd-jwt/sd-jwt-vc": "^0.9.2",
29
29
  "@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
30
- "@sphereon/oid4vci-common": "0.19.0",
31
- "@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
32
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
33
- "@sphereon/ssi-sdk-ext.jwt-service": "0.29.0",
34
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.9+a052acba",
30
+ "@sphereon/oid4vci-common": "0.19.1-next.2",
31
+ "@sphereon/ssi-sdk-ext.did-utils": "0.29.1-next.3",
32
+ "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.1-next.3",
33
+ "@sphereon/ssi-sdk-ext.jwt-service": "0.29.1-next.3",
34
+ "@sphereon/ssi-sdk.credential-vcdm": "0.34.1-next.29+2593a430",
35
+ "@sphereon/ssi-sdk.data-store": "0.34.1-next.29+2593a430",
36
+ "@sphereon/ssi-types": "0.34.1-next.29+2593a430",
35
37
  "@sphereon/vc-status-list": "7.0.0-next.0",
36
38
  "@veramo/core": "4.2.0",
37
39
  "@veramo/credential-status": "4.2.0",
@@ -70,5 +72,5 @@
70
72
  "SSI",
71
73
  "StatusList2021"
72
74
  ],
73
- "gitHead": "a052acbaa88acf4be22236ca3afaadd5b2821fe1"
75
+ "gitHead": "2593a430ac4faca47b620a3e12b297899518f2af"
74
76
  }
package/src/functions.ts CHANGED
@@ -1,24 +1,26 @@
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
- CredentialMapper,
4
- type CredentialProofFormat,
5
- DocumentFormat,
6
- type StatusListCredential,
7
- StatusListDriverType,
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
 
15
14
  // @ts-ignore
16
15
  import { CredentialJwtOrJSON, StatusMethod } from 'credential-status'
17
16
  import {
18
- BitstringStatus,
19
17
  CreateNewStatusListFuncArgs,
18
+ IMergeDetailsWithEntityArgs,
19
+ IToDetailsFromCredentialArgs,
20
20
  Status2021,
21
+ StatusList2021EntryCredentialStatus,
21
22
  StatusList2021ToVerifiableCredentialArgs,
23
+ StatusListOAuthEntryCredentialStatus,
22
24
  StatusListResult,
23
25
  StatusOAuth,
24
26
  UpdateStatusListFromEncodedListArgs,
@@ -26,7 +28,19 @@ import {
26
28
  } from './types'
27
29
  import { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'
28
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'
29
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
+ */
30
44
  export async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {
31
45
  const url = getAssertedValue('statusListCredential', args.statusListCredential)
32
46
  try {
@@ -45,6 +59,11 @@ export async function fetchStatusListCredential(args: { statusListCredential: st
45
59
  }
46
60
  }
47
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
+ */
48
67
  export function statusPluginStatusFunction(args: {
49
68
  documentLoader: any
50
69
  suite: any
@@ -70,7 +89,8 @@ export function statusPluginStatusFunction(args: {
70
89
 
71
90
  /**
72
91
  * Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc
73
- * @param args
92
+ * @param args - Configuration options for status verification
93
+ * @returns Function for checking credential status
74
94
  */
75
95
  export function vcLibCheckStatusFunction(args: {
76
96
  mandatoryCredentialStatus?: boolean
@@ -97,6 +117,11 @@ export function vcLibCheckStatusFunction(args: {
97
117
  }
98
118
  }
99
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
+ */
100
125
  export async function checkStatusForCredential(args: {
101
126
  credential: StatusListCredential
102
127
  documentLoader: any
@@ -137,21 +162,26 @@ export async function simpleCheckStatusFromStatusListUrl(args: {
137
162
  type?: StatusListType | 'StatusList2021Entry'
138
163
  id?: string
139
164
  statusListIndex: string
140
- }): Promise<number | Status2021 | StatusOAuth | BitstringStatus> {
165
+ }): Promise<number | Status2021 | StatusOAuth> {
141
166
  return checkStatusIndexFromStatusListCredential({
142
167
  ...args,
143
168
  statusListCredential: await fetchStatusListCredential(args),
144
169
  })
145
170
  }
146
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
+ */
147
177
  export async function checkStatusIndexFromStatusListCredential(args: {
148
178
  statusListCredential: StatusListCredential
149
- statusPurpose?: StatusPurpose2021
179
+ statusPurpose?: StatusPurpose2021 | string | string[]
150
180
  type?: StatusListType | 'StatusList2021Entry' | 'BitstringStatusListEntry'
151
181
  id?: string
152
182
  statusListIndex: string | number
153
183
  bitsPerStatus?: number
154
- }): Promise<number | Status2021 | StatusOAuth | BitstringStatus> {
184
+ }): Promise<number | Status2021 | StatusOAuth> {
155
185
  const statusListType: StatusListType = determineStatusListType(args.statusListCredential)
156
186
  const implementation = getStatusListImplementation(statusListType)
157
187
  return implementation.checkStatusIndex(args)
@@ -159,16 +189,22 @@ export async function checkStatusIndexFromStatusListCredential(args: {
159
189
 
160
190
  export async function createNewStatusList(
161
191
  args: CreateNewStatusListFuncArgs,
162
- context: IAgentContext<(ICredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
192
+ context: IAgentContext<(IVcdmCredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
163
193
  ): Promise<StatusListResult> {
164
194
  const { type } = getAssertedValues(args)
165
195
  const implementation = getStatusListImplementation(type)
166
196
  return implementation.createNewStatusList(args, context)
167
197
  }
168
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
+ */
169
205
  export async function updateStatusIndexFromStatusListCredential(
170
206
  args: UpdateStatusListIndexArgs,
171
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
207
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
172
208
  ): Promise<StatusListResult> {
173
209
  const credential = getAssertedValue('statusListCredential', args.statusListCredential)
174
210
  const statusListType: StatusListType = determineStatusListType(credential)
@@ -176,63 +212,97 @@ export async function updateStatusIndexFromStatusListCredential(
176
212
  return implementation.updateStatusListIndex(args, context)
177
213
  }
178
214
 
179
- // Keeping helper function for backward compatibility
180
- export async function statusListCredentialToDetails({
181
- correlationId,
182
- driverType,
183
- statusListCredential,
184
- bitsPerStatus,
185
- }: {
186
- statusListCredential: StatusListCredential
187
- correlationId?: string
188
- driverType?: StatusListDriverType
189
- bitsPerStatus?: number
190
- }): Promise<StatusListResult> {
191
- const credential = getAssertedValue('statusListCredential', statusListCredential)
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
+ }
192
225
 
193
- let statusListType: StatusListType | undefined
194
- const documentFormat = CredentialMapper.detectDocumentType(credential)
195
- if (documentFormat === DocumentFormat.JWT) {
196
- const [header] = credential.split('.')
197
- const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())
226
+ export async function toStatusListDetails(
227
+ args: IToDetailsFromCredentialArgs,
228
+ ): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
198
229
 
199
- if (decodedHeader.typ === 'statuslist+jwt') {
200
- statusListType = StatusListType.OAuthStatusList
201
- }
202
- } else if (documentFormat === DocumentFormat.MSO_MDOC) {
203
- statusListType = StatusListType.OAuthStatusList
204
- // TODO check CBOR content?
205
- }
206
- if (!statusListType) {
207
- const uniform = CredentialMapper.toUniformCredential(credential)
208
- const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList') || t.includes('BitstringStatusList'))
209
- if (!type) {
210
- throw new Error('Invalid status list credential type')
211
- }
212
- statusListType = type.replace('Credential', '') as StatusListType
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)
213
255
  }
256
+ }
214
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!)
215
272
  const implementation = getStatusListImplementation(statusListType)
216
- return await implementation.toStatusListDetails({
217
- statusListPayload: credential,
218
- correlationId: correlationId,
219
- driverType: driverType,
220
- bitsPerStatus: bitsPerStatus,
273
+
274
+ // Each implementation should have a method to create credential status
275
+ return implementation.createCredentialStatus({
276
+ statusList,
277
+ statusListEntry,
278
+ statusListIndex,
221
279
  })
222
280
  }
223
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
+ */
224
288
  export async function updateStatusListIndexFromEncodedList(
225
289
  args: UpdateStatusListFromEncodedListArgs,
226
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
290
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
227
291
  ): Promise<StatusListResult> {
228
292
  const { type } = getAssertedValue('type', args)
229
293
  const implementation = getStatusListImplementation(type!)
230
294
  return implementation.updateStatusListFromEncodedList(args, context)
231
295
  }
232
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
+ */
233
303
  export async function statusList2021ToVerifiableCredential(
234
304
  args: StatusList2021ToVerifiableCredentialArgs,
235
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
305
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
236
306
  ): Promise<StatusListCredential> {
237
307
  const { issuer, id, type } = getAssertedValues(args)
238
308
  const identifier = await context.agent.identifierManagedGet({