@runeditrun/rer 0.2.97 → 0.2.99
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/README.md +44 -28
- package/cli/business/api.mjs +15 -9
- package/cli/business/command.mjs +31 -13
- package/cli/business/connect.mjs +134 -4
- package/cli/business/device.mjs +10 -0
- package/cli/business/questions.mjs +2 -2
- package/cli/business/state.mjs +45 -3
- package/cli/business/supervisor.mjs +46 -7
- package/cli/business/vendor-door.mjs +3 -2
- package/global/CHANGELOG.md +41 -0
- package/global/README.md +44 -28
- package/global/cli/repo-command.mjs +3 -3
- package/global/launch/capture.mjs +36 -0
- package/global/launch/dev.mjs +4 -3
- package/global/launch/failure.mjs +1 -1
- package/global/launch/render.mjs +9 -0
- package/global/launch/state.mjs +4 -2
- package/global/launch/steps.mjs +24 -45
- package/global/launch/worker.mjs +9 -6
- package/modules/owner-claim/README.md +5 -4
- package/modules/owner-claim/index.d.mts +1 -1
- package/modules/owner-claim/index.mjs +2 -1
- package/onboarding/redaction-wrapped.mjs +38 -0
- package/onboarding/redaction.mjs +8 -2
- package/package.json +1 -1
|
@@ -10,11 +10,12 @@ export { OwnerClaimError, verifyOwnerClaim } from './verify.mjs';
|
|
|
10
10
|
export function createOwnerClaimHandler({ db, authConfig, clientIp, clock = Date.now, ...input }) {
|
|
11
11
|
const config = configureClaim(input);
|
|
12
12
|
const auth = configure(authConfig);
|
|
13
|
-
if (auth.origin !== config.appOrigin || auth.OWNER_EMAIL !== config.expectedEmail
|
|
13
|
+
if (auth.origin !== config.appOrigin || auth.OWNER_EMAIL !== config.expectedEmail
|
|
14
14
|
|| typeof clientIp !== 'function' || typeof clock !== 'function' || !db?.prepare || !db?.batch) throw new OwnerClaimError('invalid_configuration', 503);
|
|
15
15
|
return async request => {
|
|
16
16
|
const url = new URL(request.url);
|
|
17
17
|
if (url.pathname !== '/auth/owner-claim') return null;
|
|
18
|
+
if (!auth.SETUP_TOKEN) return Response.json({ error: 'claim_unavailable' }, { status: 409, headers: securityHeaders() });
|
|
18
19
|
try {
|
|
19
20
|
requireOrigin(request, auth);
|
|
20
21
|
// Credential URLs are never accepted, including legacy query transport.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// A terminal may wrap a registered credential inside its bytes. Retain the
|
|
2
|
+
// original offsets so both complete masks and streaming holds cover the wrap.
|
|
3
|
+
export function compactSecretText(text) {
|
|
4
|
+
const offsets = [], ends = [], characters = [];
|
|
5
|
+
for (let at = 0; at < text.length;) {
|
|
6
|
+
const start = at;
|
|
7
|
+
let character = text[at++];
|
|
8
|
+
// URL encoders may escape even unreserved ASCII, or encode a URL twice.
|
|
9
|
+
// Decode with source offsets so mixed encoded/plain key bytes also match.
|
|
10
|
+
if (character === '%' && /^[0-9a-f]{2}/i.test(text.slice(at, at + 2))) {
|
|
11
|
+
character = String.fromCharCode(parseInt(text.slice(at, at + 2), 16)); at += 2;
|
|
12
|
+
if (character === '%' && /^[0-9a-f]{2}/i.test(text.slice(at, at + 2))) { character = String.fromCharCode(parseInt(text.slice(at, at + 2), 16)); at += 2; }
|
|
13
|
+
}
|
|
14
|
+
if (!/\s/.test(character)) { offsets.push(start); ends.push(at); characters.push(character); }
|
|
15
|
+
}
|
|
16
|
+
const compact = characters.join('');
|
|
17
|
+
return {
|
|
18
|
+
ranges(secrets) {
|
|
19
|
+
const ranges = [];
|
|
20
|
+
for (const secret of secrets) {
|
|
21
|
+
if (/\s/.test(secret)) continue;
|
|
22
|
+
let at = 0;
|
|
23
|
+
while ((at = compact.indexOf(secret, at)) >= 0) { ranges.push([offsets[at], ends[at + secret.length - 1]]); at++; }
|
|
24
|
+
}
|
|
25
|
+
return ranges;
|
|
26
|
+
},
|
|
27
|
+
prefix(secrets, minimum) {
|
|
28
|
+
let cutoff = text.length;
|
|
29
|
+
for (const secret of secrets) {
|
|
30
|
+
if (/\s/.test(secret)) continue;
|
|
31
|
+
for (let at = Math.max(0, compact.length - secret.length + 1); at <= compact.length - minimum; at++) {
|
|
32
|
+
if (secret.startsWith(compact.slice(at))) { cutoff = Math.min(cutoff, offsets[at]); break; }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return cutoff;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
package/onboarding/redaction.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StringDecoder } from 'node:string_decoder';
|
|
2
2
|
import { jwtRanges, jwtHold } from './redaction-jwt.mjs';
|
|
3
|
+
import { compactSecretText } from './redaction-wrapped.mjs';
|
|
3
4
|
|
|
4
5
|
const MASK = '[REDACTED]';
|
|
5
6
|
const PEM_BEGIN = /-----BEGIN [A-Z0-9 ]{0,64}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
@@ -13,6 +14,7 @@ const CREDENTIAL_NAME = new RegExp(`(?:^|[_.-])(?:${CREDENTIAL_WORD})s?(?:$|[_.-
|
|
|
13
14
|
// Base's maintained Node 22 runtime. These names require a real case boundary.
|
|
14
15
|
const CAMEL_CREDENTIAL_NAME = /[A-Za-z0-9](?:Token|Secret|Credential|Key|Pat|Dsn|Auth|Pass|Passwd|Password|Pwd|Signature|Sig|Cookie)s?(?:$|[_.-]|[A-Z0-9])/;
|
|
15
16
|
const FIELD_NAME = '(?:api[_-]?key|access[_-]?token|auth[_-]?token|token|password|secret|signature|sig|key|pat|dsn|auth|pass)';
|
|
17
|
+
const DEV_FIELD = '(?<![A-Za-z0-9])rer-dev';
|
|
16
18
|
// A field name may follow `_` or `-` (DB_PASSWORD, client_secret, x-api-key),
|
|
17
19
|
// but not a letter or digit inside an ordinary word.
|
|
18
20
|
const FIELD = '(?<![A-Za-z0-9])' + FIELD_NAME;
|
|
@@ -34,6 +36,7 @@ const NOT_FLAG = '(?!(?:' + FLAG_WORDS + ')(?:[\\s"\'<>;&,)\\]}]|$))';
|
|
|
34
36
|
const DOUBLE_QUOTED = /"(?:\\[^\r\n]|[^"\\\r\n])*(?:\\(?=[\r\n]|$))?/.source;
|
|
35
37
|
const SINGLE_QUOTED = /'(?:\\[^\r\n]|[^'\\\r\n])*(?:\\(?=[\r\n]|$))?/.source;
|
|
36
38
|
const PRIVATE_VALUE = `(?:${DOUBLE_QUOTED}(?:"|(?=[\\r\\n]|$))|${SINGLE_QUOTED}(?:'|(?=[\\r\\n]|$))|[^\\s"'<>;&]+)`;
|
|
39
|
+
const DEV_KEY_PATTERN = new RegExp(DEV_FIELD + '["\']?\\s*[=:]\\s*(' + PRIVATE_VALUE + ')', 'gi');
|
|
37
40
|
const FIELD_VALUE = '["\']?\\s*[=:]\\s*' + NOT_FLAG + PRIVATE_VALUE;
|
|
38
41
|
// These deploy flags take a binding name, never the secret value. Explicitly
|
|
39
42
|
// registered private bytes remain redacted by the exact-value pass.
|
|
@@ -80,7 +83,7 @@ const privateAssignment = match => !AMBIGUOUS_FIELD.test(match[1]) || match[2].r
|
|
|
80
83
|
// stream, has nothing more to arrive, so a trailing bare field name, dash run
|
|
81
84
|
// or plain host:port is ordinary diagnostic text there.
|
|
82
85
|
const PREFIX_TAIL = '["\']?\\s*(?:[=:]\\s*)?["\']?$';
|
|
83
|
-
const FIELD_PREFIX = new RegExp('(?:\\b(?:Bearer|Basic)|' + FIELD + ')' + PREFIX_TAIL, 'i');
|
|
86
|
+
const FIELD_PREFIX = new RegExp('(?:\\b(?:Bearer|Basic)|' + FIELD + '|' + DEV_FIELD + ')' + PREFIX_TAIL, 'i');
|
|
84
87
|
const CAMEL_PREFIX = new RegExp(CAMEL_CONTEXT + PREFIX_TAIL);
|
|
85
88
|
const CLI_PREFIX_HOLD = new RegExp(CLI_PREFIX + FIELD_NAME + '\\s+$', 'i');
|
|
86
89
|
// Keep a quoted value's opening field until its closing quote arrives, even
|
|
@@ -145,7 +148,7 @@ function controlCleaner() {
|
|
|
145
148
|
const cleanText = text => controlCleaner().write(String(text));
|
|
146
149
|
|
|
147
150
|
// Keep every value for this session, even after its credential scope is cleared.
|
|
148
|
-
export function createRedaction({mask = MASK} = {}) {
|
|
151
|
+
export function createRedaction({mask = MASK, wrappedSecrets = false} = {}) {
|
|
149
152
|
const secrets = new Set();
|
|
150
153
|
let longest = 1;
|
|
151
154
|
// Each known value is registered with the encodings and parts a tool may print
|
|
@@ -175,6 +178,7 @@ export function createRedaction({mask = MASK} = {}) {
|
|
|
175
178
|
const ranges = text => {
|
|
176
179
|
const assignments = [...text.matchAll(CAMEL_PATTERN), ...text.matchAll(CLI_PATTERN)].filter(privateAssignment);
|
|
177
180
|
const found = [...text.matchAll(PATTERNS), ...assignments].map(match => [match.index, match.index + match[0].length]);
|
|
181
|
+
for (const match of text.matchAll(DEV_KEY_PATTERN)) found.push([match.index + match[0].length - match[1].length, match.index + match[0].length]);
|
|
178
182
|
found.push(...jwtRanges(text));
|
|
179
183
|
for (const begin of text.matchAll(PEM_BEGIN)) {
|
|
180
184
|
const end = [...text.slice(begin.index + begin[0].length).matchAll(PEM_END)][0];
|
|
@@ -184,6 +188,7 @@ export function createRedaction({mask = MASK} = {}) {
|
|
|
184
188
|
let from = 0, at;
|
|
185
189
|
while ((at = text.indexOf(secret, from)) >= 0) { found.push([at, at + secret.length]); from = at + 1; }
|
|
186
190
|
}
|
|
191
|
+
if (wrappedSecrets) found.push(...compactSecretText(text).ranges(secrets));
|
|
187
192
|
return found.sort((a,b) => a[0]-b[0]);
|
|
188
193
|
};
|
|
189
194
|
const replace = text => {
|
|
@@ -200,6 +205,7 @@ export function createRedaction({mask = MASK} = {}) {
|
|
|
200
205
|
// unterminated private-key block stays held there.
|
|
201
206
|
const incompleteStart = (text, minimumPrefix=1, complete=false) => {
|
|
202
207
|
let cutoff = text.length;
|
|
208
|
+
if (wrappedSecrets) cutoff = Math.min(cutoff, compactSecretText(text).prefix(secrets, minimumPrefix));
|
|
203
209
|
for (const secret of secrets) {
|
|
204
210
|
// The earliest start whose remaining text begins this secret is its longest held prefix.
|
|
205
211
|
for (let at=Math.max(0,text.length-secret.length+1); at<=text.length-minimumPrefix; at++) {
|