@sd-jwt/core 0.3.0 → 2.0.2-next.26

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 (107) hide show
  1. package/LICENSE +201 -0
  2. package/dist/index.d.mts +106 -0
  3. package/dist/index.d.ts +106 -0
  4. package/dist/index.js +606 -0
  5. package/dist/index.mjs +586 -0
  6. package/package.json +60 -48
  7. package/src/decoy.ts +15 -0
  8. package/src/index.ts +235 -0
  9. package/src/jwt.ts +107 -0
  10. package/src/kbjwt.ts +45 -0
  11. package/src/sdjwt.ts +318 -0
  12. package/src/test/decoy.spec.ts +30 -0
  13. package/src/test/index.spec.ts +379 -0
  14. package/src/test/jwt.spec.ts +141 -0
  15. package/src/test/kbjwt.spec.ts +275 -0
  16. package/src/test/pass.spec.ts +6 -0
  17. package/src/test/sdjwt.spec.ts +382 -0
  18. package/test/app-e2e.spec.ts +248 -0
  19. package/test/array_data_types.json +29 -0
  20. package/test/array_full_sd.json +21 -0
  21. package/test/array_in_sd.json +13 -0
  22. package/test/array_nested_in_plain.json +20 -0
  23. package/test/array_none_disclosed.json +17 -0
  24. package/test/array_of_nulls.json +15 -0
  25. package/test/array_of_objects.json +58 -0
  26. package/test/array_of_scalars.json +15 -0
  27. package/test/array_recursive_sd.json +35 -0
  28. package/test/array_recursive_sd_some_disclosed.json +55 -0
  29. package/test/complex.json +43 -0
  30. package/test/header_mod.json +44 -0
  31. package/test/json_serialization.json +44 -0
  32. package/test/key_binding.json +44 -0
  33. package/test/no_sd.json +36 -0
  34. package/test/object_data_types.json +60 -0
  35. package/test/recursions.json +98 -0
  36. package/tsconfig.json +7 -0
  37. package/vitest.config.mts +4 -0
  38. package/README.md +0 -97
  39. package/build/index.d.ts +0 -13
  40. package/build/index.js +0 -20
  41. package/build/index.js.map +0 -1
  42. package/build/jwt/error.d.ts +0 -2
  43. package/build/jwt/error.js +0 -7
  44. package/build/jwt/error.js.map +0 -1
  45. package/build/jwt/index.d.ts +0 -2
  46. package/build/jwt/index.js +0 -19
  47. package/build/jwt/index.js.map +0 -1
  48. package/build/jwt/jwt.d.ts +0 -208
  49. package/build/jwt/jwt.js +0 -325
  50. package/build/jwt/jwt.js.map +0 -1
  51. package/build/keyBinding/index.d.ts +0 -1
  52. package/build/keyBinding/index.js +0 -18
  53. package/build/keyBinding/index.js.map +0 -1
  54. package/build/keyBinding/keyBinding.d.ts +0 -64
  55. package/build/keyBinding/keyBinding.js +0 -119
  56. package/build/keyBinding/keyBinding.js.map +0 -1
  57. package/build/sdJwt/decoys.d.ts +0 -3
  58. package/build/sdJwt/decoys.js +0 -35
  59. package/build/sdJwt/decoys.js.map +0 -1
  60. package/build/sdJwt/disclosureFrame.d.ts +0 -8
  61. package/build/sdJwt/disclosureFrame.js +0 -87
  62. package/build/sdJwt/disclosureFrame.js.map +0 -1
  63. package/build/sdJwt/disclosures.d.ts +0 -33
  64. package/build/sdJwt/disclosures.js +0 -114
  65. package/build/sdJwt/disclosures.js.map +0 -1
  66. package/build/sdJwt/error.d.ts +0 -2
  67. package/build/sdJwt/error.js +0 -7
  68. package/build/sdJwt/error.js.map +0 -1
  69. package/build/sdJwt/index.d.ts +0 -6
  70. package/build/sdJwt/index.js +0 -23
  71. package/build/sdJwt/index.js.map +0 -1
  72. package/build/sdJwt/sdJwt.d.ts +0 -206
  73. package/build/sdJwt/sdJwt.js +0 -442
  74. package/build/sdJwt/sdJwt.js.map +0 -1
  75. package/build/sdJwt/types.d.ts +0 -5
  76. package/build/sdJwt/types.js +0 -3
  77. package/build/sdJwt/types.js.map +0 -1
  78. package/build/sdJwtVc/error.d.ts +0 -2
  79. package/build/sdJwtVc/error.js +0 -7
  80. package/build/sdJwtVc/error.js.map +0 -1
  81. package/build/sdJwtVc/index.d.ts +0 -2
  82. package/build/sdJwtVc/index.js +0 -19
  83. package/build/sdJwtVc/index.js.map +0 -1
  84. package/build/sdJwtVc/sdJwtVc.d.ts +0 -47
  85. package/build/sdJwtVc/sdJwtVc.js +0 -149
  86. package/build/sdJwtVc/sdJwtVc.js.map +0 -1
  87. package/build/signatureAndEncryptionAlgorithm.d.ts +0 -105
  88. package/build/signatureAndEncryptionAlgorithm.js +0 -110
  89. package/build/signatureAndEncryptionAlgorithm.js.map +0 -1
  90. package/build/types/disclosure.d.ts +0 -5
  91. package/build/types/disclosure.js +0 -3
  92. package/build/types/disclosure.js.map +0 -1
  93. package/build/types/index.d.ts +0 -5
  94. package/build/types/index.js +0 -22
  95. package/build/types/index.js.map +0 -1
  96. package/build/types/saltGenerator.d.ts +0 -17
  97. package/build/types/saltGenerator.js +0 -3
  98. package/build/types/saltGenerator.js.map +0 -1
  99. package/build/types/signer.d.ts +0 -2
  100. package/build/types/signer.js +0 -3
  101. package/build/types/signer.js.map +0 -1
  102. package/build/types/utils.d.ts +0 -2
  103. package/build/types/utils.js +0 -3
  104. package/build/types/utils.js.map +0 -1
  105. package/build/types/verifier.d.ts +0 -14
  106. package/build/types/verifier.js +0 -3
  107. package/build/types/verifier.js.map +0 -1
@@ -1,206 +0,0 @@
1
- import { PresentationFrame } from '@sd-jwt/present';
2
- import { Jwt, JwtAdditionalOptions, JwtVerificationResult } from '../jwt/jwt';
3
- import { KeyBinding } from '../keyBinding';
4
- import { DisclosureFrame, SaltGenerator, Verifier } from '../types';
5
- import { Disclosure, DisclosureWithDigest } from './disclosures';
6
- import { ReturnSdJwtWithHeaderAndPayload, ReturnSdJwtWithKeyBinding, ReturnSdJwtWithPayload } from './types';
7
- import { HasherAlgorithm, HasherAndAlgorithm } from '@sd-jwt/types';
8
- export type SdJwtToCompactOptions<DisclosablePayload extends Record<string, unknown>> = {
9
- disclosureFrame?: DisclosureFrame<DisclosablePayload>;
10
- shouldApplyFrame?: boolean;
11
- };
12
- export type SdJwtOptions<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
13
- header?: Header;
14
- payload?: Payload;
15
- signature?: Uint8Array;
16
- keyBinding?: KeyBinding;
17
- disclosures?: Array<Disclosure>;
18
- };
19
- export type SdJwtAdditionalOptions<Payload extends Record<string, unknown>> = JwtAdditionalOptions & {
20
- hasherAndAlgorithm?: HasherAndAlgorithm;
21
- saltGenerator?: SaltGenerator;
22
- disclosureFrame?: DisclosureFrame<Payload>;
23
- };
24
- export type SdJwtVerificationResult = JwtVerificationResult & {
25
- isKeyBindingValid?: boolean;
26
- };
27
- export declare class SdJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> extends Jwt<Header, Payload> {
28
- disclosures?: Array<Disclosure>;
29
- keyBinding?: KeyBinding;
30
- private saltGenerator?;
31
- private hasherAndAlgorithm?;
32
- disclosureFrame?: DisclosureFrame<Payload>;
33
- constructor(options?: SdJwtOptions<Header, Payload>, additionalOptions?: SdJwtAdditionalOptions<Payload>);
34
- /**
35
- *
36
- * Create an sd-jwt from a compact format. This will succeed for a normal jwt as well.
37
- *
38
- */
39
- static fromCompact<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(compact: string): ReturnSdJwtWithHeaderAndPayload<Header, Payload, SdJwt<Header, Payload>>;
40
- /**
41
- *
42
- * Add a salt generator.
43
- *
44
- * Recommended size is 128 bits (i.e. 16 bytes).
45
- *
46
- * Salts will not be seeded and a new one will be used for each claim.
47
- *
48
- * @example
49
- *
50
- * Node.js: `crypto.randomBytes(128 / 8)`
51
- *
52
- * React Native: `expo-standard-web-crypto`
53
- *
54
- * Browser: `crypto.getRandomValues(new Uint8Array(128 / 8))`
55
- *
56
- */
57
- withSaltGenerator(saltGenerator: SaltGenerator): this;
58
- /**
59
- *
60
- * Add a hasher that will be used to hash the disclosures.
61
- *
62
- * @note Make sure to return a base64url encoded version of the hash.
63
- *
64
- * @example
65
- *
66
- * Node.js: `createHash('sha256').update(input).digest().toString('base64url')`
67
- *
68
- */
69
- withHasher(hasherAndAlgorithm: HasherAndAlgorithm): ReturnSdJwtWithPayload<Header, Payload, this>;
70
- /**
71
- *
72
- * Adds the algorithm of the hasher to the payload.
73
- *
74
- * For convience, this also allows you to set the hasher.
75
- *
76
- * @throws when the hasher and algorithm are not set.
77
- *
78
- */
79
- addHasherAlgorithmToPayload(hasherAndAlgorithm?: HasherAndAlgorithm): ReturnSdJwtWithPayload<Header, Payload, this>;
80
- /**
81
- *
82
- * Set the `KeyBinding` jwt.
83
- *
84
- * This can be done as a holder to provide proof of possession of key material
85
- *
86
- */
87
- withKeyBinding(keyBinding: Jwt | KeyBinding<any, any> | string): ReturnSdJwtWithKeyBinding<Header, Payload, this>;
88
- /**
89
- *
90
- * Set the disclosure frame which will be applied via `SdJwt.applyDisclosureFrame` or when `SdJwt.toCompact` is called.
91
- *
92
- */
93
- withDisclosureFrame(disclosureFrame: DisclosureFrame<Payload>): this;
94
- /**
95
- *
96
- * Apply the disclosure frame.
97
- *
98
- * @throws when the salt generator is not set
99
- * @throws when the hasher and algorithm is not set
100
- * @throws when the payload is not set
101
- * @throws when no disclosure frame is set
102
- * @throws when disclosures are included and a signature is set, but no signer is provided `*`
103
- * @throws when the disclosure frame is inconsistent with the payload
104
- *
105
- * * This is done as removing items from the payload alters the signature and it has to be resigned.
106
- *
107
- */
108
- applyDisclosureFrame(): Promise<void>;
109
- disclosuresWithDigest(): Promise<DisclosureWithDigest[] | undefined>;
110
- /**
111
- *
112
- * Assert that the disclosure frame is set.
113
- *
114
- */
115
- assertDisclosureFrame(): void;
116
- /**
117
- *
118
- * Assert that the salt generator is set.
119
- *
120
- */
121
- private assertSaltGenerator;
122
- /**
123
- *
124
- * Assert that the hasher and algorithm is set.
125
- *
126
- */
127
- private assertHashAndAlgorithm;
128
- /**
129
- *
130
- * Assert that a certain claim is included in the disclosure frame.
131
- *
132
- * @throws when the disclosure frame is not set
133
- *
134
- */
135
- assertClaimInDisclosureFrame(claimKey: string): void;
136
- /**
137
- * This function creates a presentation of an SD-JWT, based on the presentation frame. The
138
- * presentation frame is similar to the disclosure frame, and allows you to present a subset
139
- * of the disclosures.
140
- *
141
- * If no `presentationFrame` is passed, the entire SD-JWT will be presented.
142
- * To create a presentation without any of the disclosures, pass an empty object as the `presentationFrame`.
143
- *
144
- * @example
145
- * The following example will expose `name`, `a.nested`, and `orderItems[0]` and `orderItems[2]`.
146
- * Based on the disclosures it will also expose the parent and child disclosures when needed.
147
- * E.g. if `a` can only be disclosed as a whole, disclosing `a.nested` will also disclose `a`.
148
- * The same is true for child disclosures. If you expose `name`, and it potentially contains recursive
149
- * disclosures, all disclosures under name will be disclosed as well.
150
- * ```ts
151
- * await sdJwt.present({
152
- * name: true,
153
- * a: {
154
- * nested: 'property'
155
- * }
156
- * orderItems: [true, false, true]
157
- * })
158
- * ```
159
- *
160
- * @throws when the presentation frame does not match the decoded/pretty payload of the sd-jwt
161
- * @throws when the presentation frame contains fields other than object, array or boolean
162
- *
163
- */
164
- present(presentationFrame?: PresentationFrame<Payload>): Promise<string>;
165
- /**
166
- *
167
- * Verify the sd-jwt.
168
- *
169
- * It validates the following properties:
170
- * - sd-jwt issuer signature
171
- * - Optionally, the required claims
172
- * - The `nbf` and `exp` claims
173
- * - Whether the key binding is valid
174
- *
175
- */
176
- verify(verifier: Verifier<Header>, requiredClaimKeys?: Array<keyof Payload | string>, kbJwtPublicKeyJwk?: Record<string, unknown>, issuerPublicKeyJwk?: Record<string, unknown>): Promise<SdJwtVerificationResult>;
177
- /**
178
- *
179
- * Utility method to check whether the expected hasher algorithm is used.
180
- *
181
- */
182
- checkHasher(expectedHasher: HasherAlgorithm | string): boolean;
183
- assertNonSelectivelyDisclosableClaim(claimKey: string): void;
184
- assertNonSelectivelyDisclosableClaims(): void;
185
- /**
186
- *
187
- * Return all claims from the payload and the disclosures on their original place.
188
- *
189
- */
190
- getPrettyClaims<Claims extends Record<string, unknown> = Payload>(): Promise<Claims>;
191
- /**
192
- *
193
- * Create a compact format of the sd-jwt.
194
- *
195
- * This will
196
- * - Apply the disclosure frame
197
- * - Add a signature if there is none
198
- *
199
- * @throws When the signature and signer are not defined
200
- * @throws When a claim is requested to be selectively disclosable, but it was not found in the payload
201
- *
202
- */
203
- toCompact(): Promise<string>;
204
- private __toCompact;
205
- private calculateSdHash;
206
- }
@@ -1,442 +0,0 @@
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.SdJwt = void 0;
13
- const decode_1 = require("@sd-jwt/decode");
14
- const present_1 = require("@sd-jwt/present");
15
- const utils_1 = require("@sd-jwt/utils");
16
- const jwt_1 = require("../jwt/jwt");
17
- const keyBinding_1 = require("../keyBinding");
18
- const disclosureFrame_1 = require("./disclosureFrame");
19
- const disclosures_1 = require("./disclosures");
20
- const error_1 = require("./error");
21
- class SdJwt extends jwt_1.Jwt {
22
- constructor(options, additionalOptions) {
23
- super(options, additionalOptions);
24
- this.header = options === null || options === void 0 ? void 0 : options.header;
25
- this.payload = options === null || options === void 0 ? void 0 : options.payload;
26
- this.signature = options === null || options === void 0 ? void 0 : options.signature;
27
- this.disclosures = options === null || options === void 0 ? void 0 : options.disclosures;
28
- this.keyBinding = options === null || options === void 0 ? void 0 : options.keyBinding;
29
- if (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hasherAndAlgorithm) {
30
- this.withHasher(additionalOptions.hasherAndAlgorithm);
31
- }
32
- if (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.saltGenerator) {
33
- this.withSaltGenerator(additionalOptions.saltGenerator);
34
- }
35
- if (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.disclosureFrame) {
36
- this.withDisclosureFrame(additionalOptions.disclosureFrame);
37
- }
38
- if (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.signer) {
39
- this.withSigner(additionalOptions.signer);
40
- }
41
- }
42
- /**
43
- *
44
- * Create an sd-jwt from a compact format. This will succeed for a normal jwt as well.
45
- *
46
- */
47
- static fromCompact(compact) {
48
- const { disclosures: d, keyBinding: kb, signature, payload, header } = (0, decode_1.sdJwtFromCompact)(compact);
49
- const disclosures = d === null || d === void 0 ? void 0 : d.map((disclosure) => new disclosures_1.Disclosure(disclosure.salt, disclosure.value, disclosure.key));
50
- const keyBinding = kb
51
- ? new keyBinding_1.KeyBinding()
52
- .withHeader(kb.header)
53
- .withPayload(kb.payload)
54
- .withSignature(kb.signature)
55
- : undefined;
56
- const sdJwt = new SdJwt({
57
- header,
58
- payload,
59
- signature,
60
- disclosures,
61
- keyBinding
62
- });
63
- sdJwt.compact = compact;
64
- return sdJwt;
65
- }
66
- /**
67
- *
68
- * Add a salt generator.
69
- *
70
- * Recommended size is 128 bits (i.e. 16 bytes).
71
- *
72
- * Salts will not be seeded and a new one will be used for each claim.
73
- *
74
- * @example
75
- *
76
- * Node.js: `crypto.randomBytes(128 / 8)`
77
- *
78
- * React Native: `expo-standard-web-crypto`
79
- *
80
- * Browser: `crypto.getRandomValues(new Uint8Array(128 / 8))`
81
- *
82
- */
83
- withSaltGenerator(saltGenerator) {
84
- this.saltGenerator = saltGenerator;
85
- return this;
86
- }
87
- /**
88
- *
89
- * Add a hasher that will be used to hash the disclosures.
90
- *
91
- * @note Make sure to return a base64url encoded version of the hash.
92
- *
93
- * @example
94
- *
95
- * Node.js: `createHash('sha256').update(input).digest().toString('base64url')`
96
- *
97
- */
98
- withHasher(hasherAndAlgorithm) {
99
- this.hasherAndAlgorithm = hasherAndAlgorithm;
100
- return this;
101
- }
102
- /**
103
- *
104
- * Adds the algorithm of the hasher to the payload.
105
- *
106
- * For convience, this also allows you to set the hasher.
107
- *
108
- * @throws when the hasher and algorithm are not set.
109
- *
110
- */
111
- addHasherAlgorithmToPayload(hasherAndAlgorithm) {
112
- if (hasherAndAlgorithm)
113
- this.withHasher(hasherAndAlgorithm);
114
- this.assertHashAndAlgorithm();
115
- this.addPayloadClaim('_sd_alg', this.hasherAndAlgorithm.algorithm);
116
- return this;
117
- }
118
- /**
119
- *
120
- * Set the `KeyBinding` jwt.
121
- *
122
- * This can be done as a holder to provide proof of possession of key material
123
- *
124
- */
125
- withKeyBinding(keyBinding) {
126
- const kb = typeof keyBinding === 'string'
127
- ? keyBinding_1.KeyBinding.fromCompact(keyBinding)
128
- : keyBinding instanceof keyBinding_1.KeyBinding
129
- ? keyBinding
130
- : keyBinding_1.KeyBinding.fromJwt(keyBinding);
131
- this.keyBinding = kb;
132
- return this;
133
- }
134
- /**
135
- *
136
- * Set the disclosure frame which will be applied via `SdJwt.applyDisclosureFrame` or when `SdJwt.toCompact` is called.
137
- *
138
- */
139
- withDisclosureFrame(disclosureFrame) {
140
- this.disclosureFrame = disclosureFrame;
141
- return this;
142
- }
143
- /**
144
- *
145
- * Apply the disclosure frame.
146
- *
147
- * @throws when the salt generator is not set
148
- * @throws when the hasher and algorithm is not set
149
- * @throws when the payload is not set
150
- * @throws when no disclosure frame is set
151
- * @throws when disclosures are included and a signature is set, but no signer is provided `*`
152
- * @throws when the disclosure frame is inconsistent with the payload
153
- *
154
- * * This is done as removing items from the payload alters the signature and it has to be resigned.
155
- *
156
- */
157
- applyDisclosureFrame() {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- this.assertSaltGenerator();
160
- this.assertHashAndAlgorithm();
161
- this.assertPayload();
162
- this.assertDisclosureFrame();
163
- if (this.disclosures &&
164
- this.disclosures.length > 0 &&
165
- this.signature &&
166
- !this.signer) {
167
- throw new error_1.SdJwtError('Signature is already set by the user when selectively disclosable items still have to be removed. This will invalidate the signature. Try to provide a signer on SdJwt.withSigner and SdJwt.toCompact will call it at the correct time.');
168
- }
169
- const { payload: framedPayload, disclosures } = yield (0, disclosureFrame_1.applyDisclosureFrame)(this.saltGenerator, this.hasherAndAlgorithm, this.addHasherAlgorithmToPayload().payload, this.disclosureFrame);
170
- this.disclosures = disclosures;
171
- this.payload = framedPayload;
172
- });
173
- }
174
- disclosuresWithDigest() {
175
- return __awaiter(this, void 0, void 0, function* () {
176
- this.assertHashAndAlgorithm();
177
- if (!this.disclosures && this.disclosureFrame) {
178
- yield this.applyDisclosureFrame();
179
- }
180
- if (!this.disclosures)
181
- return undefined;
182
- return Promise.all(this.disclosures.map((d) => d.withCalculateDigest(this.hasherAndAlgorithm)));
183
- });
184
- }
185
- /**
186
- *
187
- * Assert that the disclosure frame is set.
188
- *
189
- */
190
- assertDisclosureFrame() {
191
- if (this.disclosureFrame)
192
- return;
193
- throw new error_1.SdJwtError('Disclosureframe must be defined');
194
- }
195
- /**
196
- *
197
- * Assert that the salt generator is set.
198
- *
199
- */
200
- assertSaltGenerator() {
201
- if (!this.saltGenerator) {
202
- throw new error_1.SdJwtError('Cannot create a disclosure without a salt generator. You can set it with this.withSaltGenerator()');
203
- }
204
- }
205
- /**
206
- *
207
- * Assert that the hasher and algorithm is set.
208
- *
209
- */
210
- assertHashAndAlgorithm() {
211
- if (!this.hasherAndAlgorithm) {
212
- throw new error_1.SdJwtError('A hasher and algorithm must be set in order to create a digests for disclosures or integrity protection of a kb-jwt. You can set it with this.withHasher()');
213
- }
214
- }
215
- /**
216
- *
217
- * Assert that a certain claim is included in the disclosure frame.
218
- *
219
- * @throws when the disclosure frame is not set
220
- *
221
- */
222
- assertClaimInDisclosureFrame(claimKey) {
223
- this.assertDisclosureFrame();
224
- const value = (0, utils_1.getValueByKeyAnyLevel)(this.disclosureFrame, claimKey);
225
- if (!value) {
226
- throw new error_1.SdJwtError(`Claim key '${claimKey}' not found in any level of the disclosureFrame`);
227
- }
228
- }
229
- /**
230
- * This function creates a presentation of an SD-JWT, based on the presentation frame. The
231
- * presentation frame is similar to the disclosure frame, and allows you to present a subset
232
- * of the disclosures.
233
- *
234
- * If no `presentationFrame` is passed, the entire SD-JWT will be presented.
235
- * To create a presentation without any of the disclosures, pass an empty object as the `presentationFrame`.
236
- *
237
- * @example
238
- * The following example will expose `name`, `a.nested`, and `orderItems[0]` and `orderItems[2]`.
239
- * Based on the disclosures it will also expose the parent and child disclosures when needed.
240
- * E.g. if `a` can only be disclosed as a whole, disclosing `a.nested` will also disclose `a`.
241
- * The same is true for child disclosures. If you expose `name`, and it potentially contains recursive
242
- * disclosures, all disclosures under name will be disclosed as well.
243
- * ```ts
244
- * await sdJwt.present({
245
- * name: true,
246
- * a: {
247
- * nested: 'property'
248
- * }
249
- * orderItems: [true, false, true]
250
- * })
251
- * ```
252
- *
253
- * @throws when the presentation frame does not match the decoded/pretty payload of the sd-jwt
254
- * @throws when the presentation frame contains fields other than object, array or boolean
255
- *
256
- */
257
- present(presentationFrame) {
258
- var _a;
259
- return __awaiter(this, void 0, void 0, function* () {
260
- if (!this.disclosures && this.disclosureFrame) {
261
- yield this.applyDisclosureFrame();
262
- }
263
- // TODO: wouldn't it be easier if this returned the value so we don't have to use !
264
- this.assertHashAndAlgorithm();
265
- this.assertPayload();
266
- // If no presentationFrame is passed, we want to disclose everything
267
- if (!presentationFrame) {
268
- return yield this.__toCompact(this.disclosures, false);
269
- }
270
- if ((Object.keys(presentationFrame).length > 0 && !this.disclosures) ||
271
- ((_a = this.disclosures) === null || _a === void 0 ? void 0 : _a.length) === 0) {
272
- throw new error_1.SdJwtError('Cannot create a presentation with disclosures while no disclosures are on the sd-jwt');
273
- }
274
- // Calculate the digests for all disclosures
275
- const disclosuresWithDigest = yield this.disclosuresWithDigest();
276
- const requiredDisclosures = (0, present_1.getDisclosuresForPresentationFrame)(this.payload, presentationFrame, yield this.getPrettyClaims(), disclosuresWithDigest === null || disclosuresWithDigest === void 0 ? void 0 : disclosuresWithDigest.map((d) => d.asJson()));
277
- return yield this.__toCompact(requiredDisclosures.map((d) => disclosures_1.Disclosure.fromJson(d)), false);
278
- });
279
- }
280
- /**
281
- *
282
- * Verify the sd-jwt.
283
- *
284
- * It validates the following properties:
285
- * - sd-jwt issuer signature
286
- * - Optionally, the required claims
287
- * - The `nbf` and `exp` claims
288
- * - Whether the key binding is valid
289
- *
290
- */
291
- verify(verifier, requiredClaimKeys, kbJwtPublicKeyJwk, issuerPublicKeyJwk) {
292
- const _super = Object.create(null, {
293
- verify: { get: () => super.verify }
294
- });
295
- var _a;
296
- return __awaiter(this, void 0, void 0, function* () {
297
- this.assertSignature();
298
- if (this.keyBinding) {
299
- this.assertHashAndAlgorithm();
300
- }
301
- const jwtVerificationResult = (yield _super.verify.call(this, verifier, requiredClaimKeys, issuerPublicKeyJwk));
302
- if (this.keyBinding) {
303
- if (!this.keyBinding.expectedSdHash) {
304
- // Calculate and set expected _sd_hash
305
- const sdHash = yield this.calculateSdHash();
306
- this.keyBinding.withExpectedSdHash(sdHash);
307
- }
308
- const { isValid } = yield this.keyBinding.verify(verifier, [], kbJwtPublicKeyJwk);
309
- jwtVerificationResult.isKeyBindingValid = isValid;
310
- }
311
- const claimKeys = (0, utils_1.getAllKeys)(this.payload).concat(((_a = this.disclosures) !== null && _a !== void 0 ? _a : []).map((d) => d.decoded[1]));
312
- if (requiredClaimKeys) {
313
- jwtVerificationResult.areRequiredClaimsIncluded =
314
- requiredClaimKeys.every((key) => claimKeys.includes(key));
315
- }
316
- return Object.assign(Object.assign({}, jwtVerificationResult), { isValid: Object.entries(jwtVerificationResult)
317
- .filter(([key, value]) => typeof value === 'boolean' && key !== 'isValid')
318
- .every(([, value]) => !!value) });
319
- });
320
- }
321
- /**
322
- *
323
- * Utility method to check whether the expected hasher algorithm is used.
324
- *
325
- */
326
- checkHasher(expectedHasher) {
327
- try {
328
- this.assertPayload();
329
- this.assertClaimInPayload('_sd_alg', expectedHasher.toString());
330
- return true;
331
- }
332
- catch (e) {
333
- console.error(e);
334
- return false;
335
- }
336
- }
337
- assertNonSelectivelyDisclosableClaim(claimKey) {
338
- try {
339
- this.assertClaimInDisclosureFrame(claimKey);
340
- }
341
- catch (error) {
342
- // Check if it's an SdJwtError (to prevent other errors making the method not throw)
343
- if (error instanceof error_1.SdJwtError)
344
- return;
345
- }
346
- throw new error_1.SdJwtError(`Claim key '${claimKey}' was found in the disclosure frame. This claim is not allowed to be selectively disclosed`);
347
- }
348
- assertNonSelectivelyDisclosableClaims() {
349
- if (!this.disclosureFrame)
350
- return;
351
- // NOTE: we don't include any properties here as it is a SHOULD
352
- // in the spec, and not a MUST
353
- for (const claimKey of ['_sd', '_sd_alg', '...']) {
354
- this.assertNonSelectivelyDisclosableClaim(claimKey);
355
- }
356
- }
357
- /**
358
- *
359
- * Return all claims from the payload and the disclosures on their original place.
360
- *
361
- */
362
- getPrettyClaims() {
363
- var _a;
364
- return __awaiter(this, void 0, void 0, function* () {
365
- this.assertPayload();
366
- this.assertHashAndAlgorithm();
367
- const disclosuresWithDigest = yield this.disclosuresWithDigest();
368
- const newPayload = (0, decode_1.decodeDisclosuresInPayload)(this.payload, (_a = disclosuresWithDigest === null || disclosuresWithDigest === void 0 ? void 0 : disclosuresWithDigest.map((d) => d.asJson())) !== null && _a !== void 0 ? _a : []);
369
- return newPayload;
370
- });
371
- }
372
- /**
373
- *
374
- * Create a compact format of the sd-jwt.
375
- *
376
- * This will
377
- * - Apply the disclosure frame
378
- * - Add a signature if there is none
379
- *
380
- * @throws When the signature and signer are not defined
381
- * @throws When a claim is requested to be selectively disclosable, but it was not found in the payload
382
- *
383
- */
384
- toCompact() {
385
- return __awaiter(this, void 0, void 0, function* () {
386
- return this.__toCompact();
387
- });
388
- }
389
- __toCompact(disclosures = this.disclosures, shouldApplyFrame = true) {
390
- var _a, _b, _c, _d, _e;
391
- return __awaiter(this, void 0, void 0, function* () {
392
- this.assertHeader();
393
- this.assertPayload();
394
- if (this.keyBinding && !this.keyBinding.expectedSdHash) {
395
- this.assertHashAndAlgorithm();
396
- }
397
- if (this.disclosureFrame && shouldApplyFrame) {
398
- yield this.applyDisclosureFrame();
399
- }
400
- disclosures !== null && disclosures !== void 0 ? disclosures : (disclosures = this.disclosures);
401
- const compactHeader = utils_1.Base64url.encode(JSON.stringify(this.header));
402
- const compactPayload = utils_1.Base64url.encode(JSON.stringify(this.payload));
403
- const sSignature = this.signature
404
- ? utils_1.Base64url.encode(this.signature)
405
- : utils_1.Base64url.encode((yield this.signAndAdd()).signature);
406
- const sDisclosures = disclosures && disclosures.length > 0
407
- ? `~${disclosures.join('~')}~`
408
- : '~';
409
- const sdJwtWithoutKb = `${compactHeader}.${compactPayload}.${sSignature}${sDisclosures}`;
410
- if (this.keyBinding) {
411
- const sdHash = (_a = this.keyBinding.expectedSdHash) !== null && _a !== void 0 ? _a : (yield this.calculateSdHash(sdJwtWithoutKb));
412
- if (this.keyBinding.signature &&
413
- !((_b = this.keyBinding.payload) === null || _b === void 0 ? void 0 : _b._sd_hash)) {
414
- throw new error_1.SdJwtError("Key binding is already signed, but missing _sd_hash. If you're manually signing the kb-jwt, make sure the correct _sd_hash is set.");
415
- }
416
- // If the signature is already set we don't want to add the _sd_hash ourselves
417
- // Also the signature won't be re-calculated if it's already set -- this seems like a security issue to me
418
- if (!this.keyBinding.signature &&
419
- !((_c = this.keyBinding.payload) === null || _c === void 0 ? void 0 : _c._sd_hash)) {
420
- this.keyBinding.withSdHashClaim(sdHash);
421
- }
422
- // Make sure the sd_hash is valid. If there's already a signature set
423
- // this will ensure the signature was made with the correct _sd_hash
424
- yield this.keyBinding.assertValidForKeyBinding(sdHash);
425
- }
426
- const kb = (_e = (yield ((_d = this.keyBinding) === null || _d === void 0 ? void 0 : _d.toCompact()))) !== null && _e !== void 0 ? _e : '';
427
- return sdJwtWithoutKb + kb;
428
- });
429
- }
430
- calculateSdHash(compact) {
431
- return __awaiter(this, void 0, void 0, function* () {
432
- this.assertHashAndAlgorithm();
433
- const c = compact !== null && compact !== void 0 ? compact : this.compact;
434
- if (!c) {
435
- throw new error_1.SdJwtError("Unable to calculate _sd_hash for sd-jwt, without 'compact' variant to compare _sd_hash. Use `fromCompact`, or call `sdJwt.keyBinding.withExpectedSdHash` to set the expected _sd_hash.");
436
- }
437
- return (0, decode_1.calculateSdHash)(c, this.hasherAndAlgorithm);
438
- });
439
- }
440
- }
441
- exports.SdJwt = SdJwt;
442
- //# sourceMappingURL=sdJwt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdJwt.js","sourceRoot":"","sources":["../../src/sdJwt/sdJwt.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAIuB;AACvB,6CAGwB;AACxB,yCAA4E;AAC5E,oCAA6E;AAC7E,8CAA0C;AAE1C,uDAAwD;AACxD,+CAAgE;AAChE,mCAAoC;AAqCpC,MAAa,KAGX,SAAQ,SAAoB;IAQ1B,YACI,OAAuC,EACvC,iBAAmD;QAEnD,KAAK,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;QACnC,IAAI,CAAC,WAAW,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA;QACvC,IAAI,CAAC,UAAU,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA;QAErC,IAAI,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,kBAAkB,EAAE,CAAC;YACxC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,aAAa,EAAE,CAAC;YACnC,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,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AAO,0CAAE,QAAQ,CAAA,EACpC,CAAC;oBACC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;gBAC3C,CAAC;gBAED,qEAAqE;gBACrE,oEAAoE;gBACpE,MAAM,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;YAC1D,CAAC;YAED,MAAM,EAAE,GAAG,MAAA,CAAC,MAAM,CAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,SAAS,EAAE,CAAA,CAAC,mCAAI,EAAE,CAAA;YACrD,OAAO,cAAc,GAAG,EAAE,CAAA;;KAC7B;IAEa,eAAe,CAAC,OAAgB;;YAC1C,IAAI,CAAC,sBAAsB,EAAE,CAAA;YAC7B,MAAM,CAAC,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,OAAO,CAAA;YAEjC,IAAI,CAAC,CAAC,EAAE,CAAC;gBACL,MAAM,IAAI,kBAAU,CAChB,wLAAwL,CAC3L,CAAA;YACL,CAAC;YAED,OAAO,IAAA,wBAAe,EAAC,CAAC,EAAE,IAAI,CAAC,kBAAmB,CAAC,CAAA;QACvD,CAAC;KAAA;CACJ;AAlkBD,sBAkkBC"}
@@ -1,5 +0,0 @@
1
- import { MakePropertyRequired } from '../types';
2
- import { SdJwt } from './sdJwt';
3
- export type ReturnSdJwtWithHeaderAndPayload<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends SdJwt<H, P>> = MakePropertyRequired<T, 'header' | 'payload'>;
4
- export type ReturnSdJwtWithPayload<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends SdJwt<H, P>> = MakePropertyRequired<T, 'payload'>;
5
- export type ReturnSdJwtWithKeyBinding<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends SdJwt<H, P>> = MakePropertyRequired<T, 'keyBinding'>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sdJwt/types.ts"],"names":[],"mappings":""}