@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.26.54 → 0.34.1-feature.SSISDK.26.RP.57

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