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

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.11+b492941c",
4
+ "version": "0.34.1-feature.SSISDK.17.bitstring.sl.14+35c8ca99",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -31,8 +31,9 @@
31
31
  "@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
32
32
  "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
33
33
  "@sphereon/ssi-sdk-ext.jwt-service": "0.29.0",
34
- "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.17.bitstring.sl.11+b492941c",
35
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.11+b492941c",
34
+ "@sphereon/ssi-sdk.credential-vcdm": "0.34.1-feature.SSISDK.17.bitstring.sl.14+35c8ca99",
35
+ "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.17.bitstring.sl.14+35c8ca99",
36
+ "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.14+35c8ca99",
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": "b492941ccbdde19ae30ec024956ca9f6f336a699"
75
+ "gitHead": "35c8ca99b499927dfffd929ae709750a7337b017"
75
76
  }
package/src/functions.ts CHANGED
@@ -1,25 +1,22 @@
1
1
  import type { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
2
- 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'
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'
12
4
 
13
- import { IAddStatusListArgs, IBitstringStatusListEntryEntity, IStatusListEntryEntity, StatusListEntity } from '@sphereon/ssi-sdk.data-store'
5
+ import {
6
+ BitstringStatusListEntryCredentialStatus,
7
+ IBitstringStatusListEntryEntity,
8
+ IStatusListEntryEntity,
9
+ StatusListEntity,
10
+ } from '@sphereon/ssi-sdk.data-store'
14
11
 
15
12
  import { checkStatus } from '@sphereon/vc-status-list'
16
13
 
17
14
  // @ts-ignore
18
15
  import { CredentialJwtOrJSON, StatusMethod } from 'credential-status'
19
16
  import {
20
- BitstringStatus,
21
- BitstringStatusListEntryCredentialStatus,
22
17
  CreateNewStatusListFuncArgs,
18
+ IMergeDetailsWithEntityArgs,
19
+ IToDetailsFromCredentialArgs,
23
20
  Status2021,
24
21
  StatusList2021EntryCredentialStatus,
25
22
  StatusList2021ToVerifiableCredentialArgs,
@@ -31,6 +28,13 @@ import {
31
28
  } from './types'
32
29
  import { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'
33
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'
34
38
 
35
39
  export async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {
36
40
  const url = getAssertedValue('statusListCredential', args.statusListCredential)
@@ -142,7 +146,7 @@ export async function simpleCheckStatusFromStatusListUrl(args: {
142
146
  type?: StatusListType | 'StatusList2021Entry'
143
147
  id?: string
144
148
  statusListIndex: string
145
- }): Promise<number | Status2021 | StatusOAuth | BitstringStatus> {
149
+ }): Promise<number | Status2021 | StatusOAuth> {
146
150
  return checkStatusIndexFromStatusListCredential({
147
151
  ...args,
148
152
  statusListCredential: await fetchStatusListCredential(args),
@@ -156,7 +160,7 @@ export async function checkStatusIndexFromStatusListCredential(args: {
156
160
  id?: string
157
161
  statusListIndex: string | number
158
162
  bitsPerStatus?: number
159
- }): Promise<number | Status2021 | StatusOAuth | BitstringStatus> {
163
+ }): Promise<number | Status2021 | StatusOAuth> {
160
164
  const statusListType: StatusListType = determineStatusListType(args.statusListCredential)
161
165
  const implementation = getStatusListImplementation(statusListType)
162
166
  return implementation.checkStatusIndex(args)
@@ -164,7 +168,7 @@ export async function checkStatusIndexFromStatusListCredential(args: {
164
168
 
165
169
  export async function createNewStatusList(
166
170
  args: CreateNewStatusListFuncArgs,
167
- context: IAgentContext<(ICredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
171
+ context: IAgentContext<(IVcdmCredentialPlugin | any) /*IvcdMCredentialPlugin is not available*/ & IIdentifierResolution>,
168
172
  ): Promise<StatusListResult> {
169
173
  const { type } = getAssertedValues(args)
170
174
  const implementation = getStatusListImplementation(type)
@@ -173,7 +177,7 @@ export async function createNewStatusList(
173
177
 
174
178
  export async function updateStatusIndexFromStatusListCredential(
175
179
  args: UpdateStatusListIndexArgs,
176
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
180
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
177
181
  ): Promise<StatusListResult> {
178
182
  const credential = getAssertedValue('statusListCredential', args.statusListCredential)
179
183
  const statusListType: StatusListType = determineStatusListType(credential)
@@ -181,52 +185,36 @@ export async function updateStatusIndexFromStatusListCredential(
181
185
  return implementation.updateStatusListIndex(args, context)
182
186
  }
183
187
 
184
- export async function statusListCredentialToDetails({
185
- correlationId,
186
- driverType,
187
- statusListCredential,
188
- bitsPerStatus,
189
- }: {
190
- statusListCredential: StatusListCredential
191
- correlationId?: string
192
- driverType?: StatusListDriverType
193
- bitsPerStatus?: number
194
- }): Promise<StatusListResult & Partial<IAddStatusListArgs>> {
195
- const credential = getAssertedValue('statusListCredential', statusListCredential)
196
-
197
- let statusListType: StatusListType | undefined
198
- const documentFormat = CredentialMapper.detectDocumentType(credential)
199
- if (documentFormat === DocumentFormat.JWT) {
200
- const [header] = credential.split('.')
201
- const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())
202
-
203
- if (decodedHeader.typ === 'statuslist+jwt') {
204
- statusListType = StatusListType.OAuthStatusList
205
- }
206
- } else if (documentFormat === DocumentFormat.MSO_MDOC) {
207
- statusListType = StatusListType.OAuthStatusList
208
- // TODO check CBOR content?
209
- }
210
- if (!statusListType) {
211
- const uniform = CredentialMapper.toUniformCredential(credential)
212
- const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList') || t.includes('BitstringStatusList'))
213
- if (!type) {
214
- throw new Error('Invalid status list credential type')
215
- }
216
- statusListType = type.replace('Credential', '') as StatusListType
217
- }
218
-
188
+ export async function extractCredentialDetails(statusListCredential: StatusListCredential): Promise<IExtractedCredentialDetails> {
189
+ const statusListType = determineStatusListType(statusListCredential)
219
190
  const implementation = getStatusListImplementation(statusListType)
191
+ return implementation.extractCredentialDetails(statusListCredential)
192
+ }
220
193
 
221
- // The implementation should now return all the type-specific fields needed for the entity
222
- const result = await implementation.toStatusListDetails({
223
- statusListPayload: credential,
224
- correlationId: correlationId,
225
- driverType: driverType,
226
- bitsPerStatus: bitsPerStatus,
227
- })
194
+ export async function toStatusListDetails(
195
+ args: IToDetailsFromCredentialArgs,
196
+ ): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
228
197
 
229
- return result
198
+ export async function toStatusListDetails(
199
+ args: IMergeDetailsWithEntityArgs,
200
+ ): Promise<StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)>
201
+
202
+ export async function toStatusListDetails(
203
+ args: IToDetailsFromCredentialArgs | IMergeDetailsWithEntityArgs,
204
+ ): Promise<
205
+ StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)
206
+ > {
207
+ if ('statusListCredential' in args) {
208
+ // CREATE/READ context
209
+ const statusListType = args.statusListType
210
+ const implementation = getStatusListImplementation(statusListType)
211
+ return implementation.toStatusListDetails(args)
212
+ } else {
213
+ // UPDATE context
214
+ const statusListType = args.statusListEntity.type
215
+ const implementation = getStatusListImplementation(statusListType)
216
+ return implementation.toStatusListDetails(args)
217
+ }
230
218
  }
231
219
 
232
220
  export async function createCredentialStatusFromStatusList(args: {
@@ -250,7 +238,7 @@ export async function createCredentialStatusFromStatusList(args: {
250
238
 
251
239
  export async function updateStatusListIndexFromEncodedList(
252
240
  args: UpdateStatusListFromEncodedListArgs,
253
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
241
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
254
242
  ): Promise<StatusListResult> {
255
243
  const { type } = getAssertedValue('type', args)
256
244
  const implementation = getStatusListImplementation(type!)
@@ -259,7 +247,7 @@ export async function updateStatusListIndexFromEncodedList(
259
247
 
260
248
  export async function statusList2021ToVerifiableCredential(
261
249
  args: StatusList2021ToVerifiableCredentialArgs,
262
- context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,
250
+ context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
263
251
  ): Promise<StatusListCredential> {
264
252
  const { issuer, id, type } = getAssertedValues(args)
265
253
  const identifier = await context.agent.identifierManagedGet({