@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/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.26.RP.57+9836fe9c",
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.9.2",
26
+ "@sd-jwt/core": "^0.15.0",
27
27
  "@sd-jwt/jwt-status-list": "^0.9.1",
28
- "@sd-jwt/sd-jwt-vc": "^0.9.2",
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.13.32",
31
- "@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
32
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
33
- "@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
34
- "@sphereon/ssi-sdk.credential-vcdm": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
35
- "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
36
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.26.RP.57+9836fe9c",
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": "9836fe9c1ba582b925c14e88fb09c43938edd9b2"
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 * as mdoc from '@sphereon/kmp-mdoc-core'
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 = mdoc.com.sphereon.crypto.IKey
12
- export type CborItem<T> = mdoc.com.sphereon.cbor.CborItem<T>
13
- export const CborByteString = mdoc.com.sphereon.cbor.CborByteString
14
- export type CborByteStringType = mdoc.com.sphereon.cbor.CborByteString
15
- export const CborUInt = mdoc.com.sphereon.cbor.CborUInt
16
- export type CborUIntType = mdoc.com.sphereon.cbor.CborUInt
17
- export const CborString = mdoc.com.sphereon.cbor.CborString
18
- export type CborStringType = mdoc.com.sphereon.cbor.CborString
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 mdoc.com.sphereon.cbor.CborMap(
49
- mdoc.kotlin.collections.KtMutableMap.fromJsMap(
49
+ const statusListMap = new com.sphereon.cbor.CborMap(
50
+ kotlin.collections.KtMutableMap.fromJsMap(
50
51
  new Map<CborStringType, CborItem<any>>([
51
52
  [
52
- new mdoc.com.sphereon.cbor.CborString('bits'),
53
- new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus())),
53
+ new com.sphereon.cbor.CborString('bits'),
54
+ new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus())),
54
55
  ],
55
- [new mdoc.com.sphereon.cbor.CborString('lst'), new mdoc.com.sphereon.cbor.CborByteString(compressedBytes)],
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 mdoc.com.sphereon.cbor.CborMap(
61
- mdoc.kotlin.collections.KtMutableMap.fromJsMap(
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 = mdoc.com.sphereon.cbor.Cbor.encode(protectedHeader)
66
+ const protectedHeaderEncoded = com.sphereon.cbor.Cbor.encode(protectedHeader)
68
67
  const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)
69
- const claimsEncoded: Int8Array = mdoc.com.sphereon.cbor.Cbor.encode(claimsMap)
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 mdoc.com.sphereon.cbor.CborArray(mdoc.kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))
88
- const cwtEncoded = mdoc.com.sphereon.cbor.Cbor.encode(cwtArray)
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: mdoc.com.sphereon.cbor.CborMap<CborStringType, CborItem<any>>,
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(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new mdoc.com.sphereon.cbor.CborString(id)], // "sub"
105
- [new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new mdoc.com.sphereon.cbor.CborString(issuerString)], // "iss"
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(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
108
- new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // "iat"
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 mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
115
- new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // "exp"
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 mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
122
- new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(ttl)), // "time to live"
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 mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])
125
+ claimsEntries.push([new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])
127
126
 
128
- const claimsMap = new mdoc.com.sphereon.cbor.CborMap(mdoc.kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))
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(mdoc.com.sphereon.kmp.LongKMP.fromNumber(key)))
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 = mdoc.com.sphereon.cbor.Cbor.decode(encodedCborArray)
150
+ const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray)
152
151
 
153
- if (!(decodedCbor instanceof mdoc.com.sphereon.cbor.CborArray)) {
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 mdoc.com.sphereon.cbor.CborByteString)) {
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 = mdoc.com.sphereon.cbor.Cbor.decode(payload.value)
163
- if (!(claims instanceof mdoc.com.sphereon.cbor.CborMap)) {
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(mdoc.com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView()
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)