@sphereon/ssi-types 0.18.2-next.9 → 0.18.2-unstable.13
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/LICENSE +201 -201
- package/README.md +49 -49
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/mapper/credential-mapper.d.ts +107 -107
- package/dist/mapper/credential-mapper.js +556 -556
- package/dist/mapper/index.d.ts +1 -1
- package/dist/mapper/index.js +17 -17
- package/dist/types/did.d.ts +35 -35
- package/dist/types/did.js +75 -75
- package/dist/types/generic.d.ts +7 -7
- package/dist/types/generic.js +2 -2
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.js +22 -22
- package/dist/types/pex.d.ts +35 -35
- package/dist/types/pex.js +2 -2
- package/dist/types/sd-jwt-vc.d.ts +170 -170
- package/dist/types/sd-jwt-vc.js +71 -71
- package/dist/types/vc.d.ts +23 -23
- package/dist/types/vc.js +23 -23
- package/dist/types/w3c-vc.d.ts +247 -247
- package/dist/types/w3c-vc.js +29 -29
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +17 -17
- package/dist/utils/object.d.ts +6 -6
- package/dist/utils/object.js +20 -20
- package/package.json +2 -2
- package/src/index.ts +3 -3
- package/src/mapper/credential-mapper.ts +686 -686
- package/src/mapper/index.ts +1 -1
- package/src/types/generic.ts +8 -8
- package/src/types/index.ts +6 -6
- package/src/types/pex.ts +36 -36
- package/src/types/sd-jwt-vc.ts +232 -232
- package/src/types/vc.ts +62 -62
- package/src/types/w3c-vc.ts +300 -300
- package/src/utils/index.ts +1 -1
- package/src/utils/object.ts +19 -19
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import { OriginalType, WrappedVerifiableCredential, WrappedVerifiablePresentation } from './vc';
|
|
2
|
-
type JsonValue = string | number | boolean | {
|
|
3
|
-
[x: string]: JsonValue | undefined;
|
|
4
|
-
} | Array<JsonValue>;
|
|
5
|
-
type SdJwtJsonValue = string | number | boolean | {
|
|
6
|
-
[x: string]: SdJwtJsonValue | undefined;
|
|
7
|
-
_sd?: string[];
|
|
8
|
-
} | Array<SdJwtJsonValue | {
|
|
9
|
-
'...': string;
|
|
10
|
-
}>;
|
|
11
|
-
/**
|
|
12
|
-
* Decoded 'pretty' SD JWT Verifiable Credential. This representation has all the `_sd` properties
|
|
13
|
-
* removed, and includes the disclosures directly within the payload.
|
|
14
|
-
*/
|
|
15
|
-
export interface SdJwtDecodedVerifiableCredentialPayload {
|
|
16
|
-
vct: string;
|
|
17
|
-
iss: string;
|
|
18
|
-
iat: number;
|
|
19
|
-
nbf?: number;
|
|
20
|
-
exp?: number;
|
|
21
|
-
cnf?: {
|
|
22
|
-
jwk?: any;
|
|
23
|
-
kid?: string;
|
|
24
|
-
};
|
|
25
|
-
status?: {
|
|
26
|
-
idx: number;
|
|
27
|
-
uri: string;
|
|
28
|
-
};
|
|
29
|
-
sub?: string;
|
|
30
|
-
[key: string]: JsonValue | undefined;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Represents a selective disclosure JWT vc in compact form.
|
|
34
|
-
*/
|
|
35
|
-
export type CompactSdJwtVc = string;
|
|
36
|
-
/**
|
|
37
|
-
* The signed payload of an SD-JWT. Includes fields such as `_sd`, `...` and `_sd_alg`
|
|
38
|
-
*/
|
|
39
|
-
interface SdJwtSignedVerifiableCredentialPayload extends SdJwtDecodedVerifiableCredentialPayload {
|
|
40
|
-
_sd?: string[];
|
|
41
|
-
_sd_alg?: string;
|
|
42
|
-
[x: string]: SdJwtJsonValue | undefined;
|
|
43
|
-
}
|
|
44
|
-
type SdJwtFrameValue = boolean | Array<SdJwtFrameValue> | {
|
|
45
|
-
[x: string]: SdJwtFrameValue;
|
|
46
|
-
};
|
|
47
|
-
export type SdJwtDisclosureFrame = Record<string, SdJwtFrameValue>;
|
|
48
|
-
export type SdJwtPresentationFrame = Record<string, SdJwtFrameValue>;
|
|
49
|
-
/**
|
|
50
|
-
* Input for creating a SD JWT Verifiable Credential. This representation optionally includes the disclosure frame,
|
|
51
|
-
* (as `__disclosureFrame`) to indicate which fields in the signed SD-JWT should be selectively discloseable
|
|
52
|
-
*/
|
|
53
|
-
export interface SdJwtCredentialInput extends SdJwtDecodedVerifiableCredentialPayload {
|
|
54
|
-
/**
|
|
55
|
-
* Disclosure frame, indicating which fields in the signed SD-JWT should be selectively discloseable
|
|
56
|
-
* Will be removed from the actual SD-JWT payload before signing
|
|
57
|
-
*/
|
|
58
|
-
__disclosureFrame?: SdJwtDisclosureFrame;
|
|
59
|
-
}
|
|
60
|
-
export type SdJwtDecodedDisclosure = [string, string, JsonValue] | [string, JsonValue];
|
|
61
|
-
export interface SdJwtDisclosure {
|
|
62
|
-
encoded: string;
|
|
63
|
-
decoded: SdJwtDecodedDisclosure;
|
|
64
|
-
digest: string;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The decoded SD JWT Verifiable Credential. This representation includes multiple representations of the
|
|
68
|
-
* same SD-JWT, and allows to fully process an SD-JWT, as well as create a presentation SD-JWT (minus the KB-JWT) by removing
|
|
69
|
-
* certain disclosures from the compact SD-JWT.
|
|
70
|
-
*
|
|
71
|
-
* This representation is useful as it doesn't require a hasher implementation to match the different digests in the signed SD-JWT
|
|
72
|
-
* payload, with the different disclosures.
|
|
73
|
-
*/
|
|
74
|
-
export interface SdJwtDecodedVerifiableCredential {
|
|
75
|
-
/**
|
|
76
|
-
* The compact sd jwt is the sd-jwt encoded as string. It is a normal JWT,
|
|
77
|
-
* with the disclosures and kb-jwt appended separated by ~ */
|
|
78
|
-
compactSdJwtVc: string;
|
|
79
|
-
/**
|
|
80
|
-
* The disclosures included within the SD-JWT in both encoded and decoded format.
|
|
81
|
-
* The digests are also included, and allows the disclosures to be linked against
|
|
82
|
-
* the digests in the signed payload.
|
|
83
|
-
*/
|
|
84
|
-
disclosures: Array<SdJwtDisclosure>;
|
|
85
|
-
/**
|
|
86
|
-
* The signed payload is the payload of the sd-jwt that is actually signed, and that includes
|
|
87
|
-
* the `_sd` and `...` digests.
|
|
88
|
-
*/
|
|
89
|
-
signedPayload: SdJwtSignedVerifiableCredentialPayload;
|
|
90
|
-
/**
|
|
91
|
-
* The decoded payload is the payload when all `_sd` and `...` digests have been replaced
|
|
92
|
-
* by the actual values from the disclosures. This format could also be seen as the 'pretty`
|
|
93
|
-
* version of the SD JWT payload.
|
|
94
|
-
*
|
|
95
|
-
* This is useful for displaying the contents of the SD JWT VC to the user, or for example
|
|
96
|
-
* for querying the contents of the SD JWT VC using a PEX presentation definition path.
|
|
97
|
-
*/
|
|
98
|
-
decodedPayload: SdJwtDecodedVerifiableCredentialPayload;
|
|
99
|
-
}
|
|
100
|
-
export interface WrappedSdJwtVerifiableCredential {
|
|
101
|
-
/**
|
|
102
|
-
* Original VC that we've received. Can be either the encoded or decoded variant.
|
|
103
|
-
*/
|
|
104
|
-
original: SdJwtDecodedVerifiableCredential | CompactSdJwtVc;
|
|
105
|
-
/**
|
|
106
|
-
* Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT as the `decoded` property
|
|
107
|
-
* is used in e.g. PEX to check for path filters from fields. The full decoded credential can be found in the `credential` field.
|
|
108
|
-
*/
|
|
109
|
-
decoded: SdJwtDecodedVerifiableCredentialPayload;
|
|
110
|
-
/**
|
|
111
|
-
* Type of this credential.
|
|
112
|
-
*/
|
|
113
|
-
type: OriginalType.SD_JWT_VC_DECODED | OriginalType.SD_JWT_VC_ENCODED;
|
|
114
|
-
/**
|
|
115
|
-
* The claim format, typically used during exchange transport protocols
|
|
116
|
-
*/
|
|
117
|
-
format: 'vc+sd-jwt';
|
|
118
|
-
/**
|
|
119
|
-
* Internal stable representation of a Credential
|
|
120
|
-
*/
|
|
121
|
-
credential: SdJwtDecodedVerifiableCredential;
|
|
122
|
-
}
|
|
123
|
-
export interface WrappedSdJwtVerifiablePresentation {
|
|
124
|
-
/**
|
|
125
|
-
* Original VP that we've received. Can be either the encoded or decoded variant.
|
|
126
|
-
*/
|
|
127
|
-
original: SdJwtDecodedVerifiableCredential | CompactSdJwtVc;
|
|
128
|
-
/**
|
|
129
|
-
* Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT.
|
|
130
|
-
*/
|
|
131
|
-
decoded: SdJwtDecodedVerifiableCredentialPayload;
|
|
132
|
-
/**
|
|
133
|
-
* Type of this Presentation.
|
|
134
|
-
*/
|
|
135
|
-
type: OriginalType.SD_JWT_VC_DECODED | OriginalType.SD_JWT_VC_ENCODED;
|
|
136
|
-
/**
|
|
137
|
-
* The claim format, typically used during exchange transport protocols
|
|
138
|
-
*/
|
|
139
|
-
format: 'vc+sd-jwt';
|
|
140
|
-
/**
|
|
141
|
-
* Internal stable representation of a Presentation
|
|
142
|
-
*/
|
|
143
|
-
presentation: SdJwtDecodedVerifiableCredential;
|
|
144
|
-
/**
|
|
145
|
-
* Wrapped Verifiable Credentials belonging to the Presentation. Will always be an array
|
|
146
|
-
* with a single SdJwtVerifiableCredential entry.
|
|
147
|
-
*/
|
|
148
|
-
vcs: [WrappedSdJwtVerifiableCredential];
|
|
149
|
-
}
|
|
150
|
-
export declare function isWrappedSdJwtVerifiableCredential(vc: WrappedVerifiableCredential): vc is WrappedSdJwtVerifiableCredential;
|
|
151
|
-
export declare function isWrappedSdJwtVerifiablePresentation(vp: WrappedVerifiablePresentation): vp is WrappedSdJwtVerifiablePresentation;
|
|
152
|
-
export type Hasher = (data: string, alg: string) => Uint8Array;
|
|
153
|
-
export type AsyncHasher = (data: string, alg: string) => Promise<Uint8Array>;
|
|
154
|
-
/**
|
|
155
|
-
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
156
|
-
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
157
|
-
*
|
|
158
|
-
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
159
|
-
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
160
|
-
*/
|
|
161
|
-
export declare function decodeSdJwtVc(compactSdJwtVc: CompactSdJwtVc, hasher: Hasher): SdJwtDecodedVerifiableCredential;
|
|
162
|
-
/**
|
|
163
|
-
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
164
|
-
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
165
|
-
*
|
|
166
|
-
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
167
|
-
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
168
|
-
*/
|
|
169
|
-
export declare function decodeSdJwtVcAsync(compactSdJwtVc: CompactSdJwtVc, hasher: AsyncHasher): Promise<SdJwtDecodedVerifiableCredential>;
|
|
170
|
-
export {};
|
|
1
|
+
import { OriginalType, WrappedVerifiableCredential, WrappedVerifiablePresentation } from './vc';
|
|
2
|
+
type JsonValue = string | number | boolean | {
|
|
3
|
+
[x: string]: JsonValue | undefined;
|
|
4
|
+
} | Array<JsonValue>;
|
|
5
|
+
type SdJwtJsonValue = string | number | boolean | {
|
|
6
|
+
[x: string]: SdJwtJsonValue | undefined;
|
|
7
|
+
_sd?: string[];
|
|
8
|
+
} | Array<SdJwtJsonValue | {
|
|
9
|
+
'...': string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Decoded 'pretty' SD JWT Verifiable Credential. This representation has all the `_sd` properties
|
|
13
|
+
* removed, and includes the disclosures directly within the payload.
|
|
14
|
+
*/
|
|
15
|
+
export interface SdJwtDecodedVerifiableCredentialPayload {
|
|
16
|
+
vct: string;
|
|
17
|
+
iss: string;
|
|
18
|
+
iat: number;
|
|
19
|
+
nbf?: number;
|
|
20
|
+
exp?: number;
|
|
21
|
+
cnf?: {
|
|
22
|
+
jwk?: any;
|
|
23
|
+
kid?: string;
|
|
24
|
+
};
|
|
25
|
+
status?: {
|
|
26
|
+
idx: number;
|
|
27
|
+
uri: string;
|
|
28
|
+
};
|
|
29
|
+
sub?: string;
|
|
30
|
+
[key: string]: JsonValue | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents a selective disclosure JWT vc in compact form.
|
|
34
|
+
*/
|
|
35
|
+
export type CompactSdJwtVc = string;
|
|
36
|
+
/**
|
|
37
|
+
* The signed payload of an SD-JWT. Includes fields such as `_sd`, `...` and `_sd_alg`
|
|
38
|
+
*/
|
|
39
|
+
interface SdJwtSignedVerifiableCredentialPayload extends SdJwtDecodedVerifiableCredentialPayload {
|
|
40
|
+
_sd?: string[];
|
|
41
|
+
_sd_alg?: string;
|
|
42
|
+
[x: string]: SdJwtJsonValue | undefined;
|
|
43
|
+
}
|
|
44
|
+
type SdJwtFrameValue = boolean | Array<SdJwtFrameValue> | {
|
|
45
|
+
[x: string]: SdJwtFrameValue;
|
|
46
|
+
};
|
|
47
|
+
export type SdJwtDisclosureFrame = Record<string, SdJwtFrameValue>;
|
|
48
|
+
export type SdJwtPresentationFrame = Record<string, SdJwtFrameValue>;
|
|
49
|
+
/**
|
|
50
|
+
* Input for creating a SD JWT Verifiable Credential. This representation optionally includes the disclosure frame,
|
|
51
|
+
* (as `__disclosureFrame`) to indicate which fields in the signed SD-JWT should be selectively discloseable
|
|
52
|
+
*/
|
|
53
|
+
export interface SdJwtCredentialInput extends SdJwtDecodedVerifiableCredentialPayload {
|
|
54
|
+
/**
|
|
55
|
+
* Disclosure frame, indicating which fields in the signed SD-JWT should be selectively discloseable
|
|
56
|
+
* Will be removed from the actual SD-JWT payload before signing
|
|
57
|
+
*/
|
|
58
|
+
__disclosureFrame?: SdJwtDisclosureFrame;
|
|
59
|
+
}
|
|
60
|
+
export type SdJwtDecodedDisclosure = [string, string, JsonValue] | [string, JsonValue];
|
|
61
|
+
export interface SdJwtDisclosure {
|
|
62
|
+
encoded: string;
|
|
63
|
+
decoded: SdJwtDecodedDisclosure;
|
|
64
|
+
digest: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The decoded SD JWT Verifiable Credential. This representation includes multiple representations of the
|
|
68
|
+
* same SD-JWT, and allows to fully process an SD-JWT, as well as create a presentation SD-JWT (minus the KB-JWT) by removing
|
|
69
|
+
* certain disclosures from the compact SD-JWT.
|
|
70
|
+
*
|
|
71
|
+
* This representation is useful as it doesn't require a hasher implementation to match the different digests in the signed SD-JWT
|
|
72
|
+
* payload, with the different disclosures.
|
|
73
|
+
*/
|
|
74
|
+
export interface SdJwtDecodedVerifiableCredential {
|
|
75
|
+
/**
|
|
76
|
+
* The compact sd jwt is the sd-jwt encoded as string. It is a normal JWT,
|
|
77
|
+
* with the disclosures and kb-jwt appended separated by ~ */
|
|
78
|
+
compactSdJwtVc: string;
|
|
79
|
+
/**
|
|
80
|
+
* The disclosures included within the SD-JWT in both encoded and decoded format.
|
|
81
|
+
* The digests are also included, and allows the disclosures to be linked against
|
|
82
|
+
* the digests in the signed payload.
|
|
83
|
+
*/
|
|
84
|
+
disclosures: Array<SdJwtDisclosure>;
|
|
85
|
+
/**
|
|
86
|
+
* The signed payload is the payload of the sd-jwt that is actually signed, and that includes
|
|
87
|
+
* the `_sd` and `...` digests.
|
|
88
|
+
*/
|
|
89
|
+
signedPayload: SdJwtSignedVerifiableCredentialPayload;
|
|
90
|
+
/**
|
|
91
|
+
* The decoded payload is the payload when all `_sd` and `...` digests have been replaced
|
|
92
|
+
* by the actual values from the disclosures. This format could also be seen as the 'pretty`
|
|
93
|
+
* version of the SD JWT payload.
|
|
94
|
+
*
|
|
95
|
+
* This is useful for displaying the contents of the SD JWT VC to the user, or for example
|
|
96
|
+
* for querying the contents of the SD JWT VC using a PEX presentation definition path.
|
|
97
|
+
*/
|
|
98
|
+
decodedPayload: SdJwtDecodedVerifiableCredentialPayload;
|
|
99
|
+
}
|
|
100
|
+
export interface WrappedSdJwtVerifiableCredential {
|
|
101
|
+
/**
|
|
102
|
+
* Original VC that we've received. Can be either the encoded or decoded variant.
|
|
103
|
+
*/
|
|
104
|
+
original: SdJwtDecodedVerifiableCredential | CompactSdJwtVc;
|
|
105
|
+
/**
|
|
106
|
+
* Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT as the `decoded` property
|
|
107
|
+
* is used in e.g. PEX to check for path filters from fields. The full decoded credential can be found in the `credential` field.
|
|
108
|
+
*/
|
|
109
|
+
decoded: SdJwtDecodedVerifiableCredentialPayload;
|
|
110
|
+
/**
|
|
111
|
+
* Type of this credential.
|
|
112
|
+
*/
|
|
113
|
+
type: OriginalType.SD_JWT_VC_DECODED | OriginalType.SD_JWT_VC_ENCODED;
|
|
114
|
+
/**
|
|
115
|
+
* The claim format, typically used during exchange transport protocols
|
|
116
|
+
*/
|
|
117
|
+
format: 'vc+sd-jwt';
|
|
118
|
+
/**
|
|
119
|
+
* Internal stable representation of a Credential
|
|
120
|
+
*/
|
|
121
|
+
credential: SdJwtDecodedVerifiableCredential;
|
|
122
|
+
}
|
|
123
|
+
export interface WrappedSdJwtVerifiablePresentation {
|
|
124
|
+
/**
|
|
125
|
+
* Original VP that we've received. Can be either the encoded or decoded variant.
|
|
126
|
+
*/
|
|
127
|
+
original: SdJwtDecodedVerifiableCredential | CompactSdJwtVc;
|
|
128
|
+
/**
|
|
129
|
+
* Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT.
|
|
130
|
+
*/
|
|
131
|
+
decoded: SdJwtDecodedVerifiableCredentialPayload;
|
|
132
|
+
/**
|
|
133
|
+
* Type of this Presentation.
|
|
134
|
+
*/
|
|
135
|
+
type: OriginalType.SD_JWT_VC_DECODED | OriginalType.SD_JWT_VC_ENCODED;
|
|
136
|
+
/**
|
|
137
|
+
* The claim format, typically used during exchange transport protocols
|
|
138
|
+
*/
|
|
139
|
+
format: 'vc+sd-jwt';
|
|
140
|
+
/**
|
|
141
|
+
* Internal stable representation of a Presentation
|
|
142
|
+
*/
|
|
143
|
+
presentation: SdJwtDecodedVerifiableCredential;
|
|
144
|
+
/**
|
|
145
|
+
* Wrapped Verifiable Credentials belonging to the Presentation. Will always be an array
|
|
146
|
+
* with a single SdJwtVerifiableCredential entry.
|
|
147
|
+
*/
|
|
148
|
+
vcs: [WrappedSdJwtVerifiableCredential];
|
|
149
|
+
}
|
|
150
|
+
export declare function isWrappedSdJwtVerifiableCredential(vc: WrappedVerifiableCredential): vc is WrappedSdJwtVerifiableCredential;
|
|
151
|
+
export declare function isWrappedSdJwtVerifiablePresentation(vp: WrappedVerifiablePresentation): vp is WrappedSdJwtVerifiablePresentation;
|
|
152
|
+
export type Hasher = (data: string, alg: string) => Uint8Array;
|
|
153
|
+
export type AsyncHasher = (data: string, alg: string) => Promise<Uint8Array>;
|
|
154
|
+
/**
|
|
155
|
+
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
156
|
+
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
157
|
+
*
|
|
158
|
+
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
159
|
+
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
160
|
+
*/
|
|
161
|
+
export declare function decodeSdJwtVc(compactSdJwtVc: CompactSdJwtVc, hasher: Hasher): SdJwtDecodedVerifiableCredential;
|
|
162
|
+
/**
|
|
163
|
+
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
164
|
+
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
165
|
+
*
|
|
166
|
+
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
167
|
+
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
168
|
+
*/
|
|
169
|
+
export declare function decodeSdJwtVcAsync(compactSdJwtVc: CompactSdJwtVc, hasher: AsyncHasher): Promise<SdJwtDecodedVerifiableCredential>;
|
|
170
|
+
export {};
|
|
171
171
|
//# sourceMappingURL=sd-jwt-vc.d.ts.map
|
package/dist/types/sd-jwt-vc.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.decodeSdJwtVcAsync = exports.decodeSdJwtVc = exports.isWrappedSdJwtVerifiablePresentation = exports.isWrappedSdJwtVerifiableCredential = void 0;
|
|
13
|
-
const decode_1 = require("@sd-jwt/decode");
|
|
14
|
-
function isWrappedSdJwtVerifiableCredential(vc) {
|
|
15
|
-
return vc.format === 'vc+sd-jwt';
|
|
16
|
-
}
|
|
17
|
-
exports.isWrappedSdJwtVerifiableCredential = isWrappedSdJwtVerifiableCredential;
|
|
18
|
-
function isWrappedSdJwtVerifiablePresentation(vp) {
|
|
19
|
-
return vp.format === 'vc+sd-jwt';
|
|
20
|
-
}
|
|
21
|
-
exports.isWrappedSdJwtVerifiablePresentation = isWrappedSdJwtVerifiablePresentation;
|
|
22
|
-
/**
|
|
23
|
-
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
24
|
-
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
25
|
-
*
|
|
26
|
-
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
27
|
-
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
28
|
-
*/
|
|
29
|
-
function decodeSdJwtVc(compactSdJwtVc, hasher) {
|
|
30
|
-
const { signedPayload, decodedPayload, disclosures } = (0, decode_1.decodeSdJwtVc)(compactSdJwtVc, hasher);
|
|
31
|
-
return {
|
|
32
|
-
compactSdJwtVc,
|
|
33
|
-
decodedPayload: decodedPayload,
|
|
34
|
-
disclosures: disclosures.map((d) => {
|
|
35
|
-
const decoded = d.key ? [d.salt, d.key, d.value] : [d.salt, d.value];
|
|
36
|
-
return {
|
|
37
|
-
decoded: decoded,
|
|
38
|
-
digest: d.digest,
|
|
39
|
-
encoded: d.encoded,
|
|
40
|
-
};
|
|
41
|
-
}),
|
|
42
|
-
signedPayload: signedPayload,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
exports.decodeSdJwtVc = decodeSdJwtVc;
|
|
46
|
-
/**
|
|
47
|
-
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
48
|
-
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
49
|
-
*
|
|
50
|
-
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
51
|
-
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
52
|
-
*/
|
|
53
|
-
function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const { signedPayload, decodedPayload, disclosures } = yield (0, decode_1.decodeSdJwtVc)(compactSdJwtVc, hasher);
|
|
56
|
-
return {
|
|
57
|
-
compactSdJwtVc,
|
|
58
|
-
decodedPayload: decodedPayload,
|
|
59
|
-
disclosures: disclosures.map((d) => {
|
|
60
|
-
const decoded = d.key ? [d.salt, d.key, d.value] : [d.salt, d.value];
|
|
61
|
-
return {
|
|
62
|
-
decoded: decoded,
|
|
63
|
-
digest: d.digest,
|
|
64
|
-
encoded: d.encoded,
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
signedPayload: signedPayload,
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
exports.decodeSdJwtVcAsync = decodeSdJwtVcAsync;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.decodeSdJwtVcAsync = exports.decodeSdJwtVc = exports.isWrappedSdJwtVerifiablePresentation = exports.isWrappedSdJwtVerifiableCredential = void 0;
|
|
13
|
+
const decode_1 = require("@sd-jwt/decode");
|
|
14
|
+
function isWrappedSdJwtVerifiableCredential(vc) {
|
|
15
|
+
return vc.format === 'vc+sd-jwt';
|
|
16
|
+
}
|
|
17
|
+
exports.isWrappedSdJwtVerifiableCredential = isWrappedSdJwtVerifiableCredential;
|
|
18
|
+
function isWrappedSdJwtVerifiablePresentation(vp) {
|
|
19
|
+
return vp.format === 'vc+sd-jwt';
|
|
20
|
+
}
|
|
21
|
+
exports.isWrappedSdJwtVerifiablePresentation = isWrappedSdJwtVerifiablePresentation;
|
|
22
|
+
/**
|
|
23
|
+
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
24
|
+
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
25
|
+
*
|
|
26
|
+
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
27
|
+
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
28
|
+
*/
|
|
29
|
+
function decodeSdJwtVc(compactSdJwtVc, hasher) {
|
|
30
|
+
const { signedPayload, decodedPayload, disclosures } = (0, decode_1.decodeSdJwtVc)(compactSdJwtVc, hasher);
|
|
31
|
+
return {
|
|
32
|
+
compactSdJwtVc,
|
|
33
|
+
decodedPayload: decodedPayload,
|
|
34
|
+
disclosures: disclosures.map((d) => {
|
|
35
|
+
const decoded = d.key ? [d.salt, d.key, d.value] : [d.salt, d.value];
|
|
36
|
+
return {
|
|
37
|
+
decoded: decoded,
|
|
38
|
+
digest: d.digest,
|
|
39
|
+
encoded: d.encoded,
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
42
|
+
signedPayload: signedPayload,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.decodeSdJwtVc = decodeSdJwtVc;
|
|
46
|
+
/**
|
|
47
|
+
* Decode an SD-JWT vc from its compact format (string) to an object containing the disclosures,
|
|
48
|
+
* signed payload, decoded payload and the compact SD-JWT vc.
|
|
49
|
+
*
|
|
50
|
+
* Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so
|
|
51
|
+
* this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core)
|
|
52
|
+
*/
|
|
53
|
+
function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const { signedPayload, decodedPayload, disclosures } = yield (0, decode_1.decodeSdJwtVc)(compactSdJwtVc, hasher);
|
|
56
|
+
return {
|
|
57
|
+
compactSdJwtVc,
|
|
58
|
+
decodedPayload: decodedPayload,
|
|
59
|
+
disclosures: disclosures.map((d) => {
|
|
60
|
+
const decoded = d.key ? [d.salt, d.key, d.value] : [d.salt, d.value];
|
|
61
|
+
return {
|
|
62
|
+
decoded: decoded,
|
|
63
|
+
digest: d.digest,
|
|
64
|
+
encoded: d.encoded,
|
|
65
|
+
};
|
|
66
|
+
}),
|
|
67
|
+
signedPayload: signedPayload,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.decodeSdJwtVcAsync = decodeSdJwtVcAsync;
|
|
72
72
|
//# sourceMappingURL=sd-jwt-vc.js.map
|
package/dist/types/vc.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { SdJwtDecodedVerifiableCredential, WrappedSdJwtVerifiableCredential, WrappedSdJwtVerifiablePresentation } from './sd-jwt-vc';
|
|
2
|
-
import { JwtDecodedVerifiableCredential, JwtDecodedVerifiablePresentation, W3CVerifiableCredential, W3CVerifiablePresentation, WrappedW3CVerifiableCredential, WrappedW3CVerifiablePresentation } from './w3c-vc';
|
|
3
|
-
export type WrappedVerifiableCredential = WrappedW3CVerifiableCredential | WrappedSdJwtVerifiableCredential;
|
|
4
|
-
export type WrappedVerifiablePresentation = WrappedW3CVerifiablePresentation | WrappedSdJwtVerifiablePresentation;
|
|
5
|
-
export declare enum OriginalType {
|
|
6
|
-
JSONLD = "json-ld",
|
|
7
|
-
JWT_ENCODED = "jwt-encoded",
|
|
8
|
-
JWT_DECODED = "jwt-decoded",
|
|
9
|
-
SD_JWT_VC_ENCODED = "sd-jwt-vc-encoded",
|
|
10
|
-
SD_JWT_VC_DECODED = "sd-jwt-vc-decoded"
|
|
11
|
-
}
|
|
12
|
-
export type CredentialFormat = 'jwt_vc' | 'ldp_vc' | 'vc+sd-jwt' | 'jwt' | 'ldp' | string;
|
|
13
|
-
export type PresentationFormat = 'jwt_vp' | 'ldp_vp' | 'vc+sd-jwt' | 'jwt' | 'ldp' | string;
|
|
14
|
-
export type ClaimFormat = CredentialFormat | PresentationFormat;
|
|
15
|
-
export type OriginalVerifiableCredential = W3CVerifiableCredential | JwtDecodedVerifiableCredential | SdJwtDecodedVerifiableCredential;
|
|
16
|
-
export type OriginalVerifiablePresentation = W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | SdJwtDecodedVerifiableCredential;
|
|
17
|
-
export type Original = OriginalVerifiablePresentation | OriginalVerifiableCredential;
|
|
18
|
-
export declare const enum DocumentFormat {
|
|
19
|
-
JWT = 0,
|
|
20
|
-
JSONLD = 1,
|
|
21
|
-
SD_JWT_VC = 2,
|
|
22
|
-
EIP712 = 3
|
|
23
|
-
}
|
|
1
|
+
import { SdJwtDecodedVerifiableCredential, WrappedSdJwtVerifiableCredential, WrappedSdJwtVerifiablePresentation } from './sd-jwt-vc';
|
|
2
|
+
import { JwtDecodedVerifiableCredential, JwtDecodedVerifiablePresentation, W3CVerifiableCredential, W3CVerifiablePresentation, WrappedW3CVerifiableCredential, WrappedW3CVerifiablePresentation } from './w3c-vc';
|
|
3
|
+
export type WrappedVerifiableCredential = WrappedW3CVerifiableCredential | WrappedSdJwtVerifiableCredential;
|
|
4
|
+
export type WrappedVerifiablePresentation = WrappedW3CVerifiablePresentation | WrappedSdJwtVerifiablePresentation;
|
|
5
|
+
export declare enum OriginalType {
|
|
6
|
+
JSONLD = "json-ld",
|
|
7
|
+
JWT_ENCODED = "jwt-encoded",
|
|
8
|
+
JWT_DECODED = "jwt-decoded",
|
|
9
|
+
SD_JWT_VC_ENCODED = "sd-jwt-vc-encoded",
|
|
10
|
+
SD_JWT_VC_DECODED = "sd-jwt-vc-decoded"
|
|
11
|
+
}
|
|
12
|
+
export type CredentialFormat = 'jwt_vc' | 'ldp_vc' | 'vc+sd-jwt' | 'jwt' | 'ldp' | string;
|
|
13
|
+
export type PresentationFormat = 'jwt_vp' | 'ldp_vp' | 'vc+sd-jwt' | 'jwt' | 'ldp' | string;
|
|
14
|
+
export type ClaimFormat = CredentialFormat | PresentationFormat;
|
|
15
|
+
export type OriginalVerifiableCredential = W3CVerifiableCredential | JwtDecodedVerifiableCredential | SdJwtDecodedVerifiableCredential;
|
|
16
|
+
export type OriginalVerifiablePresentation = W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | SdJwtDecodedVerifiableCredential;
|
|
17
|
+
export type Original = OriginalVerifiablePresentation | OriginalVerifiableCredential;
|
|
18
|
+
export declare const enum DocumentFormat {
|
|
19
|
+
JWT = 0,
|
|
20
|
+
JSONLD = 1,
|
|
21
|
+
SD_JWT_VC = 2,
|
|
22
|
+
EIP712 = 3
|
|
23
|
+
}
|
|
24
24
|
//# sourceMappingURL=vc.d.ts.map
|
package/dist/types/vc.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentFormat = exports.OriginalType = void 0;
|
|
4
|
-
var OriginalType;
|
|
5
|
-
(function (OriginalType) {
|
|
6
|
-
// W3C
|
|
7
|
-
OriginalType["JSONLD"] = "json-ld";
|
|
8
|
-
OriginalType["JWT_ENCODED"] = "jwt-encoded";
|
|
9
|
-
OriginalType["JWT_DECODED"] = "jwt-decoded";
|
|
10
|
-
// SD-JWT
|
|
11
|
-
OriginalType["SD_JWT_VC_ENCODED"] = "sd-jwt-vc-encoded";
|
|
12
|
-
OriginalType["SD_JWT_VC_DECODED"] = "sd-jwt-vc-decoded";
|
|
13
|
-
})(OriginalType = exports.OriginalType || (exports.OriginalType = {}));
|
|
14
|
-
var DocumentFormat;
|
|
15
|
-
(function (DocumentFormat) {
|
|
16
|
-
// W3C
|
|
17
|
-
DocumentFormat[DocumentFormat["JWT"] = 0] = "JWT";
|
|
18
|
-
DocumentFormat[DocumentFormat["JSONLD"] = 1] = "JSONLD";
|
|
19
|
-
// SD-JWT
|
|
20
|
-
DocumentFormat[DocumentFormat["SD_JWT_VC"] = 2] = "SD_JWT_VC";
|
|
21
|
-
// Remaining
|
|
22
|
-
DocumentFormat[DocumentFormat["EIP712"] = 3] = "EIP712";
|
|
23
|
-
})(DocumentFormat = exports.DocumentFormat || (exports.DocumentFormat = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentFormat = exports.OriginalType = void 0;
|
|
4
|
+
var OriginalType;
|
|
5
|
+
(function (OriginalType) {
|
|
6
|
+
// W3C
|
|
7
|
+
OriginalType["JSONLD"] = "json-ld";
|
|
8
|
+
OriginalType["JWT_ENCODED"] = "jwt-encoded";
|
|
9
|
+
OriginalType["JWT_DECODED"] = "jwt-decoded";
|
|
10
|
+
// SD-JWT
|
|
11
|
+
OriginalType["SD_JWT_VC_ENCODED"] = "sd-jwt-vc-encoded";
|
|
12
|
+
OriginalType["SD_JWT_VC_DECODED"] = "sd-jwt-vc-decoded";
|
|
13
|
+
})(OriginalType = exports.OriginalType || (exports.OriginalType = {}));
|
|
14
|
+
var DocumentFormat;
|
|
15
|
+
(function (DocumentFormat) {
|
|
16
|
+
// W3C
|
|
17
|
+
DocumentFormat[DocumentFormat["JWT"] = 0] = "JWT";
|
|
18
|
+
DocumentFormat[DocumentFormat["JSONLD"] = 1] = "JSONLD";
|
|
19
|
+
// SD-JWT
|
|
20
|
+
DocumentFormat[DocumentFormat["SD_JWT_VC"] = 2] = "SD_JWT_VC";
|
|
21
|
+
// Remaining
|
|
22
|
+
DocumentFormat[DocumentFormat["EIP712"] = 3] = "EIP712";
|
|
23
|
+
})(DocumentFormat = exports.DocumentFormat || (exports.DocumentFormat = {}));
|
|
24
24
|
//# sourceMappingURL=vc.js.map
|