@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.26.RP.57 → 0.34.1-feature.SSISDK.45.135
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 +36 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -35
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/impl/encoding/cbor.ts +40 -41
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.
|
|
4
|
+
"version": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@4sure-tech/vc-bitstring-status-lists": "0.1.0-unstable.1",
|
|
26
|
-
"@sd-jwt/core": "^0.
|
|
26
|
+
"@sd-jwt/core": "^0.15.0",
|
|
27
27
|
"@sd-jwt/jwt-status-list": "^0.9.1",
|
|
28
|
-
"@sd-jwt/sd-jwt-vc": "^0.
|
|
28
|
+
"@sd-jwt/sd-jwt-vc": "^0.15.0",
|
|
29
29
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
30
|
-
"@sphereon/oid4vci-common": "0.19.1-feature.SSISDK.
|
|
31
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.
|
|
33
|
-
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.
|
|
34
|
-
"@sphereon/ssi-sdk.credential-vcdm": "0.34.1-feature.SSISDK.
|
|
35
|
-
"@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.
|
|
36
|
-
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.
|
|
30
|
+
"@sphereon/oid4vci-common": "0.19.1-feature.SSISDK.45.120",
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
34
|
+
"@sphereon/ssi-sdk.credential-vcdm": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
35
|
+
"@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
36
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.45.135+c34457e7",
|
|
37
37
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
38
38
|
"@veramo/core": "4.2.0",
|
|
39
39
|
"@veramo/credential-status": "4.2.0",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"SSI",
|
|
73
73
|
"StatusList2021"
|
|
74
74
|
],
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "c34457e783e778691ef94a2a266dca8bc8a44404"
|
|
76
76
|
}
|
|
@@ -2,20 +2,21 @@ import type { BitsPerStatus } from '@sd-jwt/jwt-status-list'
|
|
|
2
2
|
import { StatusList } from '@sd-jwt/jwt-status-list'
|
|
3
3
|
import { deflate, inflate } from 'pako'
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import mdocPkg from '@sphereon/kmp-mdoc-core'
|
|
6
|
+
const { com, kotlin } = mdocPkg
|
|
6
7
|
|
|
7
8
|
import base64url from 'base64url'
|
|
8
9
|
import type { IRequiredContext, SignedStatusListData } from '../../types'
|
|
9
10
|
import { type DecodedStatusListPayload, resolveIdentifier } from './common'
|
|
10
11
|
|
|
11
|
-
export type IKey =
|
|
12
|
-
export type CborItem<T> =
|
|
13
|
-
export const CborByteString =
|
|
14
|
-
export type CborByteStringType =
|
|
15
|
-
export const CborUInt =
|
|
16
|
-
export type CborUIntType =
|
|
17
|
-
export const CborString =
|
|
18
|
-
export type CborStringType =
|
|
12
|
+
export type IKey = mdocPkg.com.sphereon.crypto.IKey
|
|
13
|
+
export type CborItem<T> = mdocPkg.com.sphereon.cbor.CborItem<T>
|
|
14
|
+
export const CborByteString = mdocPkg.com.sphereon.cbor.CborByteString
|
|
15
|
+
export type CborByteStringType = mdocPkg.com.sphereon.cbor.CborByteString
|
|
16
|
+
export const CborUInt = mdocPkg.com.sphereon.cbor.CborUInt
|
|
17
|
+
export type CborUIntType = mdocPkg.com.sphereon.cbor.CborUInt
|
|
18
|
+
export const CborString = mdocPkg.com.sphereon.cbor.CborString
|
|
19
|
+
export type CborStringType = mdocPkg.com.sphereon.cbor.CborString
|
|
19
20
|
|
|
20
21
|
// const cbor = cborpkg.com.sphereon.cbor
|
|
21
22
|
// const kmp = cborpkg. mdoc.com.sphereon.kmp
|
|
@@ -45,28 +46,26 @@ export const createSignedCbor = async (
|
|
|
45
46
|
const compressedList = deflate(encodeStatusList, { level: 9 })
|
|
46
47
|
const compressedBytes = new Int8Array(compressedList)
|
|
47
48
|
|
|
48
|
-
const statusListMap = new
|
|
49
|
-
|
|
49
|
+
const statusListMap = new com.sphereon.cbor.CborMap(
|
|
50
|
+
kotlin.collections.KtMutableMap.fromJsMap(
|
|
50
51
|
new Map<CborStringType, CborItem<any>>([
|
|
51
52
|
[
|
|
52
|
-
new
|
|
53
|
-
new
|
|
53
|
+
new com.sphereon.cbor.CborString('bits'),
|
|
54
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus())),
|
|
54
55
|
],
|
|
55
|
-
[new
|
|
56
|
+
[new com.sphereon.cbor.CborString('lst'), new com.sphereon.cbor.CborByteString(compressedBytes)],
|
|
56
57
|
]),
|
|
57
58
|
),
|
|
58
59
|
)
|
|
59
60
|
|
|
60
|
-
const protectedHeader = new
|
|
61
|
-
|
|
62
|
-
new Map([
|
|
63
|
-
[new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(16)), new mdoc.com.sphereon.cbor.CborString('statuslist+cwt')],
|
|
64
|
-
]), // "type"
|
|
61
|
+
const protectedHeader = new com.sphereon.cbor.CborMap(
|
|
62
|
+
kotlin.collections.KtMutableMap.fromJsMap(
|
|
63
|
+
new Map([[new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(16)), new com.sphereon.cbor.CborString('statuslist+cwt')]]), // "type"
|
|
65
64
|
),
|
|
66
65
|
)
|
|
67
|
-
const protectedHeaderEncoded =
|
|
66
|
+
const protectedHeaderEncoded = com.sphereon.cbor.Cbor.encode(protectedHeader)
|
|
68
67
|
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)
|
|
69
|
-
const claimsEncoded: Int8Array =
|
|
68
|
+
const claimsEncoded: Int8Array = com.sphereon.cbor.Cbor.encode(claimsMap)
|
|
70
69
|
|
|
71
70
|
const signedCWT: string = await context.agent.keyManagerSign({
|
|
72
71
|
keyRef: identifier.kmsKeyRef,
|
|
@@ -84,8 +83,8 @@ export const createSignedCbor = async (
|
|
|
84
83
|
new CborByteString(claimsEncodedInt8),
|
|
85
84
|
new CborByteString(signatureInt8),
|
|
86
85
|
]
|
|
87
|
-
const cwtArray = new
|
|
88
|
-
const cwtEncoded =
|
|
86
|
+
const cwtArray = new com.sphereon.cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))
|
|
87
|
+
const cwtEncoded = com.sphereon.cbor.Cbor.encode(cwtArray)
|
|
89
88
|
const cwtBuffer = Buffer.from(cwtEncoded)
|
|
90
89
|
return {
|
|
91
90
|
statusListCredential: base64url.encode(cwtBuffer),
|
|
@@ -96,36 +95,36 @@ export const createSignedCbor = async (
|
|
|
96
95
|
function buildClaimsMap(
|
|
97
96
|
id: string,
|
|
98
97
|
issuerString: string,
|
|
99
|
-
statusListMap:
|
|
98
|
+
statusListMap: mdocPkg.com.sphereon.cbor.CborMap<CborStringType, CborItem<any>>,
|
|
100
99
|
expiresAt?: Date,
|
|
101
100
|
) {
|
|
102
101
|
const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp
|
|
103
102
|
const claimsEntries: Array<[CborUIntType, CborItem<any>]> = [
|
|
104
|
-
[new CborUInt(
|
|
105
|
-
[new CborUInt(
|
|
103
|
+
[new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new com.sphereon.cbor.CborString(id)], // "sub"
|
|
104
|
+
[new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new com.sphereon.cbor.CborString(issuerString)], // "iss"
|
|
106
105
|
[
|
|
107
|
-
new CborUInt(
|
|
108
|
-
new CborUInt(
|
|
106
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
107
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // "iat"
|
|
109
108
|
],
|
|
110
109
|
]
|
|
111
110
|
|
|
112
111
|
if (expiresAt) {
|
|
113
112
|
claimsEntries.push([
|
|
114
|
-
new
|
|
115
|
-
new
|
|
113
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
114
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // "exp"
|
|
116
115
|
])
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
if (ttl) {
|
|
120
119
|
claimsEntries.push([
|
|
121
|
-
new
|
|
122
|
-
new
|
|
120
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
121
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(ttl)), // "time to live"
|
|
123
122
|
])
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
claimsEntries.push([new
|
|
125
|
+
claimsEntries.push([new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])
|
|
127
126
|
|
|
128
|
-
const claimsMap = new
|
|
127
|
+
const claimsMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))
|
|
129
128
|
return claimsMap
|
|
130
129
|
}
|
|
131
130
|
|
|
@@ -138,7 +137,7 @@ const getCborValueFromMap = <T>(map: Map<CborItem<any>, CborItem<any>>, key: num
|
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
const getCborOptionalValueFromMap = <T>(map: Map<CborItem<any>, CborItem<any>>, key: number): T | undefined | never => {
|
|
141
|
-
const value = map.get(new CborUInt(
|
|
140
|
+
const value = map.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(key)))
|
|
142
141
|
if (!value) {
|
|
143
142
|
return undefined
|
|
144
143
|
}
|
|
@@ -148,25 +147,25 @@ const getCborOptionalValueFromMap = <T>(map: Map<CborItem<any>, CborItem<any>>,
|
|
|
148
147
|
export const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {
|
|
149
148
|
const encodedCbor = base64url.toBuffer(cwt)
|
|
150
149
|
const encodedCborArray = new Int8Array(encodedCbor)
|
|
151
|
-
const decodedCbor =
|
|
150
|
+
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray)
|
|
152
151
|
|
|
153
|
-
if (!(decodedCbor instanceof
|
|
152
|
+
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
154
153
|
throw new Error('Invalid CWT format: Expected a CBOR array')
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
const [, payload] = decodedCbor.value.asJsArrayView()
|
|
158
|
-
if (!(payload instanceof
|
|
157
|
+
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
159
158
|
throw new Error('Invalid payload format: Expected a CBOR ByteString')
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
const claims =
|
|
163
|
-
if (!(claims instanceof
|
|
161
|
+
const claims = com.sphereon.cbor.Cbor.decode(payload.value)
|
|
162
|
+
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
164
163
|
throw new Error('Invalid claims format: Expected a CBOR map')
|
|
165
164
|
}
|
|
166
165
|
|
|
167
166
|
const claimsMap = claims.value.asJsMapView()
|
|
168
167
|
|
|
169
|
-
const statusListMap = claimsMap.get(new CborUInt(
|
|
168
|
+
const statusListMap = claimsMap.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView()
|
|
170
169
|
|
|
171
170
|
const bits = Number(statusListMap.get(new CborString('bits')).value) as BitsPerStatus
|
|
172
171
|
const decoded = new Uint8Array(statusListMap.get(new CborString('lst')).value)
|