@pagopa/io-react-native-wallet 2.4.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +148 -123
  2. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  3. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  4. package/lib/commonjs/utils/parser.js +20 -0
  5. package/lib/commonjs/utils/parser.js.map +1 -0
  6. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +144 -119
  7. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  8. package/lib/module/sd-jwt/__test__/index.test.js +1 -1
  9. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  10. package/lib/module/sd-jwt/index.js +1 -3
  11. package/lib/module/sd-jwt/index.js.map +1 -1
  12. package/lib/module/utils/parser.js +12 -0
  13. package/lib/module/utils/parser.js.map +1 -0
  14. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  15. package/lib/typescript/sd-jwt/index.d.ts +1 -1
  16. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  17. package/lib/typescript/utils/parser.d.ts +9 -0
  18. package/lib/typescript/utils/parser.d.ts.map +1 -0
  19. package/package.json +7 -2
  20. package/src/credential/issuance/07-verify-and-parse-credential.ts +138 -94
  21. package/src/sd-jwt/__test__/index.test.ts +1 -1
  22. package/src/sd-jwt/index.ts +7 -5
  23. package/src/utils/parser.ts +18 -0
  24. package/lib/commonjs/utils/nestedProperty.js +0 -153
  25. package/lib/commonjs/utils/nestedProperty.js.map +0 -1
  26. package/lib/module/utils/nestedProperty.js +0 -147
  27. package/lib/module/utils/nestedProperty.js.map +0 -1
  28. package/lib/typescript/utils/nestedProperty.d.ts +0 -24
  29. package/lib/typescript/utils/nestedProperty.d.ts.map +0 -1
  30. package/src/utils/nestedProperty.ts +0 -223
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-wallet",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "Provide data structures, helpers and API for IO Wallet",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -74,6 +74,7 @@
74
74
  "react": "19.0.0",
75
75
  "react-native": "0.78.3",
76
76
  "react-native-builder-bob": "^0.20.0",
77
+ "react-native-quick-crypto": "^0.7.17",
77
78
  "release-it": "^19.0.6",
78
79
  "typed-openapi": "^0.4.1",
79
80
  "typescript": "5.0.4"
@@ -83,7 +84,8 @@
83
84
  "@pagopa/io-react-native-iso18013": "*",
84
85
  "@pagopa/io-react-native-jwt": "*",
85
86
  "react": "*",
86
- "react-native": "*"
87
+ "react-native": "*",
88
+ "react-native-quick-crypto": "*"
87
89
  },
88
90
  "engines": {
89
91
  "node": ">= 16.0.0"
@@ -134,6 +136,9 @@
134
136
  ]
135
137
  },
136
138
  "dependencies": {
139
+ "@sd-jwt/core": "^0.18.0",
140
+ "@sd-jwt/crypto-nodejs": "^0.18.0",
141
+ "@sd-jwt/types": "^0.18.0",
137
142
  "dcql": "^0.2.21",
138
143
  "js-base64": "^3.7.7",
139
144
  "js-sha256": "^0.9.0",
@@ -3,17 +3,17 @@ import { type Out } from "../../utils/misc";
3
3
  import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
4
4
  import { IoWalletError } from "../../utils/errors";
5
5
  import { SdJwt4VC, verify as verifySdJwt } from "../../sd-jwt";
6
- import { getValueFromDisclosures } from "../../sd-jwt/converters";
7
6
  import { isSameThumbprint, type JWK } from "../../utils/jwk";
8
7
  import type { ObtainCredential } from "./06-obtain-credential";
9
- import { verify as verifyMdoc } from "../../mdoc";
8
+ import { getParsedCredentialClaimKey, verify as verifyMdoc } from "../../mdoc";
10
9
  import { MDOC_DEFAULT_NAMESPACE } from "../../mdoc/const";
11
- import { getParsedCredentialClaimKey } from "../../mdoc/utils";
12
10
  import { Logger, LogLevel } from "../../utils/logging";
13
11
  import { extractElementValueAsDate } from "../../mdoc/converter";
14
12
  import type { CBOR } from "@pagopa/io-react-native-iso18013";
15
13
  import type { PublicKey } from "@pagopa/io-react-native-crypto";
16
- import { createNestedProperty } from "../../utils/nestedProperty";
14
+ import { type SDJwt, SDJwtInstance } from "@sd-jwt/core";
15
+ import { digest } from "@sd-jwt/crypto-nodejs";
16
+ import { isPathEqual, isPrefixOf } from "../../utils/parser";
17
17
 
18
18
  type IssuerConf = Out<EvaluateIssuerTrust>["issuerConf"];
19
19
  type CredentialConf =
@@ -60,112 +60,139 @@ type ParsedCredential = {
60
60
  };
61
61
  };
62
62
 
63
- // handy alias
64
- type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
65
- sdJwt: SdJwt4VC;
66
- };
67
-
63
+ /**
64
+ * Parse a Sd-Jwt credential according to the issuer configuration
65
+ * @param credentialConfig - the list of supported credentials, as defined in the issuer configuration with their claims metadata
66
+ * @param parsedCredentialRaw - the raw parsed credential
67
+ * @param ignoreMissingAttributes - skip error when attributes declared in the issuer configuration are not found within disclosures
68
+ * @param includeUndefinedAttributes - include attributes not explicitly declared in the issuer configuration
69
+ * @returns The parsed credential with attributes in plain value
70
+ */
68
71
  const parseCredentialSdJwt = (
69
- // The credential configuration to use to parse the provided credential
70
72
  credentialConfig: CredentialConf,
71
- { sdJwt, disclosures }: DecodedSdJwtCredential,
73
+ parsedCredentialRaw: Record<string, unknown>,
72
74
  ignoreMissingAttributes: boolean = false,
73
75
  includeUndefinedAttributes: boolean = false
74
76
  ): ParsedCredential => {
75
- if (credentialConfig.format !== sdJwt.header.typ) {
76
- const message = `Received credential is of an unknown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
77
- Logger.log(LogLevel.ERROR, message);
78
- throw new IoWalletError(message);
79
- }
77
+ const claimsMetadata = credentialConfig.claims || [];
80
78
 
81
- if (!credentialConfig.claims) {
82
- Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
83
- throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
84
- }
85
-
86
- const attrDefinitions = credentialConfig.claims;
87
-
88
- // Validate that all attributes from the config exist in either disclosures OR payload
79
+ // Check that all mandatory attributes defined in the issuer configuration are present in the credential
89
80
  if (!ignoreMissingAttributes) {
90
- const disclosedKeys = new Set(disclosures.map(([, name]) => name));
91
- const payloadKeys = new Set(Object.keys(sdJwt.payload ?? {}));
92
-
93
- const definedTopLevelKeys = new Set(
94
- attrDefinitions.map((def) => def.path[0] as string)
81
+ const missingPaths: string[] = [];
82
+ const rootKeysToVerify = new Set(
83
+ claimsMetadata
84
+ .map((c) => c.path[0])
85
+ .filter((p): p is string => typeof p === "string")
95
86
  );
96
87
 
97
- const missingKeys = [...definedTopLevelKeys].filter(
98
- (key) => !disclosedKeys.has(key) && !payloadKeys.has(key)
99
- );
88
+ for (const rootKey of rootKeysToVerify) {
89
+ if (!(rootKey in parsedCredentialRaw)) {
90
+ missingPaths.push(rootKey);
91
+ }
92
+ }
100
93
 
101
- if (missingKeys.length > 0) {
94
+ if (missingPaths.length > 0) {
95
+ const missing = missingPaths.join(", ");
96
+ const received = Object.keys(parsedCredentialRaw).join(", ");
102
97
  throw new IoWalletError(
103
- `Some attributes are missing in the credential. Missing: [${missingKeys.join(", ")}]`
98
+ `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
104
99
  );
105
100
  }
106
101
  }
107
102
 
108
- const definedValues: ParsedCredential = {};
109
-
110
- // Group all schema definitions by their top-level key
111
- const groupedDefinitions = attrDefinitions.reduce(
112
- (acc, def) => {
113
- const key = def.path[0] as string;
114
- const group = acc[key];
115
- if (group) {
116
- group.push(def);
117
- } else {
118
- acc[key] = [def];
119
- }
120
- return acc;
121
- },
122
- {} as Record<string, typeof attrDefinitions>
123
- );
124
-
125
- // Loop through each group
126
- for (const topLevelKey in groupedDefinitions) {
127
- const definitionsForThisKey = groupedDefinitions[topLevelKey];
103
+ /**
104
+ * Helper to find display metadata for any given path
105
+ */
106
+ const getDisplayNames = (
107
+ path: (string | number | null)[]
108
+ ): Record<string, string> | undefined => {
109
+ const match = claimsMetadata.find((c) => isPathEqual(c.path, path));
110
+ if (!match) return undefined;
111
+
112
+ const nameMap: Record<string, string> = {};
113
+ for (const entry of match.display) {
114
+ nameMap[entry.locale] = entry.name;
115
+ }
116
+ return nameMap;
117
+ };
128
118
 
129
- if (!definitionsForThisKey) {
130
- continue;
119
+ /**
120
+ * Recursive function to build the localized structure
121
+ */
122
+ const processLevel = (
123
+ currentData: unknown,
124
+ currentPath: (string | number | null)[]
125
+ ): unknown => {
126
+ // Handle Arrays
127
+ if (Array.isArray(currentData)) {
128
+ return currentData.map((item) =>
129
+ processLevel(item, [...currentPath, null])
130
+ );
131
131
  }
132
132
 
133
- const disclosureForThisKey = disclosures.find(
134
- ([, name]) => name === topLevelKey
135
- );
133
+ // Handle Objects
134
+ if (typeof currentData !== "object" || currentData === null) {
135
+ return currentData;
136
+ }
136
137
 
137
- if (!disclosureForThisKey) {
138
- continue;
138
+ const dataObj = currentData as Record<string, unknown>;
139
+ const result: ParsedCredential = {};
140
+ const processedKeys = new Set<string | number>();
141
+
142
+ // Identify unique keys in config at this level
143
+ const configKeysAtThisLevel: (string | number)[] = [];
144
+ for (const claim of claimsMetadata) {
145
+ // Check if the claim path starts with the current path
146
+ if (isPrefixOf(currentPath, claim.path)) {
147
+ const nextPart = claim.path[currentPath.length];
148
+ if (
149
+ (typeof nextPart === "string" || typeof nextPart === "number") &&
150
+ !configKeysAtThisLevel.includes(nextPart)
151
+ ) {
152
+ configKeysAtThisLevel.push(nextPart);
153
+ }
154
+ }
139
155
  }
140
156
 
141
- const disclosureValue = disclosureForThisKey[2];
157
+ // Process keys
158
+ for (const key of configKeysAtThisLevel) {
159
+ const stringKey = key.toString();
160
+ const dataValue = dataObj[stringKey];
161
+ if (dataValue === undefined) continue;
142
162
 
143
- const tempObjectForGroup = definitionsForThisKey.reduce(
144
- (acc, { path, display }) =>
145
- createNestedProperty(acc, path, disclosureValue, display),
146
- {}
147
- );
163
+ const newPath = [...currentPath, key];
148
164
 
149
- // Merge the fully constructed object into the final result
150
- Object.assign(definedValues, tempObjectForGroup);
151
- }
165
+ let localizedNames = getDisplayNames(newPath);
152
166
 
153
- if (includeUndefinedAttributes) {
154
- // attributes that are in the disclosure set
155
- // but are not defined in the issuer configuration
156
- const undefinedValues = Object.fromEntries(
157
- disclosures
158
- .filter((_) => !Object.keys(definedValues).includes(_[1]))
159
- .map(([, key, value]) => [key, { value, name: key }])
160
- );
167
+ // Fallback for arrays
168
+ if (!localizedNames && Array.isArray(dataValue)) {
169
+ localizedNames = getDisplayNames([...newPath, null]);
170
+ }
161
171
 
162
- return {
163
- ...definedValues,
164
- ...undefinedValues,
165
- };
166
- }
172
+ result[stringKey] = {
173
+ name: localizedNames || stringKey,
174
+ value: processLevel(dataValue, newPath),
175
+ };
167
176
 
168
- return definedValues;
177
+ processedKeys.add(key);
178
+ }
179
+
180
+ // Handle Undefined Attributes
181
+ if (includeUndefinedAttributes) {
182
+ for (const [key, value] of Object.entries(dataObj)) {
183
+ if (!processedKeys.has(key)) {
184
+ result[key] = {
185
+ name: key,
186
+ value: value,
187
+ };
188
+ }
189
+ }
190
+ }
191
+
192
+ return result;
193
+ };
194
+
195
+ return processLevel(parsedCredentialRaw, []) as ParsedCredential;
169
196
  };
170
197
 
171
198
  const parseCredentialMDoc = (
@@ -305,7 +332,8 @@ async function verifyCredentialSdJwt(
305
332
  rawCredential: string,
306
333
  issuerKeys: JWK[],
307
334
  holderBindingContext: CryptoContext
308
- ): Promise<DecodedSdJwtCredential> {
335
+ ): Promise<SDJwt> {
336
+ // TODO: change verification using sd-jwt library with 1.3.x update
309
337
  const [decodedCredential, holderBindingKey] =
310
338
  // parallel for optimization
311
339
  await Promise.all([
@@ -320,8 +348,13 @@ async function verifyCredentialSdJwt(
320
348
  throw new IoWalletError(message);
321
349
  }
322
350
 
323
- return decodedCredential;
351
+ const sdJwtInstance = new SDJwtInstance({
352
+ hasher: digest,
353
+ });
354
+
355
+ return await sdJwtInstance.decode(rawCredential);
324
356
  }
357
+
325
358
  /**
326
359
  * Given a credential, verify it's in the supported format
327
360
  * and the credential is correctly signed
@@ -396,26 +429,37 @@ const verifyAndParseCredentialSdJwt: VerifyAndParseCredential = async (
396
429
  throw new IoWalletError("Credential type not supported by the issuer");
397
430
  }
398
431
 
432
+ const parsedCredentialRaw = (await decoded.getClaims(digest)) as Record<
433
+ string,
434
+ unknown
435
+ >;
436
+
399
437
  const parsedCredential = parseCredentialSdJwt(
400
438
  credentialConfig,
401
- decoded,
439
+ parsedCredentialRaw,
402
440
  ignoreMissingAttributes,
403
441
  includeUndefinedAttributes
404
442
  );
405
- const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
443
+
444
+ const issuedAt =
445
+ typeof parsedCredentialRaw.iat === "number"
446
+ ? new Date(parsedCredentialRaw.iat * 1000)
447
+ : undefined;
448
+
449
+ if (typeof parsedCredentialRaw.exp !== "number") {
450
+ throw new IoWalletError("Invalid or missing expiration claim (exp)");
451
+ }
452
+ const expiration = new Date(parsedCredentialRaw.exp * 1000);
406
453
 
407
454
  Logger.log(
408
455
  LogLevel.DEBUG,
409
- `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`
456
+ `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${issuedAt}`
410
457
  );
411
458
 
412
459
  return {
413
460
  parsedCredential,
414
- expiration: new Date(decoded.sdJwt.payload.exp * 1000),
415
- issuedAt:
416
- typeof maybeIssuedAt === "number"
417
- ? new Date(maybeIssuedAt * 1000)
418
- : undefined,
461
+ expiration,
462
+ issuedAt,
419
463
  };
420
464
  };
421
465
 
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { decode, disclose } from "../index";
3
3
 
4
- import { encodeBase64, decodeBase64 } from "@pagopa/io-react-native-jwt";
4
+ import { decodeBase64, encodeBase64 } from "@pagopa/io-react-native-jwt";
5
5
  import { SdJwt4VC } from "../types";
6
6
  import { pid } from "../__mocks__/sd-jwt";
7
7
 
@@ -1,9 +1,12 @@
1
1
  import { z } from "zod";
2
2
 
3
- import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
4
- import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
5
- import { SignJWT, sha256ToBase64 } from "@pagopa/io-react-native-jwt";
6
- import { Disclosure, SdJwt4VC, type DisclosureWithEncoded } from "./types";
3
+ import {
4
+ decode as decodeJwt,
5
+ sha256ToBase64,
6
+ SignJWT,
7
+ verify as verifyJwt,
8
+ } from "@pagopa/io-react-native-jwt";
9
+ import { Disclosure, type DisclosureWithEncoded, SdJwt4VC } from "./types";
7
10
  import { verifyDisclosure } from "./verifier";
8
11
  import type { JWK } from "../utils/jwk";
9
12
  import * as Errors from "./errors";
@@ -123,7 +126,6 @@ export const disclose = async (
123
126
 
124
127
  // compose the final disclosed token
125
128
  const disclosedToken = [rawSdJwt, ...filteredDisclosures].join("~");
126
-
127
129
  return { token: disclosedToken, paths };
128
130
  };
129
131
 
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Helper to determine if two paths are equal (Supports string | number | null)
3
+ */
4
+ export const isPathEqual = (
5
+ pathA: (string | number | null)[],
6
+ pathB: (string | number | null)[]
7
+ ): boolean =>
8
+ pathA.length === pathB.length && pathA.every((v, i) => v === pathB[i]);
9
+ /**
10
+ * Helper to check if prefix is the start of fullPath
11
+ */
12
+ export const isPrefixOf = (
13
+ prefix: (string | number | null)[],
14
+ fullPath: (string | number | null)[]
15
+ ): boolean => {
16
+ if (prefix.length >= fullPath.length) return false;
17
+ return prefix.every((v, i) => v === fullPath[i]);
18
+ };
@@ -1,153 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createNestedProperty = void 0;
7
- var _misc = require("./misc");
8
- // The data used to create localized names
9
-
10
- // The resulting object of localized names { en: "Name", it: "Nome" }
11
-
12
- // The core structure being built: a node containing the actual value and its localized names
13
-
14
- // A path can consist of object keys, array indices, or null for mapping
15
-
16
- // A union of all possible shapes. It can be a custom PropertyNode or a standard object/array structure
17
-
18
- // Helper to build localized names from the display data.
19
- const buildName = display => display.reduce((names, _ref) => {
20
- let {
21
- locale,
22
- name
23
- } = _ref;
24
- return {
25
- ...names,
26
- [locale]: name
27
- };
28
- }, {});
29
-
30
- // Handles the case where the path key is `null` (indicating an array)
31
- const handleNullKeyCase = (currentObject, rest, sourceValue, displayData) => {
32
- if (!Array.isArray(sourceValue)) return currentObject;
33
-
34
- // We assert the type here because we know this branch handles PropertyNodes
35
- const node = currentObject;
36
- const existingValue = Array.isArray(node.value) ? node.value : [];
37
- const mappedArray = sourceValue.map((item, idx) =>
38
- // When mapping over an array, recursively call with `skipMissingLeaves` set to `true`.
39
- // This tells the function to skip optional keys inside these array objects.
40
- createNestedProperty(existingValue[idx] || {}, rest, item, displayData, true));
41
- return {
42
- ...node,
43
- value: mappedArray,
44
- name: node.name ?? buildName(displayData)
45
- };
46
- };
47
-
48
- // Handles the case where the path key is a string
49
- const handleStringKeyCase = (currentObject, key, rest, sourceValue, displayData, skipMissingLeaves) => {
50
- let nextSourceValue = sourceValue;
51
- const isLeaf = rest.length === 0;
52
- if ((0, _misc.isObject)(sourceValue)) {
53
- // Check if any remaining string keys in the path exist in current sourceValue
54
- // This handles nested object paths (unlike arrays which use null in the path)
55
- const hasRestKey = rest.some(r => typeof r === "string" && r in sourceValue);
56
- if (hasRestKey) {
57
- return handleRestKey(currentObject, key, rest, sourceValue, displayData);
58
- }
59
-
60
- // Skip processing when the key is not found within the claim object
61
- if (!(key in sourceValue)) {
62
- // If the flag is set (we're inside an array), skip the missing key completely.
63
- if (skipMissingLeaves) {
64
- return currentObject;
65
- }
66
-
67
- // If the flag is NOT set, create the empty placeholder
68
- // so that its children can be attached later.
69
- if (isLeaf) {
70
- return {
71
- ...currentObject,
72
- [key]: {
73
- value: {},
74
- name: buildName(displayData)
75
- }
76
- };
77
- }
78
- // Skip processing when the key is not found within the claim object
79
- return currentObject;
80
- }
81
- nextSourceValue = sourceValue[key];
82
- }
83
-
84
- // base case
85
- if (isLeaf) {
86
- return {
87
- ...currentObject,
88
- [key]: {
89
- value: nextSourceValue,
90
- name: buildName(displayData)
91
- }
92
- };
93
- }
94
-
95
- // recursive step
96
- const nextObject = currentObject[key] || {};
97
- return {
98
- ...currentObject,
99
- [key]: createNestedProperty(nextObject, rest, nextSourceValue, displayData, skipMissingLeaves)
100
- };
101
- };
102
-
103
- // Handles the case where the path key is a number
104
- const handleNumberKeyCase = (currentObject, key, rest, sourceValue, displayData) => {
105
- const newArray = Array.isArray(currentObject) ? [...currentObject] : [];
106
- const nextValue = Array.isArray(sourceValue) ? sourceValue[key] : undefined;
107
- newArray[key] = createNestedProperty(newArray[key] || {}, rest, nextValue, displayData);
108
- return newArray;
109
- };
110
-
111
- /**
112
- * Recursively constructs a nested object with descriptive properties from a path.
113
- *
114
- * @param currentObject - The object or array being built upon.
115
- * @param path - The path segments to follow.
116
- * @param sourceValue - The raw value to place at the end of the path.
117
- * @param displayData - The data for generating localized names.
118
- * @param skipMissingLeaves - If true, skips optional keys when mapping over arrays.
119
- * @returns The new object or array structure.
120
- */
121
- const createNestedProperty = function (currentObject, path, sourceValue, displayData) {
122
- let skipMissingLeaves = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
123
- const [key, ...rest] = path;
124
- switch (true) {
125
- case key === null:
126
- return handleNullKeyCase(currentObject, rest, sourceValue, displayData);
127
- case typeof key === "string":
128
- return handleStringKeyCase(currentObject, key, rest, sourceValue, displayData, skipMissingLeaves);
129
- case typeof key === "number":
130
- return handleNumberKeyCase(currentObject, key, rest, sourceValue, displayData);
131
- default:
132
- return currentObject;
133
- }
134
- };
135
-
136
- // Handles the case where the next key in the path exists in the source object
137
- exports.createNestedProperty = createNestedProperty;
138
- const handleRestKey = (currentObject, key, rest, sourceValue, displayData) => {
139
- const currentNode = currentObject[key] ?? {};
140
- const restKey = rest[0];
141
- const nextSourceValue = sourceValue[restKey];
142
- if (typeof nextSourceValue === "undefined") {
143
- return currentObject;
144
- }
145
- return {
146
- ...currentObject,
147
- [key]: {
148
- ...currentNode,
149
- value: createNestedProperty(currentNode.value ?? {}, rest, nextSourceValue, displayData)
150
- }
151
- };
152
- };
153
- //# sourceMappingURL=nestedProperty.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_misc","require","buildName","display","reduce","names","_ref","locale","name","handleNullKeyCase","currentObject","rest","sourceValue","displayData","Array","isArray","node","existingValue","value","mappedArray","map","item","idx","createNestedProperty","handleStringKeyCase","key","skipMissingLeaves","nextSourceValue","isLeaf","length","isObject","hasRestKey","some","r","handleRestKey","nextObject","handleNumberKeyCase","newArray","nextValue","undefined","path","arguments","exports","currentNode","restKey"],"sourceRoot":"../../../src","sources":["utils/nestedProperty.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA;;AAGA;;AAGA;;AAMA;;AAGA;;AAGA;AACA,MAAMC,SAAS,GAAIC,OAAoB,IACrCA,OAAO,CAACC,MAAM,CACZ,CAACC,KAAK,EAAAC,IAAA;EAAA,IAAE;IAAEC,MAAM;IAAEC;EAAK,CAAC,GAAAF,IAAA;EAAA,OAAM;IAAE,GAAGD,KAAK;IAAE,CAACE,MAAM,GAAGC;EAAK,CAAC;AAAA,CAAC,EAC3D,CAAC,CACH,CAAC;;AAEH;AACA,MAAMC,iBAAiB,GAAGA,CACxBC,aAA8B,EAC9BC,IAAU,EACVC,WAAoB,EACpBC,WAAwB,KACJ;EACpB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,WAAW,CAAC,EAAE,OAAOF,aAAa;;EAErD;EACA,MAAMM,IAAI,GAAGN,aAAiD;EAC9D,MAAMO,aAAa,GAAGH,KAAK,CAACC,OAAO,CAACC,IAAI,CAACE,KAAK,CAAC,GAAGF,IAAI,CAACE,KAAK,GAAG,E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