@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-feature.SSISDK.17.bitstring.sl.24

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.2+0a0992f6",
4
+ "version": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -22,17 +22,18 @@
22
22
  "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
23
23
  },
24
24
  "dependencies": {
25
- "@digitalbazaar/bitstring": "^3.1.0",
26
- "@digitalbazaar/vc-bitstring-status-list": "^2.0.1",
25
+ "@4sure-tech/vc-bitstring-status-lists": "0.1.0-unstable.1",
27
26
  "@sd-jwt/core": "^0.9.2",
28
27
  "@sd-jwt/jwt-status-list": "^0.9.1",
29
28
  "@sd-jwt/sd-jwt-vc": "^0.9.2",
30
29
  "@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
31
- "@sphereon/oid4vci-common": "0.19.0",
32
- "@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
33
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
34
- "@sphereon/ssi-sdk-ext.jwt-service": "0.29.0",
35
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
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-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
35
+ "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
36
+ "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
36
37
  "@sphereon/vc-status-list": "7.0.0-next.0",
37
38
  "@veramo/core": "4.2.0",
38
39
  "@veramo/credential-status": "4.2.0",
@@ -71,5 +72,5 @@
71
72
  "SSI",
72
73
  "StatusList2021"
73
74
  ],
74
- "gitHead": "0a0992f6323610a12e82716b1d80a2eedf4b4669"
75
+ "gitHead": "d486d9b69ca1a5c0df614642a2d1e158a60edee8"
75
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,20 +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
- }): Promise<number | Status2021 | StatusOAuth | BitstringStatus> {
183
+ bitsPerStatus?: number
184
+ }): Promise<number | Status2021 | StatusOAuth> {
154
185
  const statusListType: StatusListType = determineStatusListType(args.statusListCredential)
155
186
  const implementation = getStatusListImplementation(statusListType)
156
187
  return implementation.checkStatusIndex(args)
@@ -158,16 +189,22 @@ export async function checkStatusIndexFromStatusListCredential(args: {
158
189
 
159
190
  export async function createNewStatusList(
160
191
  args: CreateNewStatusListFuncArgs,
161
- context: IAgentContext<(ICredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
192
+ context: IAgentContext<(IVcdmCredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
162
193
  ): Promise<StatusListResult> {
163
194
  const { type } = getAssertedValues(args)
164
195
  const implementation = getStatusListImplementation(type)
165
196
  return implementation.createNewStatusList(args, context)
166
197
  }
167
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
+ */
168
205
  export async function updateStatusIndexFromStatusListCredential(
169
206
  args: UpdateStatusListIndexArgs,
170
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
207
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
171
208
  ): Promise<StatusListResult> {
172
209
  const credential = getAssertedValue('statusListCredential', args.statusListCredential)
173
210
  const statusListType: StatusListType = determineStatusListType(credential)
@@ -175,56 +212,97 @@ export async function updateStatusIndexFromStatusListCredential(
175
212
  return implementation.updateStatusListIndex(args, context)
176
213
  }
177
214
 
178
- // Keeping helper function for backward compatibility
179
- export async function statusListCredentialToDetails(args: {
180
- statusListCredential: StatusListCredential
181
- correlationId?: string
182
- driverType?: StatusListDriverType
183
- }): Promise<StatusListResult> {
184
- const credential = getAssertedValue('statusListCredential', args.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
+ }
185
225
 
186
- let statusListType: StatusListType | undefined
187
- const documentFormat = CredentialMapper.detectDocumentType(credential)
188
- if (documentFormat === DocumentFormat.JWT) {
189
- const [header] = credential.split('.')
190
- const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())
226
+ export async function toStatusListDetails(
227
+ args: IToDetailsFromCredentialArgs,
228
+ ): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
191
229
 
192
- if (decodedHeader.typ === 'statuslist+jwt') {
193
- statusListType = StatusListType.OAuthStatusList
194
- }
195
- } else if (documentFormat === DocumentFormat.MSO_MDOC) {
196
- statusListType = StatusListType.OAuthStatusList
197
- // TODO check CBOR content?
198
- }
199
- if (!statusListType) {
200
- const uniform = CredentialMapper.toUniformCredential(credential)
201
- const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList') || t.includes('BitstringStatusList'))
202
- if (!type) {
203
- throw new Error('Invalid status list credential type')
204
- }
205
- 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)
206
255
  }
256
+ }
207
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!)
208
272
  const implementation = getStatusListImplementation(statusListType)
209
- return await implementation.toStatusListDetails({
210
- statusListPayload: credential,
211
- correlationId: args.correlationId,
212
- driverType: args.driverType,
273
+
274
+ // Each implementation should have a method to create credential status
275
+ return implementation.createCredentialStatus({
276
+ statusList,
277
+ statusListEntry,
278
+ statusListIndex,
213
279
  })
214
280
  }
215
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
+ */
216
288
  export async function updateStatusListIndexFromEncodedList(
217
289
  args: UpdateStatusListFromEncodedListArgs,
218
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
290
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
219
291
  ): Promise<StatusListResult> {
220
292
  const { type } = getAssertedValue('type', args)
221
293
  const implementation = getStatusListImplementation(type!)
222
294
  return implementation.updateStatusListFromEncodedList(args, context)
223
295
  }
224
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
+ */
225
303
  export async function statusList2021ToVerifiableCredential(
226
304
  args: StatusList2021ToVerifiableCredentialArgs,
227
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
305
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
228
306
  ): Promise<StatusListCredential> {
229
307
  const { issuer, id, type } = getAssertedValues(args)
230
308
  const identifier = await context.agent.identifierManagedGet({