@platform-sec/sensitive-string-testing 0.0.0-stage → 0.2.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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +329 -2
  3. package/dist/assertions.d.ts +81 -0
  4. package/dist/assertions.d.ts.map +1 -0
  5. package/dist/assertions.js +132 -0
  6. package/dist/assertions.js.map +1 -0
  7. package/dist/canary.d.ts +49 -0
  8. package/dist/canary.d.ts.map +1 -0
  9. package/dist/canary.js +116 -0
  10. package/dist/canary.js.map +1 -0
  11. package/dist/create-test-secret.d.ts +78 -0
  12. package/dist/create-test-secret.d.ts.map +1 -0
  13. package/dist/create-test-secret.js +91 -0
  14. package/dist/create-test-secret.js.map +1 -0
  15. package/dist/describe-type.d.ts +16 -0
  16. package/dist/describe-type.d.ts.map +1 -0
  17. package/dist/describe-type.js +35 -0
  18. package/dist/describe-type.js.map +1 -0
  19. package/dist/index.d.ts +51 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +77 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/leak-scan.d.ts +94 -0
  24. package/dist/leak-scan.d.ts.map +1 -0
  25. package/dist/leak-scan.js +309 -0
  26. package/dist/leak-scan.js.map +1 -0
  27. package/dist/matchers.d.ts +93 -0
  28. package/dist/matchers.d.ts.map +1 -0
  29. package/dist/matchers.js +170 -0
  30. package/dist/matchers.js.map +1 -0
  31. package/dist/mocks.d.ts +140 -0
  32. package/dist/mocks.d.ts.map +1 -0
  33. package/dist/mocks.js +146 -0
  34. package/dist/mocks.js.map +1 -0
  35. package/dist/serializer.d.ts +136 -0
  36. package/dist/serializer.d.ts.map +1 -0
  37. package/dist/serializer.js +210 -0
  38. package/dist/serializer.js.map +1 -0
  39. package/dist/vitest.d.ts +59 -0
  40. package/dist/vitest.d.ts.map +1 -0
  41. package/dist/vitest.js +3 -0
  42. package/dist/vitest.js.map +1 -0
  43. package/package.json +55 -3
@@ -0,0 +1,140 @@
1
+ import type { AuditContext, ISensitiveString, RevealContext, RevealDetails, SensitivityClass } from '@platform-sec/sensitive-string-core';
2
+ /**
3
+ * The audit callback shape core invokes, named so a mock factory can be typed
4
+ * against it.
5
+ */
6
+ export type AuditRevealFn = (value: ISensitiveString, details: RevealDetails, context: AuditContext) => void;
7
+ /**
8
+ * A factory that wraps a function in the host framework's spy, such as `vi.fn`
9
+ * or `jest.fn`.
10
+ *
11
+ * The factory is passed in rather than detected at runtime. Detection would
12
+ * mean reading a `vi` or `jest` global that only exists under one framework and
13
+ * only when globals are enabled, and importing either framework would make this
14
+ * package depend on the one the consumer might not be using.
15
+ */
16
+ export type MockFunctionFactory = (implementation: AuditRevealFn) => AuditRevealFn;
17
+ /** One recorded call to a mock context's audit hook. */
18
+ export interface AuditCall {
19
+ readonly timestamp: Date;
20
+ /**
21
+ * The value that was accessed.
22
+ *
23
+ * The instance, not its raw value: an assertion can read `klass` and `label`
24
+ * from it, and reading anything more still has to go through `reveal()`.
25
+ */
26
+ readonly value: ISensitiveString;
27
+ /** What the operation was, and its parameters. */
28
+ readonly details: RevealDetails;
29
+ /**
30
+ * The context the operation ran under, copied rather than referenced.
31
+ *
32
+ * Not necessarily the mock context itself: an integration that nests a child
33
+ * over it to tag a reveal is audited under the child, and the child's name
34
+ * and tags are what appear here.
35
+ *
36
+ * A copy because the live context of a mock holds `calls`, and a record
37
+ * pointing back at it would make the call log a cycle that neither
38
+ * `JSON.stringify` nor a snapshot assertion could walk. `tags` is copied one
39
+ * level, so a later reveal under the same context cannot rewrite what an
40
+ * earlier record says.
41
+ *
42
+ * A caller that forwards the hook with two arguments names no context, and
43
+ * the record then carries this context's own name and no tags.
44
+ */
45
+ readonly context: AuditContext;
46
+ }
47
+ /** Options for `mockRevealContext`. */
48
+ export interface MockRevealContextOptions {
49
+ /** Spy factory, such as `vi.fn` or `jest.fn`. */
50
+ fn?: MockFunctionFactory;
51
+ /** Reason recorded on the context. */
52
+ reason?: string;
53
+ /** Tags recorded on the context. */
54
+ tags?: Record<string, unknown>;
55
+ }
56
+ /** A `RevealContext` that records what was accessed through it. */
57
+ export interface MockRevealContext extends RevealContext {
58
+ readonly name: string;
59
+ /** The audit hook. A spy when a factory was given, a plain function otherwise. */
60
+ auditReveal: AuditRevealFn;
61
+ /** Calls in order. Recorded whether or not a spy factory was given. */
62
+ readonly calls: readonly AuditCall[];
63
+ /** Forget every recorded call, and clear the spy if there is one. */
64
+ reset(): void;
65
+ }
66
+ /**
67
+ * Create a `RevealContext` that records every access made through it.
68
+ *
69
+ * Pass it to `reveal()`, `mask()`, or `withRevealContext()` and assert on
70
+ * `calls`. Passing a spy factory additionally makes `auditReveal` a spy, so the
71
+ * framework's own call assertions work on it.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const ctx = mockRevealContext('payment-handler', { fn: vi.fn });
76
+ * const token = createTestSecret('credential', 'api_key');
77
+ *
78
+ * token.reveal(ctx);
79
+ *
80
+ * expect(ctx.calls).toHaveLength(1);
81
+ * expect(ctx.calls[0]?.details.operation).toBe('reveal');
82
+ * expect(ctx.auditReveal).toHaveBeenCalledTimes(1);
83
+ * ```
84
+ */
85
+ export declare function mockRevealContext(name: string, options?: MockRevealContextOptions): MockRevealContext;
86
+ /**
87
+ * One recorded access, reduced to what an audit sink would keep.
88
+ *
89
+ * There is deliberately no raw value and no reference to the instance here: an
90
+ * audit log is the thing most likely to be printed by a failing assertion or
91
+ * dumped into a snapshot, so it holds classification and nothing else.
92
+ */
93
+ export interface AuditEntry {
94
+ readonly timestamp: Date;
95
+ readonly klass: SensitivityClass;
96
+ readonly label: string | undefined;
97
+ /**
98
+ * Name of the context the access was made under.
99
+ *
100
+ * Read from the context core reports, so a reveal made under a child context
101
+ * is recorded under the child's name rather than this log's. A caller that
102
+ * forwards the hook with two arguments names no context, and the entry then
103
+ * carries this log's own name.
104
+ */
105
+ readonly contextName: string;
106
+ /** `reveal`, `mask`, or `renew`. */
107
+ readonly operation: RevealDetails['operation'];
108
+ readonly details: RevealDetails;
109
+ }
110
+ /** A recording audit sink, plus the context that feeds it. */
111
+ export interface MockAuditLog {
112
+ readonly entries: readonly AuditEntry[];
113
+ /** Pass this to `withRevealContext()` or to an individual operation. */
114
+ readonly context: RevealContext;
115
+ /** Entries whose value carried this label. */
116
+ getEntriesFor(label: string): AuditEntry[];
117
+ /** Entries whose value had this sensitivity class. */
118
+ getEntriesByClass(klass: SensitivityClass): AuditEntry[];
119
+ /** Forget every entry. */
120
+ clear(): void;
121
+ }
122
+ /**
123
+ * Create a context whose audit hook records classification only.
124
+ *
125
+ * Use it to assert that a code path audited what it accessed, without the test
126
+ * holding a second reference to the values.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const audit = createMockAuditLog();
131
+ *
132
+ * await withRevealContext(audit.context, async () => {
133
+ * await chargeCard(card);
134
+ * });
135
+ *
136
+ * expect(audit.getEntriesFor('card_number')).toHaveLength(1);
137
+ * ```
138
+ */
139
+ export declare function createMockAuditLog(name?: string): MockAuditLog;
140
+ //# sourceMappingURL=mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,gBAAgB,EACjB,MAAM,qCAAqC,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,YAAY,KAClB,IAAI,CAAC;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,aAAa,KAAK,aAAa,CAAC;AAEnF,wDAAwD;AACxD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,gBAAgB,C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,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,8CAA8C;IAC9C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAAC;IAC3C,sDAAsD;IACtD,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,EAAE,CAAC;IACzD,0BAA0B;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAmB,GAAG,YAAY,CAqCxE"}
package/dist/mocks.js ADDED
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockRevealContext = mockRevealContext;
4
+ exports.createMockAuditLog = createMockAuditLog;
5
+ /**
6
+ * Create a `RevealContext` that records every access made through it.
7
+ *
8
+ * Pass it to `reveal()`, `mask()`, or `withRevealContext()` and assert on
9
+ * `calls`. Passing a spy factory additionally makes `auditReveal` a spy, so the
10
+ * framework's own call assertions work on it.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const ctx = mockRevealContext('payment-handler', { fn: vi.fn });
15
+ * const token = createTestSecret('credential', 'api_key');
16
+ *
17
+ * token.reveal(ctx);
18
+ *
19
+ * expect(ctx.calls).toHaveLength(1);
20
+ * expect(ctx.calls[0]?.details.operation).toBe('reveal');
21
+ * expect(ctx.auditReveal).toHaveBeenCalledTimes(1);
22
+ * ```
23
+ */
24
+ function mockRevealContext(name, options = {}) {
25
+ const calls = [];
26
+ const record = (value, details, context) => {
27
+ calls.push({ timestamp: new Date(), value, details, context: snapshot(context, name) });
28
+ };
29
+ const auditReveal = options.fn ? options.fn(record) : record;
30
+ const context = {
31
+ name,
32
+ auditReveal,
33
+ calls,
34
+ reset() {
35
+ calls.length = 0;
36
+ clearSpy(auditReveal);
37
+ },
38
+ };
39
+ if (options.reason !== undefined) {
40
+ context.reason = options.reason;
41
+ }
42
+ if (options.tags !== undefined) {
43
+ context.tags = options.tags;
44
+ }
45
+ return context;
46
+ }
47
+ /**
48
+ * Create a context whose audit hook records classification only.
49
+ *
50
+ * Use it to assert that a code path audited what it accessed, without the test
51
+ * holding a second reference to the values.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const audit = createMockAuditLog();
56
+ *
57
+ * await withRevealContext(audit.context, async () => {
58
+ * await chargeCard(card);
59
+ * });
60
+ *
61
+ * expect(audit.getEntriesFor('card_number')).toHaveLength(1);
62
+ * ```
63
+ */
64
+ function createMockAuditLog(name = 'mock-audit-log') {
65
+ const entries = [];
66
+ const context = {
67
+ name,
68
+ // An arrow rather than a method, deliberately: this hook exists to be
69
+ // handed to `withRevealContext()` and forwarded on, and a method that is
70
+ // detached from its object loses `this`. It reads none, and this way it
71
+ // cannot start to.
72
+ auditReveal: (value, details, auditedUnder) => {
73
+ entries.push({
74
+ timestamp: new Date(),
75
+ klass: value.klass,
76
+ label: value.label,
77
+ // Falls back for the same reason `snapshot()` does: a caller
78
+ // forwarding this hook with two arguments names no context, and this
79
+ // one is then the context the operation ran under.
80
+ contextName: contextNameOr(auditedUnder, name),
81
+ operation: details.operation,
82
+ details,
83
+ });
84
+ },
85
+ };
86
+ return {
87
+ entries,
88
+ context,
89
+ getEntriesFor(label) {
90
+ return entries.filter((entry) => entry.label === label);
91
+ },
92
+ getEntriesByClass(klass) {
93
+ return entries.filter((entry) => entry.klass === klass);
94
+ },
95
+ clear() {
96
+ entries.length = 0;
97
+ },
98
+ };
99
+ }
100
+ /**
101
+ * What a record keeps of the context an operation ran under.
102
+ *
103
+ * The descriptive fields only, one level deep. See `AuditCall.context` for why
104
+ * this is a copy.
105
+ *
106
+ * `undefined` is not a shape core produces, and it is the shape a caller
107
+ * forwarding the hook itself produces: a two-argument call, which is what core
108
+ * made before it carried the context and what a consumer's own forwarder still
109
+ * makes. This runs inside the raw-value gate, where a `TypeError` would surface
110
+ * as a failing reveal in somebody's test rather than as a missing tag, so the
111
+ * answer is the context the hook was installed on. For a two-argument caller
112
+ * that is the truthful one: it is the context the operation ran under, and the
113
+ * argument exists only because a nested child can now say otherwise.
114
+ */
115
+ function snapshot(context, installedOn) {
116
+ if (context === undefined)
117
+ return { name: installedOn };
118
+ const copy = {
119
+ name: context.name,
120
+ };
121
+ if (context.reason !== undefined)
122
+ copy.reason = context.reason;
123
+ if (context.tags !== undefined)
124
+ copy.tags = { ...context.tags };
125
+ return copy;
126
+ }
127
+ /**
128
+ * The name of the context an operation ran under, falling back to the context
129
+ * holding the hook when a two-argument caller named none. See `snapshot()`.
130
+ */
131
+ function contextNameOr(context, installedOn) {
132
+ return context === undefined ? installedOn : context.name;
133
+ }
134
+ /**
135
+ * Clear a spy's recorded calls when the function turns out to be one.
136
+ *
137
+ * Both frameworks expose `mockClear`, so this needs no knowledge of which one
138
+ * produced the spy.
139
+ */
140
+ function clearSpy(fn) {
141
+ const candidate = fn;
142
+ if (typeof candidate.mockClear === 'function') {
143
+ candidate.mockClear();
144
+ }
145
+ }
146
+ //# sourceMappingURL=mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":";;AAoGA,8CA+BC;AAyDD,gDAqCC;AAhJD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,UAAoC,EAAE;IAEtC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QACxD,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAA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out here so the
5
+ * package keeps its rule that nothing in it depends on a test framework. The
6
+ * serializer is handed to Vitest's or Jest's `expect.addSnapshotSerializer`,
7
+ * both of which type that parameter as `NewPlugin`, and a structural match is
8
+ * what lets one object satisfy both without importing either.
9
+ *
10
+ * `pretty-format` passes `serialize` five more arguments: the print config, the
11
+ * current indentation, the depth, the values already visited, and a printer for
12
+ * children. This serializer needs none of them, because it renders a leaf: it
13
+ * never prints a child and never recurses, so there is nothing to indent, no
14
+ * depth to track, and no cycle to break. They are declared as optional
15
+ * `unknown` rather than imported so no `pretty-format` version pins this
16
+ * package.
17
+ */
18
+ export interface SnapshotSerializerPlugin {
19
+ /** Whether this plugin renders the value. Called for every value printed. */
20
+ test(value: unknown): boolean;
21
+ /** The rendering. Called only for values `test` accepted. */
22
+ serialize(value: unknown, config?: unknown, indentation?: string, depth?: number, refs?: unknown, printer?: unknown): string;
23
+ }
24
+ /** Options for {@link createSensitiveSerializer}. */
25
+ export interface SensitiveSerializerOptions {
26
+ /**
27
+ * Add `{expired}` to the default format, so a value whose deadline has passed
28
+ * renders as `SensitiveString<credential:otp:EXPIRED>`.
29
+ *
30
+ * Off by default, and worth leaving off for a stored snapshot: whether a
31
+ * value is expired depends on when the test ran, so a snapshot that records
32
+ * it holds only while the deadline stays on the same side of the clock. It
33
+ * earns its place in an inline snapshot of a value built with `ttl: 0`, which
34
+ * is expired at construction and stays that way.
35
+ *
36
+ * @defaultValue false
37
+ */
38
+ readonly showExpiration?: boolean;
39
+ /**
40
+ * Add `{length}` to the default format, so a value renders as
41
+ * `SensitiveString<credential:api_key:len=32>`.
42
+ *
43
+ * Off by default. The length is not the value, and core treats it as
44
+ * metadata, but a snapshot is committed to version control and the length of
45
+ * a credential says more about it than its class and label do.
46
+ *
47
+ * @defaultValue false
48
+ */
49
+ readonly showLength?: boolean;
50
+ /**
51
+ * The rendering, with `{class}`, `{label}`, `{length}` and `{expired}` as
52
+ * placeholders. There is deliberately no placeholder for the value.
53
+ *
54
+ * Each placeholder carries its own separator, so a format is a template for
55
+ * the whole rendering rather than a list of fields to join: `{label}` expands
56
+ * to `:api_key` or to nothing, and the three optional placeholders collapse
57
+ * cleanly on a value with no label, no length shown and no deadline.
58
+ *
59
+ * A format supersedes `showLength` and `showExpiration`: the placeholders
60
+ * written here decide what appears, so the two ways of asking for a field
61
+ * cannot disagree. An unknown placeholder is rejected rather than passed
62
+ * through, so a `{value}` someone expected to work fails at registration
63
+ * instead of printing itself into every snapshot in the suite.
64
+ *
65
+ * @defaultValue `'SensitiveString<{class}{label}>'`, plus `{length}` and
66
+ * `{expired}` when the options above ask for them
67
+ */
68
+ readonly format?: string;
69
+ }
70
+ /**
71
+ * Build a snapshot serializer with a custom rendering.
72
+ *
73
+ * @param options - The format, and the fields to include.
74
+ * @returns A plugin for `expect.addSnapshotSerializer` or for a runner's config.
75
+ * @throws TypeError If an option has the wrong type, or the format names a placeholder that does not exist.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const verbose = createSensitiveSerializer({ showLength: true, showExpiration: true });
80
+ *
81
+ * expect.addSnapshotSerializer(verbose);
82
+ * // SensitiveString<credential:api_key:len=32>
83
+ * // SensitiveString<credential:otp:len=6:EXPIRED>
84
+ * ```
85
+ */
86
+ export declare function createSensitiveSerializer(options?: SensitiveSerializerOptions): SnapshotSerializerPlugin;
87
+ /**
88
+ * A snapshot serializer for `SensitiveString`, with the default format.
89
+ *
90
+ * Register it once, in a setup file:
91
+ *
92
+ * ```ts
93
+ * import { expect } from 'vitest';
94
+ * import { sensitiveSerializer } from '@platform-sec/sensitive-string-testing';
95
+ *
96
+ * expect.addSnapshotSerializer(sensitiveSerializer);
97
+ * ```
98
+ *
99
+ * A snapshot of a structure holding sensitive values then keeps the shape of
100
+ * the structure and says what each sensitive field is, without recording what
101
+ * it holds:
102
+ *
103
+ * ```
104
+ * {
105
+ * "id": 1,
106
+ * "email": SensitiveString<sensitive:email>,
107
+ * "apiKey": SensitiveString<credential:api_key>,
108
+ * }
109
+ * ```
110
+ *
111
+ * The rendering is built from the class and the label, which are public
112
+ * metadata, and never from the value: nothing here calls `reveal()`, and no
113
+ * format placeholder prints a value. It also does not use the class policy's
114
+ * `redact()`, so a project that registered a custom redaction format gets the
115
+ * same snapshots as one that did not, and a policy registered with
116
+ * `skipRedactValidation` cannot route a value into a snapshot through it.
117
+ */
118
+ export declare const sensitiveSerializer: SnapshotSerializerPlugin;
119
+ /**
120
+ * The plugin again, as a default export, for a runner that loads it by path
121
+ * rather than by importing it:
122
+ *
123
+ * ```js
124
+ * // jest.config.js
125
+ * module.exports = {
126
+ * snapshotSerializers: ['@platform-sec/sensitive-string-testing/serializer'],
127
+ * };
128
+ * ```
129
+ *
130
+ * That path is loaded with `require`, which is what this export is for. Code
131
+ * that imports the module should use the named `sensitiveSerializer` instead:
132
+ * this package builds to CommonJS, and a default import of a CommonJS module
133
+ * from ES module code yields the module's exports rather than this value.
134
+ */
135
+ export default sensitiveSerializer;
136
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,wBAAwB;IACvC,6EAA6E;IAC7E,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,6DAA6D;IAC7D,SAAS,CACP,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAAC;CACX;AAED,qDAAqD;AACrD,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AA6BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,wBAAwB,CAyB1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,mBAAmB,EAAE,wBAAsD,CAAC;AAEzF;;;;;;;;;;;;;;;GAeG;AACH,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sensitiveSerializer = void 0;
4
+ exports.createSensitiveSerializer = createSensitiveSerializer;
5
+ const sensitive_string_core_1 = require("@platform-sec/sensitive-string-core");
6
+ const describe_type_js_1 = require("./describe-type.js");
7
+ /** The placeholders a format may contain. */
8
+ const PLACEHOLDERS = ['class', 'label', 'length', 'expired'];
9
+ /** Matches one `{placeholder}`, and nothing that merely looks like one. */
10
+ const PLACEHOLDER_PATTERN = /\{([a-z]+)\}/g;
11
+ /**
12
+ * Control characters, which a label must not carry into the rendering.
13
+ *
14
+ * Matching them is the point, so `no-control-regex` has nothing to warn about
15
+ * here: the rule guards against a control character reaching a pattern by
16
+ * accident, and this one is looking for them.
17
+ */
18
+ // eslint-disable-next-line no-control-regex
19
+ const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/g;
20
+ /** The escapes worth reading, for the control characters a label might hold. */
21
+ const CONTROL_ESCAPES = {
22
+ '\b': '\\b',
23
+ '\t': '\\t',
24
+ '\n': '\\n',
25
+ '\f': '\\f',
26
+ '\r': '\\r',
27
+ };
28
+ /**
29
+ * Build a snapshot serializer with a custom rendering.
30
+ *
31
+ * @param options - The format, and the fields to include.
32
+ * @returns A plugin for `expect.addSnapshotSerializer` or for a runner's config.
33
+ * @throws TypeError If an option has the wrong type, or the format names a placeholder that does not exist.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const verbose = createSensitiveSerializer({ showLength: true, showExpiration: true });
38
+ *
39
+ * expect.addSnapshotSerializer(verbose);
40
+ * // SensitiveString<credential:api_key:len=32>
41
+ * // SensitiveString<credential:otp:len=6:EXPIRED>
42
+ * ```
43
+ */
44
+ function createSensitiveSerializer(options = {}) {
45
+ // Resolved once, at registration, so a bad format is a loud failure in a
46
+ // setup file rather than a failure inside the first snapshot that happens to
47
+ // hold a sensitive value.
48
+ const format = resolveFormat(options);
49
+ return {
50
+ test(value) {
51
+ return isSensitiveString(value);
52
+ },
53
+ serialize(value) {
54
+ if (!isSensitiveString(value)) {
55
+ // Reachable only by calling the plugin directly, since `pretty-format`
56
+ // calls `serialize` only for what `test` accepted. Naming the type is
57
+ // safe; rendering the value would not be, because whatever arrived here
58
+ // may be a raw copy of a secret.
59
+ throw new TypeError(`The sensitive-string snapshot serializer received ${(0, describe_type_js_1.describeType)(value)}, not a SensitiveString.`);
60
+ }
61
+ return render(format, value);
62
+ },
63
+ };
64
+ }
65
+ /**
66
+ * A snapshot serializer for `SensitiveString`, with the default format.
67
+ *
68
+ * Register it once, in a setup file:
69
+ *
70
+ * ```ts
71
+ * import { expect } from 'vitest';
72
+ * import { sensitiveSerializer } from '@platform-sec/sensitive-string-testing';
73
+ *
74
+ * expect.addSnapshotSerializer(sensitiveSerializer);
75
+ * ```
76
+ *
77
+ * A snapshot of a structure holding sensitive values then keeps the shape of
78
+ * the structure and says what each sensitive field is, without recording what
79
+ * it holds:
80
+ *
81
+ * ```
82
+ * {
83
+ * "id": 1,
84
+ * "email": SensitiveString<sensitive:email>,
85
+ * "apiKey": SensitiveString<credential:api_key>,
86
+ * }
87
+ * ```
88
+ *
89
+ * The rendering is built from the class and the label, which are public
90
+ * metadata, and never from the value: nothing here calls `reveal()`, and no
91
+ * format placeholder prints a value. It also does not use the class policy's
92
+ * `redact()`, so a project that registered a custom redaction format gets the
93
+ * same snapshots as one that did not, and a policy registered with
94
+ * `skipRedactValidation` cannot route a value into a snapshot through it.
95
+ */
96
+ exports.sensitiveSerializer = createSensitiveSerializer();
97
+ /**
98
+ * The plugin again, as a default export, for a runner that loads it by path
99
+ * rather than by importing it:
100
+ *
101
+ * ```js
102
+ * // jest.config.js
103
+ * module.exports = {
104
+ * snapshotSerializers: ['@platform-sec/sensitive-string-testing/serializer'],
105
+ * };
106
+ * ```
107
+ *
108
+ * That path is loaded with `require`, which is what this export is for. Code
109
+ * that imports the module should use the named `sensitiveSerializer` instead:
110
+ * this package builds to CommonJS, and a default import of a CommonJS module
111
+ * from ES module code yields the module's exports rather than this value.
112
+ */
113
+ exports.default = exports.sensitiveSerializer;
114
+ /**
115
+ * The format to render with, after checking the options.
116
+ *
117
+ * `showLength` and `showExpiration` are shorthand for adding a placeholder to
118
+ * the default format, so they have nothing to say once a format is given.
119
+ */
120
+ function resolveFormat(options) {
121
+ const { showExpiration = false, showLength = false, format } = options;
122
+ checkBoolean(showExpiration, 'showExpiration');
123
+ checkBoolean(showLength, 'showLength');
124
+ if (format === undefined) {
125
+ return [
126
+ 'SensitiveString<{class}{label}',
127
+ showLength ? '{length}' : '',
128
+ showExpiration ? '{expired}' : '',
129
+ '>',
130
+ ].join('');
131
+ }
132
+ if (typeof format !== 'string') {
133
+ throw new TypeError(`format must be a string, but got ${(0, describe_type_js_1.describeType)(format)}.`);
134
+ }
135
+ for (const match of format.matchAll(PLACEHOLDER_PATTERN)) {
136
+ const name = match[1];
137
+ if (name !== undefined && !isPlaceholder(name)) {
138
+ throw new TypeError([
139
+ `format contains an unknown placeholder '{${name}}'. `,
140
+ `The known placeholders are ${PLACEHOLDERS.map((known) => `{${known}}`).join(', ')}. `,
141
+ 'There is none for the value: a snapshot is committed to version control, ',
142
+ 'so the serializer has no way to print one.',
143
+ ].join(''));
144
+ }
145
+ }
146
+ return format;
147
+ }
148
+ /**
149
+ * Expand the placeholders in one pass.
150
+ *
151
+ * One pass with a replacement function, rather than a `replace` per
152
+ * placeholder, for two reasons. A label is arbitrary text, so a label of
153
+ * `{class}`, or one holding `$&`, would otherwise be expanded by a later pass
154
+ * or read as a replacement pattern. And a format may name a placeholder twice,
155
+ * which a `String.prototype.replace` per placeholder would honour only the
156
+ * first time.
157
+ */
158
+ function render(format, value) {
159
+ return format.replace(PLACEHOLDER_PATTERN, (whole, name) => isPlaceholder(name) ? expand(name, value) : whole);
160
+ }
161
+ function expand(placeholder, value) {
162
+ switch (placeholder) {
163
+ case 'class':
164
+ return value.klass;
165
+ case 'label':
166
+ return value.label === undefined ? '' : `:${escapeLabel(value.label)}`;
167
+ case 'length':
168
+ return `:len=${value.length}`;
169
+ case 'expired':
170
+ // `ttlRemaining()` rather than `isExpired()`, which asks the same question
171
+ // without the side effect: the first `isExpired()` on a lapsed value fires
172
+ // the `onExpire` callback of every source it derives from. Printing a
173
+ // snapshot must not be what triggers an expiry hook, and a snapshot that
174
+ // is printed twice must not fire it twice.
175
+ return value.ttlRemaining() === -1 ? ':EXPIRED' : '';
176
+ }
177
+ }
178
+ /**
179
+ * A label with its control characters escaped.
180
+ *
181
+ * A label is developer-supplied text rather than a value, so it prints as it
182
+ * stands. A newline or a tab in one would break the line being rendered into
183
+ * and silently corrupt the indentation of the whole snapshot, so those become
184
+ * escapes. Everything printable is left alone, including a `{`, which cannot be
185
+ * re-expanded because the format expands in a single pass.
186
+ */
187
+ function escapeLabel(label) {
188
+ return label.replace(CONTROL_CHARACTERS, (character) => CONTROL_ESCAPES[character] ?? `\\x${character.charCodeAt(0).toString(16).padStart(2, '0')}`);
189
+ }
190
+ /**
191
+ * Whether the value is a `SensitiveString`, as a predicate rather than a bare
192
+ * `instanceof`.
193
+ *
194
+ * `instanceof SensitiveString` narrows to `SensitiveString<any>`, because the
195
+ * class is generic in its sensitivity class and the check says nothing about
196
+ * which one. The predicate names the union instead, so nothing downstream of
197
+ * the narrowing is typed `any`.
198
+ */
199
+ function isSensitiveString(value) {
200
+ return value instanceof sensitive_string_core_1.SensitiveString;
201
+ }
202
+ function isPlaceholder(name) {
203
+ return PLACEHOLDERS.includes(name);
204
+ }
205
+ function checkBoolean(value, name) {
206
+ if (typeof value !== 'boolean') {
207
+ throw new TypeError(`${name} must be a boolean, but got ${(0, describe_type_js_1.describeType)(value)}.`);
208
+ }
209
+ }
210
+ //# sourceMappingURL=serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";;;AA+HA,8DA2BC;AA1JD,+EAAsE;AAEtE,yDAAkD;AAkFlD,6CAA6C;AAC7C,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAItE,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C;;;;;;GAMG;AACH,4CAA4C;AAC5C,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AAEpD,gFAAgF;AAChF,MAAM,eAAe,GAAqC;IACxD,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,yBAAyB,CACvC,UAAsC,EAAE;IAExC,yEAAyE;IACzE,6EAA6E;IAC7E,0BAA0B;IAC1B,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI,CAAC,KAAc;YACjB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,SAAS,CAAC,KAAc;YACtB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,uEAAuE;gBACvE,sEAAsE;gBACtE,wEAAwE;gBACxE,iCAAiC;gBACjC,MAAM,IAAI,SAAS,CACjB,qDAAqD,IAAA,+BAAY,EAAC,KAAK,CAAC,0BAA0B,CACnG,CAAC;YACJ,CAAC;YAED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