@platform-sec/sensitive-string-core 0.6.0 → 0.6.1

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 (153) hide show
  1. package/dist/bson.d.ts +28 -0
  2. package/dist/bson.d.ts.map +1 -0
  3. package/dist/bson.js +37 -0
  4. package/dist/bson.js.map +1 -0
  5. package/dist/classification.d.ts +69 -0
  6. package/dist/classification.d.ts.map +1 -0
  7. package/dist/classification.js +104 -0
  8. package/dist/classification.js.map +1 -0
  9. package/dist/compare.d.ts +36 -0
  10. package/dist/compare.d.ts.map +1 -0
  11. package/dist/compare.js +123 -0
  12. package/dist/compare.js.map +1 -0
  13. package/dist/context.d.ts +78 -0
  14. package/dist/context.d.ts.map +1 -0
  15. package/dist/context.js +110 -0
  16. package/dist/context.js.map +1 -0
  17. package/dist/derive.d.ts +110 -0
  18. package/dist/derive.d.ts.map +1 -0
  19. package/dist/derive.js +153 -0
  20. package/dist/derive.js.map +1 -0
  21. package/dist/destination.d.ts +120 -0
  22. package/dist/destination.d.ts.map +1 -0
  23. package/dist/destination.js +352 -0
  24. package/dist/destination.js.map +1 -0
  25. package/dist/deterministic.d.ts +145 -0
  26. package/dist/deterministic.d.ts.map +1 -0
  27. package/dist/deterministic.js +352 -0
  28. package/dist/deterministic.js.map +1 -0
  29. package/dist/dev-mode.d.ts +177 -0
  30. package/dist/dev-mode.d.ts.map +1 -0
  31. package/dist/dev-mode.js +503 -0
  32. package/dist/dev-mode.js.map +1 -0
  33. package/dist/environment.d.ts +181 -0
  34. package/dist/environment.d.ts.map +1 -0
  35. package/dist/environment.js +558 -0
  36. package/dist/environment.js.map +1 -0
  37. package/dist/errors.d.ts +23 -0
  38. package/dist/errors.d.ts.map +1 -0
  39. package/dist/errors.js +21 -0
  40. package/dist/errors.js.map +1 -0
  41. package/dist/global-state.d.ts +8 -0
  42. package/dist/global-state.d.ts.map +1 -0
  43. package/dist/global-state.js +22 -0
  44. package/dist/global-state.js.map +1 -0
  45. package/dist/hash.d.ts +74 -0
  46. package/dist/hash.d.ts.map +1 -0
  47. package/dist/hash.js +253 -0
  48. package/dist/hash.js.map +1 -0
  49. package/dist/hygiene.d.ts +242 -0
  50. package/dist/hygiene.d.ts.map +1 -0
  51. package/dist/hygiene.js +257 -0
  52. package/dist/hygiene.js.map +1 -0
  53. package/dist/index.d.ts +85 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +233 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/mask.d.ts +51 -0
  58. package/dist/mask.d.ts.map +1 -0
  59. package/dist/mask.js +461 -0
  60. package/dist/mask.js.map +1 -0
  61. package/dist/own-property.d.ts +20 -0
  62. package/dist/own-property.d.ts.map +1 -0
  63. package/dist/own-property.js +34 -0
  64. package/dist/own-property.js.map +1 -0
  65. package/dist/patterns.d.ts +12 -0
  66. package/dist/patterns.d.ts.map +1 -0
  67. package/dist/patterns.js +19 -0
  68. package/dist/patterns.js.map +1 -0
  69. package/dist/policy.d.ts +51 -0
  70. package/dist/policy.d.ts.map +1 -0
  71. package/dist/policy.js +181 -0
  72. package/dist/policy.js.map +1 -0
  73. package/dist/probe.d.ts +141 -0
  74. package/dist/probe.d.ts.map +1 -0
  75. package/dist/probe.js +213 -0
  76. package/dist/probe.js.map +1 -0
  77. package/dist/redact-copy.d.ts +61 -0
  78. package/dist/redact-copy.d.ts.map +1 -0
  79. package/dist/redact-copy.js +217 -0
  80. package/dist/redact-copy.js.map +1 -0
  81. package/dist/redact.d.ts +141 -0
  82. package/dist/redact.d.ts.map +1 -0
  83. package/dist/redact.js +514 -0
  84. package/dist/redact.js.map +1 -0
  85. package/dist/redaction-marker.d.ts +48 -0
  86. package/dist/redaction-marker.d.ts.map +1 -0
  87. package/dist/redaction-marker.js +138 -0
  88. package/dist/redaction-marker.js.map +1 -0
  89. package/dist/redaction-observer.d.ts +108 -0
  90. package/dist/redaction-observer.d.ts.map +1 -0
  91. package/dist/redaction-observer.js +103 -0
  92. package/dist/redaction-observer.js.map +1 -0
  93. package/dist/redaction-scope.d.ts +21 -0
  94. package/dist/redaction-scope.d.ts.map +1 -0
  95. package/dist/redaction-scope.js +44 -0
  96. package/dist/redaction-scope.js.map +1 -0
  97. package/dist/reference.d.ts +101 -0
  98. package/dist/reference.d.ts.map +1 -0
  99. package/dist/reference.js +123 -0
  100. package/dist/reference.js.map +1 -0
  101. package/dist/regexp.d.ts +25 -0
  102. package/dist/regexp.d.ts.map +1 -0
  103. package/dist/regexp.js +61 -0
  104. package/dist/regexp.js.map +1 -0
  105. package/dist/release.d.ts +88 -0
  106. package/dist/release.d.ts.map +1 -0
  107. package/dist/release.js +108 -0
  108. package/dist/release.js.map +1 -0
  109. package/dist/reveal-budget.d.ts +148 -0
  110. package/dist/reveal-budget.d.ts.map +1 -0
  111. package/dist/reveal-budget.js +314 -0
  112. package/dist/reveal-budget.js.map +1 -0
  113. package/dist/revocation.d.ts +168 -0
  114. package/dist/revocation.d.ts.map +1 -0
  115. package/dist/revocation.js +541 -0
  116. package/dist/revocation.js.map +1 -0
  117. package/dist/sealing.d.ts +283 -0
  118. package/dist/sealing.d.ts.map +1 -0
  119. package/dist/sealing.js +523 -0
  120. package/dist/sealing.js.map +1 -0
  121. package/dist/sensitive-string.d.ts +919 -0
  122. package/dist/sensitive-string.d.ts.map +1 -0
  123. package/dist/sensitive-string.js +2260 -0
  124. package/dist/sensitive-string.js.map +1 -0
  125. package/dist/serialized.d.ts +33 -0
  126. package/dist/serialized.d.ts.map +1 -0
  127. package/dist/serialized.js +65 -0
  128. package/dist/serialized.js.map +1 -0
  129. package/dist/template.d.ts +69 -0
  130. package/dist/template.d.ts.map +1 -0
  131. package/dist/template.js +158 -0
  132. package/dist/template.js.map +1 -0
  133. package/dist/ttl.d.ts +104 -0
  134. package/dist/ttl.d.ts.map +1 -0
  135. package/dist/ttl.js +330 -0
  136. package/dist/ttl.js.map +1 -0
  137. package/dist/types.d.ts +859 -0
  138. package/dist/types.d.ts.map +1 -0
  139. package/dist/types.js +13 -0
  140. package/dist/types.js.map +1 -0
  141. package/dist/winston.d.ts +114 -0
  142. package/dist/winston.d.ts.map +1 -0
  143. package/dist/winston.js +170 -0
  144. package/dist/winston.js.map +1 -0
  145. package/dist/worker.d.ts +398 -0
  146. package/dist/worker.d.ts.map +1 -0
  147. package/dist/worker.js +861 -0
  148. package/dist/worker.js.map +1 -0
  149. package/dist/wrap.d.ts +287 -0
  150. package/dist/wrap.d.ts.map +1 -0
  151. package/dist/wrap.js +553 -0
  152. package/dist/wrap.js.map +1 -0
  153. package/package.json +10 -10
package/dist/wrap.js ADDED
@@ -0,0 +1,553 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapSensitiveByPath = wrapSensitiveByPath;
4
+ exports.wrapSensitiveByClassification = wrapSensitiveByClassification;
5
+ exports.checkClassifiedFieldsWrapped = checkClassifiedFieldsWrapped;
6
+ exports.unwrapSensitiveByPath = unwrapSensitiveByPath;
7
+ exports.validateSensitiveFieldConfig = validateSensitiveFieldConfig;
8
+ exports.checkSensitiveFieldsWrapped = checkSensitiveFieldsWrapped;
9
+ const sensitive_string_js_1 = require("./sensitive-string.js");
10
+ const context_js_1 = require("./context.js");
11
+ const own_property_js_1 = require("./own-property.js");
12
+ const classification_js_1 = require("./classification.js");
13
+ /**
14
+ * Get a value from an object by dot-notation path.
15
+ *
16
+ * @param obj - The object to traverse
17
+ * @param path - Dot-notation path (e.g., 'user.email' or 'additionalData.cardBin')
18
+ * @returns The value at the path, or undefined if not found
19
+ */
20
+ function getByPath(obj, path) {
21
+ const parts = path.split('.');
22
+ let current = obj;
23
+ for (const part of parts) {
24
+ if (part === '__proto__' || part === 'constructor' || part === 'prototype') {
25
+ return undefined;
26
+ }
27
+ if (current === null || current === undefined) {
28
+ return undefined;
29
+ }
30
+ if (typeof current !== 'object') {
31
+ return undefined;
32
+ }
33
+ current = current[part];
34
+ }
35
+ return current;
36
+ }
37
+ /**
38
+ * Set a value in an object by dot-notation path.
39
+ * Creates intermediate objects if they don't exist.
40
+ *
41
+ * @param obj - The object to modify (mutates in place)
42
+ * @param path - Dot-notation path
43
+ * @param value - The value to set
44
+ */
45
+ function setByPath(obj, path, value) {
46
+ const parts = path.split('.');
47
+ let current = obj;
48
+ for (let i = 0; i < parts.length - 1; i++) {
49
+ const part = parts[i];
50
+ if (part === undefined)
51
+ continue;
52
+ if (part === '__proto__' || part === 'constructor' || part === 'prototype') {
53
+ return;
54
+ }
55
+ if (!(part in current) || typeof current[part] !== 'object' || current[part] === null) {
56
+ current[part] = {};
57
+ }
58
+ current = current[part];
59
+ }
60
+ const lastPart = parts[parts.length - 1];
61
+ if (lastPart !== undefined) {
62
+ if (lastPart === '__proto__' || lastPart === 'constructor' || lastPart === 'prototype') {
63
+ return;
64
+ }
65
+ current[lastPart] = value;
66
+ }
67
+ }
68
+ /**
69
+ * Refuse a protected value handed in as the whole object to wrap.
70
+ *
71
+ * `deepClone` returns an instance by reference, and a walk over it would see
72
+ * its own public `klass` and `label` and write wrapped values over them in
73
+ * place, on the caller's object, leaving an instance that cannot render or
74
+ * reveal. A value that is already protected has nothing here to do.
75
+ */
76
+ function refuseInstanceRoot(obj, where) {
77
+ if (obj instanceof sensitive_string_js_1.SensitiveString) {
78
+ throw new TypeError(`${where}: expected a parsed object, received a SensitiveString. The value is already ` +
79
+ 'protected; wrap the object that holds it.');
80
+ }
81
+ }
82
+ /**
83
+ * Deep clone an object, preserving most types.
84
+ * Does not clone functions, symbols, or class instances (except Date).
85
+ *
86
+ * A key named `__proto__` is copied as the own data property it was, never
87
+ * assigned: see `assignOwn`. A webhook body is the input this function was
88
+ * written for, and an attacker chooses its keys.
89
+ */
90
+ function deepClone(obj) {
91
+ if (obj === null || typeof obj !== 'object') {
92
+ return obj;
93
+ }
94
+ if (obj instanceof Date) {
95
+ return new Date(obj.getTime());
96
+ }
97
+ if (obj instanceof sensitive_string_js_1.SensitiveString) {
98
+ return obj; // Don't clone SensitiveString instances
99
+ }
100
+ if (Array.isArray(obj)) {
101
+ return obj.map((item) => deepClone(item));
102
+ }
103
+ const cloned = {};
104
+ for (const [key, value] of Object.entries(obj)) {
105
+ (0, own_property_js_1.assignOwn)(cloned, key, deepClone(value));
106
+ }
107
+ return cloned;
108
+ }
109
+ /**
110
+ * Wrap sensitive fields in an object by path, converting string values
111
+ * to SensitiveString instances.
112
+ *
113
+ * This is the primary utility for protecting sensitive data at boundary layers
114
+ * (e.g., when receiving webhook payloads from payment providers).
115
+ *
116
+ * @typeParam T - The type of the input object
117
+ * @param obj - The object containing sensitive data
118
+ * @param config - Mapping of dot-notation paths to class or class-and-label configuration
119
+ * @returns A deep clone of the object with specified fields wrapped as SensitiveString
120
+ *
121
+ * @remarks
122
+ * - Wraps a string at a declared path, and every string element of an array
123
+ * at one, through nested arrays; a list of connection strings declared once
124
+ * becomes a list of wrapped connection strings. Until 2026-09-19 an array
125
+ * was skipped, silently, and the corpus study found the two report
126
+ * functions vouching for the config that skipped it.
127
+ * - Any other value at a declared path, an object, a number, `null`, is left
128
+ * as it is, and `validateSensitiveFieldConfig` reports it as unwrappable
129
+ * - Non-existent paths are silently ignored
130
+ * - Already-wrapped SensitiveString values are preserved
131
+ * - The original object is not mutated
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const PSP_SENSITIVE_FIELDS = {
136
+ * 'additionalData.hmacSignature': 'credential',
137
+ * 'additionalData.cardSummary': 'sensitive',
138
+ * 'additionalData.cardBin': 'sensitive',
139
+ * 'additionalData.shopperIP': 'sensitive',
140
+ * 'reason': 'sensitive',
141
+ * } as const;
142
+ *
143
+ * const rawWebhook = JSON.parse(body);
144
+ * const safeWebhook = wrapSensitiveByPath(rawWebhook, PSP_SENSITIVE_FIELDS);
145
+ *
146
+ * console.log(safeWebhook.additionalData.cardSummary);
147
+ * // SensitiveString<sensitive> { [REDACTED:sensitive] }
148
+ * ```
149
+ */
150
+ function wrapSensitiveByPath(obj, config) {
151
+ refuseInstanceRoot(obj, 'wrapSensitiveByPath');
152
+ // Deep clone to avoid mutating the original
153
+ const result = deepClone(obj);
154
+ for (const [path, fieldConfig] of Object.entries(config)) {
155
+ const value = getByPath(result, path);
156
+ const resolved = typeof fieldConfig === 'string' ? { klass: fieldConfig } : fieldConfig;
157
+ if (typeof value === 'string') {
158
+ const wrapped = new sensitive_string_js_1.SensitiveString(value, resolved.klass, resolved.label, resolved.options);
159
+ setByPath(result, path, wrapped);
160
+ }
161
+ else if (Array.isArray(value)) {
162
+ // The clone's own array, so wrapping in place mutates nothing the caller
163
+ // holds. Each element gets the class, the label and the options the path
164
+ // declared: one declaration is one classification, however many values
165
+ // stand at it.
166
+ wrapElements(value, resolved);
167
+ }
168
+ // If already a SensitiveString, leave it alone
169
+ // If undefined/null/other type, skip
170
+ }
171
+ return result;
172
+ }
173
+ /**
174
+ * Wrap every string element of an array a declared path holds, through nested
175
+ * arrays. Anything else, an object or a number, stays as it is, for the reason
176
+ * the leaf walk leaves them: a path names values of one class, and an object
177
+ * inside the list is addressed by a deeper path or left alone.
178
+ */
179
+ function wrapElements(list, resolved) {
180
+ list.forEach((item, index) => {
181
+ if (typeof item === 'string') {
182
+ list[index] = new sensitive_string_js_1.SensitiveString(item, resolved.klass, resolved.label, resolved.options);
183
+ }
184
+ else if (Array.isArray(item)) {
185
+ wrapElements(item, resolved);
186
+ }
187
+ });
188
+ }
189
+ /** The reverse, for `unwrapSensitiveByPath`: every instance in the list is revealed. */
190
+ function unwrapElements(list, ctx) {
191
+ list.forEach((item, index) => {
192
+ if (item instanceof sensitive_string_js_1.SensitiveString) {
193
+ list[index] = item.reveal(ctx);
194
+ }
195
+ else if (Array.isArray(item)) {
196
+ unwrapElements(item, ctx);
197
+ }
198
+ });
199
+ }
200
+ /**
201
+ * Whether `wrapSensitiveByPath` would act on everything in this array: each
202
+ * element is a string, an instance, or such an array. An empty array passes,
203
+ * since nothing in it is left unprotected.
204
+ */
205
+ function isWrappableArray(list) {
206
+ return list.every((item) => typeof item === 'string' ||
207
+ item instanceof sensitive_string_js_1.SensitiveString ||
208
+ (Array.isArray(item) && isWrappableArray(item)));
209
+ }
210
+ /**
211
+ * Whether every element of this array is an instance, through nested arrays.
212
+ * A plain string is unwrapped, and so is anything else that is not an
213
+ * instance, on the rule `checkSensitiveFieldsWrapped` applies at the path.
214
+ */
215
+ function isWrappedArray(list) {
216
+ return list.every((item) => item instanceof sensitive_string_js_1.SensitiveString || (Array.isArray(item) && isWrappedArray(item)));
217
+ }
218
+ /**
219
+ * The classification a leaf gets under a spec.
220
+ *
221
+ * The authoritative name is the dot path with array indices, so a spec can
222
+ * name one element. The aliases are the same path with its trailing indices
223
+ * stripped, so `fields: { 'db.replicaUrls': 'credential' }` classifies every
224
+ * element of that array, and the nearest key name, so a rule written as
225
+ * `/password/` matches `db.password` without the caller anticipating the
226
+ * nesting. The secrets layer classifies with the same three names.
227
+ */
228
+ function classifyLeaf(spec, path, keyPath, key) {
229
+ return spec.classify(path, path === keyPath ? [key] : [keyPath, key]);
230
+ }
231
+ /** A container the classification walk descends into: a plain object or an array. */
232
+ function isContainer(value) {
233
+ return (value !== null &&
234
+ typeof value === 'object' &&
235
+ !(value instanceof sensitive_string_js_1.SensitiveString) &&
236
+ !(value instanceof Date));
237
+ }
238
+ /**
239
+ * Visit every string leaf of a JSON-shaped object with its classification.
240
+ *
241
+ * `path` carries array indices and `keyPath` does not, so a leaf inside an
242
+ * array is classified under the array's own name as well as its own. `key` is
243
+ * the nearest object key, which an index never replaces.
244
+ */
245
+ function walkLeaves(node, spec, path, keyPath, key, visit) {
246
+ if (Array.isArray(node)) {
247
+ node.forEach((value, index) => {
248
+ const childPath = path === '' ? String(index) : `${path}.${index}`;
249
+ if (isContainer(value)) {
250
+ walkLeaves(value, spec, childPath, keyPath, key, visit);
251
+ return;
252
+ }
253
+ visit(node, String(index), value, classifyLeaf(spec, childPath, keyPath, key), childPath, key);
254
+ });
255
+ return;
256
+ }
257
+ for (const [entry, value] of Object.entries(node)) {
258
+ // `constructor`, `prototype` and an own `__proto__` are visited like any
259
+ // other key. The path helpers refuse to traverse those names because a
260
+ // dot path is a route into the object, and the route is the hazard; here
261
+ // the key is data the payload chose, `constructor` is a legal header
262
+ // name, and a string under it is exactly what a fallback means to wrap
263
+ // and a check means to report. The write goes through `assignOwn`, so an
264
+ // own `__proto__` stays the inert data property the clone gave it.
265
+ const childPath = path === '' ? entry : `${path}.${entry}`;
266
+ const childKeyPath = keyPath === '' ? entry : `${keyPath}.${entry}`;
267
+ if (isContainer(value)) {
268
+ walkLeaves(value, spec, childPath, childKeyPath, entry, visit);
269
+ continue;
270
+ }
271
+ visit(node, entry, value, classifyLeaf(spec, childPath, childKeyPath, entry), childPath, entry);
272
+ }
273
+ }
274
+ /**
275
+ * Wrap every string leaf of an object that a classification spec says is
276
+ * sensitive, including the ones whose keys nobody could enumerate in advance.
277
+ *
278
+ * `wrapSensitiveByPath` takes a list of the paths that are sensitive, which is
279
+ * the right entry when the payload's shape is known: a webhook from a named
280
+ * provider. It is the wrong entry for a bag whose keys the caller does not
281
+ * choose, which is a header bag, a `.env` file, the return value of a plugin
282
+ * loaded at run time, or a per-provider credential object whose keys are data.
283
+ * A path list over such a bag is a denylist turned inside out, and it fails
284
+ * the way every denylist in this library's adoption corpus failed: a key the
285
+ * list does not name arrives unwrapped, silently, in the unsafe direction.
286
+ *
287
+ * This entry inverts the default. A spec with a `fallback` wraps every string
288
+ * leaf the spec does not classify `'plain'`, so the list the caller maintains
289
+ * is the short one, of what may stay readable, and a key nobody anticipated is
290
+ * wrapped rather than missed. A spec with no `fallback` classifies by name
291
+ * pattern alone, which is what a credential object with sixty provider shapes
292
+ * needs: one rule set instead of sixty lists. Precedence is `fields`, then
293
+ * `rules` in order, then `fallback`, as `compileClassification` documents.
294
+ *
295
+ * What it wraps and what it leaves:
296
+ *
297
+ * - Strings only. A number, a boolean and `null` keep their type whatever the
298
+ * spec says, because `port: 5432` is not a secret and a wrapped one would
299
+ * break `config.port === 5432` in a way that reads as a configuration bug.
300
+ * `checkClassifiedFieldsWrapped` reports nothing about them either.
301
+ * - Every element of an array of strings, each classified under the array's
302
+ * own name, so a list of connection strings is a list of wrapped
303
+ * connection strings, as `wrapSensitiveByPath` does at a declared path.
304
+ * - An already wrapped value is kept as it is, and not descended into.
305
+ * - A `Date` is copied, not descended into.
306
+ * - The input is deep-cloned first, as `wrapSensitiveByPath` does, and the
307
+ * clone keeps an own `__proto__` key as the inert data property it was.
308
+ * - A `fields` entry written as a bare key matches that key at any depth,
309
+ * which is the alias rule `compileClassification` documents, so under a
310
+ * `fallback` a bare `password: 'plain'` leaves every `password` readable.
311
+ * Write the dot path to mean one of them.
312
+ *
313
+ * Reveal on the way out with `unwrapSensitiveByPath` and a list of the paths
314
+ * that may leave, which is the allowlist this entry pairs with, or with each
315
+ * value's own `reveal()`.
316
+ *
317
+ * @typeParam T - The type of the input object
318
+ * @param obj - A parsed, JSON-shaped object. Not a string, and not a `Map`.
319
+ * @param spec - Which keys become which class
320
+ * @param options - A label and construction options for every wrapped leaf
321
+ * @returns A deep clone with every classified string leaf wrapped
322
+ *
323
+ * @example
324
+ * ```ts
325
+ * // A header bag: keep one header readable, wrap the rest.
326
+ * const headers = wrapSensitiveByClassification(req.headers, {
327
+ * fields: { referer: 'plain', host: 'plain' },
328
+ * fallback: 'sensitive',
329
+ * });
330
+ *
331
+ * // A plugin's return value: every string it hands back is a credential.
332
+ * const creds = wrapSensitiveByClassification(await plugin.getCredentials(), {
333
+ * fallback: 'credential',
334
+ * });
335
+ *
336
+ * // A provider credential object with keys nobody enumerates: classify by name.
337
+ * const provider = wrapSensitiveByClassification(config, {
338
+ * rules: [
339
+ * { pattern: /secret|token|password|key$/i, klass: 'credential' },
340
+ * { pattern: /email|phone/i, klass: 'sensitive' },
341
+ * ],
342
+ * });
343
+ * ```
344
+ */
345
+ function wrapSensitiveByClassification(obj, spec, options = {}) {
346
+ if (obj === null || typeof obj !== 'object') {
347
+ throw new TypeError(`wrapSensitiveByClassification: expected a parsed object, received ${obj === null ? 'null' : typeof obj}`);
348
+ }
349
+ refuseInstanceRoot(obj, 'wrapSensitiveByClassification');
350
+ const compiled = (0, classification_js_1.compileClassification)(spec);
351
+ const result = deepClone(obj);
352
+ const { label, options: construction } = options;
353
+ walkLeaves(result, compiled, '', '', '', (container, entry, value, klass, path, key) => {
354
+ if (typeof value !== 'string' || klass === undefined || klass === 'plain') {
355
+ return;
356
+ }
357
+ const resolvedLabel = typeof label === 'function' ? label(path, key) : label;
358
+ const wrapped = new sensitive_string_js_1.SensitiveString(value, klass, resolvedLabel, construction);
359
+ if (Array.isArray(container)) {
360
+ container[Number(entry)] = wrapped;
361
+ }
362
+ else {
363
+ (0, own_property_js_1.assignOwn)(container, entry, wrapped);
364
+ }
365
+ });
366
+ return result;
367
+ }
368
+ /**
369
+ * Report every string leaf a classification spec says is sensitive and that
370
+ * is still a plain string.
371
+ *
372
+ * The inverse of `checkSensitiveFieldsWrapped`: that one walks the config and
373
+ * asks the object, so a key the object carries and the config does not name
374
+ * is invisible to it, which is exactly the key an untrusted payload adds.
375
+ * This one walks the object and asks the spec, so the key it reports is the
376
+ * one nobody declared.
377
+ *
378
+ * Used the way the path helper's checks are used: in a test over a sample
379
+ * payload, or as a guard at a boundary before the object is logged or sent.
380
+ * Non-string leaves are not reported, since the wrapper would not have
381
+ * wrapped them.
382
+ *
383
+ * @param obj - The object to check
384
+ * @param spec - The classification the object should satisfy
385
+ * @returns `allWrapped`, and the dot paths of the string leaves that are not
386
+ *
387
+ * @example
388
+ * ```ts
389
+ * const check = checkClassifiedFieldsWrapped(payload, { fallback: 'credential' });
390
+ * if (!check.allWrapped) {
391
+ * throw new Error(`Unwrapped sensitive fields: ${check.unwrappedPaths.join(', ')}`);
392
+ * }
393
+ * ```
394
+ */
395
+ function checkClassifiedFieldsWrapped(obj, spec) {
396
+ const unwrappedPaths = [];
397
+ if (isContainer(obj)) {
398
+ walkLeaves(obj, (0, classification_js_1.compileClassification)(spec), '', '', '', (_container, _entry, value, klass, path) => {
399
+ if (typeof value === 'string' && klass !== undefined && klass !== 'plain') {
400
+ unwrappedPaths.push(path);
401
+ }
402
+ });
403
+ }
404
+ return {
405
+ allWrapped: unwrappedPaths.length === 0,
406
+ unwrappedPaths,
407
+ };
408
+ }
409
+ /**
410
+ * Unwrap sensitive fields in an object by path, converting SensitiveString
411
+ * instances back to raw strings.
412
+ *
413
+ * This is useful when you need to serialize data for external transmission
414
+ * or when interfacing with APIs that don't understand SensitiveString.
415
+ *
416
+ * @typeParam T - The type of the input object
417
+ * @param obj - The object containing SensitiveString instances
418
+ * @param config - Mapping of dot-notation paths (same as used for wrapping)
419
+ * @param ctx - Optional reveal context for auditing
420
+ * @returns A deep clone of the object with specified SensitiveString fields unwrapped
421
+ *
422
+ * @remarks
423
+ * - Audits each unwrap operation if a RevealContext is active, once per
424
+ * instance, so an array of five reveals five times
425
+ * - An array at a declared path has every instance in it unwrapped
426
+ * - Non-existent paths are silently ignored
427
+ * - Regular string values are preserved as-is
428
+ * - The original object is not mutated
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * // When you need to forward data to another service
433
+ * const rawPayload = unwrapSensitiveByPath(
434
+ * safeWebhook,
435
+ * PSP_SENSITIVE_FIELDS,
436
+ * { name: 'forward-to-processor', reason: 'payment processing' }
437
+ * );
438
+ * ```
439
+ */
440
+ function unwrapSensitiveByPath(obj, config, ctx) {
441
+ const effectiveCtx = ctx ?? (0, context_js_1.getCurrentRevealContext)() ?? undefined;
442
+ // Deep clone to avoid mutating the original
443
+ const result = deepClone(obj);
444
+ for (const path of Object.keys(config)) {
445
+ const value = getByPath(result, path);
446
+ if (value instanceof sensitive_string_js_1.SensitiveString) {
447
+ const raw = value.reveal(effectiveCtx);
448
+ setByPath(result, path, raw);
449
+ }
450
+ else if (Array.isArray(value)) {
451
+ // The wrap side's counterpart: every instance in the clone's array is
452
+ // revealed under the same context, and a plain element stays as it is.
453
+ unwrapElements(value, effectiveCtx);
454
+ }
455
+ // If already a plain string or other type, leave it alone
456
+ }
457
+ return result;
458
+ }
459
+ /**
460
+ * Validate that all paths in a config exist in a sample object.
461
+ * Useful for catching typos in path configurations during testing.
462
+ *
463
+ * `missingPaths` holds a declared path that is not in the object at all, which
464
+ * is usually a typo. `unwrappablePaths` holds one that is there and holds
465
+ * something `wrapSensitiveByPath` will not act on: an object, a number, `null`,
466
+ * or an array with any of those in it. That case used to pass silently and is
467
+ * the one worth failing a test over, since the config reads as though the field
468
+ * is protected and nothing protects it. An array of strings is not such a case
469
+ * since 2026-09-19: the helper wraps every element of it.
470
+ *
471
+ * @param sampleObj - A sample object to validate against
472
+ * @param config - The sensitive field configuration to validate
473
+ * @returns `valid`, plus `missingPaths` and `unwrappablePaths`
474
+ *
475
+ * @example
476
+ * ```ts
477
+ * // In your test file
478
+ * const validation = validateSensitiveFieldConfig(samplePSPWebhook, PSP_SENSITIVE_FIELDS);
479
+ * expect(validation.valid).toBe(true);
480
+ * expect(validation.missingPaths).toEqual([]);
481
+ * expect(validation.unwrappablePaths).toEqual([]);
482
+ * ```
483
+ */
484
+ function validateSensitiveFieldConfig(sampleObj, config) {
485
+ const missingPaths = [];
486
+ const unwrappablePaths = [];
487
+ for (const path of Object.keys(config)) {
488
+ const value = getByPath(sampleObj, path);
489
+ if (value === undefined || value === null) {
490
+ missingPaths.push(path);
491
+ continue;
492
+ }
493
+ // Declared, present, and something `wrapSensitiveByPath` will not act on
494
+ // in full. Reported separately from a missing path: the path is right and
495
+ // the value is the wrong shape, which is a different mistake and has a
496
+ // different fix. An array is the wrong shape only when something in it is.
497
+ if (typeof value !== 'string' &&
498
+ !(value instanceof sensitive_string_js_1.SensitiveString) &&
499
+ !(Array.isArray(value) && isWrappableArray(value))) {
500
+ unwrappablePaths.push(path);
501
+ }
502
+ }
503
+ return {
504
+ valid: missingPaths.length === 0 && unwrappablePaths.length === 0,
505
+ missingPaths,
506
+ unwrappablePaths,
507
+ };
508
+ }
509
+ /**
510
+ * Check if an object contains any unwrapped sensitive fields
511
+ * based on the provided configuration.
512
+ *
513
+ * Useful for validation to ensure all sensitive fields have been wrapped.
514
+ *
515
+ * @param obj - The object to check
516
+ * @param config - The sensitive field configuration
517
+ * @returns An object with `allWrapped` boolean and `unwrappedPaths` array
518
+ *
519
+ * @example
520
+ * ```ts
521
+ * const check = checkSensitiveFieldsWrapped(webhook, PSP_SENSITIVE_FIELDS);
522
+ * if (!check.allWrapped) {
523
+ * throw new Error(`Unwrapped sensitive fields: ${check.unwrappedPaths.join(', ')}`);
524
+ * }
525
+ * ```
526
+ */
527
+ function checkSensitiveFieldsWrapped(obj, config) {
528
+ const unwrappedPaths = [];
529
+ for (const path of Object.keys(config)) {
530
+ const value = getByPath(obj, path);
531
+ // Absent is not unwrapped. An optional field that is not there carries no
532
+ // secret, and `validateSensitiveFieldConfig` is what reports a path that
533
+ // should be there and is not.
534
+ if (value === undefined || value === null)
535
+ continue;
536
+ // Anything else that is not a `SensitiveString`, or an array of them, is
537
+ // unwrapped, whatever its type. Until 2026-09-19 this tested
538
+ // `typeof value === 'string'`, so a declared path holding an array of
539
+ // secrets, or an object, answered `allWrapped: true`: the guard this
540
+ // function's own documentation puts in a caller's path passed, and the
541
+ // values went out in the clear. A config that wrapped nothing was affirmed
542
+ // by both of this module's report functions. An array is reported once,
543
+ // under the declared path, if anything in it is not an instance.
544
+ if (!(value instanceof sensitive_string_js_1.SensitiveString) && !(Array.isArray(value) && isWrappedArray(value))) {
545
+ unwrappedPaths.push(path);
546
+ }
547
+ }
548
+ return {
549
+ allWrapped: unwrappedPaths.length === 0,
550
+ unwrappedPaths,
551
+ };
552
+ }
553
+ //# sourceMappingURL=wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap.js","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":";;AAyMA,kDA2BC;AAuOD,sEAiCC;AA6BD,oEAyBC;AAiCD,sDAyBC;AA2BD,oEA+BC;AAoBD,kEA+BC;AAzsBD,+DAAwD;AAExD,6CAAuD;A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A4B;IAE5B,MAAM,cAAc,GAAa,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEnC,0EAA0E;QAC1E,yEAAyE;QACzE,8BAA8B;QAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAEpD,yEAAyE;QACzE,6DAA6D;QAC7D,sEAAsE;QACtE,qEAAqE;QACrE,uEAAuE;QACvE,2EAA2E;QAC3E,wEAAwE;QACxE,iEAAiE;QACjE,IAAI,CAAC,CAAC,KAAK,YAAY,qCAAe,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAC5F,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU,EAAE,cAAc,CAAC,MAAM,KAAK,CAAC;QACvC,cAAc;KACf,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-sec/sensitive-string-core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Core library for handling sensitive string data with automatic redaction",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -14,11 +14,6 @@
14
14
  "files": [
15
15
  "dist"
16
16
  ],
17
- "scripts": {
18
- "build": "tsc",
19
- "test": "vitest run --root ../.. packages/sensitive-core/",
20
- "test:watch": "vitest --root ../.. packages/sensitive-core/"
21
- },
22
17
  "keywords": [
23
18
  "security",
24
19
  "sensitive-data",
@@ -37,10 +32,15 @@
37
32
  "node": ">=22.12.0"
38
33
  },
39
34
  "devDependencies": {
40
- "@types/node": "^22.20.1",
41
- "bson": "^7.3.2",
35
+ "@types/node": "^22.20.5",
36
+ "bson": "^7.3.4",
42
37
  "typescript": "^5.9.3",
43
- "vitest": "^4.1.11",
38
+ "vitest": "^4.1.12",
44
39
  "winston": "^3.19.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc",
43
+ "test": "vitest run --root ../.. packages/sensitive-core/",
44
+ "test:watch": "vitest --root ../.. packages/sensitive-core/"
45
45
  }
46
- }
46
+ }