@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.
- package/dist/mapper/credential-mapper.d.ts +11 -10
- package/dist/mapper/credential-mapper.d.ts.map +1 -1
- package/dist/mapper/credential-mapper.js +22 -29
- package/dist/mapper/credential-mapper.js.map +1 -1
- package/dist/types/dcql.d.ts +33 -0
- package/dist/types/dcql.d.ts.map +1 -0
- package/dist/types/dcql.js +4 -0
- package/dist/types/dcql.js.map +1 -0
- package/dist/types/generic.d.ts +3 -0
- package/dist/types/generic.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/sd-jwt-vc.d.ts +5 -4
- package/dist/types/sd-jwt-vc.d.ts.map +1 -1
- package/dist/types/sd-jwt-vc.js.map +1 -1
- package/dist/types/status-list.d.ts +10 -0
- package/dist/types/status-list.d.ts.map +1 -0
- package/dist/types/status-list.js +9 -0
- package/dist/types/status-list.js.map +1 -0
- package/dist/types/w3c-vc.d.ts +0 -3
- package/dist/types/w3c-vc.d.ts.map +1 -1
- package/dist/types/w3c-vc.js +1 -5
- package/dist/types/w3c-vc.js.map +1 -1
- package/dist/utils/hasher.d.ts +4 -0
- package/dist/utils/hasher.d.ts.map +1 -0
- package/dist/utils/hasher.js +40 -0
- package/dist/utils/hasher.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -3
- package/src/mapper/credential-mapper.ts +47 -52
- package/src/types/dcql.ts +39 -0
- package/src/types/generic.ts +5 -0
- package/src/types/index.ts +2 -0
- package/src/types/mso_mdoc.ts +2 -2
- package/src/types/sd-jwt-vc.ts +6 -5
- package/src/types/status-list.ts +12 -0
- package/src/types/w3c-vc.ts +3 -1
- package/src/utils/hasher.ts +17 -0
- package/src/utils/index.ts +1 -0
package/src/types/w3c-vc.ts
CHANGED
|
@@ -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
|
package/src/utils/index.ts
CHANGED