@sphereon/ssi-types 0.32.1-next.54 → 0.33.0

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.
Files changed (44) hide show
  1. package/dist/mapper/credential-mapper.d.ts +11 -10
  2. package/dist/mapper/credential-mapper.d.ts.map +1 -1
  3. package/dist/mapper/credential-mapper.js +22 -29
  4. package/dist/mapper/credential-mapper.js.map +1 -1
  5. package/dist/types/dcql.d.ts +33 -0
  6. package/dist/types/dcql.d.ts.map +1 -0
  7. package/dist/types/dcql.js +4 -0
  8. package/dist/types/dcql.js.map +1 -0
  9. package/dist/types/generic.d.ts +3 -0
  10. package/dist/types/generic.d.ts.map +1 -1
  11. package/dist/types/index.d.ts +2 -0
  12. package/dist/types/index.d.ts.map +1 -1
  13. package/dist/types/index.js +2 -0
  14. package/dist/types/index.js.map +1 -1
  15. package/dist/types/sd-jwt-vc.d.ts +5 -4
  16. package/dist/types/sd-jwt-vc.d.ts.map +1 -1
  17. package/dist/types/sd-jwt-vc.js.map +1 -1
  18. package/dist/types/status-list.d.ts +10 -0
  19. package/dist/types/status-list.d.ts.map +1 -0
  20. package/dist/types/status-list.js +9 -0
  21. package/dist/types/status-list.js.map +1 -0
  22. package/dist/types/w3c-vc.d.ts +0 -3
  23. package/dist/types/w3c-vc.d.ts.map +1 -1
  24. package/dist/types/w3c-vc.js +1 -5
  25. package/dist/types/w3c-vc.js.map +1 -1
  26. package/dist/utils/hasher.d.ts +4 -0
  27. package/dist/utils/hasher.d.ts.map +1 -0
  28. package/dist/utils/hasher.js +40 -0
  29. package/dist/utils/hasher.js.map +1 -0
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/index.d.ts.map +1 -1
  32. package/dist/utils/index.js +1 -0
  33. package/dist/utils/index.js.map +1 -1
  34. package/package.json +4 -3
  35. package/src/mapper/credential-mapper.ts +47 -52
  36. package/src/types/dcql.ts +39 -0
  37. package/src/types/generic.ts +5 -0
  38. package/src/types/index.ts +2 -0
  39. package/src/types/mso_mdoc.ts +2 -2
  40. package/src/types/sd-jwt-vc.ts +6 -5
  41. package/src/types/status-list.ts +12 -0
  42. package/src/types/w3c-vc.ts +3 -1
  43. package/src/utils/hasher.ts +17 -0
  44. package/src/utils/index.ts +1 -0
@@ -229,9 +229,6 @@ export interface IErrorDetails {
229
229
  url?: string;
230
230
  cause?: IError;
231
231
  }
232
- export declare enum StatusListType {
233
- StatusList2021 = "StatusList2021"
234
- }
235
232
  export type StatusPurpose2021 = 'revocation' | 'suspension' | string;
236
233
  export declare enum StatusListCredentialIdMode {
237
234
  ISSUANCE = "ISSUANCE",
@@ -1 +1 @@
1
- {"version":3,"file":"w3c-vc.d.ts","sourceRoot":"","sources":["../../src/types/w3c-vc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,MAAM,CAAA;AAE/F,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAElD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAA;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,gBAAgB,CAAC,EAAE,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,EAAE,CAAA;IAE9E,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAE3B,YAAY,EAAE,MAAM,CAAA;IAEpB,iBAAiB,EAAE,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,EAAE,CAAA;IAEtG,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,EAAE,CAAC,EAAE,MA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I,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAQD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAA;AAEpE,oBAAY,0BAA0B;IACpC,QAAQ,aAAa;IAErB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAA;AAEvD,oBAAY,oBAAoB;IAC9B,aAAa,kBAAkB;CAIhC;AAED,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,2BAA2B,GAAG,EAAE,IAAI,8BAA8B,CAEtH;AAED,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,6BAA6B,GAAG,EAAE,IAAI,gCAAgC,CAE5H"}
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatusListDriverType = exports.StatusListCredentialIdMode = exports.StatusListType = exports.JWT_PROOF_TYPE_2020 = void 0;
3
+ exports.StatusListDriverType = exports.StatusListCredentialIdMode = exports.JWT_PROOF_TYPE_2020 = void 0;
4
4
  exports.isWrappedW3CVerifiableCredential = isWrappedW3CVerifiableCredential;
5
5
  exports.isWrappedW3CVerifiablePresentation = isWrappedW3CVerifiablePresentation;
6
6
  exports.JWT_PROOF_TYPE_2020 = 'JwtProof2020';
7
- var StatusListType;
8
- (function (StatusListType) {
9
- StatusListType["StatusList2021"] = "StatusList2021";
10
- })(StatusListType || (exports.StatusListType = StatusListType = {}));
11
7
  var StatusListCredentialIdMode;
12
8
  (function (StatusListCredentialIdMode) {
13
9
  StatusListCredentialIdMode["ISSUANCE"] = "ISSUANCE";
@@ -1 +1 @@
1
- {"version":3,"file":"w3c-vc.js","sourceRoot":"","sources":["../../src/types/w3c-vc.ts"],"names":[],"mappings":";;;AA2SA,4EAEC;AAED,gFAEC;AA5GY,QAAA,mBAAmB,GAAG,cAAc,CAAA;AAiFjD,IA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E,CAAC,MAAM,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,QAAQ,CAAA;AACzD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HasherSync } from '../types';
2
+ export declare const shaHasher: HasherSync;
3
+ export declare const defaultHasher: HasherSync;
4
+ //# sourceMappingURL=hasher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../../src/utils/hasher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAKrC,eAAO,MAAM,SAAS,EAAE,UAOvB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,UAAsB,CAAA"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.defaultHasher = exports.shaHasher = void 0;
27
+ const sha2_1 = require("@noble/hashes/sha2");
28
+ const u8a = __importStar(require("uint8arrays"));
29
+ const supportedAlgorithms = ['sha256', 'sha384', 'sha512'];
30
+ const shaHasher = (data, algorithm) => {
31
+ const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');
32
+ if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
33
+ throw new Error(`Unsupported hashing algorithm ${algorithm}`);
34
+ }
35
+ const hasher = sanitizedAlgorithm === 'sha384' ? sha2_1.sha384 : sanitizedAlgorithm === 'sha512' ? sha2_1.sha512 : sha2_1.sha256;
36
+ return hasher(typeof data === 'string' ? u8a.fromString(data) : new Uint8Array(data));
37
+ };
38
+ exports.shaHasher = shaHasher;
39
+ exports.defaultHasher = exports.shaHasher;
40
+ //# sourceMappingURL=hasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasher.js","sourceRoot":"","sources":["../../src/utils/hasher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2D;AAC3D,iDAAkC;AAGlC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAG5D,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;IACvD,MAAM,kBAAkB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACvE,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,kBAAyC,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAA;IAC/D,CAAC;IACD,MAAM,MAAM,GAAG,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAM,CAAC,CAAC,CAAC,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAM,CAAC,CAAC,CAAC,aAAM,CAAA;IAC3G,OAAO,MAAM,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;AACvF,CAAC,CAAA;AAPY,QAAA,SAAS,aAOrB;AAEY,QAAA,aAAa,GAAe,iBAAS,CAAA"}
@@ -1,2 +1,3 @@
1
1
  export * from './object';
2
+ export * from './hasher';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA"}
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./object"), exports);
18
+ __exportStar(require("./hasher"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,2CAAwB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-types",
3
3
  "description": "SSI Common Types",
4
- "version": "0.32.1-next.54+3b988a2b",
4
+ "version": "0.33.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -9,7 +9,8 @@
9
9
  "build:clean": "tsc --build --clean && tsc --build"
10
10
  },
11
11
  "dependencies": {
12
- "@sd-jwt/decode": "^0.7.2",
12
+ "@noble/hashes": "1.6.1",
13
+ "@sd-jwt/decode": "^0.9.2",
13
14
  "@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
14
15
  "debug": "^4.3.5",
15
16
  "events": "^3.3.0",
@@ -47,5 +48,5 @@
47
48
  "DIDs"
48
49
  ],
49
50
  "nx": {},
50
- "gitHead": "3b988a2bb62a7c4534a2670ea3a0985fd93d00f2"
51
+ "gitHead": "c575bdd6642bda761881f0152e0a70ddc82d7f61"
51
52
  }
@@ -1,12 +1,13 @@
1
1
  import { IssuerType } from '@veramo/core'
2
2
  import {
3
- AsyncHasher,
4
3
  decodeMdocDeviceResponse,
5
4
  decodeMdocIssuerSigned,
6
5
  decodeSdJwtVc,
7
6
  decodeSdJwtVcAsync,
8
7
  DocumentFormat,
8
+ getMdocDecodedPayload,
9
9
  Hasher,
10
+ HasherSync,
10
11
  ICredential,
11
12
  IPresentation,
12
13
  IProof,
@@ -24,6 +25,7 @@ import {
24
25
  JwtDecodedVerifiablePresentation,
25
26
  mdocDecodedCredentialToUniformCredential,
26
27
  MdocDeviceResponse,
28
+ MdocDocument,
27
29
  MdocOid4vpMdocVpToken,
28
30
  OriginalType,
29
31
  OriginalVerifiableCredential,
@@ -40,19 +42,22 @@ import {
40
42
  WrappedVerifiablePresentation,
41
43
  WrappedW3CVerifiableCredential,
42
44
  } from '../types'
43
- import { getMdocDecodedPayload, MdocDocument } from '../types/mso_mdoc'
44
- import { ObjectUtils } from '../utils'
45
+ import { defaultHasher, ObjectUtils } from '../utils'
45
46
  import { com } from '@sphereon/kmp-mdoc-core'
46
- import DeviceResponseCbor = com.sphereon.mdoc.data.device.DeviceResponseCbor
47
47
  import { jwtDecode } from 'jwt-decode'
48
+ import DeviceResponseCbor = com.sphereon.mdoc.data.device.DeviceResponseCbor
49
+
50
+ export const sha256 = (data: string | ArrayBuffer): Uint8Array => {
51
+ return defaultHasher(data, 'sha256')
52
+ }
48
53
 
49
54
  export class CredentialMapper {
50
55
  /**
51
56
  * Decodes a compact SD-JWT vc to it's decoded variant. This method can be used when the hasher implementation used is Async, and therefore not suitable for usage
52
57
  * with the other decode methods.
53
58
  */
54
- static decodeSdJwtVcAsync(compactSdJwtVc: string, hasher: AsyncHasher) {
55
- return decodeSdJwtVcAsync(compactSdJwtVc, hasher)
59
+ static decodeSdJwtVcAsync(compactSdJwtVc: string, hasher: Hasher) {
60
+ return decodeSdJwtVcAsync(compactSdJwtVc, hasher ?? sha256)
56
61
  }
57
62
 
58
63
  /**
@@ -62,11 +67,12 @@ export class CredentialMapper {
62
67
  * an async hasher implementation, use the decodeSdJwtVcAsync method instead and you can provide the decoded payload to methods
63
68
  * instead of the compact SD-JWT.
64
69
  *
70
+ * @param presentation
65
71
  * @param hasher Hasher implementation to use for SD-JWT decoding.
66
72
  */
67
73
  static decodeVerifiablePresentation(
68
74
  presentation: OriginalVerifiablePresentation,
69
- hasher?: Hasher
75
+ hasher?: HasherSync,
70
76
  ): JwtDecodedVerifiablePresentation | IVerifiablePresentation | SdJwtDecodedVerifiableCredential | MdocOid4vpMdocVpToken | MdocDeviceResponse {
71
77
  if (CredentialMapper.isJwtEncoded(presentation)) {
72
78
  const payload = jwtDecode(presentation as string) as JwtDecodedVerifiablePresentation
@@ -83,10 +89,7 @@ export class CredentialMapper {
83
89
  } else if (CredentialMapper.isJwtDecodedPresentation(presentation)) {
84
90
  return presentation as JwtDecodedVerifiablePresentation
85
91
  } else if (CredentialMapper.isSdJwtEncoded(presentation)) {
86
- if (!hasher) {
87
- throw new Error('Hasher implementation is required to decode SD-JWT')
88
- }
89
- return decodeSdJwtVc(presentation, hasher)
92
+ return decodeSdJwtVc(presentation, hasher ?? sha256)
90
93
  } else if (CredentialMapper.isSdJwtDecodedCredential(presentation)) {
91
94
  return presentation as SdJwtDecodedVerifiableCredential
92
95
  } else if (CredentialMapper.isMsoMdocOid4VPEncoded(presentation)) {
@@ -111,7 +114,7 @@ export class CredentialMapper {
111
114
  */
112
115
  static decodeVerifiableCredential(
113
116
  credential: OriginalVerifiableCredential,
114
- hasher?: Hasher
117
+ hasher?: HasherSync,
115
118
  ): JwtDecodedVerifiableCredential | IVerifiableCredential | SdJwtDecodedVerifiableCredential {
116
119
  if (CredentialMapper.isJwtEncoded(credential)) {
117
120
  const payload = jwtDecode(credential as string) as JwtDecodedVerifiableCredential
@@ -129,10 +132,7 @@ export class CredentialMapper {
129
132
  } else if (CredentialMapper.isJsonLdAsString(credential)) {
130
133
  return JSON.parse(credential as string) as IVerifiableCredential
131
134
  } else if (CredentialMapper.isSdJwtEncoded(credential)) {
132
- if (!hasher) {
133
- throw new Error('Hasher implementation is required to decode SD-JWT')
134
- }
135
- return decodeSdJwtVc(credential, hasher)
135
+ return decodeSdJwtVc(credential, hasher ?? sha256)
136
136
  } else if (CredentialMapper.isSdJwtDecodedCredential(credential)) {
137
137
  return credential
138
138
  } else {
@@ -151,7 +151,7 @@ export class CredentialMapper {
151
151
  */
152
152
  static toWrappedVerifiablePresentation(
153
153
  originalPresentation: OriginalVerifiablePresentation,
154
- opts?: { maxTimeSkewInMS?: number; hasher?: Hasher }
154
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
155
155
  ): WrappedVerifiablePresentation {
156
156
  // MSO_MDOC
157
157
  if (CredentialMapper.isMsoMdocDecodedPresentation(originalPresentation) || CredentialMapper.isMsoMdocOid4VPEncoded(originalPresentation)) {
@@ -166,7 +166,7 @@ export class CredentialMapper {
166
166
  }
167
167
 
168
168
  const mdocCredentials = deviceResponse.documents?.map(
169
- (doc) => CredentialMapper.toWrappedVerifiableCredential(doc, opts) as WrappedMdocCredential
169
+ (doc) => CredentialMapper.toWrappedVerifiableCredential(doc, opts) as WrappedMdocCredential,
170
170
  )
171
171
  if (!mdocCredentials || mdocCredentials.length === 0) {
172
172
  throw new Error('could not extract any mdoc credentials from mdoc device response')
@@ -185,10 +185,7 @@ export class CredentialMapper {
185
185
  if (CredentialMapper.isSdJwtDecodedCredential(originalPresentation) || CredentialMapper.isSdJwtEncoded(originalPresentation)) {
186
186
  let decodedPresentation: SdJwtDecodedVerifiableCredential
187
187
  if (CredentialMapper.isSdJwtEncoded(originalPresentation)) {
188
- if (!opts?.hasher) {
189
- throw new Error('Hasher implementation is required to decode SD-JWT')
190
- }
191
- decodedPresentation = decodeSdJwtVc(originalPresentation, opts.hasher)
188
+ decodedPresentation = decodeSdJwtVc(originalPresentation, opts?.hasher ?? sha256)
192
189
  } else {
193
190
  decodedPresentation = originalPresentation
194
191
  }
@@ -209,7 +206,7 @@ export class CredentialMapper {
209
206
  typeof originalPresentation !== 'string' && CredentialMapper.hasJWTProofType(originalPresentation) ? proof?.jwt : originalPresentation
210
207
  if (!original) {
211
208
  throw Error(
212
- 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof'
209
+ 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof',
213
210
  )
214
211
  }
215
212
  const decoded = CredentialMapper.decodeVerifiablePresentation(original) as IVerifiablePresentation | JwtDecodedVerifiablePresentation
@@ -237,7 +234,7 @@ export class CredentialMapper {
237
234
  ? []
238
235
  : (CredentialMapper.toWrappedVerifiableCredentials(
239
236
  vp.verifiableCredential ?? [] /*.map(value => value.original)*/,
240
- opts
237
+ opts,
241
238
  ) as WrappedW3CVerifiableCredential[])
242
239
 
243
240
  const presentation = {
@@ -265,7 +262,7 @@ export class CredentialMapper {
265
262
  */
266
263
  static toWrappedVerifiableCredentials(
267
264
  verifiableCredentials: OriginalVerifiableCredential[],
268
- opts?: { maxTimeSkewInMS?: number; hasher?: Hasher }
265
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
269
266
  ): WrappedVerifiableCredential[] {
270
267
  return verifiableCredentials.map((vc) => CredentialMapper.toWrappedVerifiableCredential(vc, opts))
271
268
  }
@@ -281,7 +278,7 @@ export class CredentialMapper {
281
278
  */
282
279
  static toWrappedVerifiableCredential(
283
280
  verifiableCredential: OriginalVerifiableCredential,
284
- opts?: { maxTimeSkewInMS?: number; hasher?: Hasher }
281
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
285
282
  ): WrappedVerifiableCredential {
286
283
  // MSO_MDOC
287
284
  if (CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) || CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
@@ -304,10 +301,8 @@ export class CredentialMapper {
304
301
  if (CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) || CredentialMapper.isSdJwtEncoded(verifiableCredential)) {
305
302
  let decodedCredential: SdJwtDecodedVerifiableCredential
306
303
  if (CredentialMapper.isSdJwtEncoded(verifiableCredential)) {
307
- if (!opts?.hasher) {
308
- throw new Error('Hasher implementation is required to decode SD-JWT')
309
- }
310
- decodedCredential = decodeSdJwtVc(verifiableCredential, opts.hasher)
304
+ const hasher = opts?.hasher ?? sha256
305
+ decodedCredential = decodeSdJwtVc(verifiableCredential, hasher)
311
306
  } else {
312
307
  decodedCredential = verifiableCredential
313
308
  }
@@ -323,10 +318,10 @@ export class CredentialMapper {
323
318
 
324
319
  // If the VC is not an encoded/decoded SD-JWT, we assume it will be a W3C VC
325
320
  const proof = CredentialMapper.getFirstProof(verifiableCredential)
326
- const original = CredentialMapper.hasJWTProofType(verifiableCredential) && proof ? proof.jwt ?? verifiableCredential : verifiableCredential
321
+ const original = CredentialMapper.hasJWTProofType(verifiableCredential) && proof ? (proof.jwt ?? verifiableCredential) : verifiableCredential
327
322
  if (!original) {
328
323
  throw Error(
329
- 'Could not determine original credential, probably it was a converted JWT credential, that is now missing the JWT value in the proof'
324
+ 'Could not determine original credential, probably it was a converted JWT credential, that is now missing the JWT value in the proof',
330
325
  )
331
326
  }
332
327
  const decoded = CredentialMapper.decodeVerifiableCredential(original) as JwtDecodedVerifiableCredential | IVerifiableCredential
@@ -442,7 +437,7 @@ export class CredentialMapper {
442
437
  }
443
438
 
444
439
  public static isW3cPresentation(
445
- presentation: UniformVerifiablePresentation | IPresentation | SdJwtDecodedVerifiableCredential | DeviceResponseCbor
440
+ presentation: UniformVerifiablePresentation | IPresentation | SdJwtDecodedVerifiableCredential | DeviceResponseCbor,
446
441
  ): presentation is IPresentation {
447
442
  return (
448
443
  typeof presentation === 'object' &&
@@ -452,7 +447,7 @@ export class CredentialMapper {
452
447
  }
453
448
 
454
449
  public static isSdJwtDecodedCredentialPayload(
455
- credential: ICredential | SdJwtDecodedVerifiableCredentialPayload
450
+ credential: ICredential | SdJwtDecodedVerifiableCredentialPayload,
456
451
  ): credential is SdJwtDecodedVerifiableCredentialPayload {
457
452
  return typeof credential === 'object' && 'vct' in credential
458
453
  }
@@ -484,7 +479,7 @@ export class CredentialMapper {
484
479
  }
485
480
 
486
481
  public static isSdJwtDecodedCredential(
487
- original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation
482
+ original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation,
488
483
  ): original is SdJwtDecodedVerifiableCredential {
489
484
  return (
490
485
  typeof original === 'object' &&
@@ -493,7 +488,7 @@ export class CredentialMapper {
493
488
  }
494
489
 
495
490
  public static isMsoMdocDecodedCredential(
496
- original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation
491
+ original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation,
497
492
  ): original is MdocDocument {
498
493
  return typeof original === 'object' && 'issuerSigned' in original && (<MdocDocument>original).issuerSigned !== undefined
499
494
  }
@@ -528,7 +523,7 @@ export class CredentialMapper {
528
523
  static jwtEncodedPresentationToUniformPresentation(
529
524
  jwt: string,
530
525
  makeCredentialsUniform: boolean = true,
531
- opts?: { maxTimeSkewInMS?: number }
526
+ opts?: { maxTimeSkewInMS?: number },
532
527
  ): IPresentation {
533
528
  return CredentialMapper.jwtDecodedPresentationToUniformPresentation(jwtDecode(jwt), makeCredentialsUniform, opts)
534
529
  }
@@ -536,7 +531,7 @@ export class CredentialMapper {
536
531
  static jwtDecodedPresentationToUniformPresentation(
537
532
  decoded: JwtDecodedVerifiablePresentation,
538
533
  makeCredentialsUniform: boolean = true,
539
- opts?: { maxTimeSkewInMS?: number }
534
+ opts?: { maxTimeSkewInMS?: number },
540
535
  ): IVerifiablePresentation {
541
536
  const { iss, aud, jti, vp, ...rest } = decoded
542
537
 
@@ -582,8 +577,8 @@ export class CredentialMapper {
582
577
  verifiableCredential: OriginalVerifiableCredential,
583
578
  opts?: {
584
579
  maxTimeSkewInMS?: number
585
- hasher?: Hasher
586
- }
580
+ hasher?: HasherSync
581
+ },
587
582
  ): IVerifiableCredential {
588
583
  if (CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential)) {
589
584
  return mdocDecodedCredentialToUniformCredential(verifiableCredential)
@@ -597,10 +592,10 @@ export class CredentialMapper {
597
592
  : verifiableCredential
598
593
  if (!original) {
599
594
  throw Error(
600
- 'Could not determine original credential from passed in credential. Probably because a JWT proof type was present, but now is not available anymore'
595
+ 'Could not determine original credential from passed in credential. Probably because a JWT proof type was present, but now is not available anymore',
601
596
  )
602
597
  }
603
- const decoded = CredentialMapper.decodeVerifiableCredential(original, opts?.hasher)
598
+ const decoded = CredentialMapper.decodeVerifiableCredential(original, opts?.hasher ?? sha256)
604
599
 
605
600
  const isJwtEncoded: boolean = CredentialMapper.isJwtEncoded(original)
606
601
  const isJwtDecoded: boolean = CredentialMapper.isJwtDecodedCredential(original)
@@ -620,7 +615,7 @@ export class CredentialMapper {
620
615
 
621
616
  static toUniformPresentation(
622
617
  presentation: OriginalVerifiablePresentation,
623
- opts?: { maxTimeSkewInMS?: number; addContextIfMissing?: boolean; hasher?: Hasher }
618
+ opts?: { maxTimeSkewInMS?: number; addContextIfMissing?: boolean; hasher?: HasherSync },
624
619
  ): IVerifiablePresentation {
625
620
  if (CredentialMapper.isSdJwtDecodedCredential(presentation)) {
626
621
  throw new Error('Converting SD-JWT VC to uniform VP is not supported.')
@@ -632,10 +627,10 @@ export class CredentialMapper {
632
627
  const original = typeof presentation !== 'string' && CredentialMapper.hasJWTProofType(presentation) ? proof?.jwt : presentation
633
628
  if (!original) {
634
629
  throw Error(
635
- 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof'
630
+ 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof',
636
631
  )
637
632
  }
638
- const decoded = CredentialMapper.decodeVerifiablePresentation(original, opts?.hasher)
633
+ const decoded = CredentialMapper.decodeVerifiablePresentation(original, opts?.hasher ?? sha256)
639
634
  const isJwtEncoded: boolean = CredentialMapper.isJwtEncoded(original)
640
635
  const isJwtDecoded: boolean = CredentialMapper.isJwtDecodedPresentation(original)
641
636
  const uniformPresentation =
@@ -649,7 +644,7 @@ export class CredentialMapper {
649
644
  }
650
645
 
651
646
  uniformPresentation.verifiableCredential = uniformPresentation.verifiableCredential?.map((vc) =>
652
- CredentialMapper.toUniformCredential(vc, opts)
647
+ CredentialMapper.toUniformCredential(vc, opts),
653
648
  ) as IVerifiableCredential[] // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended)
654
649
  return uniformPresentation
655
650
  }
@@ -658,14 +653,14 @@ export class CredentialMapper {
658
653
  jwt: string,
659
654
  opts?: {
660
655
  maxTimeSkewInMS?: number
661
- }
656
+ },
662
657
  ): IVerifiableCredential {
663
658
  return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwtDecode(jwt), opts)
664
659
  }
665
660
 
666
661
  static jwtDecodedCredentialToUniformCredential(
667
662
  decoded: JwtDecodedVerifiableCredential,
668
- opts?: { maxTimeSkewInMS?: number }
663
+ opts?: { maxTimeSkewInMS?: number },
669
664
  ): IVerifiableCredential {
670
665
  const { exp, nbf, iss, vc, sub, jti, ...rest } = decoded
671
666
  const credential: IVerifiableCredential = {
@@ -833,7 +828,7 @@ export class CredentialMapper {
833
828
  }
834
829
 
835
830
  static toCompactJWT(
836
- jwtDocument: W3CVerifiableCredential | JwtDecodedVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | string
831
+ jwtDocument: W3CVerifiableCredential | JwtDecodedVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | string,
837
832
  ): string {
838
833
  if (!jwtDocument || CredentialMapper.detectDocumentType(jwtDocument) !== DocumentFormat.JWT) {
839
834
  throw Error('Cannot convert non JWT credential to JWT')
@@ -863,7 +858,7 @@ export class CredentialMapper {
863
858
  | JwtDecodedVerifiablePresentation
864
859
  | SdJwtDecodedVerifiableCredential
865
860
  | MdocDeviceResponse
866
- | MdocDocument
861
+ | MdocDocument,
867
862
  ): DocumentFormat {
868
863
  if (this.isMsoMdocOid4VPEncoded(document as any) || this.isMsoMdocDecodedCredential(document as any)) {
869
864
  return DocumentFormat.MSO_MDOC
@@ -891,7 +886,7 @@ export class CredentialMapper {
891
886
  }
892
887
 
893
888
  private static hasJWTProofType(
894
- document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation
889
+ document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation,
895
890
  ): boolean {
896
891
  if (typeof document === 'string') {
897
892
  return false
@@ -900,7 +895,7 @@ export class CredentialMapper {
900
895
  }
901
896
 
902
897
  private static getFirstProof(
903
- document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation
898
+ document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation,
904
899
  ): IProof | undefined {
905
900
  if (!document || typeof document === 'string') {
906
901
  return undefined
@@ -0,0 +1,39 @@
1
+ // FIXME Temporary minimal DCQL schema for PD manager, the DcqlQuery used by Animo does not serialize properly (over REST / Veramo)
2
+
3
+ export interface DcqlQueryREST {
4
+ credentials: DcqlCredentialQuery[]
5
+ }
6
+
7
+ export interface DcqlCredentialQuery {
8
+ id: string
9
+ format: string
10
+ alg?: string[]
11
+ claims: DcqlClaim[]
12
+ meta?: Record<string, any>
13
+ }
14
+
15
+ export interface DcqlClaim {
16
+ namespace: string
17
+ claim_name: string
18
+ filter?: DcqlFilter
19
+ }
20
+
21
+ export interface DcqlFilter {
22
+ type: 'string' | 'number' | 'boolean'
23
+ pattern?: string
24
+ minimum?: number
25
+ maximum?: number
26
+ }
27
+
28
+ export interface DcqlPresentationResult {
29
+ canBeSatisfied: boolean
30
+ credential_matches: Record<string, DcqlCredentialMatch>
31
+ invalid_matches?: Record<string, DcqlCredentialMatch>
32
+ }
33
+
34
+ export interface DcqlCredentialMatch {
35
+ success: boolean
36
+ input_credential_index: number
37
+ claim_set_index?: number
38
+ output: any
39
+ }
@@ -6,6 +6,11 @@
6
6
  export type OrPromise<T> = T | Promise<T>
7
7
  export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
8
8
 
9
+ export type RequireOneOf<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
10
+ {
11
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>
12
+ }[Keys]
13
+
9
14
  export type BearerTokenArg = (() => Promise<string>) | string
10
15
 
11
16
  /**
@@ -9,3 +9,5 @@ export * from './jose'
9
9
  export * from './cose'
10
10
  export * from './mso_mdoc'
11
11
  export * from './metadata-types'
12
+ export * from './status-list'
13
+ export * from './dcql'
@@ -108,7 +108,7 @@ export function getMdocDecodedPayload(mdoc: MdocDocument): MdocDecodedPayload {
108
108
  ...acc,
109
109
  [item.key]: item.value.value,
110
110
  }),
111
- {}
111
+ {},
112
112
  )
113
113
  }
114
114
 
@@ -146,7 +146,7 @@ export function decodeMdocDeviceResponse(vpToken: MdocOid4vpMdocVpToken): MdocDe
146
146
  export const mdocDecodedCredentialToUniformCredential = (
147
147
  decoded: MdocDocument,
148
148
  // @ts-ignore
149
- opts?: { maxTimeSkewInMS?: number }
149
+ opts?: { maxTimeSkewInMS?: number },
150
150
  ): IVerifiableCredential => {
151
151
  const mdoc = decoded.toJson()
152
152
  const json = mdoc.toJsonDTO<DocumentJson>()
@@ -2,6 +2,7 @@ import { OriginalType, WrappedVerifiableCredential, WrappedVerifiablePresentatio
2
2
  import { decodeSdJwt, decodeSdJwtSync, getClaims, getClaimsSync } from '@sd-jwt/decode'
3
3
  import { CompactJWT, IVerifiableCredential } from './w3c-vc'
4
4
  import { IProofPurpose, IProofType } from './did'
5
+ import { OrPromise } from './generic'
5
6
 
6
7
  type JsonValue = string | number | boolean | { [x: string]: JsonValue | undefined } | Array<JsonValue>
7
8
 
@@ -167,6 +168,9 @@ export interface WrappedSdJwtVerifiableCredential {
167
168
  credential: SdJwtDecodedVerifiableCredential
168
169
  }
169
170
 
171
+ export type HasherSync = (data: string | ArrayBuffer, alg: string) => Uint8Array
172
+ export type Hasher = (data: string | ArrayBuffer, alg: string) => OrPromise<Uint8Array>
173
+
170
174
  export interface WrappedSdJwtVerifiablePresentation {
171
175
  /**
172
176
  * Original VP that we've received. Can be either the encoded or decoded variant.
@@ -203,9 +207,6 @@ export function isWrappedSdJwtVerifiablePresentation(vp: WrappedVerifiablePresen
203
207
  return vp.format === 'vc+sd-jwt'
204
208
  }
205
209
 
206
- export type Hasher = (data: string, alg: string) => Uint8Array
207
- export type AsyncHasher = (data: string, alg: string) => Promise<Uint8Array>
208
-
209
210
  /**
210
211
  * Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
211
212
  * signed payload, decoded payload and the compact SD-JWT vc.
@@ -213,7 +214,7 @@ export type AsyncHasher = (data: string, alg: string) => Promise<Uint8Array>
213
214
  * Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
214
215
  * this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
215
216
  */
216
- export function decodeSdJwtVc(compactSdJwtVc: CompactSdJwtVc, hasher: Hasher): SdJwtDecodedVerifiableCredential {
217
+ export function decodeSdJwtVc(compactSdJwtVc: CompactSdJwtVc, hasher: HasherSync): SdJwtDecodedVerifiableCredential {
217
218
  const { jwt, disclosures, kbJwt } = decodeSdJwtSync(compactSdJwtVc, hasher)
218
219
 
219
220
  const signedPayload = jwt.payload as SdJwtSignedVerifiableCredentialPayload
@@ -251,7 +252,7 @@ export function decodeSdJwtVc(compactSdJwtVc: CompactSdJwtVc, hasher: Hasher): S
251
252
  * Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
252
253
  * this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
253
254
  */
254
- export async function decodeSdJwtVcAsync(compactSdJwtVc: CompactSdJwtVc, hasher: AsyncHasher): Promise<SdJwtDecodedVerifiableCredential> {
255
+ export async function decodeSdJwtVcAsync(compactSdJwtVc: CompactSdJwtVc, hasher: Hasher): Promise<SdJwtDecodedVerifiableCredential> {
255
256
  const { jwt, disclosures, kbJwt } = await decodeSdJwt(compactSdJwtVc, hasher)
256
257
 
257
258
  const signedPayload = jwt.payload as SdJwtSignedVerifiableCredentialPayload
@@ -0,0 +1,12 @@
1
+ import { W3CVerifiableCredential } from './w3c-vc'
2
+ import { ProofFormat as VeramoProofFormat } from '@veramo/core'
3
+
4
+ export enum StatusListType {
5
+ StatusList2021 = 'StatusList2021',
6
+ OAuthStatusList = 'OAuthStatusList',
7
+ }
8
+ export type CWT = string
9
+
10
+ export type StatusListCredential = W3CVerifiableCredential | CWT
11
+
12
+ export type ProofFormat = VeramoProofFormat | 'cbor'