@sphereon/ssi-types 0.34.0 → 0.34.1-feat.SSISDK.35.59

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-types",
3
3
  "description": "SSI Common Types",
4
- "version": "0.34.0",
4
+ "version": "0.34.1-feat.SSISDK.35.59+3d9323d6",
5
5
  "source": "./src/index.ts",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -57,5 +57,5 @@
57
57
  "Verifiable Credentials",
58
58
  "DIDs"
59
59
  ],
60
- "gitHead": "b1c9c5e91a9ce4bc677ff2cce5f2d520a16b366d"
60
+ "gitHead": "3d9323d6265fa9d65b34d0e2b39d0df975d0674e"
61
61
  }
@@ -73,7 +73,7 @@ export class CredentialMapper {
73
73
  */
74
74
  static decodeVerifiablePresentation(
75
75
  presentation: OriginalVerifiablePresentation,
76
- hasher?: HasherSync,
76
+ hasher?: HasherSync
77
77
  ): JwtDecodedVerifiablePresentation | IVerifiablePresentation | SdJwtDecodedVerifiableCredential | MdocOid4vpMdocVpToken | MdocDeviceResponse {
78
78
  if (CredentialMapper.isJwtEncoded(presentation)) {
79
79
  const payload = jwtDecode(presentation as string) as JwtDecodedVerifiablePresentation
@@ -115,7 +115,7 @@ export class CredentialMapper {
115
115
  */
116
116
  static decodeVerifiableCredential(
117
117
  credential: OriginalVerifiableCredential,
118
- hasher?: HasherSync,
118
+ hasher?: HasherSync
119
119
  ): JwtDecodedVerifiableCredential | IVerifiableCredential | SdJwtDecodedVerifiableCredential {
120
120
  if (CredentialMapper.isJwtEncoded(credential)) {
121
121
  const payload = jwtDecode(credential as string) as JwtDecodedVerifiableCredential
@@ -153,7 +153,7 @@ export class CredentialMapper {
153
153
  */
154
154
  static toWrappedVerifiablePresentation(
155
155
  originalPresentation: OriginalVerifiablePresentation,
156
- opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
156
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync }
157
157
  ): WrappedVerifiablePresentation {
158
158
  // MSO_MDOC
159
159
  if (CredentialMapper.isMsoMdocDecodedPresentation(originalPresentation) || CredentialMapper.isMsoMdocOid4VPEncoded(originalPresentation)) {
@@ -168,7 +168,7 @@ export class CredentialMapper {
168
168
  }
169
169
 
170
170
  const mdocCredentials = deviceResponse.documents?.map(
171
- (doc) => CredentialMapper.toWrappedVerifiableCredential(doc, opts) as WrappedMdocCredential,
171
+ (doc) => CredentialMapper.toWrappedVerifiableCredential(doc, opts) as WrappedMdocCredential
172
172
  )
173
173
  if (!mdocCredentials || mdocCredentials.length === 0) {
174
174
  throw new Error('could not extract any mdoc credentials from mdoc device response')
@@ -193,7 +193,7 @@ export class CredentialMapper {
193
193
  }
194
194
  return {
195
195
  type: CredentialMapper.isSdJwtDecodedCredential(originalPresentation) ? OriginalType.SD_JWT_VC_DECODED : OriginalType.SD_JWT_VC_ENCODED,
196
- format: 'vc+sd-jwt',
196
+ format: 'dc+sd-jwt',
197
197
  original: originalPresentation,
198
198
  presentation: decodedPresentation,
199
199
  decoded: decodedPresentation.decodedPayload,
@@ -208,7 +208,7 @@ export class CredentialMapper {
208
208
  typeof originalPresentation !== 'string' && CredentialMapper.hasJWTProofType(originalPresentation) ? proof?.jwt : originalPresentation
209
209
  if (!original) {
210
210
  throw Error(
211
- 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof',
211
+ 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof'
212
212
  )
213
213
  }
214
214
  const decoded = CredentialMapper.decodeVerifiablePresentation(original) as IVerifiablePresentation | JwtDecodedVerifiablePresentation
@@ -236,7 +236,7 @@ export class CredentialMapper {
236
236
  ? []
237
237
  : (CredentialMapper.toWrappedVerifiableCredentials(
238
238
  vp.verifiableCredential ?? [] /*.map(value => value.original)*/,
239
- opts,
239
+ opts
240
240
  ) as WrappedW3CVerifiableCredential[])
241
241
 
242
242
  const presentation = {
@@ -264,7 +264,7 @@ export class CredentialMapper {
264
264
  */
265
265
  static toWrappedVerifiableCredentials(
266
266
  verifiableCredentials: OriginalVerifiableCredential[],
267
- opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
267
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync }
268
268
  ): WrappedVerifiableCredential[] {
269
269
  return verifiableCredentials.map((vc) => CredentialMapper.toWrappedVerifiableCredential(vc, opts))
270
270
  }
@@ -280,7 +280,7 @@ export class CredentialMapper {
280
280
  */
281
281
  static toWrappedVerifiableCredential(
282
282
  verifiableCredential: OriginalVerifiableCredential,
283
- opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync },
283
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync }
284
284
  ): WrappedVerifiableCredential {
285
285
  // MSO_MDOC
286
286
  if (CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) || CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
@@ -311,7 +311,7 @@ export class CredentialMapper {
311
311
 
312
312
  return {
313
313
  type: CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) ? OriginalType.SD_JWT_VC_DECODED : OriginalType.SD_JWT_VC_ENCODED,
314
- format: 'vc+sd-jwt',
314
+ format: 'dc+sd-jwt',
315
315
  original: verifiableCredential,
316
316
  credential: decodedCredential,
317
317
  decoded: decodedCredential.decodedPayload,
@@ -320,10 +320,10 @@ export class CredentialMapper {
320
320
 
321
321
  // If the VC is not an encoded/decoded SD-JWT, we assume it will be a W3C VC
322
322
  const proof = CredentialMapper.getFirstProof(verifiableCredential)
323
- const original = CredentialMapper.hasJWTProofType(verifiableCredential) && proof ? (proof.jwt ?? verifiableCredential) : verifiableCredential
323
+ const original = CredentialMapper.hasJWTProofType(verifiableCredential) && proof ? proof.jwt ?? verifiableCredential : verifiableCredential
324
324
  if (!original) {
325
325
  throw Error(
326
- 'Could not determine original credential, probably it was a converted JWT credential, that is now missing the JWT value in the proof',
326
+ 'Could not determine original credential, probably it was a converted JWT credential, that is now missing the JWT value in the proof'
327
327
  )
328
328
  }
329
329
  const decoded = CredentialMapper.decodeVerifiableCredential(original) as JwtDecodedVerifiableCredential | IVerifiableCredential
@@ -439,7 +439,7 @@ export class CredentialMapper {
439
439
  }
440
440
 
441
441
  public static isW3cPresentation(
442
- presentation: UniformVerifiablePresentation | IPresentation | SdJwtDecodedVerifiableCredential | DeviceResponseCbor,
442
+ presentation: UniformVerifiablePresentation | IPresentation | SdJwtDecodedVerifiableCredential | DeviceResponseCbor
443
443
  ): presentation is IPresentation {
444
444
  return (
445
445
  typeof presentation === 'object' &&
@@ -449,7 +449,7 @@ export class CredentialMapper {
449
449
  }
450
450
 
451
451
  public static isSdJwtDecodedCredentialPayload(
452
- credential: ICredential | SdJwtDecodedVerifiableCredentialPayload,
452
+ credential: ICredential | SdJwtDecodedVerifiableCredentialPayload
453
453
  ): credential is SdJwtDecodedVerifiableCredentialPayload {
454
454
  return typeof credential === 'object' && 'vct' in credential
455
455
  }
@@ -481,7 +481,7 @@ export class CredentialMapper {
481
481
  }
482
482
 
483
483
  public static isSdJwtDecodedCredential(
484
- original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation,
484
+ original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation
485
485
  ): original is SdJwtDecodedVerifiableCredential {
486
486
  return (
487
487
  typeof original === 'object' &&
@@ -490,7 +490,7 @@ export class CredentialMapper {
490
490
  }
491
491
 
492
492
  public static isMsoMdocDecodedCredential(
493
- original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation,
493
+ original: OriginalVerifiableCredential | OriginalVerifiablePresentation | ICredential | IPresentation
494
494
  ): original is MdocDocument {
495
495
  return typeof original === 'object' && 'issuerSigned' in original && (<MdocDocument>original).issuerSigned !== undefined
496
496
  }
@@ -525,7 +525,7 @@ export class CredentialMapper {
525
525
  static jwtEncodedPresentationToUniformPresentation(
526
526
  jwt: string,
527
527
  makeCredentialsUniform: boolean = true,
528
- opts?: { maxTimeSkewInMS?: number },
528
+ opts?: { maxTimeSkewInMS?: number }
529
529
  ): IPresentation {
530
530
  return CredentialMapper.jwtDecodedPresentationToUniformPresentation(jwtDecode(jwt), makeCredentialsUniform, opts)
531
531
  }
@@ -533,7 +533,7 @@ export class CredentialMapper {
533
533
  static jwtDecodedPresentationToUniformPresentation(
534
534
  decoded: JwtDecodedVerifiablePresentation,
535
535
  makeCredentialsUniform: boolean = true,
536
- opts?: { maxTimeSkewInMS?: number },
536
+ opts?: { maxTimeSkewInMS?: number }
537
537
  ): IVerifiablePresentation {
538
538
  const { iss, aud, jti, vp, ...rest } = decoded
539
539
 
@@ -580,7 +580,7 @@ export class CredentialMapper {
580
580
  opts?: {
581
581
  maxTimeSkewInMS?: number
582
582
  hasher?: HasherSync
583
- },
583
+ }
584
584
  ): IVerifiableCredential {
585
585
  if (CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential)) {
586
586
  return mdocDecodedCredentialToUniformCredential(verifiableCredential)
@@ -594,7 +594,7 @@ export class CredentialMapper {
594
594
  : verifiableCredential
595
595
  if (!original) {
596
596
  throw Error(
597
- 'Could not determine original credential from passed in credential. Probably because a JWT proof type was present, but now is not available anymore',
597
+ 'Could not determine original credential from passed in credential. Probably because a JWT proof type was present, but now is not available anymore'
598
598
  )
599
599
  }
600
600
  const decoded = CredentialMapper.decodeVerifiableCredential(original, opts?.hasher ?? sha256)
@@ -617,7 +617,7 @@ export class CredentialMapper {
617
617
 
618
618
  static toUniformPresentation(
619
619
  presentation: OriginalVerifiablePresentation,
620
- opts?: { maxTimeSkewInMS?: number; addContextIfMissing?: boolean; hasher?: HasherSync },
620
+ opts?: { maxTimeSkewInMS?: number; addContextIfMissing?: boolean; hasher?: HasherSync }
621
621
  ): IVerifiablePresentation {
622
622
  if (CredentialMapper.isSdJwtDecodedCredential(presentation)) {
623
623
  throw new Error('Converting SD-JWT VC to uniform VP is not supported.')
@@ -629,7 +629,7 @@ export class CredentialMapper {
629
629
  const original = typeof presentation !== 'string' && CredentialMapper.hasJWTProofType(presentation) ? proof?.jwt : presentation
630
630
  if (!original) {
631
631
  throw Error(
632
- 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof',
632
+ 'Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof'
633
633
  )
634
634
  }
635
635
  const decoded = CredentialMapper.decodeVerifiablePresentation(original, opts?.hasher ?? sha256)
@@ -646,7 +646,7 @@ export class CredentialMapper {
646
646
  }
647
647
 
648
648
  uniformPresentation.verifiableCredential = uniformPresentation.verifiableCredential?.map((vc) =>
649
- CredentialMapper.toUniformCredential(vc, opts),
649
+ CredentialMapper.toUniformCredential(vc, opts)
650
650
  ) as IVerifiableCredential[] // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended)
651
651
  return uniformPresentation
652
652
  }
@@ -655,14 +655,14 @@ export class CredentialMapper {
655
655
  jwt: string,
656
656
  opts?: {
657
657
  maxTimeSkewInMS?: number
658
- },
658
+ }
659
659
  ): IVerifiableCredential {
660
660
  return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwtDecode(jwt), opts)
661
661
  }
662
662
 
663
663
  static jwtDecodedCredentialToUniformCredential(
664
664
  decoded: JwtDecodedVerifiableCredential,
665
- opts?: { maxTimeSkewInMS?: number },
665
+ opts?: { maxTimeSkewInMS?: number }
666
666
  ): IVerifiableCredential {
667
667
  const { exp, nbf, iss, vc, sub, jti, ...rest } = decoded
668
668
  const credential: IVerifiableCredential = {
@@ -830,7 +830,7 @@ export class CredentialMapper {
830
830
  }
831
831
 
832
832
  static toCompactJWT(
833
- jwtDocument: W3CVerifiableCredential | JwtDecodedVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | string,
833
+ jwtDocument: W3CVerifiableCredential | JwtDecodedVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | string
834
834
  ): string {
835
835
  if (!jwtDocument || CredentialMapper.detectDocumentType(jwtDocument) !== DocumentFormat.JWT) {
836
836
  throw Error('Cannot convert non JWT credential to JWT')
@@ -860,7 +860,7 @@ export class CredentialMapper {
860
860
  | JwtDecodedVerifiablePresentation
861
861
  | SdJwtDecodedVerifiableCredential
862
862
  | MdocDeviceResponse
863
- | MdocDocument,
863
+ | MdocDocument
864
864
  ): DocumentFormat {
865
865
  if (this.isMsoMdocOid4VPEncoded(document as any) || this.isMsoMdocDecodedCredential(document as any)) {
866
866
  return DocumentFormat.MSO_MDOC
@@ -888,7 +888,7 @@ export class CredentialMapper {
888
888
  }
889
889
 
890
890
  private static hasJWTProofType(
891
- document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation,
891
+ document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation
892
892
  ): boolean {
893
893
  if (typeof document === 'string') {
894
894
  return false
@@ -897,7 +897,7 @@ export class CredentialMapper {
897
897
  }
898
898
 
899
899
  private static getFirstProof(
900
- document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation,
900
+ document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation
901
901
  ): IProof | undefined {
902
902
  if (!document || typeof document === 'string') {
903
903
  return undefined
@@ -924,11 +924,11 @@ export class CredentialMapper {
924
924
  }
925
925
 
926
926
  export function isWrappedSdJwtVerifiableCredential(vc: WrappedVerifiableCredential): vc is WrappedSdJwtVerifiableCredential {
927
- return vc.format === 'vc+sd-jwt'
927
+ return vc.format === 'dc+sd-jwt'
928
928
  }
929
929
 
930
930
  export function isWrappedSdJwtVerifiablePresentation(vp: WrappedVerifiablePresentation): vp is WrappedSdJwtVerifiablePresentation {
931
- return vp.format === 'vc+sd-jwt'
931
+ return vp.format === 'dc+sd-jwt'
932
932
  }
933
933
 
934
934
  export enum OriginalType {
@@ -159,7 +159,7 @@ export interface WrappedSdJwtVerifiableCredential {
159
159
  /**
160
160
  * The claim format, typically used during exchange transport protocols
161
161
  */
162
- format: 'vc+sd-jwt'
162
+ format: 'dc+sd-jwt'
163
163
  /**
164
164
  * Internal stable representation of a Credential
165
165
  */
@@ -185,7 +185,7 @@ export interface WrappedSdJwtVerifiablePresentation {
185
185
  /**
186
186
  * The claim format, typically used during exchange transport protocols
187
187
  */
188
- format: 'vc+sd-jwt'
188
+ format: 'dc+sd-jwt'
189
189
  /**
190
190
  * Internal stable representation of a Presentation
191
191
  */
package/src/types/vc.ts CHANGED
@@ -28,7 +28,7 @@ export type CredentialFormat =
28
28
  | 'ldp_vc'
29
29
  | 'vc+jwt'
30
30
  // SD-JWT
31
- | 'vc+sd-jwt'
31
+ | 'dc+sd-jwt'
32
32
  // Remaining
33
33
  | 'jwt'
34
34
  | 'ldp'
@@ -42,6 +42,7 @@ export type PresentationFormat =
42
42
  | 'vp+jwt'
43
43
  // SD-JWT
44
44
  | 'vp+sd-jwt'
45
+ | 'dc+sd-jwt'
45
46
  // Remaining
46
47
  | 'jwt'
47
48
  | 'ldp'
package/src/utils/vc.ts CHANGED
@@ -19,11 +19,12 @@ export function isWrappedW3CVerifiablePresentation(vp: WrappedVerifiablePresenta
19
19
  export enum StatusListType {
20
20
  StatusList2021 = 'StatusList2021',
21
21
  OAuthStatusList = 'OAuthStatusList',
22
+ BitstringStatusList = 'BitstringStatusList',
22
23
  }
23
24
 
24
25
  function isVcdmCredential(
25
26
  credential: CredentialPayload | IVerifiableCredential | ICredential | VerifiableCredential | unknown,
26
- vcdmType: string,
27
+ vcdmType: string
27
28
  ): boolean {
28
29
  if (!credential || typeof credential !== 'object') {
29
30
  return false