@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.7 → 0.34.1-feature.SSISDK.17.bitstring.sl.9
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 +32 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/impl/BitstringStatusListImplementation.ts +5 -5
- package/src/impl/OAuthStatusList.ts +8 -5
- package/src/utils.ts +32 -0
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.
|
|
4
|
+
"version": "0.34.1-feature.SSISDK.17.bitstring.sl.9+a052acba",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
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-types": "0.34.1-feature.SSISDK.17.bitstring.sl.
|
|
34
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.9+a052acba",
|
|
35
35
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/credential-status": "4.2.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"SSI",
|
|
71
71
|
"StatusList2021"
|
|
72
72
|
],
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "a052acbaa88acf4be22236ca3afaadd5b2821fe1"
|
|
74
74
|
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
UpdateStatusListIndexArgs,
|
|
21
21
|
} from '../types'
|
|
22
22
|
|
|
23
|
-
import { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'
|
|
23
|
+
import { assertValidProofType, ensureDate, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'
|
|
24
24
|
import { BitstringStatusListCredential } from '../types/BitstringStatusList'
|
|
25
25
|
import { BitstreamStatusList, BitstringStatusPurpose, createStatusListCredential } from '@4sure-tech/vc-bitstring-status-lists'
|
|
26
26
|
|
|
@@ -50,8 +50,8 @@ export class BitstringStatusListImplementation implements IStatusList {
|
|
|
50
50
|
...args,
|
|
51
51
|
proofFormat: veramoProofFormat,
|
|
52
52
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
53
|
-
validFrom,
|
|
54
|
-
validUntil,
|
|
53
|
+
validFrom: ensureDate(validFrom),
|
|
54
|
+
validUntil: ensureDate(validUntil),
|
|
55
55
|
ttl,
|
|
56
56
|
},
|
|
57
57
|
context,
|
|
@@ -170,8 +170,8 @@ export class BitstringStatusListImplementation implements IStatusList {
|
|
|
170
170
|
proofFormat: veramoProofFormat,
|
|
171
171
|
keyRef: args.keyRef,
|
|
172
172
|
statusPurpose,
|
|
173
|
-
validFrom,
|
|
174
|
-
validUntil,
|
|
173
|
+
validFrom: ensureDate(validFrom),
|
|
174
|
+
validUntil: ensureDate(validUntil),
|
|
175
175
|
ttl,
|
|
176
176
|
},
|
|
177
177
|
context,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IAgentContext, ICredentialPlugin, IKeyManager } from '@veramo/core'
|
|
2
|
-
import { type CompactJWT, type
|
|
2
|
+
import { type CompactJWT, type CredentialProofFormat, type CWT, StatusListType } from '@sphereon/ssi-types'
|
|
3
3
|
import type {
|
|
4
4
|
CheckStatusIndexArgs,
|
|
5
5
|
CreateStatusListArgs,
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
UpdateStatusListFromEncodedListArgs,
|
|
11
11
|
UpdateStatusListIndexArgs,
|
|
12
12
|
} from '../types'
|
|
13
|
-
import { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils'
|
|
13
|
+
import { determineProofFormat, ensureDate, getAssertedValue, getAssertedValues } from '../utils'
|
|
14
14
|
import type { IStatusList } from './IStatusList'
|
|
15
15
|
import { StatusList } from '@sd-jwt/jwt-status-list'
|
|
16
16
|
import type { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
@@ -32,7 +32,8 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
32
32
|
|
|
33
33
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT
|
|
34
34
|
const { issuer, id, oauthStatusList, keyRef } = args
|
|
35
|
-
const { bitsPerStatus
|
|
35
|
+
const { bitsPerStatus } = oauthStatusList
|
|
36
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt)
|
|
36
37
|
const length = args.length ?? DEFAULT_LIST_LENGTH
|
|
37
38
|
const issuerString = typeof issuer === 'string' ? issuer : issuer.id
|
|
38
39
|
const correlationId = getAssertedValue('correlationId', args.correlationId)
|
|
@@ -56,7 +57,8 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
async updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IRequiredContext): Promise<StatusListResult> {
|
|
59
|
-
const { statusListCredential, value,
|
|
60
|
+
const { statusListCredential, value, keyRef } = args
|
|
61
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt)
|
|
60
62
|
if (typeof statusListCredential !== 'string') {
|
|
61
63
|
return Promise.reject('statusListCredential in neither JWT nor CWT')
|
|
62
64
|
}
|
|
@@ -106,7 +108,8 @@ export class OAuthStatusListImplementation implements IStatusList {
|
|
|
106
108
|
throw new Error('OAuthStatusList options are required for type OAuthStatusList')
|
|
107
109
|
}
|
|
108
110
|
const { proofFormat, oauthStatusList, keyRef } = args
|
|
109
|
-
const { bitsPerStatus
|
|
111
|
+
const { bitsPerStatus } = oauthStatusList
|
|
112
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt)
|
|
110
113
|
|
|
111
114
|
const { issuer, id } = getAssertedValues(args)
|
|
112
115
|
const issuerString = typeof issuer === 'string' ? issuer : issuer.id
|
package/src/utils.ts
CHANGED
|
@@ -94,3 +94,35 @@ export function determineProofFormat(credential: StatusListCredential): Credenti
|
|
|
94
94
|
throw Error('Cannot determine credential payload type')
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Ensures a value is converted to a Date object if it's a valid date string,
|
|
100
|
+
* otherwise returns the original value or undefined
|
|
101
|
+
*
|
|
102
|
+
* @param value - The value to convert to Date (can be Date, string, or undefined)
|
|
103
|
+
* @returns Date object, undefined, or the original value if conversion fails
|
|
104
|
+
*/
|
|
105
|
+
export function ensureDate(value: Date | string | undefined): Date | undefined {
|
|
106
|
+
if (value === undefined || value === null) {
|
|
107
|
+
return undefined
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (value instanceof Date) {
|
|
111
|
+
return value
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (typeof value === 'string') {
|
|
115
|
+
if (value.trim() === '') {
|
|
116
|
+
return undefined
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const date = new Date(value)
|
|
120
|
+
// Check if the date is valid
|
|
121
|
+
if (isNaN(date.getTime())) {
|
|
122
|
+
return undefined
|
|
123
|
+
}
|
|
124
|
+
return date
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return undefined
|
|
128
|
+
}
|