@sd-jwt/core 0.1.2-alpha.8 → 0.1.2-alpha.9

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 (51) hide show
  1. package/build/index.d.ts +3 -1
  2. package/build/index.js +1 -0
  3. package/build/index.js.map +1 -1
  4. package/build/jwt/jwt.js +1 -1
  5. package/build/jwt/jwt.js.map +1 -1
  6. package/build/sdJwt/decoys.d.ts +2 -2
  7. package/build/sdJwt/decoys.js +2 -2
  8. package/build/sdJwt/decoys.js.map +1 -1
  9. package/build/sdJwt/disclosureFrame.d.ts +3 -3
  10. package/build/sdJwt/disclosureFrame.js +6 -6
  11. package/build/sdJwt/disclosureFrame.js.map +1 -1
  12. package/build/sdJwt/disclosures.d.ts +7 -3
  13. package/build/sdJwt/disclosures.js +25 -9
  14. package/build/sdJwt/disclosures.js.map +1 -1
  15. package/build/sdJwt/index.d.ts +0 -1
  16. package/build/sdJwt/index.js +0 -1
  17. package/build/sdJwt/index.js.map +1 -1
  18. package/build/sdJwt/sdJwt.d.ts +4 -4
  19. package/build/sdJwt/sdJwt.js +12 -13
  20. package/build/sdJwt/sdJwt.js.map +1 -1
  21. package/build/types/disclosure.d.ts +1 -1
  22. package/build/types/hasher.d.ts +4 -8
  23. package/build/types/index.d.ts +0 -1
  24. package/build/types/index.js +0 -1
  25. package/build/types/index.js.map +1 -1
  26. package/build/types/utils.d.ts +0 -3
  27. package/package.json +6 -5
  28. package/build/sdJwt/disclosureMapping.d.ts +0 -43
  29. package/build/sdJwt/disclosureMapping.js +0 -278
  30. package/build/sdJwt/disclosureMapping.js.map +0 -1
  31. package/build/sdJwt/presentationFrame.d.ts +0 -3
  32. package/build/sdJwt/presentationFrame.js +0 -64
  33. package/build/sdJwt/presentationFrame.js.map +0 -1
  34. package/build/sdJwt/swapClaim.d.ts +0 -2
  35. package/build/sdJwt/swapClaim.js +0 -79
  36. package/build/sdJwt/swapClaim.js.map +0 -1
  37. package/build/types/frame.d.ts +0 -5
  38. package/build/types/frame.js +0 -3
  39. package/build/types/frame.js.map +0 -1
  40. package/build/types/present.d.ts +0 -2
  41. package/build/types/present.js +0 -3
  42. package/build/types/present.js.map +0 -1
  43. package/build/utils/index.d.ts +0 -2
  44. package/build/utils/index.js +0 -19
  45. package/build/utils/index.js.map +0 -1
  46. package/build/utils/traverse.d.ts +0 -8
  47. package/build/utils/traverse.js +0 -29
  48. package/build/utils/traverse.js.map +0 -1
  49. package/build/utils/utils.d.ts +0 -8
  50. package/build/utils/utils.js +0 -118
  51. package/build/utils/utils.js.map +0 -1
@@ -1,278 +0,0 @@
1
- "use strict";
2
- // This file contains helpers functions for mapping between disclosures entries and the payload of an SD-JWT.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getDisclosureMap = exports.getPayloadDisclosureMapping = void 0;
5
- const utils_1 = require("../utils");
6
- const error_1 = require("./error");
7
- /**
8
- * Returns an array that includes the digests that should be disclosed for each item in the array.
9
- *
10
- * E.g. if the following array is passed:
11
- * ```ts
12
- * [ { '...': <SD_HASH_DIGEST_1> }, 'string_value', { '...': <SD_HASH_DIGEST_2> } ]
13
- * ```
14
- *
15
- * The return value will be:
16
- * ```ts
17
- * ['<SD_HASH_DIGEST_1>', null, '<SD_HASH_DIGEST_2>']
18
- * ```
19
- *
20
- * The second value will be null, as it's already disclosed, and thus there's no digests that
21
- * need to be disclosed to reveal it. For the other values, it will include the digest that needs
22
- * to be disclosed to reveal that array entry.
23
- *
24
- * In the case the array entry contains nested disclosures, the value will not be a digest, but rather
25
- * the structure of the nested disclosures.
26
- *
27
- * Let's say the `<SD_HASH_DIGEST_1>` is the digest of the following disclosure:
28
- * ```ts
29
- * {
30
- * // `<SD_HASH_DIGEST_3>` is the digest of the dateOfBirth property
31
- * _sd: ['<SD_HASH_DIGEST_3>'],
32
- * name: 'Jane Doe',
33
- * }
34
- * ```
35
- *
36
- * In this case the return value will be:
37
- * ```ts
38
- * [{ __digest: '<SD_HASH_DIGEST_1>', dateOfBirth: '<SD_HASH_DIGEST_3>' }, null, '<SD_HASH_DIGEST_2>']
39
- * ```
40
- * The `__digest` property indicates the digest of the encapsulating disclosure, and it being an object
41
- * indicates that there's nested disclosures that need to be revealed.
42
- *
43
- * In the end the result value is an array, and all the string values in the return value are the digests.
44
- * This allows you to easily build a path of digests to disclose to reveal a certain value.
45
- *
46
- * The return value can be endlessly nested, and will also call `getPayloadDisclosureMapping` recursively
47
- * if the inner values are not arrays, but objects. That method in turn can call this method if the value
48
- * of an object property is an array.
49
- */
50
- function getArrayPayloadDisclosureMapping(array, map) {
51
- const arrayPayloadDisclosureMapping = [];
52
- // Loop through all the payload values of the array
53
- for (const item of array) {
54
- // If the item is an object, (both array and object are objects)
55
- // it means there may be some values in here that need to be disclosed to
56
- // reveal this array entry
57
- if (item instanceof Object) {
58
- // if Array item is { '...': <SD_HASH_DIGEST> }
59
- // It means this item can be disclosed.
60
- if ('...' in item) {
61
- const digest = item['...'];
62
- if (typeof digest !== 'string') {
63
- throw new error_1.SdJwtError(`Expected value of key '...' to be of type string, but found ${typeof digest}`);
64
- }
65
- // Look up disclosure. It's valid that the disclosure is not present (decoy digests)
66
- const disclosed = map[digest];
67
- if (disclosed) {
68
- // value is always the last item in the disclosure array
69
- const value = [...disclosed.disclosure.decoded].pop();
70
- // Recursively look if the disclosed value contains any disclosure references
71
- // of itself. Based on the type we can decide how to handle it.
72
- if ((0, utils_1.isObject)(value)) {
73
- // Get nested disclosures for the object value
74
- const unpacked = getPayloadDisclosureMapping(value, map);
75
- // If there's any nested disclosures, we need to include both this item's
76
- // disclosure, as well as the nested disclosures
77
- if (unpacked && Object.keys(unpacked).length > 0) {
78
- arrayPayloadDisclosureMapping.push(Object.assign(Object.assign({}, unpacked), { __digest: digest }));
79
- }
80
- else {
81
- arrayPayloadDisclosureMapping.push(digest);
82
- }
83
- }
84
- else if (Array.isArray(value)) {
85
- // Get nested disclosures for the array value
86
- const nestedUnpackedArray = getArrayPayloadDisclosureMapping(value, map);
87
- // If all entries are null, it means there's no nested disclosures
88
- // And thus we push the digest directly
89
- if (nestedUnpackedArray.every((item) => item === null)) {
90
- arrayPayloadDisclosureMapping.push(digest);
91
- }
92
- else {
93
- arrayPayloadDisclosureMapping.push(Object.assign(Object.assign({}, nestedUnpackedArray), {
94
- // __digest is for encapsulating disclosure
95
- __digest: digest }));
96
- }
97
- }
98
- // If the value is not an object or a array, it means there's no nested disclosures
99
- // and thus we can push the digest directly
100
- else {
101
- arrayPayloadDisclosureMapping.push(digest);
102
- }
103
- }
104
- else {
105
- // Value is not a disclosure for an array ('...') so we unpack the object recursively
106
- const claims = getPayloadDisclosureMapping(item, map);
107
- if (claims && Object.keys(claims).length > 0) {
108
- arrayPayloadDisclosureMapping.push(claims);
109
- }
110
- else {
111
- arrayPayloadDisclosureMapping.push(null);
112
- }
113
- }
114
- }
115
- }
116
- // If the value is not an Object it means the actual value is disclosed
117
- // in the array directly (so we don't need to disclose anything to reveal it)
118
- else {
119
- arrayPayloadDisclosureMapping.push(null);
120
- }
121
- }
122
- return arrayPayloadDisclosureMapping;
123
- }
124
- /**
125
- * Get a mapping in the structure of the pretty payload, to indicate which digests should be disclosed for a
126
- * given entry.
127
- *
128
- * For example if you call this method with the following payload:
129
- * ```ts
130
- * {
131
- * _sd: ['iss_digest', 'nested_field_digest'],
132
- * }
133
- * ```
134
- *
135
- * It can return the following mapping:
136
- * ```ts
137
- * {
138
- * iss: 'iss_digest',
139
- * nested_field: {
140
- * __digest: 'nested_field_digest',
141
- * more_nested_field: {
142
- * // index 1 is null, as it's always in the payload, so doesn't need to be disclosed
143
- * // separately
144
- * a: ['a_0_digest', null, 'a_2_digest'],
145
- * }
146
- * }
147
- * }
148
- * ```
149
- *
150
- * This method will recursively call itself and `getArrayPayloadDisclosureMapping` if the value of a property is an object or array.
151
- */
152
- function getPayloadDisclosureMapping(payload, map) {
153
- // Handle array
154
- if (payload instanceof Array) {
155
- return getArrayPayloadDisclosureMapping(payload, map);
156
- }
157
- // Not an array or object, so it means the top-level value is already disclosed
158
- if (!(0, utils_1.isObject)(payload)) {
159
- return null;
160
- }
161
- const payloadDisclosureMapping = {};
162
- for (const key in payload) {
163
- // if obj property value is an object or array
164
- // recursively unpack
165
- if (key !== '_sd' && key !== '...' && payload[key] instanceof Object) {
166
- const claim = getPayloadDisclosureMapping(payload[key], map);
167
- if (claim && Object.keys(claim).length > 0) {
168
- payloadDisclosureMapping[key] = claim;
169
- }
170
- }
171
- }
172
- // If the payload contains a _sd property, it means there's disclosures
173
- if (payload._sd) {
174
- if (!Array.isArray(payload._sd)) {
175
- throw new error_1.SdJwtError(`Expect value of '_sd' to be of type array, but found ${typeof payload._sd}`);
176
- }
177
- // We are going to resolve all digests
178
- for (const digest of payload._sd) {
179
- if (typeof digest !== 'string') {
180
- throw new error_1.SdJwtError(`Expected entries in '_sd' property to be of type string, found ${typeof digest}`);
181
- }
182
- // Look up disclosure. It's valid that the disclosure is not present (decoy digests)
183
- const disclosed = map[digest];
184
- if (disclosed) {
185
- // value is always the last item in the disclosure array
186
- // We know this is an object, so the associated disclosure MUST have length 3
187
- const value = [...disclosed.disclosure.decoded].pop();
188
- if (disclosed.disclosure.decoded.length !== 3) {
189
- throw new error_1.SdJwtError(`Expected disclosure for value ${value} to have 3 items, but found ${disclosed.disclosure.decoded.length}`);
190
- }
191
- const key = disclosed.disclosure.decoded[1];
192
- // This checks if there's a nested disclosure anywhere down the tree
193
- // So when a disclosure value is an object or array, it can contain disclosures
194
- // of itself (using `_sd` and `...` keys)
195
- if ((0, utils_1.isObject)(value)) {
196
- const unpacked = getPayloadDisclosureMapping(value, map);
197
- if (unpacked && Object.keys(unpacked).length > 0) {
198
- payloadDisclosureMapping[key] = Object.assign(Object.assign({}, unpacked), { __digest: digest });
199
- }
200
- // If there's no nested disclosures, we add the digest directly
201
- else {
202
- payloadDisclosureMapping[key] = digest;
203
- }
204
- }
205
- else if (Array.isArray(value)) {
206
- // Get nested disclosures for the array value
207
- const nestedUnpackedArray = getArrayPayloadDisclosureMapping(value, map);
208
- // If all entries are null, it means there's no nested disclosures
209
- // And thus we push the digest directly
210
- if (nestedUnpackedArray.every((item) => item === null)) {
211
- payloadDisclosureMapping[key] = digest;
212
- }
213
- else {
214
- payloadDisclosureMapping[key] = Object.assign(Object.assign({}, nestedUnpackedArray), {
215
- // __digest is for encapsulating disclosure
216
- __digest: digest });
217
- }
218
- }
219
- else {
220
- payloadDisclosureMapping[key] = digest;
221
- }
222
- }
223
- }
224
- }
225
- return payloadDisclosureMapping;
226
- }
227
- exports.getPayloadDisclosureMapping = getPayloadDisclosureMapping;
228
- const getParentDisclosure = (disclosure, digestMap) => {
229
- const parent = digestMap[disclosure.digest];
230
- if (!parent) {
231
- return [];
232
- }
233
- if (digestMap[disclosure.digest]) {
234
- return [parent].concat(getParentDisclosure(parent, digestMap));
235
- }
236
- return [parent];
237
- };
238
- /**
239
- * Get a mapping from a digest to the corresponding disclosure and its parent disclosures.
240
- */
241
- const getDisclosureMap = (disclosures) => {
242
- const map = {};
243
- const parentMap = {};
244
- for (const disclosure of disclosures) {
245
- // value is always the last item in the disclosure array
246
- const value = [...disclosure.decoded].pop();
247
- (0, utils_1.traverseNodes)(value).forEach(({ path, value }) => {
248
- const lastPathItem = path[path.length - 1];
249
- if (lastPathItem === '_sd') {
250
- if (!Array.isArray(value)) {
251
- throw new error_1.SdJwtError(`Expect value of '_sd' to be of type array, but found ${typeof value}`);
252
- }
253
- value.forEach((digest) => {
254
- if (typeof digest !== 'string') {
255
- throw new error_1.SdJwtError(`Expected entries in '_sd' property to be of type string, found ${typeof digest}`);
256
- }
257
- parentMap[digest] = disclosure;
258
- });
259
- }
260
- else if (lastPathItem === '...') {
261
- if (typeof value !== 'string') {
262
- throw new error_1.SdJwtError(`Expected value of '...' to be of type string, but found ${typeof value}`);
263
- }
264
- parentMap[value] = disclosure;
265
- }
266
- });
267
- }
268
- for (const disclosure of disclosures) {
269
- const parent = getParentDisclosure(disclosure, parentMap);
270
- map[disclosure.digest] = {
271
- disclosure,
272
- parentDisclosures: parent
273
- };
274
- }
275
- return map;
276
- };
277
- exports.getDisclosureMap = getDisclosureMap;
278
- //# sourceMappingURL=disclosureMapping.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"disclosureMapping.js","sourceRoot":"","sources":["../../src/sdJwt/disclosureMapping.ts"],"names":[],"mappings":";AAAA,6GAA6G;;;AAE7G,oCAAkD;AAElD,mCAAoC;AAYpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,SAAS,gCAAgC,CACrC,KAAqB,EACrB,GAAkB;IAElB,MAAM,6BAA6B,GAAU,EAAE,CAAA;IAE/C,mDAAmD;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,gEAAgE;QAChE,yEAAyE;QACzE,0BAA0B;QAC1B,IAAI,IAAI,YAAY,MAAM,EAAE,CAAC;YACzB,+CAA+C;YAC/C,uCAAuC;YACvC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAChB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;gBAC1B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAC7B,MAAM,IAAI,kBAAU,CAChB,+DAA+D,OAAO,MAAM,EAAE,CACjF,CAAA;gBACL,CAAC;gBAED,oFAAoF;gBACpF,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;gBAC7B,IAAI,SAAS,EAAE,CAAC;oBACZ,wDAAwD;oBACxD,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAA;oBAErD,6EAA6E;oBAC7E,+DAA+D;oBAC/D,IAAI,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;wBAClB,8CAA8C;wBAC9C,MAAM,QAAQ,GAAG,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;w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,GAAG;YACrB,UAAU;YACV,iBAAiB,EAAE,MAAM;SAC5B,CAAA;IACL,CAAC;IAED,OAAO,GAAG,CAAA;AACd,CAAC,CAAA;AAjDY,QAAA,gBAAgB,oBAiD5B"}
@@ -1,3 +0,0 @@
1
- import { DisclosureWithDigest } from './disclosures';
2
- import { PresentationFrame } from '../types/present';
3
- export declare const getDisclosuresForPresentationFrame: <Payload extends Record<string, unknown> = Record<string, unknown>>(signedPayload: Payload, presentationFrame: PresentationFrame<Payload>, prettyClaims: Payload, disclosures?: Array<DisclosureWithDigest>) => Array<DisclosureWithDigest>;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDisclosuresForPresentationFrame = void 0;
4
- const utils_1 = require("../utils");
5
- const error_1 = require("./error");
6
- const disclosureMapping_1 = require("./disclosureMapping");
7
- const getDisclosuresForPresentationFrame = (signedPayload, presentationFrame, prettyClaims, disclosures = []) => {
8
- const requiredDisclosureDigests = new Set();
9
- const disclosureMap = (0, disclosureMapping_1.getDisclosureMap)(disclosures);
10
- const payloadDisclosureMapping = (0, disclosureMapping_1.getPayloadDisclosureMapping)(signedPayload, disclosureMap);
11
- // No disclosures needed
12
- if (payloadDisclosureMapping === null) {
13
- if (disclosures.length > 0) {
14
- throw new error_1.SdJwtError('Payload disclosure mapping is null, but disclosures are present.');
15
- }
16
- return [];
17
- }
18
- for (const node of (0, utils_1.traverseNodes)(presentationFrame)) {
19
- // We only want to process leaf nodes here
20
- if (!node.isLeaf)
21
- continue;
22
- if (typeof node.value !== 'boolean') {
23
- throw new error_1.SdJwtError(`Expected leaf value in presentation frame to be of type boolean, but found ${typeof node.value}`);
24
- }
25
- // If the value is false, it means we don't want to disclose it
26
- if (node.value === false)
27
- continue;
28
- if (!(0, utils_1.hasByPath)(prettyClaims, node.path)) {
29
- throw new error_1.SdJwtError(`Path ${node.path.join('.')} from presentation frame is not present in pretty SD-JWT payload. The presentation frame may only include properties that are present in the SD-JWT payload.`);
30
- }
31
- let path = [...node.path];
32
- while (!(0, utils_1.hasByPath)(payloadDisclosureMapping, path)) {
33
- if (path.pop() === undefined)
34
- break;
35
- }
36
- // There are no disclosures on this path, meaning the property is disclosed by default in the signed payload
37
- if (path.length === 0)
38
- continue;
39
- const disclosure = (0, utils_1.getByPath)(payloadDisclosureMapping, path);
40
- // If disclosure is string, it means it's already the digest
41
- if (typeof disclosure === 'string')
42
- requiredDisclosureDigests.add(disclosure);
43
- // Otherwise we want to get all the child digests as well
44
- else {
45
- for (const nestedItem of (0, utils_1.traverseNodes)(disclosure)) {
46
- if (!nestedItem.isLeaf ||
47
- typeof nestedItem.value !== 'string') {
48
- continue;
49
- }
50
- requiredDisclosureDigests.add(nestedItem.value);
51
- }
52
- }
53
- }
54
- for (const disclosureDigest of requiredDisclosureDigests.values()) {
55
- const disclosure = disclosureMap[disclosureDigest];
56
- if (!disclosure) {
57
- throw new Error('disclosure not found');
58
- }
59
- disclosure.parentDisclosures.forEach((d) => requiredDisclosureDigests.add(d.digest));
60
- }
61
- return Array.from(requiredDisclosureDigests).map((digest) => disclosureMap[digest].disclosure);
62
- };
63
- exports.getDisclosuresForPresentationFrame = getDisclosuresForPresentationFrame;
64
- //# sourceMappingURL=presentationFrame.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentationFrame.js","sourceRoot":"","sources":["../../src/sdJwt/presentationFrame.ts"],"names":[],"mappings":";;;AAAA,oCAA8D;AAE9D,mCAAoC;AAEpC,2DAG4B;AAErB,MAAM,kCAAkC,GAAG,CAG9C,aAAsB,EACtB,iBAA6C,EAC7C,YAAqB,EACrB,cAA2C,EAAE,EAClB,EAAE;IAC7B,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAU,CAAA;IACnD,MAAM,aAAa,GAAG,IAAA,oCAAgB,EAAC,WAAW,CAAC,CAAA;IACnD,MAAM,wBAAwB,GAAG,IAAA,+CAA2B,EACxD,aAAa,EACb,aAAa,CAChB,CAAA;IAED,wBAA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AC7C,yDAAyD;aACpD,CAAC;YACF,KAAK,MAAM,UAAU,IAAI,IAAA,qBAAa,EAAC,UAAU,CAAC,EAAE,CAAC;gBACjD,IACI,CAAC,UAAU,CAAC,MAAM;oBAClB,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ,EACtC,CAAC;oBACC,SAAQ;gBACZ,CAAC;gBACD,yBAAyB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YACnD,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,MAAM,gBAAgB,IAAI,yBAAyB,CAAC,MAAM,EAAE,EAAE,CAAC;QAChE,MAAM,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA;QAElD,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QAC3C,CAAC;QAED,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACvC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAC1C,CAAA;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,GAAG,CAC5C,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,UAAU,CAC/C,CAAA;AACL,CAAC,CAAA;AAxFY,QAAA,kCAAkC,sCAwF9C"}
@@ -1,2 +0,0 @@
1
- import { DisclosureWithDigest } from './disclosures';
2
- export declare const swapClaims: (payload: Record<string, unknown>, disclosures: DisclosureWithDigest[], newPayload?: Record<string, unknown>) => Record<string, unknown>;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.swapClaims = void 0;
4
- const shouldInsertDisclosure = (key, value, disclosures) => {
5
- if (key !== '_sd')
6
- return [];
7
- if (!Array.isArray(value))
8
- return [];
9
- const filteredDisclosures = [];
10
- for (const d of disclosures) {
11
- if (value.includes(d.digest)) {
12
- filteredDisclosures.push(d);
13
- }
14
- }
15
- return filteredDisclosures;
16
- };
17
- const shouldIncludeCleartextClaim = (key, value) => key !== '_sd' && key !== '_sd_alg' && typeof value !== 'object';
18
- const swapClaims = (payload, disclosures, newPayload = {}) => {
19
- const entries = Object.entries(payload);
20
- // Loop over de payload
21
- for (let i = 0; i < entries.length; i++) {
22
- const [key, value] = entries[i];
23
- // See whether we have an `_sd` key with an array of disclosures.
24
- const foundDisclosures = shouldInsertDisclosure(key, value, disclosures);
25
- // Add the disclosed items to the pretty payload
26
- foundDisclosures.forEach((d) => {
27
- const [, disclosureKey, disclosureValue] = d.decoded;
28
- newPayload[disclosureKey] = disclosureValue;
29
- });
30
- // Skip the rest as `_sd` is a special case
31
- if (key === '_sd') {
32
- continue;
33
- }
34
- // Include all the primitive claims into the new payload
35
- if (shouldIncludeCleartextClaim(key, value)) {
36
- newPayload[key] = value;
37
- continue;
38
- }
39
- if (typeof value === 'object' && Array.isArray(value)) {
40
- newPayload[key] = swapClaimsInsideArray(value, disclosures);
41
- continue;
42
- }
43
- if (typeof value === 'object' &&
44
- value !== null &&
45
- !Array.isArray(value)) {
46
- newPayload[key] = (0, exports.swapClaims)(value, disclosures);
47
- }
48
- }
49
- return newPayload;
50
- };
51
- exports.swapClaims = swapClaims;
52
- const swapClaimsInsideArray = (array, disclosures) => {
53
- const processedArray = [];
54
- for (const el of array) {
55
- if (typeof el === 'object' && el !== null && '...' in el) {
56
- const hash = el['...'];
57
- let disclosureFound = false;
58
- let disclosureValue;
59
- for (const d of disclosures) {
60
- if (d.digest === hash && d.decoded[2] === undefined) {
61
- disclosureValue = d.decoded[1];
62
- disclosureFound = true;
63
- break;
64
- }
65
- }
66
- if (disclosureFound) {
67
- processedArray.push(disclosureValue);
68
- }
69
- else {
70
- processedArray.push(el);
71
- }
72
- }
73
- else {
74
- processedArray.push(el);
75
- }
76
- }
77
- return processedArray;
78
- };
79
- //# sourceMappingURL=swapClaim.js.map
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AC3B,IAAI,eAAe,CAAA;YAEnB,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;gBAC1B,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;oBAClD,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;oBAC9B,eAAe,GAAG,IAAI,CAAA;oBACtB,MAAK;gBACT,CAAC;YACL,CAAC;YAED,IAAI,eAAe,EAAE,CAAC;gBAClB,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;YACxC,CAAC;iBAAM,CAAC;gBACJ,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAC3B,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC3B,CAAC;IACL,CAAC;IAED,OAAO,cAAc,CAAA;AACzB,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- export type BaseFrame<Payload, ExtraProperties> = Payload extends Array<unknown> ? {
2
- [K in keyof Payload]?: Payload[K] extends Record<string | number, unknown> ? BaseFrame<Payload[K], ExtraProperties> | boolean : boolean;
3
- } : Payload extends Record<string, unknown> ? {
4
- [K in keyof Payload]?: Payload[K] extends Array<unknown> ? BaseFrame<Payload[K], ExtraProperties> | boolean : Payload[K] extends Record<string, unknown> ? (ExtraProperties & BaseFrame<Payload[K], ExtraProperties>) | boolean : boolean;
5
- } & ExtraProperties & Record<string, unknown> : boolean;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=frame.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/types/frame.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { BaseFrame } from './frame';
2
- export type PresentationFrame<T> = BaseFrame<T, {}>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=present.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/types/present.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * from './traverse';
2
- export * from './utils';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./traverse"), exports);
18
- __exportStar(require("./utils"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0CAAuB"}
@@ -1,8 +0,0 @@
1
- export declare const traverseNodes: (object: any, path?: PathNode[]) => LeafNode[];
2
- type PathNode = string | number;
3
- interface LeafNode {
4
- path: PathNode[];
5
- value: any;
6
- isLeaf: boolean;
7
- }
8
- export {};
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traverseNodes = void 0;
4
- const traverseNodes = (object, path = []) => {
5
- const result = [];
6
- if (typeof object !== 'object' || object === null) {
7
- return [{ path: [], value: object, isLeaf: true }];
8
- }
9
- for (const key in object) {
10
- if (object.hasOwnProperty(key)) {
11
- const currentPath = [...path, key];
12
- const value = object[key];
13
- // Value must be object / array, and have at least some values in it
14
- if (typeof value === 'object' &&
15
- value !== null &&
16
- Object.keys(value).length > 0) {
17
- // Recursively traverse nested objects or arrays
18
- result.push(...(0, exports.traverseNodes)(value, currentPath));
19
- }
20
- else {
21
- // Leaf node found
22
- result.push({ path: currentPath, value, isLeaf: true });
23
- }
24
- }
25
- }
26
- return result;
27
- };
28
- exports.traverseNodes = traverseNodes;
29
- //# sourceMappingURL=traverse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/utils/traverse.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CACzB,MAAW,EACX,OAAmB,EAAE,EACX,EAAE;IACZ,MAAM,MAAM,GAAe,EAAE,CAAA;IAE7B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACtD,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;YAClC,MAAM,KAAK,GAAG,MAAM,CAAC,GAA0B,CAAC,CAAA;YAEhD,oEAAoE;YACpE,IACI,OAAO,KAAK,KAAK,QAAQ;gBACzB,KAAK,KAAK,IAAI;gBACd,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAC/B,CAAC;gBACC,gDAAgD;gBAChD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,qBAAa,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;YACrD,CAAC;iBAAM,CAAC;gBACJ,kBAAkB;gBAClB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;YAC3D,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AA/BY,QAAA,aAAa,iBA+BzB"}
@@ -1,8 +0,0 @@
1
- export declare const getAllKeys: (object: unknown, keys?: Array<string>) => Array<string>;
2
- export declare const getValueByKeyAnyLevel: <T = unknown>(obj: Record<string, unknown>, key: string) => T | undefined;
3
- export declare const simpleDeepEqual: (lhs: unknown, rhs: unknown) => boolean;
4
- export declare const deleteByPath: (object: Record<string, unknown>, path: string[]) => void;
5
- export declare const getByPath: (item: any[] | Record<string, unknown>, path: Array<string | number>) => unknown;
6
- export declare const hasByPath: (item: any[] | Record<string, unknown>, path: Array<string | number>) => boolean;
7
- export declare function isObject(input: any): boolean;
8
- export declare function isPromise<T>(value: Promise<T> | T): value is Promise<T>;