@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.10 → 0.34.1-feature.SSISDK.17.bitstring.sl.13
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 +234 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -32
- package/dist/index.d.ts +43 -32
- package/dist/index.js +235 -86
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/functions.ts +39 -33
- package/src/impl/BitstringStatusListImplementation.ts +210 -67
- package/src/impl/IStatusList.ts +71 -6
- package/src/impl/OAuthStatusList.ts +48 -11
- package/src/impl/StatusList2021.ts +50 -14
- package/src/types/index.ts +32 -34
- package/src/utils.ts +1 -1
package/src/impl/IStatusList.ts
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
import type { IAgentContext
|
|
1
|
+
import type { IAgentContext } from '@veramo/core'
|
|
2
2
|
import type { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
3
3
|
import {
|
|
4
4
|
BitstringStatus,
|
|
5
|
+
BitstringStatusListEntryCredentialStatus,
|
|
5
6
|
CheckStatusIndexArgs,
|
|
6
7
|
CreateStatusListArgs,
|
|
7
8
|
Status2021,
|
|
9
|
+
StatusList2021EntryCredentialStatus,
|
|
10
|
+
StatusListOAuthEntryCredentialStatus,
|
|
8
11
|
StatusListResult,
|
|
9
12
|
StatusOAuth,
|
|
10
13
|
ToStatusListDetailsArgs,
|
|
11
14
|
UpdateStatusListFromEncodedListArgs,
|
|
12
15
|
UpdateStatusListIndexArgs,
|
|
13
16
|
} from '../types'
|
|
17
|
+
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists'
|
|
18
|
+
import {
|
|
19
|
+
CredentialProofFormat,
|
|
20
|
+
IIssuer,
|
|
21
|
+
StatusListCredential,
|
|
22
|
+
StatusListDriverType,
|
|
23
|
+
StatusListIndexingDirection,
|
|
24
|
+
StatusListType,
|
|
25
|
+
StatusPurpose2021,
|
|
26
|
+
} from '@sphereon/ssi-types'
|
|
27
|
+
import { IBitstringStatusListEntryEntity, IStatusListEntryEntity, StatusListEntity } from '@sphereon/ssi-sdk.data-store'
|
|
28
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
14
29
|
|
|
15
30
|
export interface IStatusList {
|
|
16
31
|
/**
|
|
17
32
|
* Creates a new status list of the specific type
|
|
18
33
|
*/
|
|
19
|
-
createNewStatusList(args: CreateStatusListArgs, context: IAgentContext<
|
|
34
|
+
createNewStatusList(args: CreateStatusListArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>
|
|
20
35
|
|
|
21
36
|
/**
|
|
22
37
|
* Updates a status at the given index in the status list
|
|
23
38
|
*/
|
|
24
|
-
updateStatusListIndex(
|
|
39
|
+
updateStatusListIndex(
|
|
40
|
+
args: UpdateStatusListIndexArgs,
|
|
41
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
42
|
+
): Promise<StatusListResult>
|
|
25
43
|
|
|
26
44
|
/**
|
|
27
45
|
* Updates a status list using a base64 encoded list of statuses
|
|
28
46
|
*/
|
|
29
47
|
updateStatusListFromEncodedList(
|
|
30
48
|
args: UpdateStatusListFromEncodedListArgs,
|
|
31
|
-
context: IAgentContext<
|
|
49
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
32
50
|
): Promise<StatusListResult>
|
|
33
51
|
|
|
34
52
|
/**
|
|
@@ -37,7 +55,54 @@ export interface IStatusList {
|
|
|
37
55
|
checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021 | StatusOAuth | BitstringStatus>
|
|
38
56
|
|
|
39
57
|
/**
|
|
40
|
-
* Collects the status list details
|
|
58
|
+
* Collects the status list details - returns flattened entity data ready for storage
|
|
41
59
|
*/
|
|
42
|
-
toStatusListDetails(
|
|
60
|
+
toStatusListDetails(
|
|
61
|
+
args: ToStatusListDetailsArgs,
|
|
62
|
+
): Promise<
|
|
63
|
+
StatusListResult & (IStatusList2021ImplementationResult | IOAuthStatusListImplementationResult | IBitstringStatusListImplementationResult)
|
|
64
|
+
>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a credential status object from a status list and entry
|
|
68
|
+
*/
|
|
69
|
+
createCredentialStatus(args: {
|
|
70
|
+
statusList: StatusListEntity
|
|
71
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
72
|
+
statusListIndex: number
|
|
73
|
+
}): Promise<StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface IStatusListImplementationResult {
|
|
77
|
+
id: string
|
|
78
|
+
encodedList: string
|
|
79
|
+
issuer: string | IIssuer
|
|
80
|
+
type: StatusListType
|
|
81
|
+
proofFormat: CredentialProofFormat
|
|
82
|
+
length: number
|
|
83
|
+
statusListCredential: StatusListCredential
|
|
84
|
+
statuslistContentType: string
|
|
85
|
+
correlationId?: string
|
|
86
|
+
driverType?: StatusListDriverType
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IStatusList2021ImplementationResult extends IStatusListImplementationResult {
|
|
90
|
+
type: StatusListType.StatusList2021
|
|
91
|
+
indexingDirection: StatusListIndexingDirection
|
|
92
|
+
statusPurpose: StatusPurpose2021
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface IOAuthStatusListImplementationResult extends IStatusListImplementationResult {
|
|
96
|
+
type: StatusListType.OAuthStatusList
|
|
97
|
+
bitsPerStatus: number
|
|
98
|
+
expiresAt?: Date
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface IBitstringStatusListImplementationResult extends IStatusListImplementationResult {
|
|
102
|
+
type: StatusListType.BitstringStatusList
|
|
103
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
104
|
+
bitsPerStatus?: number
|
|
105
|
+
validFrom?: Date
|
|
106
|
+
validUntil?: Date
|
|
107
|
+
ttl?: number
|
|
43
108
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { IAgentContext,
|
|
1
|
+
import type { IAgentContext, IKeyManager } from '@veramo/core'
|
|
2
2
|
import { type CompactJWT, type CredentialProofFormat, type CWT, StatusListType } from '@sphereon/ssi-types'
|
|
3
3
|
import type {
|
|
4
4
|
CheckStatusIndexArgs,
|
|
5
5
|
CreateStatusListArgs,
|
|
6
6
|
SignedStatusListData,
|
|
7
|
+
StatusListOAuthEntryCredentialStatus,
|
|
7
8
|
StatusListResult,
|
|
8
9
|
StatusOAuth,
|
|
9
10
|
ToStatusListDetailsArgs,
|
|
@@ -11,14 +12,16 @@ import type {
|
|
|
11
12
|
UpdateStatusListIndexArgs,
|
|
12
13
|
} from '../types'
|
|
13
14
|
import { determineProofFormat, ensureDate, getAssertedValue, getAssertedValues } from '../utils'
|
|
14
|
-
import type { IStatusList } from './IStatusList'
|
|
15
|
+
import type { IOAuthStatusListImplementationResult, IStatusList } from './IStatusList'
|
|
15
16
|
import { StatusList } from '@sd-jwt/jwt-status-list'
|
|
16
17
|
import type { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
17
18
|
import type { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
18
19
|
import { createSignedJwt, decodeStatusListJWT } from './encoding/jwt'
|
|
19
20
|
import { createSignedCbor, decodeStatusListCWT } from './encoding/cbor'
|
|
21
|
+
import { IBitstringStatusListEntryEntity, IStatusListEntryEntity, OAuthStatusListEntity, StatusListEntity } from '@sphereon/ssi-sdk.data-store'
|
|
22
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
20
23
|
|
|
21
|
-
type IRequiredContext = IAgentContext<
|
|
24
|
+
type IRequiredContext = IAgentContext<IVcdmCredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>
|
|
22
25
|
|
|
23
26
|
export const DEFAULT_BITS_PER_STATUS = 1 // 1 bit is sufficient for 0x00 - "VALID" 0x01 - "INVALID" saving space in the process
|
|
24
27
|
export const DEFAULT_LIST_LENGTH = 250000
|
|
@@ -144,10 +147,6 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
private buildContentType(proofFormat: CredentialProofFormat | undefined) {
|
|
148
|
-
return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`
|
|
149
|
-
}
|
|
150
|
-
|
|
151
150
|
async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | StatusOAuth> {
|
|
152
151
|
const { statusListCredential, statusListIndex } = args
|
|
153
152
|
if (typeof statusListCredential !== 'string') {
|
|
@@ -165,13 +164,17 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
165
164
|
return statusList.getStatus(index)
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {
|
|
167
|
+
async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult & IOAuthStatusListImplementationResult> {
|
|
169
168
|
const { statusListPayload } = args as { statusListPayload: CompactJWT | CWT }
|
|
170
169
|
const proofFormat = determineProofFormat(statusListPayload)
|
|
171
170
|
const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload)
|
|
172
171
|
const { statusList, issuer, id, exp } = decoded
|
|
173
172
|
|
|
173
|
+
const bitsPerStatus = statusList.getBitsPerStatus()
|
|
174
|
+
const expiresAt = exp ? new Date(exp * 1000) : undefined
|
|
175
|
+
|
|
174
176
|
return {
|
|
177
|
+
// Base implementation fields
|
|
175
178
|
id,
|
|
176
179
|
encodedList: statusList.compressStatusList(),
|
|
177
180
|
issuer,
|
|
@@ -180,18 +183,52 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
180
183
|
length: statusList.statusList.length,
|
|
181
184
|
statusListCredential: statusListPayload,
|
|
182
185
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
186
|
+
correlationId: args.correlationId, // FIXME these do not need to be inside the impl
|
|
187
|
+
driverType: args.driverType, // FIXME these do not need to be inside the impl
|
|
188
|
+
|
|
189
|
+
// Flattened OAuth-specific fields
|
|
190
|
+
bitsPerStatus,
|
|
191
|
+
...(expiresAt && { expiresAt }),
|
|
192
|
+
|
|
193
|
+
// Legacy nested structure for backward compatibility
|
|
183
194
|
oauthStatusList: {
|
|
184
|
-
bitsPerStatus
|
|
185
|
-
...(
|
|
195
|
+
bitsPerStatus,
|
|
196
|
+
...(expiresAt && { expiresAt }),
|
|
186
197
|
},
|
|
198
|
+
|
|
199
|
+
// Optional fields from args
|
|
187
200
|
...(args.correlationId && { correlationId: args.correlationId }),
|
|
188
201
|
...(args.driverType && { driverType: args.driverType }),
|
|
189
202
|
}
|
|
190
203
|
}
|
|
191
204
|
|
|
205
|
+
async createCredentialStatus(args: {
|
|
206
|
+
statusList: StatusListEntity
|
|
207
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
208
|
+
statusListIndex: number
|
|
209
|
+
}): Promise<StatusListOAuthEntryCredentialStatus> {
|
|
210
|
+
const { statusList, statusListIndex } = args
|
|
211
|
+
|
|
212
|
+
// Cast to OAuthStatusListEntity to access specific properties
|
|
213
|
+
const oauthStatusList = statusList as OAuthStatusListEntity
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
217
|
+
type: 'OAuthStatusListEntry',
|
|
218
|
+
bitsPerStatus: oauthStatusList.bitsPerStatus,
|
|
219
|
+
statusListIndex: '' + statusListIndex,
|
|
220
|
+
statusListCredential: statusList.id,
|
|
221
|
+
expiresAt: oauthStatusList.expiresAt,
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private buildContentType(proofFormat: CredentialProofFormat | undefined) {
|
|
226
|
+
return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`
|
|
227
|
+
}
|
|
228
|
+
|
|
192
229
|
private async createSignedStatusList(
|
|
193
230
|
proofFormat: CredentialProofFormat,
|
|
194
|
-
context: IAgentContext<
|
|
231
|
+
context: IAgentContext<IVcdmCredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>,
|
|
195
232
|
statusList: StatusList,
|
|
196
233
|
issuerString: string,
|
|
197
234
|
id: string,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { IAgentContext,
|
|
1
|
+
import type { IAgentContext, ProofFormat as VeramoProofFormat } from '@veramo/core'
|
|
2
2
|
import type { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
3
3
|
import {
|
|
4
4
|
CredentialMapper,
|
|
5
|
+
type CredentialProofFormat,
|
|
5
6
|
DocumentFormat,
|
|
6
7
|
type IIssuer,
|
|
7
|
-
type CredentialProofFormat,
|
|
8
8
|
type StatusListCredential,
|
|
9
9
|
StatusListType,
|
|
10
10
|
} from '@sphereon/ssi-types'
|
|
11
11
|
|
|
12
12
|
import { StatusList } from '@sphereon/vc-status-list'
|
|
13
|
-
import type { IStatusList } from './IStatusList'
|
|
13
|
+
import type { IStatusList, IStatusList2021ImplementationResult } from './IStatusList'
|
|
14
14
|
import type {
|
|
15
15
|
CheckStatusIndexArgs,
|
|
16
16
|
CreateStatusListArgs,
|
|
@@ -19,9 +19,10 @@ import type {
|
|
|
19
19
|
UpdateStatusListFromEncodedListArgs,
|
|
20
20
|
UpdateStatusListIndexArgs,
|
|
21
21
|
} from '../types'
|
|
22
|
-
|
|
23
|
-
import { Status2021 } from '../types'
|
|
22
|
+
import { Status2021, StatusList2021EntryCredentialStatus } from '../types'
|
|
24
23
|
import { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'
|
|
24
|
+
import { IBitstringStatusListEntryEntity, IStatusListEntryEntity, StatusList2021Entity, StatusListEntity } from '@sphereon/ssi-sdk.data-store'
|
|
25
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
25
26
|
|
|
26
27
|
export const DEFAULT_LIST_LENGTH = 250000
|
|
27
28
|
export const DEFAULT_PROOF_FORMAT = 'lds' as CredentialProofFormat
|
|
@@ -29,7 +30,7 @@ export const DEFAULT_PROOF_FORMAT = 'lds' as CredentialProofFormat
|
|
|
29
30
|
export class StatusList2021Implementation implements IStatusList {
|
|
30
31
|
async createNewStatusList(
|
|
31
32
|
args: CreateStatusListArgs,
|
|
32
|
-
context: IAgentContext<
|
|
33
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
33
34
|
): Promise<StatusListResult> {
|
|
34
35
|
const length = args?.length ?? DEFAULT_LIST_LENGTH
|
|
35
36
|
const proofFormat: CredentialProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT
|
|
@@ -71,7 +72,7 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
71
72
|
|
|
72
73
|
async updateStatusListIndex(
|
|
73
74
|
args: UpdateStatusListIndexArgs,
|
|
74
|
-
context: IAgentContext<
|
|
75
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
75
76
|
): Promise<StatusListResult> {
|
|
76
77
|
const credential = args.statusListCredential
|
|
77
78
|
const uniform = CredentialMapper.toUniformCredential(credential)
|
|
@@ -96,11 +97,15 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
96
97
|
context,
|
|
97
98
|
)
|
|
98
99
|
|
|
100
|
+
if (!('statusPurpose' in credentialSubject)) {
|
|
101
|
+
return Promise.reject(Error('statusPurpose is required in credentialSubject for StatusList2021'))
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
return {
|
|
100
105
|
statusListCredential: updatedCredential,
|
|
101
106
|
encodedList,
|
|
102
107
|
statusList2021: {
|
|
103
|
-
|
|
108
|
+
statusPurpose: credentialSubject.statusPurpose,
|
|
104
109
|
indexingDirection: 'rightToLeft',
|
|
105
110
|
},
|
|
106
111
|
length: statusList.length - 1,
|
|
@@ -114,7 +119,7 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
114
119
|
|
|
115
120
|
async updateStatusListFromEncodedList(
|
|
116
121
|
args: UpdateStatusListFromEncodedListArgs,
|
|
117
|
-
context: IAgentContext<
|
|
122
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
118
123
|
): Promise<StatusListResult> {
|
|
119
124
|
if (!args.statusList2021) {
|
|
120
125
|
throw new Error('statusList2021 options required for type StatusList2021')
|
|
@@ -166,7 +171,7 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
166
171
|
return status ? Status2021.Invalid : Status2021.Valid
|
|
167
172
|
}
|
|
168
173
|
|
|
169
|
-
async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {
|
|
174
|
+
async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult & IStatusList2021ImplementationResult> {
|
|
170
175
|
const { statusListPayload } = args
|
|
171
176
|
const uniform = CredentialMapper.toUniformCredential(statusListPayload)
|
|
172
177
|
const { issuer, credentialSubject } = uniform
|
|
@@ -175,9 +180,11 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
175
180
|
const proofFormat: CredentialProofFormat = CredentialMapper.detectDocumentType(statusListPayload) === DocumentFormat.JWT ? 'jwt' : 'lds'
|
|
176
181
|
|
|
177
182
|
const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject)
|
|
183
|
+
const indexingDirection = 'rightToLeft'
|
|
178
184
|
const list = await StatusList.decode({ encodedList })
|
|
179
185
|
|
|
180
186
|
return {
|
|
187
|
+
// Base implementation fields
|
|
181
188
|
id,
|
|
182
189
|
encodedList,
|
|
183
190
|
issuer,
|
|
@@ -186,12 +193,41 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
186
193
|
length: list.length,
|
|
187
194
|
statusListCredential: statusListPayload,
|
|
188
195
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
196
|
+
correlationId: args.correlationId, // FIXME these do not need to be inside the impl
|
|
197
|
+
driverType: args.driverType, // FIXME these do not need to be inside the impl
|
|
198
|
+
|
|
199
|
+
// Flattened StatusList2021-specific fields
|
|
200
|
+
indexingDirection,
|
|
201
|
+
statusPurpose,
|
|
202
|
+
|
|
203
|
+
// Legacy nested structure for backward compatibility
|
|
189
204
|
statusList2021: {
|
|
190
|
-
indexingDirection
|
|
205
|
+
indexingDirection,
|
|
191
206
|
statusPurpose,
|
|
207
|
+
|
|
208
|
+
// Optional fields from args
|
|
209
|
+
...(args.correlationId && { correlationId: args.correlationId }),
|
|
210
|
+
...(args.driverType && { driverType: args.driverType }),
|
|
192
211
|
},
|
|
193
|
-
|
|
194
|
-
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async createCredentialStatus(args: {
|
|
216
|
+
statusList: StatusListEntity
|
|
217
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
218
|
+
statusListIndex: number
|
|
219
|
+
}): Promise<StatusList2021EntryCredentialStatus> {
|
|
220
|
+
const { statusList, statusListIndex } = args
|
|
221
|
+
|
|
222
|
+
// Cast to StatusList2021Entity to access specific properties
|
|
223
|
+
const statusList2021 = statusList as StatusList2021Entity
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
227
|
+
type: 'StatusList2021Entry',
|
|
228
|
+
statusPurpose: statusList2021.statusPurpose ?? 'revocation',
|
|
229
|
+
statusListIndex: '' + statusListIndex,
|
|
230
|
+
statusListCredential: statusList.id,
|
|
195
231
|
}
|
|
196
232
|
}
|
|
197
233
|
|
|
@@ -203,7 +239,7 @@ export class StatusList2021Implementation implements IStatusList {
|
|
|
203
239
|
proofFormat: VeramoProofFormat
|
|
204
240
|
keyRef?: string
|
|
205
241
|
},
|
|
206
|
-
context: IAgentContext<
|
|
242
|
+
context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>,
|
|
207
243
|
): Promise<StatusListCredential> {
|
|
208
244
|
const identifier = await context.agent.identifierManagedGet({
|
|
209
245
|
identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,
|
package/src/types/index.ts
CHANGED
|
@@ -7,26 +7,18 @@ import {
|
|
|
7
7
|
type IVerifiableCredential,
|
|
8
8
|
type OrPromise,
|
|
9
9
|
type StatusListCredential,
|
|
10
|
-
StatusListCredentialIdMode,
|
|
11
10
|
StatusListDriverType,
|
|
12
11
|
type StatusListIndexingDirection,
|
|
13
12
|
StatusListType,
|
|
14
13
|
type StatusPurpose2021,
|
|
15
14
|
} from '@sphereon/ssi-types'
|
|
16
|
-
import type {
|
|
17
|
-
CredentialPayload,
|
|
18
|
-
IAgentContext,
|
|
19
|
-
ICredentialIssuer,
|
|
20
|
-
ICredentialPlugin,
|
|
21
|
-
ICredentialVerifier,
|
|
22
|
-
IKeyManager,
|
|
23
|
-
IPluginMethodMap,
|
|
24
|
-
} from '@veramo/core'
|
|
15
|
+
import type { CredentialPayload, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
25
16
|
import { DataSource } from 'typeorm'
|
|
26
17
|
import type { BitsPerStatus } from '@sd-jwt/jwt-status-list'
|
|
27
18
|
import type { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'
|
|
28
19
|
import type { StatusListOpts } from '@sphereon/oid4vci-common'
|
|
29
20
|
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists'
|
|
21
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
30
22
|
|
|
31
23
|
export enum StatusOAuth {
|
|
32
24
|
Valid = 0,
|
|
@@ -48,7 +40,7 @@ export type StatusList2021Args = {
|
|
|
48
40
|
}
|
|
49
41
|
|
|
50
42
|
export type OAuthStatusListArgs = {
|
|
51
|
-
bitsPerStatus
|
|
43
|
+
bitsPerStatus: BitsPerStatus
|
|
52
44
|
expiresAt?: Date
|
|
53
45
|
}
|
|
54
46
|
|
|
@@ -114,40 +106,46 @@ export interface UpdateStatusListFromStatusListCredentialArgs {
|
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
export interface StatusListResult {
|
|
109
|
+
id: string
|
|
117
110
|
encodedList: string
|
|
118
|
-
|
|
119
|
-
length: number
|
|
111
|
+
issuer: string | IIssuer
|
|
120
112
|
type: StatusListType
|
|
121
113
|
proofFormat: CredentialProofFormat
|
|
122
|
-
|
|
114
|
+
length: number
|
|
115
|
+
statusListCredential: StatusListCredential
|
|
123
116
|
statuslistContentType: string
|
|
124
|
-
issuer: string | IIssuer
|
|
125
|
-
statusList2021?: StatusList2021Details
|
|
126
|
-
oauthStatusList?: OAuthStatusDetails
|
|
127
|
-
bitstringStatusList?: BitstringStatusDetails
|
|
128
|
-
|
|
129
|
-
// These cannot be deduced from the VC, so they are present when callers pass in these values as params
|
|
130
117
|
correlationId?: string
|
|
131
118
|
driverType?: StatusListDriverType
|
|
132
|
-
credentialIdMode?: StatusListCredentialIdMode
|
|
133
|
-
}
|
|
134
119
|
|
|
135
|
-
|
|
136
|
-
indexingDirection
|
|
137
|
-
statusPurpose?: StatusPurpose2021
|
|
138
|
-
}
|
|
120
|
+
// Flattened StatusList2021 fields
|
|
121
|
+
indexingDirection?: StatusListIndexingDirection
|
|
122
|
+
statusPurpose?: StatusPurpose2021 | BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
139
123
|
|
|
140
|
-
|
|
141
|
-
bitsPerStatus?:
|
|
124
|
+
// Flattened OAuth fields
|
|
125
|
+
bitsPerStatus?: number
|
|
142
126
|
expiresAt?: Date
|
|
143
|
-
}
|
|
144
127
|
|
|
145
|
-
|
|
146
|
-
statusPurpose: BitstringStatusPurpose
|
|
147
|
-
bitsPerStatus: number
|
|
128
|
+
// Flattened Bitstring fields
|
|
148
129
|
validFrom?: Date
|
|
149
130
|
validUntil?: Date
|
|
150
131
|
ttl?: number
|
|
132
|
+
|
|
133
|
+
// Legacy nested structures for backward compatibility
|
|
134
|
+
statusList2021?: {
|
|
135
|
+
indexingDirection: StatusListIndexingDirection
|
|
136
|
+
statusPurpose: StatusPurpose2021
|
|
137
|
+
}
|
|
138
|
+
oauthStatusList?: {
|
|
139
|
+
bitsPerStatus: number
|
|
140
|
+
expiresAt?: Date
|
|
141
|
+
}
|
|
142
|
+
bitstringStatusList?: {
|
|
143
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
144
|
+
bitsPerStatus?: number
|
|
145
|
+
validFrom?: Date
|
|
146
|
+
validUntil?: Date
|
|
147
|
+
ttl?: number
|
|
148
|
+
}
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
export interface StatusList2021EntryCredentialStatus extends ICredentialStatus {
|
|
@@ -304,5 +302,5 @@ export type SignedStatusListData = {
|
|
|
304
302
|
encodedList: string
|
|
305
303
|
}
|
|
306
304
|
|
|
307
|
-
export type IRequiredPlugins =
|
|
308
|
-
export type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager &
|
|
305
|
+
export type IRequiredPlugins = IVcdmCredentialPlugin & IIdentifierResolution
|
|
306
|
+
export type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & IVcdmCredentialPlugin>
|
package/src/utils.ts
CHANGED
|
@@ -41,7 +41,7 @@ export function getAssertedProperty<T extends object>(propertyName: string, obj:
|
|
|
41
41
|
const ValidProofTypeMap = new Map<StatusListType, CredentialProofFormat[]>([
|
|
42
42
|
[StatusListType.StatusList2021, ['jwt', 'lds']],
|
|
43
43
|
[StatusListType.OAuthStatusList, ['jwt', 'cbor']],
|
|
44
|
-
[StatusListType.BitstringStatusList, ['lds']],
|
|
44
|
+
[StatusListType.BitstringStatusList, ['lds', 'vc+jwt']],
|
|
45
45
|
])
|
|
46
46
|
|
|
47
47
|
export function assertValidProofType(type: StatusListType, proofFormat: CredentialProofFormat) {
|