@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
@@ -20,7 +20,7 @@ export interface ICredential {
20
20
  expirationDate?: string
21
21
  // If jti is present, the value MUST be used to set the value of the id property of the new JSON object.
22
22
  id?: string
23
- credentialStatus?: ICredentialStatus
23
+ credentialStatus?: ICredentialStatus // ArrayOr<ICredentialStatus> TODO this is only true for VCDM v2.0 SSISDK-2
24
24
  description?: string
25
25
  name?: string
26
26
 
@@ -276,9 +276,11 @@ export interface IErrorDetails {
276
276
  cause?: IError
277
277
  }
278
278
 
279
+ /* FIXME figurae out how to handle this, we can't have duplicates and we need one in ssi-types for the data store logic
279
280
  export enum StatusListType {
280
281
  StatusList2021 = 'StatusList2021',
281
282
  }
283
+ */
282
284
 
283
285
  export type StatusPurpose2021 = 'revocation' | 'suspension' | string
284
286
 
@@ -0,0 +1,17 @@
1
+ import { sha256, sha384, sha512 } from '@noble/hashes/sha2'
2
+ import * as u8a from 'uint8arrays'
3
+ import { HasherSync } from '../types'
4
+
5
+ const supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const
6
+ type SupportedAlgorithms = (typeof supportedAlgorithms)[number]
7
+
8
+ export const shaHasher: HasherSync = (data, algorithm) => {
9
+ const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '')
10
+ if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {
11
+ throw new Error(`Unsupported hashing algorithm ${algorithm}`)
12
+ }
13
+ const hasher = sanitizedAlgorithm === 'sha384' ? sha384 : sanitizedAlgorithm === 'sha512' ? sha512 : sha256
14
+ return hasher(typeof data === 'string' ? u8a.fromString(data) : new Uint8Array(data))
15
+ }
16
+
17
+ export const defaultHasher: HasherSync = shaHasher
@@ -1 +1,2 @@
1
1
  export * from './object'
2
+ export * from './hasher'