@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.
- package/dist/bson.d.ts +28 -0
- package/dist/bson.d.ts.map +1 -0
- package/dist/bson.js +37 -0
- package/dist/bson.js.map +1 -0
- package/dist/classification.d.ts +69 -0
- package/dist/classification.d.ts.map +1 -0
- package/dist/classification.js +104 -0
- package/dist/classification.js.map +1 -0
- package/dist/compare.d.ts +36 -0
- package/dist/compare.d.ts.map +1 -0
- package/dist/compare.js +123 -0
- package/dist/compare.js.map +1 -0
- package/dist/context.d.ts +78 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +110 -0
- package/dist/context.js.map +1 -0
- package/dist/derive.d.ts +110 -0
- package/dist/derive.d.ts.map +1 -0
- package/dist/derive.js +153 -0
- package/dist/derive.js.map +1 -0
- package/dist/destination.d.ts +120 -0
- package/dist/destination.d.ts.map +1 -0
- package/dist/destination.js +352 -0
- package/dist/destination.js.map +1 -0
- package/dist/deterministic.d.ts +145 -0
- package/dist/deterministic.d.ts.map +1 -0
- package/dist/deterministic.js +352 -0
- package/dist/deterministic.js.map +1 -0
- package/dist/dev-mode.d.ts +177 -0
- package/dist/dev-mode.d.ts.map +1 -0
- package/dist/dev-mode.js +503 -0
- package/dist/dev-mode.js.map +1 -0
- package/dist/environment.d.ts +181 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +558 -0
- package/dist/environment.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/global-state.d.ts +8 -0
- package/dist/global-state.d.ts.map +1 -0
- package/dist/global-state.js +22 -0
- package/dist/global-state.js.map +1 -0
- package/dist/hash.d.ts +74 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +253 -0
- package/dist/hash.js.map +1 -0
- package/dist/hygiene.d.ts +242 -0
- package/dist/hygiene.d.ts.map +1 -0
- package/dist/hygiene.js +257 -0
- package/dist/hygiene.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +233 -0
- package/dist/index.js.map +1 -0
- package/dist/mask.d.ts +51 -0
- package/dist/mask.d.ts.map +1 -0
- package/dist/mask.js +461 -0
- package/dist/mask.js.map +1 -0
- package/dist/own-property.d.ts +20 -0
- package/dist/own-property.d.ts.map +1 -0
- package/dist/own-property.js +34 -0
- package/dist/own-property.js.map +1 -0
- package/dist/patterns.d.ts +12 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +19 -0
- package/dist/patterns.js.map +1 -0
- package/dist/policy.d.ts +51 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +181 -0
- package/dist/policy.js.map +1 -0
- package/dist/probe.d.ts +141 -0
- package/dist/probe.d.ts.map +1 -0
- package/dist/probe.js +213 -0
- package/dist/probe.js.map +1 -0
- package/dist/redact-copy.d.ts +61 -0
- package/dist/redact-copy.d.ts.map +1 -0
- package/dist/redact-copy.js +217 -0
- package/dist/redact-copy.js.map +1 -0
- package/dist/redact.d.ts +141 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +514 -0
- package/dist/redact.js.map +1 -0
- package/dist/redaction-marker.d.ts +48 -0
- package/dist/redaction-marker.d.ts.map +1 -0
- package/dist/redaction-marker.js +138 -0
- package/dist/redaction-marker.js.map +1 -0
- package/dist/redaction-observer.d.ts +108 -0
- package/dist/redaction-observer.d.ts.map +1 -0
- package/dist/redaction-observer.js +103 -0
- package/dist/redaction-observer.js.map +1 -0
- package/dist/redaction-scope.d.ts +21 -0
- package/dist/redaction-scope.d.ts.map +1 -0
- package/dist/redaction-scope.js +44 -0
- package/dist/redaction-scope.js.map +1 -0
- package/dist/reference.d.ts +101 -0
- package/dist/reference.d.ts.map +1 -0
- package/dist/reference.js +123 -0
- package/dist/reference.js.map +1 -0
- package/dist/regexp.d.ts +25 -0
- package/dist/regexp.d.ts.map +1 -0
- package/dist/regexp.js +61 -0
- package/dist/regexp.js.map +1 -0
- package/dist/release.d.ts +88 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +108 -0
- package/dist/release.js.map +1 -0
- package/dist/reveal-budget.d.ts +148 -0
- package/dist/reveal-budget.d.ts.map +1 -0
- package/dist/reveal-budget.js +314 -0
- package/dist/reveal-budget.js.map +1 -0
- package/dist/revocation.d.ts +168 -0
- package/dist/revocation.d.ts.map +1 -0
- package/dist/revocation.js +541 -0
- package/dist/revocation.js.map +1 -0
- package/dist/sealing.d.ts +283 -0
- package/dist/sealing.d.ts.map +1 -0
- package/dist/sealing.js +523 -0
- package/dist/sealing.js.map +1 -0
- package/dist/sensitive-string.d.ts +919 -0
- package/dist/sensitive-string.d.ts.map +1 -0
- package/dist/sensitive-string.js +2260 -0
- package/dist/sensitive-string.js.map +1 -0
- package/dist/serialized.d.ts +33 -0
- package/dist/serialized.d.ts.map +1 -0
- package/dist/serialized.js +65 -0
- package/dist/serialized.js.map +1 -0
- package/dist/template.d.ts +69 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +158 -0
- package/dist/template.js.map +1 -0
- package/dist/ttl.d.ts +104 -0
- package/dist/ttl.d.ts.map +1 -0
- package/dist/ttl.js +330 -0
- package/dist/ttl.js.map +1 -0
- package/dist/types.d.ts +859 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/winston.d.ts +114 -0
- package/dist/winston.d.ts.map +1 -0
- package/dist/winston.js +170 -0
- package/dist/winston.js.map +1 -0
- package/dist/worker.d.ts +398 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +861 -0
- package/dist/worker.js.map +1 -0
- package/dist/wrap.d.ts +287 -0
- package/dist/wrap.d.ts.map +1 -0
- package/dist/wrap.js +553 -0
- package/dist/wrap.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RevocationList = exports.RevokedSensitiveValueError = void 0;
|
|
4
|
+
exports.requireReason = requireReason;
|
|
5
|
+
exports.revokeByLabel = revokeByLabel;
|
|
6
|
+
exports.revokeByPattern = revokeByPattern;
|
|
7
|
+
exports.pruneRevocations = pruneRevocations;
|
|
8
|
+
exports.revocationCount = revocationCount;
|
|
9
|
+
exports.planRevocation = planRevocation;
|
|
10
|
+
exports.revocationInForce = revocationInForce;
|
|
11
|
+
exports.observedRevocation = observedRevocation;
|
|
12
|
+
exports.revokeStates = revokeStates;
|
|
13
|
+
exports.revokeAuditDetails = revokeAuditDetails;
|
|
14
|
+
const errors_js_1 = require("./errors.js");
|
|
15
|
+
const global_state_js_1 = require("./global-state.js");
|
|
16
|
+
const regexp_js_1 = require("./regexp.js");
|
|
17
|
+
/**
|
|
18
|
+
* Describe a rejected option without disclosing it.
|
|
19
|
+
*/
|
|
20
|
+
function describeType(value) {
|
|
21
|
+
return value === null ? 'null' : typeof value;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Raised when an operation needs the raw value of a revoked instance.
|
|
25
|
+
*
|
|
26
|
+
* `scope` says which of the four revocation sources refused, and separates a
|
|
27
|
+
* value somebody revoked from one whose registry could not be reached: the
|
|
28
|
+
* first is permanent and the caller fetches a new secret, the second may clear
|
|
29
|
+
* and the caller may retry.
|
|
30
|
+
*
|
|
31
|
+
* `reason` and `label` are developer-supplied text and appear in the message.
|
|
32
|
+
* Neither may carry any part of the protected value.
|
|
33
|
+
*/
|
|
34
|
+
class RevokedSensitiveValueError extends errors_js_1.SensitiveStringError {
|
|
35
|
+
reason;
|
|
36
|
+
revokedAt;
|
|
37
|
+
label;
|
|
38
|
+
name = 'RevokedSensitiveValueError';
|
|
39
|
+
code = 'revoked-value';
|
|
40
|
+
scope;
|
|
41
|
+
constructor(reason, revokedAt, label, scope = 'instance', cause) {
|
|
42
|
+
const named = label !== undefined ? ` '${label}'` : '';
|
|
43
|
+
const message = scope === 'unavailable'
|
|
44
|
+
? `Sensitive value${named} cannot be read: ${reason}`
|
|
45
|
+
: `Sensitive value${named} was revoked at ${revokedAt.toISOString()}: ${reason}`;
|
|
46
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
47
|
+
this.reason = reason;
|
|
48
|
+
this.revokedAt = revokedAt;
|
|
49
|
+
this.label = label;
|
|
50
|
+
this.scope = scope;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.RevokedSensitiveValueError = RevokedSensitiveValueError;
|
|
54
|
+
const revocations = (0, global_state_js_1.getGlobalSingleton)('revocations', () => ({
|
|
55
|
+
labels: new Map(),
|
|
56
|
+
patterns: [],
|
|
57
|
+
generation: 0,
|
|
58
|
+
}));
|
|
59
|
+
function requireLabel(value, operation) {
|
|
60
|
+
if (typeof value !== 'string') {
|
|
61
|
+
throw new TypeError(`${operation}: label must be a string, received ${describeType(value)}`);
|
|
62
|
+
}
|
|
63
|
+
if (value.length === 0) {
|
|
64
|
+
throw new RangeError(`${operation}: label must not be empty; a value with no label cannot be revoked by label`);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
function requireReason(value, operation) {
|
|
69
|
+
if (typeof value !== 'string') {
|
|
70
|
+
throw new TypeError(`${operation}: reason must be a string, received ${describeType(value)}`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read the quantifier at `index`, or `undefined` when there is none.
|
|
76
|
+
*
|
|
77
|
+
* `unbounded` marks the quantifiers that admit more than one repetition, which
|
|
78
|
+
* are the ones that turn an ambiguous group into exponential backtracking. `?`
|
|
79
|
+
* is a quantifier but not an unbounded one: it admits a single repetition and
|
|
80
|
+
* cannot multiply the work inside the group it follows.
|
|
81
|
+
*/
|
|
82
|
+
function readQuantifier(source, index) {
|
|
83
|
+
const char = source[index];
|
|
84
|
+
if (char === '*' || char === '+') {
|
|
85
|
+
return { unbounded: true, end: index };
|
|
86
|
+
}
|
|
87
|
+
if (char === '?') {
|
|
88
|
+
return { unbounded: false, end: index };
|
|
89
|
+
}
|
|
90
|
+
if (char !== '{') {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const close = source.indexOf('}', index);
|
|
94
|
+
if (close < 0) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const body = source.slice(index + 1, close);
|
|
98
|
+
const bounds = /^(\d+)(,(\d*))?$/.exec(body);
|
|
99
|
+
if (bounds === null) {
|
|
100
|
+
// Not a quantifier at all: a literal brace, which JavaScript permits.
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const [, minimum, comma, maximum] = bounds;
|
|
104
|
+
const upper = comma === undefined ? Number(minimum) : maximum === '' ? Infinity : Number(maximum);
|
|
105
|
+
return { unbounded: upper > 1, end: close };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Whether a pattern applies a quantifier admitting more than one repetition
|
|
109
|
+
* (`*`, `+`, or a `{...}` form whose upper bound is above one) to a group that
|
|
110
|
+
* can already match the same input more than one way.
|
|
111
|
+
*
|
|
112
|
+
* This is the nested-quantifier heuristic, and it is deliberately strict: it
|
|
113
|
+
* rejects `(a+)+`, `(a*)*`, `(a|b)+`, and anything that nests them, including
|
|
114
|
+
* shapes that happen to be safe because their alternatives are disjoint. A
|
|
115
|
+
* pattern kept in a process-global list is tested against every label a value
|
|
116
|
+
* carries, on a thread that cannot be interrupted, so a false rejection with a
|
|
117
|
+
* message and an easy rewrite is the right trade against a pattern that hangs
|
|
118
|
+
* the process on the first read after somebody revokes something.
|
|
119
|
+
*
|
|
120
|
+
* It is a heuristic and not a decision procedure. It says nothing about
|
|
121
|
+
* backtracking that arises between groups rather than inside one.
|
|
122
|
+
*/
|
|
123
|
+
function nestsQuantifiers(source) {
|
|
124
|
+
// One frame per open group, plus an implicit outermost frame for the pattern
|
|
125
|
+
// itself. `ambiguous` records that the frame's body can match the same input
|
|
126
|
+
// in more than one way, which is a quantifier or an alternation inside it.
|
|
127
|
+
const stack = [{ ambiguous: false }];
|
|
128
|
+
let inClass = false;
|
|
129
|
+
for (let index = 0; index < source.length; index++) {
|
|
130
|
+
const char = source[index];
|
|
131
|
+
if (char === '\\') {
|
|
132
|
+
index++;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (inClass) {
|
|
136
|
+
if (char === ']') {
|
|
137
|
+
inClass = false;
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (char === '[') {
|
|
142
|
+
inClass = true;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const frame = stack[stack.length - 1];
|
|
146
|
+
if (frame === undefined) {
|
|
147
|
+
// Unbalanced source. The RegExp constructor already accepted it, so this
|
|
148
|
+
// is a shape the scanner does not model; refuse rather than guess.
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (char === '(') {
|
|
152
|
+
stack.push({ ambiguous: false });
|
|
153
|
+
index = skipGroupPrefix(source, index);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (char === ')') {
|
|
157
|
+
if (stack.length === 1) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
stack.pop();
|
|
161
|
+
const parent = stack[stack.length - 1];
|
|
162
|
+
if (parent === undefined) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
const quantifier = readQuantifier(source, index + 1);
|
|
166
|
+
if (quantifier !== undefined) {
|
|
167
|
+
if (quantifier.unbounded && frame.ambiguous) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
// A repeated group is itself a repetition in whatever contains it.
|
|
171
|
+
parent.ambiguous = true;
|
|
172
|
+
index = quantifier.end;
|
|
173
|
+
}
|
|
174
|
+
// A group whose body is ambiguous makes its container ambiguous too, so
|
|
175
|
+
// `((a+))+` is caught at the outer quantifier.
|
|
176
|
+
parent.ambiguous ||= frame.ambiguous;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (char === '|') {
|
|
180
|
+
frame.ambiguous = true;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const quantifier = readQuantifier(source, index);
|
|
184
|
+
if (quantifier !== undefined) {
|
|
185
|
+
frame.ambiguous = true;
|
|
186
|
+
index = quantifier.end;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Move past `(?:`, `(?=`, `(?!`, `(?<=`, `(?<!`, and `(?<name>`.
|
|
193
|
+
*
|
|
194
|
+
* Returns the index of the last character of the prefix, which the scanner's
|
|
195
|
+
* own increment steps off. Without this the `?` of `(?:` reads as a quantifier
|
|
196
|
+
* and every non-capturing group looks ambiguous.
|
|
197
|
+
*/
|
|
198
|
+
function skipGroupPrefix(source, open) {
|
|
199
|
+
if (source[open + 1] !== '?') {
|
|
200
|
+
return open;
|
|
201
|
+
}
|
|
202
|
+
const marker = source[open + 2];
|
|
203
|
+
if (marker !== '<') {
|
|
204
|
+
// (?: (?= (?!
|
|
205
|
+
return open + 2;
|
|
206
|
+
}
|
|
207
|
+
if (source[open + 3] === '=' || source[open + 3] === '!') {
|
|
208
|
+
return open + 3;
|
|
209
|
+
}
|
|
210
|
+
const close = source.indexOf('>', open + 3);
|
|
211
|
+
return close < 0 ? open + 2 : close;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Revoke every value constructed under a label, in this process.
|
|
215
|
+
*
|
|
216
|
+
* The first revocation of a label wins: a second call leaves the original
|
|
217
|
+
* reason and timestamp in place, because a revocation is a fact that already
|
|
218
|
+
* happened and re-stating it does not change when it did.
|
|
219
|
+
*
|
|
220
|
+
* @throws TypeError If `label` or `reason` is not a string.
|
|
221
|
+
* @throws RangeError If `label` is empty.
|
|
222
|
+
*/
|
|
223
|
+
function revokeByLabel(label, reason) {
|
|
224
|
+
const key = requireLabel(label, 'revokeByLabel');
|
|
225
|
+
const why = requireReason(reason, 'revokeByLabel');
|
|
226
|
+
if (revocations.labels.has(key)) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
revocations.labels.set(key, Object.freeze({ reason: why, at: Date.now(), scope: 'label' }));
|
|
230
|
+
revocations.generation++;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Revoke every value whose construction label matches a pattern, in this
|
|
234
|
+
* process.
|
|
235
|
+
*
|
|
236
|
+
* The pattern is copied out of the caller's RegExp, so mutating theirs
|
|
237
|
+
* afterwards changes nothing, and the copy drops `g` and `y`, which would
|
|
238
|
+
* otherwise make it match every other time it was consulted.
|
|
239
|
+
*
|
|
240
|
+
* @throws TypeError If `pattern` is not a regular expression, if `reason` is
|
|
241
|
+
* not a string, or if the pattern nests quantifiers.
|
|
242
|
+
*/
|
|
243
|
+
function revokeByPattern(pattern, reason) {
|
|
244
|
+
const why = requireReason(reason, 'revokeByPattern');
|
|
245
|
+
const compiled = (0, regexp_js_1.snapshotStatelessRegExp)(pattern, 'revokeByPattern');
|
|
246
|
+
if (nestsQuantifiers(compiled.source)) {
|
|
247
|
+
throw new TypeError(`revokeByPattern: /${compiled.source}/ applies an unbounded quantifier to a group that ` +
|
|
248
|
+
'can match the same input more than one way, which backtracks exponentially. ' +
|
|
249
|
+
'Rewrite it without the nested quantifier.');
|
|
250
|
+
}
|
|
251
|
+
revocations.patterns.push({
|
|
252
|
+
pattern: compiled,
|
|
253
|
+
record: Object.freeze({ reason: why, at: Date.now(), scope: 'pattern' }),
|
|
254
|
+
});
|
|
255
|
+
revocations.generation++;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Drop label and pattern revocations recorded before a cutoff, and report how
|
|
259
|
+
* many were dropped.
|
|
260
|
+
*
|
|
261
|
+
* The lists hold strong references and grow for the life of the process, so
|
|
262
|
+
* something has to be able to shrink them. Dropping an entry while a value it
|
|
263
|
+
* matches is still reachable would bring that value back, so this is only safe
|
|
264
|
+
* once every instance that could match has been collected: after a rotation has
|
|
265
|
+
* drained, after the request that held the value has finished, at a point where
|
|
266
|
+
* the process no longer holds a reference to anything constructed under the
|
|
267
|
+
* label. A value that has already been refused stays refused whatever is
|
|
268
|
+
* pruned, because the refusal is latched onto the value when it is observed.
|
|
269
|
+
*
|
|
270
|
+
* @param olderThan - A Date or epoch milliseconds. Entries recorded strictly
|
|
271
|
+
* before it are dropped.
|
|
272
|
+
*/
|
|
273
|
+
function pruneRevocations(olderThan) {
|
|
274
|
+
const cutoff = typeof olderThan === 'number' ? olderThan : olderThan.getTime();
|
|
275
|
+
if (!Number.isFinite(cutoff)) {
|
|
276
|
+
throw new RangeError('pruneRevocations: olderThan must be a valid Date or a finite number');
|
|
277
|
+
}
|
|
278
|
+
let dropped = 0;
|
|
279
|
+
for (const [label, record] of revocations.labels) {
|
|
280
|
+
if (record.at < cutoff) {
|
|
281
|
+
revocations.labels.delete(label);
|
|
282
|
+
dropped++;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
for (let index = revocations.patterns.length - 1; index >= 0; index--) {
|
|
286
|
+
const entry = revocations.patterns[index];
|
|
287
|
+
if (entry !== undefined && entry.record.at < cutoff) {
|
|
288
|
+
revocations.patterns.splice(index, 1);
|
|
289
|
+
dropped++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (dropped > 0) {
|
|
293
|
+
revocations.generation++;
|
|
294
|
+
}
|
|
295
|
+
return dropped;
|
|
296
|
+
}
|
|
297
|
+
/** How many label and pattern revocations the process is holding. */
|
|
298
|
+
function revocationCount() {
|
|
299
|
+
return { labels: revocations.labels.size, patterns: revocations.patterns.length };
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* A revocation list held in this process, for callers who want a scope smaller
|
|
303
|
+
* than the whole process, and the shape a store-backed registry implements.
|
|
304
|
+
*/
|
|
305
|
+
class RevocationList {
|
|
306
|
+
#entries = new Map();
|
|
307
|
+
/**
|
|
308
|
+
* Revoke a label. The first revocation of a label wins, as it does globally.
|
|
309
|
+
*
|
|
310
|
+
* @throws TypeError If `label` or `reason` is not a string.
|
|
311
|
+
* @throws RangeError If `label` is empty.
|
|
312
|
+
*/
|
|
313
|
+
revoke(label, reason) {
|
|
314
|
+
const key = requireLabel(label, 'RevocationList.revoke');
|
|
315
|
+
const why = requireReason(reason, 'RevocationList.revoke');
|
|
316
|
+
if (!this.#entries.has(key)) {
|
|
317
|
+
this.#entries.set(key, Object.freeze({ reason: why, at: Date.now(), scope: 'registry' }));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
isRevoked(label) {
|
|
321
|
+
return label !== undefined && this.#entries.has(label);
|
|
322
|
+
}
|
|
323
|
+
getReason(label) {
|
|
324
|
+
return this.#entries.get(label)?.reason;
|
|
325
|
+
}
|
|
326
|
+
/** When a label was revoked, or `undefined` when it was not. */
|
|
327
|
+
revokedAt(label) {
|
|
328
|
+
const at = this.#entries.get(label)?.at;
|
|
329
|
+
return at === undefined ? undefined : new Date(at);
|
|
330
|
+
}
|
|
331
|
+
/** Drop entries recorded before a cutoff. The caveat on {@link pruneRevocations} applies. */
|
|
332
|
+
prune(olderThan) {
|
|
333
|
+
const cutoff = typeof olderThan === 'number' ? olderThan : olderThan.getTime();
|
|
334
|
+
let dropped = 0;
|
|
335
|
+
for (const [label, record] of this.#entries) {
|
|
336
|
+
if (record.at < cutoff) {
|
|
337
|
+
this.#entries.delete(label);
|
|
338
|
+
dropped++;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return dropped;
|
|
342
|
+
}
|
|
343
|
+
get size() {
|
|
344
|
+
return this.#entries.size;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.RevocationList = RevocationList;
|
|
348
|
+
/**
|
|
349
|
+
* Build the revocation state for a newly constructed value.
|
|
350
|
+
*
|
|
351
|
+
* @throws TypeError If `revocationRegistry` is not an object with an `isRevoked` method.
|
|
352
|
+
*/
|
|
353
|
+
function planRevocation(options, label) {
|
|
354
|
+
const registry = options?.revocationRegistry;
|
|
355
|
+
if (registry !== undefined) {
|
|
356
|
+
if (typeof registry !== 'object' || registry === null) {
|
|
357
|
+
throw new TypeError(`SensitiveString: revocationRegistry must be an object, received ${describeType(registry)}`);
|
|
358
|
+
}
|
|
359
|
+
if (typeof registry.isRevoked !== 'function') {
|
|
360
|
+
throw new TypeError('SensitiveString: revocationRegistry must have an isRevoked method');
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return { record: undefined, generation: -1, label, registry };
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Search the process-global lists for this cell, and cache a clean answer
|
|
367
|
+
* against the generation it was taken at.
|
|
368
|
+
*
|
|
369
|
+
* Only ever called when the generation has moved, so a cell that has looked
|
|
370
|
+
* once does not search again until something is revoked or pruned. The
|
|
371
|
+
* comparison that decides that is inline at both call sites rather than here,
|
|
372
|
+
* so the common case reaches no call at all.
|
|
373
|
+
*/
|
|
374
|
+
function searchGlobal(cell, generation) {
|
|
375
|
+
const { label } = cell;
|
|
376
|
+
if (label !== undefined) {
|
|
377
|
+
const byLabel = revocations.labels.get(label);
|
|
378
|
+
if (byLabel !== undefined) {
|
|
379
|
+
return byLabel;
|
|
380
|
+
}
|
|
381
|
+
for (const { pattern, record } of revocations.patterns) {
|
|
382
|
+
if (pattern.test(label)) {
|
|
383
|
+
return record;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
cell.generation = generation;
|
|
388
|
+
return undefined;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Ask an external registry, failing closed.
|
|
392
|
+
*
|
|
393
|
+
* A registry that throws is a store that could not be reached, and a value
|
|
394
|
+
* whose revocation cannot be checked is not one to hand out. So is a registry
|
|
395
|
+
* that answers with anything but a boolean: an `async isRevoked` returns a
|
|
396
|
+
* Promise, which is truthy and would revoke everything if truthiness were the
|
|
397
|
+
* test, and is not `true`, so it would revoke nothing if strict equality were.
|
|
398
|
+
* Refusing the answer catches the mistake instead of quietly picking one of
|
|
399
|
+
* those two failures.
|
|
400
|
+
*
|
|
401
|
+
* Neither refusal is latched. Both describe the registry rather than the value,
|
|
402
|
+
* and a store that comes back must be able to answer again.
|
|
403
|
+
*/
|
|
404
|
+
function registryRevocation(cell) {
|
|
405
|
+
const { registry } = cell;
|
|
406
|
+
if (registry === undefined) {
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
let answer;
|
|
410
|
+
try {
|
|
411
|
+
answer = registry.isRevoked(cell.label);
|
|
412
|
+
}
|
|
413
|
+
catch (cause) {
|
|
414
|
+
return {
|
|
415
|
+
reason: 'the revocation registry is unreachable',
|
|
416
|
+
at: Date.now(),
|
|
417
|
+
scope: 'unavailable',
|
|
418
|
+
cause,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
if (typeof answer !== 'boolean') {
|
|
422
|
+
return {
|
|
423
|
+
reason: `the revocation registry answered with ${describeType(answer)} rather than a boolean; ` +
|
|
424
|
+
'it must answer synchronously',
|
|
425
|
+
at: Date.now(),
|
|
426
|
+
scope: 'unavailable',
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (!answer) {
|
|
430
|
+
return undefined;
|
|
431
|
+
}
|
|
432
|
+
let reason;
|
|
433
|
+
try {
|
|
434
|
+
reason = cell.label === undefined ? undefined : registry.getReason?.(cell.label);
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
// A registry that can say "revoked" but not why still said "revoked".
|
|
438
|
+
reason = undefined;
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
reason: typeof reason === 'string' ? reason : 'revoked by the registry',
|
|
442
|
+
at: Date.now(),
|
|
443
|
+
scope: 'registry',
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The revocation that refuses a read of these states, or `undefined`.
|
|
448
|
+
*
|
|
449
|
+
* A definite revocation is latched onto the cell that produced it, so a value
|
|
450
|
+
* that has once been refused stays refused even if the entry behind it is
|
|
451
|
+
* pruned. An unreachable registry is not latched: it describes the store.
|
|
452
|
+
*/
|
|
453
|
+
function revocationInForce(states) {
|
|
454
|
+
for (const state of states) {
|
|
455
|
+
const cell = state.revocation;
|
|
456
|
+
if (cell.record !== undefined) {
|
|
457
|
+
return cell.record;
|
|
458
|
+
}
|
|
459
|
+
// Read per state rather than once for the walk. A registry consulted for an
|
|
460
|
+
// earlier state is caller code, and it is free to revoke something; a
|
|
461
|
+
// generation hoisted out of the loop would let a later state cache that
|
|
462
|
+
// stale number and skip the search that would have found it.
|
|
463
|
+
const { generation } = revocations;
|
|
464
|
+
// Both guards are inline. A value that has looked once and was given no
|
|
465
|
+
// registry leaves this check having compared two integers and called
|
|
466
|
+
// nothing, which is what every read in a process that revokes nothing pays.
|
|
467
|
+
if (cell.generation !== generation) {
|
|
468
|
+
const global = searchGlobal(cell, generation);
|
|
469
|
+
if (global !== undefined) {
|
|
470
|
+
cell.record = global;
|
|
471
|
+
return global;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (cell.registry !== undefined) {
|
|
475
|
+
const external = registryRevocation(cell);
|
|
476
|
+
if (external !== undefined) {
|
|
477
|
+
if (external.scope !== 'unavailable') {
|
|
478
|
+
cell.record = external;
|
|
479
|
+
}
|
|
480
|
+
return external;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* The revocation an inspection can see.
|
|
488
|
+
*
|
|
489
|
+
* Inspection observes and does not decide: it never calls out to an external
|
|
490
|
+
* registry, because a log line must not make a network call, and it never
|
|
491
|
+
* latches, because a value that was only ever printed has not been used.
|
|
492
|
+
*/
|
|
493
|
+
function observedRevocation(states) {
|
|
494
|
+
for (const state of states) {
|
|
495
|
+
const cell = state.revocation;
|
|
496
|
+
if (cell.record !== undefined) {
|
|
497
|
+
return cell.record;
|
|
498
|
+
}
|
|
499
|
+
const { generation } = revocations;
|
|
500
|
+
if (cell.generation !== generation) {
|
|
501
|
+
const global = searchGlobal(cell, generation);
|
|
502
|
+
if (global !== undefined) {
|
|
503
|
+
return global;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return undefined;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Revoke every state a value shares, and report the record written, or
|
|
511
|
+
* `undefined` when every one of them was already revoked.
|
|
512
|
+
*
|
|
513
|
+
* Revocation runs along derivation edges in both directions. A derivative
|
|
514
|
+
* carries the material of the values it was built from, so a compromised
|
|
515
|
+
* substring is a compromised secret, and refusing to revoke through the handle
|
|
516
|
+
* a caller happens to be holding would fail open in exactly the incident this
|
|
517
|
+
* feature exists for. That is the opposite of `renew()`, which refuses on a
|
|
518
|
+
* derivative: refusing to extend a lifetime fails closed, refusing to end one
|
|
519
|
+
* does not.
|
|
520
|
+
*/
|
|
521
|
+
function revokeStates(states, reason, scope = 'instance') {
|
|
522
|
+
let written;
|
|
523
|
+
for (const state of states) {
|
|
524
|
+
if (state.revocation.record !== undefined) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
written ??= Object.freeze({ reason, at: Date.now(), scope });
|
|
528
|
+
state.revocation.record = written;
|
|
529
|
+
}
|
|
530
|
+
return written;
|
|
531
|
+
}
|
|
532
|
+
/** The audit record for a revocation that took effect. */
|
|
533
|
+
function revokeAuditDetails(record) {
|
|
534
|
+
return Object.freeze({
|
|
535
|
+
operation: 'revoke',
|
|
536
|
+
reason: record.reason,
|
|
537
|
+
revokedAt: new Date(record.at).toISOString(),
|
|
538
|
+
scope: record.scope,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
//# sourceMappingURL=revocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revocation.js","sourceRoot":"","sources":["../src/revocation.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