@runeditrun/rer 0.2.43 → 0.2.44
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/cli/README.md +3 -1
- package/cli/business/command.mjs +1 -1
- package/cli/business/keychain.mjs +1 -1
- package/cli/business/lease.mjs +1 -1
- package/cli/business/questions.mjs +2 -2
- package/cli/contract.mjs +1 -1
- package/cli/deploy-readiness.mjs +2 -2
- package/cli/deploy.mjs +17 -4
- package/cli/parse.mjs +9 -3
- package/global/CHANGELOG.md +8 -0
- package/modules/dependencies/README.md +5 -2
- package/modules/dependencies/index.mjs +4 -3
- package/modules/dependencies/protocol.mjs +7 -5
- package/modules/deploy-kit/README.md +1 -0
- package/modules/deploy-kit/owner-cli.mjs +8 -6
- package/modules/deploy-kit/owner-secret-copy.mjs +38 -0
- package/modules/deploy-kit/owner-secret-names.mjs +1 -1
- package/modules/deploy-kit/owner-secret.mjs +39 -18
- package/modules/deploy-kit/owner.mjs +23 -14
- package/modules/deploy-kit/provider.mjs +20 -3
- package/modules/operator-auth/identity/oidc/config.mjs +10 -8
- package/modules/operator-auth/signin/index.mjs +3 -3
- package/modules/release/catalogue.mjs +1 -1
- package/onboarding/schema/setup-validation.mjs +1 -1
- package/onboarding/theme.mjs +1 -1
- package/onboarding/ui/app.js +1 -1
- package/package.json +1 -1
package/cli/README.md
CHANGED
|
@@ -332,7 +332,9 @@ upload.
|
|
|
332
332
|
child build environment and are redacted; the caller environment is restored
|
|
333
333
|
on success and failure. `--remove`, `--set-secret` and `--unset-secret` always go
|
|
334
334
|
through the owner-account controller, without invoking the application's build
|
|
335
|
-
or deploy hook.
|
|
335
|
+
or deploy hook. `--set-secret A,B` (or the flag repeated) changes several
|
|
336
|
+
secrets in one Worker version or none, after checking that each is declared
|
|
337
|
+
and, when set, has its value. Failure reports distinguish deployment, owner claim and token
|
|
336
338
|
retirement and preserve the environment, checkout and env-file in recovery
|
|
337
339
|
commands. Retirement can be finished with `rer deploy --unset-secret SETUP_TOKEN`
|
|
338
340
|
plus the same `--environment`, `--env-file` and `--cwd` arguments.
|
package/cli/business/command.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const usage = `Usage: rer business VERB
|
|
|
11
11
|
run [--once] Run consented local discovery; vendor upload integration pending
|
|
12
12
|
next Return one templated question or nothing yet within 60 seconds
|
|
13
13
|
answer ID VENDOR USAGE [CONFIDENCE]
|
|
14
|
-
|
|
14
|
+
Catalog vendor or none; uses, sells, both, product-dependency
|
|
15
15
|
vendor-key add|remove VENDOR Keep a vendor key in OS credential storage
|
|
16
16
|
token MCP headersHelper output; send directly to the MCP client
|
|
17
17
|
status [--json] Pairing, service, current task and checkpoint
|
|
@@ -94,7 +94,7 @@ export async function readSecret({ input = process.stdin, output = process.stder
|
|
|
94
94
|
input.setRawMode(Boolean(wasRaw)); if (!wasFlowing) input.pause(); output.write('\n');
|
|
95
95
|
if (error) reject(error); else { try { resolve(checkedSecret(secret)); } catch (e) { reject(e); } }
|
|
96
96
|
}
|
|
97
|
-
const interrupted = () => finish(new Error('Credential entry
|
|
97
|
+
const interrupted = () => finish(new Error('Credential entry canceled.'));
|
|
98
98
|
const terminated = () => finish(new Error('Credential entry interrupted.'));
|
|
99
99
|
const ended = () => finish(new Error('Credential input ended before confirmation.'));
|
|
100
100
|
function data(chunk) {
|
package/cli/business/lease.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export class Lease {
|
|
|
43
43
|
this.expires = expires;
|
|
44
44
|
this.cursor = Number.isSafeInteger(result.cursor) ? result.cursor : this.cursor;
|
|
45
45
|
if (result.cancel_requested || result.controls?.some(control => control.kind === 'cancel' || control.instruction === 'pause')) {
|
|
46
|
-
this.controller.abort(Error('Business task was paused or
|
|
46
|
+
this.controller.abort(Error('Business task was paused or canceled in the browser.'));
|
|
47
47
|
this.signal.throwIfAborted();
|
|
48
48
|
}
|
|
49
49
|
// Controls contain only closed enums. A requested checkpoint is already
|
|
@@ -66,7 +66,7 @@ export async function next() {
|
|
|
66
66
|
export async function answer(id, vendorId, choice, rawConfidence = '1') {
|
|
67
67
|
identifier(id);
|
|
68
68
|
// Reject free text before even looking up the question or minting a bearer.
|
|
69
|
-
if (typeof vendorId !== 'string' || !/^[a-z][a-z0-9-]{0,79}$/.test(vendorId) || sensitive(vendorId)) throw Error('Choose a
|
|
69
|
+
if (typeof vendorId !== 'string' || !/^[a-z][a-z0-9-]{0,79}$/.test(vendorId) || sensitive(vendorId)) throw Error('Choose a catalog vendor id from rer business next, or none.');
|
|
70
70
|
if (!classifications.includes(choice)) throw Error(`Choose an enum: ${classifications.join(', ')}.`);
|
|
71
71
|
if (!/^(?:0(?:\.\d+)?|1(?:\.0+)?)$/.test(rawConfidence)) throw Error('Choose a numeric confidence between 0 and 1.');
|
|
72
72
|
const confidence = Number(rawConfidence);
|
|
@@ -75,7 +75,7 @@ export async function answer(id, vendorId, choice, rawConfidence = '1') {
|
|
|
75
75
|
if (summary.runner === 'owner' || ownerKinds.has(summary.kind)) throw Error(`This item requires the owner in the browser: ${ownerLink(state)}`);
|
|
76
76
|
if (summary.kind !== 'classify.row' || summary.runner !== 'executor') throw Error('This item does not accept a CLI classification answer.');
|
|
77
77
|
const { vendors } = classification(summary);
|
|
78
|
-
if (!vendors.includes(vendorId)) throw Error('Choose a
|
|
78
|
+
if (!vendors.includes(vendorId)) throw Error('Choose a catalog vendor id from this question, or none.');
|
|
79
79
|
const tool = await mcpClient(api, { taskId: id, signal });
|
|
80
80
|
let lease = summary;
|
|
81
81
|
if (summary.state === 'ready') lease = await tool('answer', { task_id: id, action: 'claim', client_event_id: randomUUID(), fence: summary.fence });
|
package/cli/contract.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const definitions = {
|
|
|
11
11
|
build: [['--site'], 'Production build with private local settings excluded and restored. --site instead writes the static run site (homepage, /run, docs) to its declared folder and prints that folder.'],
|
|
12
12
|
verify: [[], 'Run the complete internal verification target.'],
|
|
13
13
|
reset: [['--yes'], 'Confirmed removal of the declared local inventory only.'],
|
|
14
|
-
deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret', '--rotate-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. Builds and deploy hooks run with the checkout\'s local settings files moved aside, and a build output holding one (.dev.vars, .env) is refused. Declared secrets come from the environment or --env-file (an owned 0600 KEY=VALUE file); a new Worker gets the local setup owner and fresh generated secrets when they are not given. rer keeps the secrets it generates in .rer/deploy/ENVIRONMENT.secrets.env (0600) and reuses them on every redeploy; it refuses to generate a replacement for one a live Worker holds, and --rotate-secret NAME[,NAME] replaces them on purpose. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME (value from the environment or --env-file) and --unset-secret NAME change
|
|
14
|
+
deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret', '--rotate-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. Builds and deploy hooks run with the checkout\'s local settings files moved aside, and a build output holding one (.dev.vars, .env) is refused. Declared secrets come from the environment or --env-file (an owned 0600 KEY=VALUE file); a new Worker gets the local setup owner and fresh generated secrets when they are not given. rer keeps the secrets it generates in .rer/deploy/ENVIRONMENT.secrets.env (0600) and reuses them on every redeploy; it refuses to generate a replacement for one a live Worker holds, and --rotate-secret NAME[,NAME] replaces them on purpose. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME[,NAME] (each value from the environment or --env-file; repeat the flag or join names with commas) and --unset-secret NAME[,NAME] change those secrets of the deployed Worker without a build, all of them in one new Worker version or none, and record that version; a missing value refuses before any change. --remove --yes deletes what this environment\'s deploy record says rer created (Worker, D1, R2, KV, queues), reads back that each is gone, and touches nothing else. --site deploys the run site instead: an assets-only Worker on its custom domain with www redirected; with --dry-run it builds the site and prints the plan with no provider request. --demo deploys the hosted demo instead (deploy-demo.json): a front Worker on demo.<domain> giving each visitor their own signed-in, throwaway native Worker isolate of this seed with real public reads/checks and simulated external writes; --dry-run writes it to .rer/demo-host with no provider request; --demo --remove --yes deletes that demo (its Worker, demo.<domain> Custom Domain, each only while the record its deploy left proves it the demo\'s), reads back that each is gone, and is a no-op once it is.'],
|
|
15
15
|
export: [['--target', '--output', '--origin', '--session-file'], 'Complete supported archive of the local copy on this computer, with integrity and exclusions, written to --output. The hosted install cannot be exported yet: --origin or --target remote refuses (exit 2) before any effect and names the command that saves the hosted database.'],
|
|
16
16
|
import: [['--target', '--input', '--journal', '--origin', '--session-file', '--yes', '--legacy-v1', '--acknowledge-unverified-metadata', '--output'], 'Confirmed atomic restore into an empty destination; --journal LATER_ARCHIVE also fences rows that installation erased since. Backup-only local v1 recovery requires --legacy-v1 --acknowledge-unverified-metadata and a new --output v2 archive; --journal requires normal v2 import.'],
|
|
17
17
|
doctor: [[], 'Read-only installed tool, configuration and state diagnostics.'],
|
package/cli/deploy-readiness.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// response. Only show that response through the command's existing redactor.
|
|
3
3
|
export function mutationReadinessFailure(error, { again, redact }) {
|
|
4
4
|
if (!error.secretChange) return undefined;
|
|
5
|
-
const {
|
|
5
|
+
const { bindings, present } = error.secretChange, binding = bindings.join(', ');
|
|
6
6
|
const last = error.attempts?.at(-1);
|
|
7
7
|
const status = last?.status == null ? 'no HTTP response' : `HTTP ${last.status}`;
|
|
8
8
|
const first = redact(String(last?.body ?? '').split(/[\r\n]/, 1)[0]).slice(0, 256);
|
|
@@ -11,6 +11,6 @@ export function mutationReadinessFailure(error, { again, redact }) {
|
|
|
11
11
|
: `The secret change for ${binding} was applied and its new Worker version recorded.`;
|
|
12
12
|
const step = error.ownerFinalization ? 'owner claim/token retirement' : `secret change for ${binding}`;
|
|
13
13
|
const reason = /^[a-zA-Z0-9_-]{1,120}$/.test(error.message) ? error.message : 'health-check-failed';
|
|
14
|
-
const retirement = error.ownerFinalization ||
|
|
14
|
+
const retirement = error.ownerFinalization || bindings.includes('SETUP_TOKEN') && !present;
|
|
15
15
|
return redact(`${state} Hosted readiness failed after ${step}. ${status} (${reason}).${first ? ` First response line: ${first}` : ''} Update the seed/app configuration to match the changed secrets and redeploy with ${again}. ${retirement ? 'If the app requires the spent setup token, remove that requirement from its configuration before redeploying; keep the recorded owner and token retirement.' : 'If the secret input was incorrect, correct it and apply the intended secret change again.'}`);
|
|
16
16
|
}
|
package/cli/deploy.mjs
CHANGED
|
@@ -58,6 +58,7 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
58
58
|
return { dryRun: true, deployed: false };
|
|
59
59
|
}
|
|
60
60
|
const { env, supplied, generated, reused, rotated } = await deployEnvironment({ root, options, declaration, setupManifest, settings: lifecycle.settings, localOnlyKeys });
|
|
61
|
+
if (options.setSecret || options.unsetSecret) secretChangeInputs(declaration, options, env, again);
|
|
61
62
|
const kept = keptSecrets(declaration, setupManifest);
|
|
62
63
|
if (cloudflareCredentials.some(name => !env[name]?.trim())) throw missing(missingCredentialsMessage(declaration, env));
|
|
63
64
|
const { main } = await import('../modules/deploy-kit/owner-cli.mjs');
|
|
@@ -93,10 +94,10 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
93
94
|
}
|
|
94
95
|
if (change.length) {
|
|
95
96
|
step = 'secrets';
|
|
96
|
-
const
|
|
97
|
-
await owner('secret', [
|
|
98
|
-
store.report(`${options.setSecret ?
|
|
99
|
-
return {
|
|
97
|
+
const bindings = (options.setSecret ?? options.unsetSecret).split(','), flag = options.setSecret ? '--set' : '--unset';
|
|
98
|
+
await owner('secret', [...bindings.flatMap(binding => [flag, binding]), ...(state ? ['--state', state] : [])]);
|
|
99
|
+
store.report(`${options.setSecret ? 'Set' : 'Removed'} ${bindings.join(', ')} on this environment's Worker as one new version, recorded it and verified hosted readiness.`);
|
|
100
|
+
return { bindings, present: Boolean(options.setSecret), deployed: false };
|
|
100
101
|
}
|
|
101
102
|
store.report(`Deploying the ${environment} environment to your Cloudflare account.`);
|
|
102
103
|
deployed = await owner('deploy', [], env, { notice: line => store.report(line), onCreated: resource => created.push(redaction.redact(resource)) });
|
|
@@ -131,6 +132,18 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
131
132
|
}, { declaration: declarationPath, managesHostedOwner: true });
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
// Every secret named in --set-secret or --unset-secret is declared, and each one set has its
|
|
136
|
+
// value, before any provider request: a group of secrets is changed whole or not at all.
|
|
137
|
+
function secretChangeInputs(declaration, options, env, again) {
|
|
138
|
+
const declared = Array.isArray(declaration.secrets) ? declaration.secrets : [], flag = options.setSecret ? '--set-secret' : '--unset-secret';
|
|
139
|
+
const named = (options.setSecret ?? options.unsetSecret).split(',');
|
|
140
|
+
const undeclared = named.filter(name => !declared.some(item => item?.binding === name));
|
|
141
|
+
if (undeclared.length) throw invalid(`${flag} names ${undeclared.join(', ')}, which the deploy declaration does not list as ${undeclared.length > 1 ? 'secrets' : 'a secret'}${declared.length ? ` (it declares ${declared.map(item => item.binding).join(', ')})` : ''}. Nothing was changed.`);
|
|
142
|
+
if (!options.setSecret) return;
|
|
143
|
+
const absent = named.map(name => declared.find(item => item.binding === name).environment).filter(name => !env[name]?.trim());
|
|
144
|
+
if (absent.length) throw missing(`${flag} ${options.setSecret} needs a value for each secret; ${absent.join(', ')} ${absent.length > 1 ? 'are' : 'is'} not set. Set ${absent.length > 1 ? 'them' : 'it'} in the environment or in an --env-file file (owned, mode 0600, one line per secret), then run ${again} ${flag} ${options.setSecret} again. Nothing was changed.`);
|
|
145
|
+
}
|
|
146
|
+
|
|
134
147
|
// The failing step, its redacted cause, what this run created and the command that continues.
|
|
135
148
|
function failureText({ error, step, created, again, retry, secretChange, deployed, redact }) {
|
|
136
149
|
if (step === 'remove') {
|
package/cli/parse.mjs
CHANGED
|
@@ -36,14 +36,16 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
36
36
|
const suggestion=[...allowed].sort((a,b)=>distance(flag,a)-distance(flag,b))[0];
|
|
37
37
|
throw invalid(`Unsupported flag ${/^--[a-zA-Z-]{1,40}$/.test(flag)?flag:'(invalid)'} for ${verb}.${suggestion?` Did you mean ${suggestion}?`:''} Run rer ${verb} --help.`);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
// Several secrets change in one deploy: --set-secret A --set-secret B is --set-secret A,B.
|
|
40
|
+
const listed = ['--set-secret', '--unset-secret'].includes(flag);
|
|
41
|
+
if (options.supplied.has(flag) && !listed) throw invalid(`Repeated flag ${flag} for ${verb}. Run rer ${verb} --help.`);
|
|
40
42
|
options.supplied.add(flag);
|
|
41
43
|
const key = flag.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
42
44
|
if (booleans.has(flag)) options[key] = true;
|
|
43
45
|
else {
|
|
44
46
|
const value = args[++i];
|
|
45
47
|
if (value === undefined || value.startsWith('--') || !value.trim()) throw invalid(`A value is required for ${flag}.`);
|
|
46
|
-
options[key] = value;
|
|
48
|
+
options[key] = listed && options[key] !== undefined ? `${options[key]},${value}` : value;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
if (options.help) return options;
|
|
@@ -83,7 +85,11 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
83
85
|
if (options.target !== undefined && !['local', 'remote'].includes(options.target)) throw invalid('Target must be local or remote.');
|
|
84
86
|
if (options.profile !== undefined && options.profile !== 'first-party') throw invalid('The supported explicit profile is first-party.');
|
|
85
87
|
if (options.environment !== undefined && !/^[a-z][a-z0-9-]{0,39}$/.test(options.environment)) throw invalid('Provide a valid deployment environment name.');
|
|
86
|
-
for (const key of ['setSecret', 'unsetSecret']) if (options[key] !== undefined
|
|
88
|
+
for (const key of ['setSecret', 'unsetSecret']) if (options[key] !== undefined) {
|
|
89
|
+
const names = [...new Set(options[key].split(','))];
|
|
90
|
+
if (names.length > 16 || !names.every(name => /^[A-Z][A-Z0-9_]{0,63}$/.test(name))) throw invalid(`--${key === 'setSecret' ? '' : 'un'}set-secret names declared secret bindings, repeated or separated by commas, such as SESSION_SECRET or MAIL_API_KEY,MAIL_FROM.`);
|
|
91
|
+
options[key] = names.join(',');
|
|
92
|
+
}
|
|
87
93
|
if (options.rotateSecret !== undefined && !/^[A-Z][A-Z0-9_]{0,63}(?:,[A-Z][A-Z0-9_]{0,63}){0,15}$/.test(options.rotateSecret)) throw invalid('--rotate-secret names generated secret bindings, separated by commas, such as SESSION_SECRET.');
|
|
88
94
|
if(verb==='deploy'&&options.demo&&(options.site||['platform','image','bindAddress','httpPort','httpsPort','envFile','host','setSecret','unsetSecret','rotateSecret'].some(key=>options[key]!==undefined)))throw invalid('--demo takes only --environment, --dry-run and --remove --yes: the hosted demo is its own Worker on demo.<domain>.');
|
|
89
95
|
if(verb==='deploy'&&options.demo&&options.remove&&(options.dryRun||!options.yes))throw invalid(options.dryRun?'Use --remove and --dry-run on separate runs.':'deploy --demo --remove deletes the hosted demo\'s Worker, its demo.<domain> Custom Domain. Add --yes to confirm.');
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.44
|
|
4
|
+
|
|
5
|
+
- **Under `rer dev`, a seed can link to another local seed over http.** The dependencies module accepts a provider address of `http://127.0.0.1`, `http://[::1]` or `http://localhost`, on any port, for the RER auth preset, but only when the app runs under `rer dev`. That lets a local Balm link to a local Auth. Every other `http` address, and every hosted deploy, still requires https (#196).
|
|
6
|
+
- **`rer deploy` sets or removes a group of secrets in one Worker version.** Name the secrets with the flag repeated, `rer deploy --set-secret A --set-secret B`, or as a comma list, `--set-secret A,B`, and the same for `--unset-secret`. Either every named secret changes in one new Worker version, or none does, so a seed page can give one copy-paste command for the whole group. Every named secret must be declared, and each one being set needs its value in the environment or `--env-file`. Otherwise rer names each missing secret and changes nothing. An unchanged repeat writes nothing. Other repeated flags are still refused (#199).
|
|
7
|
+
- **A seed's first hosted change no longer trips the credential scan on the /contract styles.** `contract-style.ts` renames its `TOKENS` constant to `DEFAULTS`. The CSS bytes are unchanged. The old name, given a long CSS value, matched the hosted change scan's credential rule (SEC-3). A seed that carries `src/base/runtime/contract-style.ts` picks this up on its next Base refresh (#203).
|
|
8
|
+
- **A test host now moves a seed's secondary demo hosts too.** Before, the run-demo template's "Scope the test host" step moved only the demo domain. Now it also moves every deploy-demo.json setting that equals `demo.<domain>` or ends in `.demo.<domain>`, placing each under `demo.test.<domain>`. A seed such as Lamp, whose demo has a secondary page host, can now plan a test-host demo. Production runs are unchanged (#200).
|
|
9
|
+
- **Base's user-facing copy uses US spelling.** The /run footer reads "MIT license". The sign-in alerts read "Your organization requires…" and "Sign-in was canceled at the provider." Setup's "Brand color" label, "Choose a color", the color validation messages and other CLI messages now use color, catalog and canceled. Identifiers, status codes and data keys are unchanged (#206).
|
|
10
|
+
|
|
3
11
|
## 0.2.43
|
|
4
12
|
|
|
5
13
|
- **The installer ends with the line that puts `rer` on PATH.** `install.sh` and `rer cli install` end with `Next, start an app: rer dev <owner>/<repo>`. When new terminals will not find `rer`, the last line is the one command that adds `~/.local/bin` for your shell, for example `echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && export PATH="$HOME/.local/bin:$PATH"` (bash: `~/.bash_profile` on macOS and `~/.bashrc` elsewhere; fish: `fish_add_path ~/.local/bin`; otherwise `~/.profile`). Once a startup file already adds it, no line is printed. The installer still never edits a shell profile itself (#190).
|
|
@@ -22,8 +22,11 @@ The unqualified JWKS URL selects the identity interface. The application retains
|
|
|
22
22
|
its private key in the server database. Sector/install identity survives re-link,
|
|
23
23
|
provider moves and export/import. Keys are isolated per interface.
|
|
24
24
|
|
|
25
|
-
Provider origins and metadata endpoints require HTTPS.
|
|
26
|
-
|
|
25
|
+
Provider origins and metadata endpoints require HTTPS. Under `rer dev` (the
|
|
26
|
+
`local` option, which needs a loopback app origin) a provider may instead be
|
|
27
|
+
another locally running seed at `http://127.0.0.1`, `http://[::1]` or
|
|
28
|
+
`http://localhost` on any port, so two local seeds can link; every other `http`
|
|
29
|
+
address and every hosted deploy still requires HTTPS.
|
|
27
30
|
Every provider serves `/.well-known/rer-dependencies` with the same graph fields,
|
|
28
31
|
including its `provides` list and selected dependency provider origins. The CLI
|
|
29
32
|
traverses these documents before setup effects, including selected optional
|
|
@@ -2,13 +2,14 @@ import { nativeDependencyAuthority } from './native.mjs';
|
|
|
2
2
|
import { approveSetup, approveOwner, approvalFence, callbacksFor } from './approval.mjs';
|
|
3
3
|
import { dependencyStore } from './store.mjs';
|
|
4
4
|
import { publicKey, assertion, digest } from './crypto.mjs';
|
|
5
|
+
import { isLoopbackHost } from '../operator-auth/loopback.mjs';
|
|
5
6
|
import { CALLBACK, INTERFACE, PATHS, NETWORK, insist, originOf, providerMetadata } from './protocol.mjs';
|
|
6
7
|
import { readJson } from '../operator-auth/identity/oidc/network.mjs';
|
|
7
8
|
import { readInput } from '../operator-auth/input.mjs';
|
|
8
9
|
import { ownerFence, pinStatement } from './authority.mjs';
|
|
9
10
|
export { INTERFACE, CALLBACK, PATHS } from './protocol.mjs';
|
|
10
11
|
export function createDependencies({db,origin,name,provider,interfaces=[{interface:INTERFACE,provider,paths:PATHS}],provides=[],local=false,auth,claimOwner,clock=Date.now,fetch:fetcher=globalThis.fetch}) {
|
|
11
|
-
originOf(origin,local);insist(Array.isArray(provides) && new Set(provides).size===provides.length && provides.every(value=>/^[a-z][a-z0-9-]*@[1-9][0-9]*$/.test(value)));
|
|
12
|
+
originOf(origin,local);insist(!local || isLoopbackHost(new URL(origin).hostname));insist(Array.isArray(provides) && new Set(provides).size===provides.length && provides.every(value=>/^[a-z][a-z0-9-]*@[1-9][0-9]*$/.test(value)));
|
|
12
13
|
insist(Array.isArray(interfaces) && new Set(interfaces.map(d=>d.interface)).size===interfaces.length && interfaces.every(d=>/^[a-z][a-z0-9-]*@[1-9][0-9]*$/.test(d.interface) && Array.isArray(d.paths) && new Set(d.paths).size===d.paths.length && d.paths.every(p=>typeof p==='string' && /^\/[A-Za-z0-9_~/-]+$/.test(p) && !p.startsWith('//'))));
|
|
13
14
|
const store=dependencyStore(db);
|
|
14
15
|
const native=auth?.native?nativeDependencyAuthority(auth.accounts.dependencies):null;
|
|
@@ -34,7 +35,7 @@ export function createDependencies({db,origin,name,provider,interfaces=[{interfa
|
|
|
34
35
|
const pendingPin=native?null:await store.first('SELECT provider_id AS id,issuer,client_id AS clientId,linked_at AS linkedAt FROM oa_provider_session_pins WHERE session_id=?',pending.approved_session);
|
|
35
36
|
const initialApproval=await approvalFence(pending,contract,expected,callbacks,clock(),pendingPin,native);
|
|
36
37
|
insist(await store.first(`SELECT 1 WHERE ${initialApproval.sql}`,...initialApproval.args),'local_owner_proof_required',403);
|
|
37
|
-
const metadata=await providerMetadata(expected,fetcher,contract),installation=await store.installation(contract);
|
|
38
|
+
const metadata=await providerMetadata(expected,fetcher,contract,local),installation=await store.installation(contract);
|
|
38
39
|
const codeDigest=await digest(expected+'\0'+data.code);
|
|
39
40
|
const consumed=await store.first('INSERT INTO rer_dependency_codes(digest,created_at) VALUES(?,?) ON CONFLICT DO NOTHING RETURNING digest',codeDigest,clock());
|
|
40
41
|
insist(consumed?.digest===codeDigest,'link_code_used',409);
|
|
@@ -101,7 +102,7 @@ export function createDependencies({db,origin,name,provider,interfaces=[{interfa
|
|
|
101
102
|
insist(request.headers.get('origin')===origin,'invalid_link_origin',403);
|
|
102
103
|
if(path==='/auth/dependencies/unlink')return await unlink(request);
|
|
103
104
|
if(path==='/auth/dependencies/relink' || path==='/auth/dependencies/setup') {
|
|
104
|
-
const input=await readInput(request),contract=input.interface??INTERFACE;originOf(input.issuer);const declared=interfaces.find(d=>d.interface===contract);insist(declared);
|
|
105
|
+
const input=await readInput(request),contract=input.interface??INTERFACE;originOf(input.issuer,local);const declared=interfaces.find(d=>d.interface===contract);insist(declared);
|
|
105
106
|
const callbacks=callbacksFor(origin,declared);
|
|
106
107
|
if(path==='/auth/dependencies/setup') await approveSetup({db,auth,request,input,contract,callbacks,clock});
|
|
107
108
|
else await approveOwner({store,actor:await owner(request,'providers:relink'),input,contract,callbacks,clock,native});
|
|
@@ -6,19 +6,21 @@ export const CALLBACK = '/.well-known/rer-link/callback';
|
|
|
6
6
|
export const PATHS = ['/auth/oidc/auth/callback','/auth/oidc/auth/logout'];
|
|
7
7
|
export const NETWORK = { timeoutMs:5000 };
|
|
8
8
|
export function insist(value, code = 'invalid_link', status = 400) { if (!value) throw Object.assign(new Error(code),{code,status}); }
|
|
9
|
+
// https always; plain http only to a loopback host while the app runs under `rer dev`.
|
|
10
|
+
const schemeAllowed=(u,local)=>u.protocol==='https:' || local && u.protocol==='http:' && isLoopbackHost(u.hostname);
|
|
9
11
|
export function originOf(value, local = false) {
|
|
10
12
|
let u;try { u=new URL(value); } catch { insist(false); }
|
|
11
|
-
insist(u.origin===value && !u.username && !u.password && (u
|
|
13
|
+
insist(u.origin===value && !u.username && !u.password && schemeAllowed(u,local));
|
|
12
14
|
return u.origin;
|
|
13
15
|
}
|
|
14
|
-
export async function providerMetadata(issuer, fetcher, contract = INTERFACE) {
|
|
15
|
-
originOf(issuer);
|
|
16
|
-
const p={...PRESETS.auth,id:'auth',issuer,endpointOrigins:[issuer],tokenAuthMethod:'private_key_jwt',keyAlgorithm:'ES256',minimumVersion:MINIMUM_PROVIDER_VERSION};
|
|
16
|
+
export async function providerMetadata(issuer, fetcher, contract = INTERFACE, local = false) {
|
|
17
|
+
originOf(issuer,local);
|
|
18
|
+
const p={...PRESETS.auth,id:'auth',issuer,endpointOrigins:[issuer],local,tokenAuthMethod:'private_key_jwt',keyAlgorithm:'ES256',minimumVersion:MINIMUM_PROVIDER_VERSION};
|
|
17
19
|
const oidc=contract===INTERFACE?await discover(fetcher,p,NETWORK):{};
|
|
18
20
|
const link=await readJson(fetcher,`${issuer}/.well-known/rer-provider`,NETWORK);
|
|
19
21
|
insist(link.issuer===issuer && (link.interface===contract || Array.isArray(link.provides) && new Set(link.provides).size===link.provides.length && link.provides.every(i=>typeof i==='string' && /^[a-z][a-z0-9-]*@[1-9][0-9]*$/.test(i)) && link.provides.includes(contract)) && link.version===1,'unsupported_link_interface',502);
|
|
20
22
|
for (const name of ['initiate','redeem','deregister']) {
|
|
21
|
-
const u=new URL(link[name]);insist(u.origin===issuer && u
|
|
23
|
+
const u=new URL(link[name]);insist(u.origin===issuer && schemeAllowed(u,local) && !u.search && !u.hash && !u.username && !u.password,'untrusted_link_endpoint',502);
|
|
22
24
|
}
|
|
23
25
|
return {...oidc,link};
|
|
24
26
|
}
|
|
@@ -117,6 +117,7 @@ A transport failure carries `providerTransport`: the operation, sanitized endpoi
|
|
|
117
117
|
|
|
118
118
|
- **Inputs.** Declared secrets come from the environment, then `--env-file FILE` (an owned 0600 file of `KEY=VALUE` lines), which wins. For a secret the Worker does not hold yet, rer supplies the setup manifest's owner email (`emailField`) from the local setup's private settings, and for each secret field the manifest generates (`generate`) the value rer keeps for this environment in `.rer/deploy/<environment>.secrets.env` (0600, ignored by Git), else a fresh random value, which rer keeps once the Worker holds it (the one-time setup token is always fresh and never kept); a value the Worker already holds is kept. The build runs with the checkout's local settings files moved aside, and a `dist/` holding a `.dev.vars*`, `.env*` or `*.env` file is refused by name before any provider request. A still-missing secret stops the run before any write with a message that names it, unless its declaration says `"optional": true`: then the deploy binds nothing for it and reports it as not set, and `--set-secret` adds it later.
|
|
119
119
|
- **Hosted owner.** After deploy and health pass, rer claims the setup owner on the hosted app: it POSTs the setup token to the seed's standard owner step (`hooks.owner`, by default `/auth/bootstrap`). 303 means claimed; `409 already_initialized` means an owner was already claimed and is kept. Then rer deletes the token secret from the Worker, records the new Worker version in the state file, and lists the token in `retiredSecrets`, so later plans no longer declare it. The build fingerprint still names it, and the recorded claim stays as recorded, so an untouched repeat deploy writes nothing. A Worker that still holds a token rer did not upload in this run (an older deploy) first gets a fresh token through the same recorded secret change. Dependency approvals that need the token run before the claim. A seed with an owner step function, an identity-provider claim, or no declared token secret claims its owner its own way.
|
|
120
|
+
- **Several secrets at once.** `rer deploy --set-secret MAIL_API_KEY --set-secret MAIL_FROM` or `rer deploy --set-secret MAIL_API_KEY,MAIL_FROM` (likewise `--unset-secret A,B`) changes all of them in one new Worker version or none: a group of secrets is never half set. Every named secret must be declared and, for `--set-secret`, have its value in the environment or `--env-file`; otherwise rer names each missing one and changes nothing. One secret uses Cloudflare's secret call. Several are one copy of the live version through the Versions API (its own modules, assets and compatibility settings, every other binding inherited), then deployed at 100%: Cloudflare's per-secret calls each make a version, and its settings call can add secrets but not remove them (measured 17 October 2026). The copy carries a marker rer records first, so a copy whose answer was lost is recognised, and one uploaded but not deployed is deployed by the same command run again.
|
|
120
121
|
- **Secret changes.** `rer deploy --set-secret NAME` (value from the environment or `--env-file`, under the declaration's environment name), `--unset-secret NAME` and `--rotate-secret NAME[,NAME]` (a fresh value for a secret rer generates, kept in `.rer/deploy/<environment>.secrets.env` once set) change declared secrets of the recorded Worker without a build. Before writing, rer records the starting version and the exact live names of all other secrets, never their values. Accepted or ambiguous writes retain that intent until readback confirms the change; explicit refusals clear it. An ambiguous failure, or a later command's preflight, can clear an unapplied intent only when the live deployment still matches the receipt and the newest listed version matches it too. A surviving intent blocks further mutations until consistency returns; retry the same command then. Recovery requires the recorded immediate successor (or the recorded confirming rotation's successor), the receipt's script etag and fingerprint, the intended binding's presence, and an unchanged set of other secret names. Ambiguous rotations require a confirming PUT before reporting success. Older intents without names may recover only from the exact starting version's historical bindings, with its id, etag and fingerprint verified; unavailable or malformed historical bindings refuse adoption. Each historical binding must have an exact provider type supported by this kit; unrecognized types cannot prove that a name was not a secret. Added, removed or renamed other secrets refuse deploy and removal before writes. Values remain opaque: these checks cannot distinguish an otherwise identical outside change to the pending binding.
|
|
121
122
|
- **Removal.** `rer deploy --remove --yes` deletes what the state file says rer created for this environment: the Worker (schedules first; its Durable Objects go with it) and each D1, R2, KV and queue that is still the one rer created, after checking all of them before the first delete. A replaced or uncertain resource refuses the whole removal, except a D1 or KV whose create answer was lost: under this environment's derived name it is deleted once confirmed empty (a D1 with no tables, a KV namespace with no keys); one holding data is refused as `uncertain-resource-not-empty`, and an uncertain queue, whose backlog rer cannot read, as `uncertain-resource-unverifiable` (delete it by hand if it is the empty one from the interrupted run).
|
|
122
123
|
|
|
@@ -17,7 +17,7 @@ import { refuseLocalModels } from './local-only.mjs';
|
|
|
17
17
|
import { publicOrigin } from './public-origin.mjs';
|
|
18
18
|
|
|
19
19
|
export const cronNotice = 'This Worker has a Cron Trigger. Cloudflare may take up to about two hours to start its first scheduled run on some accounts.';
|
|
20
|
-
const usage = 'usage: owner-cli.mjs deploy|health|remove|inspect|record-owner|signin --declaration <file> --environment <name> [--product <dir>] [--state <file>] [--outcome claimed|kept] | secret ... --set NAME|--unset NAME';
|
|
20
|
+
const usage = 'usage: owner-cli.mjs deploy|health|remove|inspect|record-owner|signin --declaration <file> --environment <name> [--product <dir>] [--state <file>] [--outcome claimed|kept] | secret ... --set NAME [--set NAME]|--unset NAME [--unset NAME]';
|
|
21
21
|
|
|
22
22
|
/** The owner's committed source and existing local build. Run the seed's build first. */
|
|
23
23
|
async function ownerArtifact(root, product) {
|
|
@@ -30,7 +30,7 @@ async function ownerArtifact(root, product) {
|
|
|
30
30
|
/** Inputs: CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN, plus the secrets the declaration names on first deploy. */
|
|
31
31
|
export async function main(argv = process.argv.slice(2), env = process.env, {fetch = globalThis.fetch, cwd = process.cwd(), healthOptions, propagation, settle, localOnlyKeys = [], notice = line => console.error(line), onCreated} = {}) {
|
|
32
32
|
let parsed;
|
|
33
|
-
try { parsed = parseArgs({args:argv,allowPositionals:true,strict:true,options:{declaration:{type:'string'},environment:{type:'string'},product:{type:'string',default:''},state:{type:'string'},set:{type:'string'},unset:{type:'string'},outcome:{type:'string'}}}); }
|
|
33
|
+
try { parsed = parseArgs({args:argv,allowPositionals:true,strict:true,options:{declaration:{type:'string'},environment:{type:'string'},product:{type:'string',default:''},state:{type:'string'},set:{type:'string',multiple:true},unset:{type:'string',multiple:true},outcome:{type:'string'}}}); }
|
|
34
34
|
catch { throw new Error('usage'); }
|
|
35
35
|
const {positionals:[command,...rest],values} = parsed;
|
|
36
36
|
if (!['deploy','health','secret','remove','inspect','record-owner','signin'].includes(command) || rest.length || !values.declaration || !values.environment) throw new Error('usage');
|
|
@@ -66,10 +66,12 @@ export async function main(argv = process.argv.slice(2), env = process.env, {fet
|
|
|
66
66
|
const statePath = values.state ? resolve(root,values.state) : join(root,'.rer','deploy',`${target.environment}.json`);
|
|
67
67
|
if (command === 'remove') return {ok:true,...await ownerRemove({api,target,statePath}).catch(error => { throw api.annotateFailure(error,'remove'); })};
|
|
68
68
|
if (command === 'secret') {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
69
|
+
// Every named secret is changed in one Worker version, or none is.
|
|
70
|
+
const named = [...new Set(values.set ?? values.unset)], declared = Array.isArray(declaration.secrets) ? declaration.secrets : [];
|
|
71
|
+
const undeclared = named.filter(binding => !declared.some(entry => entry?.binding === binding));
|
|
72
|
+
if (undeclared.length) { const error = new Error('undeclared-secret'); error.resource = undeclared.map(binding => `secret:${binding}`).join(', '); throw error; }
|
|
73
|
+
const changes = named.map(binding => ({binding, value:values.set === undefined ? undefined : env[declared.find(entry => entry?.binding === binding).environment]}));
|
|
74
|
+
return {ok:true,...await ownerSecret({api,target,statePath,changes,fetch,healthOptions}).catch(error => { throw api.annotateFailure(error,'secrets'); })};
|
|
73
75
|
}
|
|
74
76
|
// A secret rer retired (the spent setup token) is no longer part of the plan.
|
|
75
77
|
const state = await settleOwnerState({api,target,statePath});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assert, uuid } from './validation.mjs';
|
|
2
|
+
|
|
3
|
+
// Several secrets change as ONE Worker version, so a half-changed group never runs.
|
|
4
|
+
// Cloudflare's per-secret calls each deploy a version of their own, and its settings
|
|
5
|
+
// call adds secrets but never removes one (both measured on 17 October 2026). A copy
|
|
6
|
+
// of the live version does both: its own modules, assets and compatibility settings,
|
|
7
|
+
// every binding inherited except the named secrets, which it sets or leaves out. The
|
|
8
|
+
// copy carries a marker rer saved before uploading it, so a copy whose answer was lost,
|
|
9
|
+
// or that was uploaded but not yet deployed, is recognised as this change and no other.
|
|
10
|
+
export const copyMessage = marker => `rer-secrets:${marker}`;
|
|
11
|
+
|
|
12
|
+
/** Upload the copy (not yet deployed) and return its version id. */
|
|
13
|
+
export async function uploadSecretCopy(api, worker, live, {changes, marker}) {
|
|
14
|
+
const {parts, entry} = await api.workerContent(worker, live.versionId);
|
|
15
|
+
const runtime = live.version?.resources?.script_runtime, bindings = live.version?.resources?.bindings;
|
|
16
|
+
assert(typeof runtime?.compatibility_date === 'string' && Array.isArray(bindings), 'invalid-active-version');
|
|
17
|
+
const named = new Set(changes.map(change => change.binding));
|
|
18
|
+
const metadata = {main_module:entry, compatibility_date:runtime.compatibility_date, compatibility_flags:runtime.compatibility_flags ?? [],
|
|
19
|
+
bindings:[...bindings.filter(row => !named.has(row.name)).map(row => ({type:'inherit',name:row.name})),
|
|
20
|
+
...changes.filter(change => change.value !== undefined).map(change => ({type:'secret_text',name:change.binding,text:change.value}))],
|
|
21
|
+
keep_assets:true, annotations:{'workers/message':copyMessage(marker)}};
|
|
22
|
+
const data = new FormData();
|
|
23
|
+
data.set('metadata', new Blob([JSON.stringify(metadata)], {type:'application/json'}));
|
|
24
|
+
for (const [name, file] of parts) data.set(name, file, name);
|
|
25
|
+
const version = await api.request(`/workers/scripts/${worker}/versions?bindings_inherit=strict`, {method:'POST', body:data});
|
|
26
|
+
assert(uuid(version?.id), 'invalid-secret-copy');
|
|
27
|
+
return version.id;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Send all traffic to the copy. */
|
|
31
|
+
export const deploySecretCopy = (api, worker, versionId) => api.request(`/workers/scripts/${worker}/deployments`, {method:'POST', body:{strategy:'percentage', versions:[{version_id:versionId, percentage:100}]}});
|
|
32
|
+
|
|
33
|
+
/** The newest version is this change's copy, uploaded right after the receipt's version and not deployed. */
|
|
34
|
+
export async function undeployedCopy(api, worker, {pendingSecret, receipt}, versions) {
|
|
35
|
+
if (!pendingSecret.copy || versions[1]?.id !== receipt.provider.versionId || !uuid(versions[0]?.id)) return null;
|
|
36
|
+
const copy = await api.request(`/workers/scripts/${worker}/versions/${versions[0].id}`);
|
|
37
|
+
return copy?.id === versions[0].id && copy.annotations?.['workers/message'] === copyMessage(pendingSecret.copy) ? copy.id : null;
|
|
38
|
+
}
|
|
@@ -27,5 +27,5 @@ export async function pendingSecretNames(api, worker, {pendingSecret, receipt})
|
|
|
27
27
|
if (anchor?.id !== pendingSecret.versionId || anchor?.resources?.script?.etag !== receipt.provider.etag
|
|
28
28
|
|| !Array.isArray(bindings) || !bindings.every(row => row && typeof row === 'object' && !Array.isArray(row) && historicalBindingTypes.has(row.type))
|
|
29
29
|
|| !validSecretNames(bindings.map(row => row.name)) || deployedFingerprint({bindings}) !== receipt.fingerprint) return null;
|
|
30
|
-
return bindings.filter(row => row.type === 'secret_text' && row.name
|
|
30
|
+
return bindings.filter(row => row.type === 'secret_text' && !pendingSecret.bindings.includes(row.name)).map(row => row.name);
|
|
31
31
|
}
|
|
@@ -1,45 +1,64 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
1
2
|
import { assert, identifier } from './validation.mjs';
|
|
2
3
|
import { activeWorker } from './worker.mjs';
|
|
3
|
-
import { secretNames } from './owner-secret-names.mjs';
|
|
4
|
+
import { secretNames, validSecretNames } from './owner-secret-names.mjs';
|
|
4
5
|
import { waitHealth } from './health-request.mjs';
|
|
5
6
|
import { definiteProviderRefusal } from './provider.mjs';
|
|
6
7
|
import { readOwnerState, writeOwnerState, withStateLock, withScopeHints, sameDeployment, refuse, recordSecretChange, settlePendingSecret } from './owner.mjs';
|
|
8
|
+
import { uploadSecretCopy, deploySecretCopy } from './owner-secret-copy.mjs';
|
|
7
9
|
|
|
8
|
-
/** Set (`value` given) or remove
|
|
9
|
-
*
|
|
10
|
+
/** Set (each `value` given) or remove Worker secrets of the owner's last deployment as one
|
|
11
|
+
* new Worker version, then record that version in the state file, so the next deploy
|
|
10
12
|
* recognises its own Worker. A Worker someone else replaced is refused untouched.
|
|
13
|
+
* One secret uses Cloudflare's secret call; several are one copy of the live version
|
|
14
|
+
* (owner-secret-copy.mjs). Every change sets all its secrets or removes all of them.
|
|
11
15
|
* The change is recorded as pending first: if the provider applies it but rer never
|
|
12
16
|
* sees it settle, a later run can recognise its immediate successor (see settlePendingSecret).
|
|
13
17
|
* Both success and ambiguous failure read back for up to `windowMs`. An explicit refusal
|
|
14
18
|
* clears the pending record. An accepted write keeps its intent until confirmed.
|
|
15
19
|
* An ambiguous failure clears it only when readback corroborates that the receipt's
|
|
16
|
-
* deployment is still live. An ambiguous rotation
|
|
20
|
+
* deployment is still live. An ambiguous one-secret rotation
|
|
17
21
|
* re-PUTs the value before accepting its successor as proof of the rotation.
|
|
18
22
|
* A removed declared secret is retired: later plans omit it until it is set again. */
|
|
19
|
-
export async function ownerSecret({api: provider, target, statePath,
|
|
23
|
+
export async function ownerSecret({api: provider, target, statePath, changes, fetch = globalThis.fetch, healthOptions = {}, windowMs = 30000, clock = () => performance.now(), sleep = ms => new Promise(resolve => setTimeout(resolve, ms))}) {
|
|
20
24
|
const api = withScopeHints(provider);
|
|
21
|
-
|
|
22
|
-
assert(
|
|
25
|
+
const bindings = changes.map(change => change.binding), present = changes[0]?.value !== undefined;
|
|
26
|
+
assert(bindings.length && bindings.every(identifier) && validSecretNames(bindings), 'invalid-secret-name');
|
|
27
|
+
assert(changes.every(change => (change.value !== undefined) === present), 'mixed-secret-change');
|
|
28
|
+
for (const {binding, value} of changes) assert(value === undefined || typeof value === 'string' && value.trim(), `missing-secret-${binding}`);
|
|
23
29
|
return withStateLock(statePath, async () => {
|
|
24
30
|
const state = await readOwnerState(statePath, target);
|
|
25
31
|
assert(state.receipt && !state.pendingUpload, 'missing-owner-receipt');
|
|
26
|
-
|
|
32
|
+
// A copy uploaded but never deployed is that earlier change: finish it first.
|
|
33
|
+
const deployCopy = version => deploySecretCopy(api, target.worker, version);
|
|
34
|
+
if (await settlePendingSecret(api, target.worker, state, {preflight:true, deployCopy})) await writeOwnerState(statePath, state);
|
|
27
35
|
const live = await activeWorker(api, target.worker);
|
|
28
36
|
if (!live) throw refuse('owned-resource-missing', 'worker', target.worker);
|
|
29
37
|
if (!sameDeployment(live, state.receipt.provider)) throw refuse('owned-resource-replaced', 'worker', target.worker);
|
|
30
38
|
assert(!state.pendingSecret, 'secret-change-unsettled');
|
|
31
|
-
const path = `/workers/scripts/${target.worker}/secrets
|
|
39
|
+
const path = `/workers/scripts/${target.worker}/secrets`;
|
|
32
40
|
const names = secretNames(await api.request(path));
|
|
33
41
|
assert(names, 'invalid-secret-list');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
// Removing secrets the Worker does not hold changes nothing; the rest of a removal still runs.
|
|
43
|
+
const writes = present ? changes : changes.filter(change => names.includes(change.binding));
|
|
44
|
+
const existed = writes.some(change => names.includes(change.binding)), changed = writes.length > 0, copy = writes.length > 1;
|
|
45
|
+
state.pendingSecret = {bindings, present, versionId:state.receipt.provider.versionId, names:names.filter(name => !bindings.includes(name)).sort(), ...(copy ? {copy:randomBytes(16).toString('hex')} : {})};
|
|
46
|
+
await writeOwnerState(statePath, state);
|
|
47
|
+
let failure, unchanged = false, confirming = false, uploaded = false;
|
|
48
|
+
const put = () => api.request(path, {method:'PUT', body:{name:writes[0].binding, text:writes[0].value, type:'secret_text'}});
|
|
38
49
|
try {
|
|
39
|
-
if (
|
|
40
|
-
|
|
50
|
+
if (copy) {
|
|
51
|
+
const version = await uploadSecretCopy(api, target.worker, live, {changes:writes, marker:state.pendingSecret.copy});
|
|
52
|
+
uploaded = true;
|
|
53
|
+
await deploySecretCopy(api, target.worker, version);
|
|
54
|
+
}
|
|
55
|
+
else if (present) await put();
|
|
56
|
+
else if (changed) await api.request(`${path}/${writes[0].binding}`, {method:'DELETE'});
|
|
41
57
|
} catch (error) {
|
|
42
|
-
|
|
58
|
+
// A refused upload changed nothing. A copy uploaded but refused deployment stays
|
|
59
|
+
// pending: the same command deploys it next time, as this change and no other.
|
|
60
|
+
if (definiteProviderRefusal(error) && !uploaded) { delete state.pendingSecret; await writeOwnerState(statePath, state); throw error; }
|
|
61
|
+
if (definiteProviderRefusal(error)) { await writeOwnerState(statePath, state); throw error; }
|
|
43
62
|
failure = error;
|
|
44
63
|
}
|
|
45
64
|
try {
|
|
@@ -48,7 +67,9 @@ export async function ownerSecret({api: provider, target, statePath, binding, va
|
|
|
48
67
|
try {
|
|
49
68
|
if (await settlePendingSecret(api, target.worker, state, {
|
|
50
69
|
observe: current => { unchanged = sameDeployment(current, state.receipt.provider); },
|
|
51
|
-
|
|
70
|
+
// A copy whose upload or deployment answer was lost is deployed here once it is found.
|
|
71
|
+
...(copy ? {deployCopy} : {}),
|
|
72
|
+
...(failure && present && existed && !copy ? {confirm: async current => {
|
|
52
73
|
confirming = true;
|
|
53
74
|
state.pendingSecret.repeatVersionId = current.versionId;
|
|
54
75
|
await writeOwnerState(statePath, state);
|
|
@@ -71,7 +92,7 @@ export async function ownerSecret({api: provider, target, statePath, binding, va
|
|
|
71
92
|
await writeOwnerState(statePath, state);
|
|
72
93
|
throw failure ?? error;
|
|
73
94
|
}
|
|
74
|
-
const result = {worker:target.worker,
|
|
95
|
+
const result = {worker:target.worker, bindings, present, versionId:state.receipt.provider.versionId};
|
|
75
96
|
// Settlement is durable before readiness: a failed hosted check must never
|
|
76
97
|
// erase the applied mutation or cause the next command to reject our version.
|
|
77
98
|
state.receipt.health = {ok:false,versionId:result.versionId};
|
|
@@ -12,6 +12,7 @@ import { validateMigrations } from './migrations.mjs';
|
|
|
12
12
|
import { deploy } from './deploy.mjs';
|
|
13
13
|
import { verifyHealth } from './health.mjs';
|
|
14
14
|
import { validSecretNames, secretNames, pendingSecretNames } from './owner-secret-names.mjs';
|
|
15
|
+
import { copyMessage, undeployedCopy } from './owner-secret-copy.mjs';
|
|
15
16
|
import { publicOrigin } from './public-origin.mjs';
|
|
16
17
|
|
|
17
18
|
/* Owner-account mode: the owner's own Cloudflare account, token and account id.
|
|
@@ -175,10 +176,14 @@ export async function readOwnerState(path, target) {
|
|
|
175
176
|
&& KINDS.every(kind => state.owned[kind] && typeof state.owned[kind] === 'object' && Object.values(state.owned[kind]).every(entry => ['pending','created'].includes(entry?.status))), 'invalid-owner-state');
|
|
176
177
|
assert(state.pendingUpload === undefined || typeof state.pendingUpload?.fingerprint === 'string', 'invalid-owner-state');
|
|
177
178
|
// Declared secrets rer removed on purpose (the spent setup token): later plans omit them.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
// A change recorded by an older rer names one `binding`.
|
|
180
|
+
if (typeof state.pendingSecret?.binding === 'string' && state.pendingSecret.bindings === undefined) { const {binding, ...rest} = state.pendingSecret; state.pendingSecret = {...rest, bindings:[binding]}; }
|
|
181
|
+
const pending = state.pendingSecret;
|
|
182
|
+
assert(pending === undefined || Array.isArray(pending?.bindings) && pending.bindings.length > 0 && validSecretNames(pending.bindings) && typeof pending.present === 'boolean'
|
|
183
|
+
&& (pending.versionId === undefined || uuid(pending.versionId))
|
|
184
|
+
&& (pending.repeatVersionId === undefined || uuid(pending.repeatVersionId))
|
|
185
|
+
&& (pending.copy === undefined || /^[0-9a-f]{32}$/.test(pending.copy))
|
|
186
|
+
&& (pending.names === undefined || validSecretNames(pending.names) && !pending.names.some(name => pending.bindings.includes(name))), 'invalid-owner-state');
|
|
182
187
|
assert(state.ownerClaim === undefined || ['claimed','kept'].includes(state.ownerClaim?.outcome), 'invalid-owner-state');
|
|
183
188
|
assert(state.retiredSecrets === undefined || Array.isArray(state.retiredSecrets) && state.retiredSecrets.every(identifier), 'invalid-owner-state');
|
|
184
189
|
assert(state.accountId === target.accountId && state.project === target.project && state.environment === target.environment && state.worker === target.worker, 'owner-state-target-mismatch');
|
|
@@ -242,11 +247,11 @@ async function uploadFingerprint(body) {
|
|
|
242
247
|
return fingerprint;
|
|
243
248
|
}
|
|
244
249
|
/** Record a secret change's outcome on the receipt: the Worker version it made, and whether
|
|
245
|
-
*
|
|
246
|
-
export function recordSecretChange(state, current, {
|
|
250
|
+
* its secrets are now retired (a removed declared secret stays out of later plans). */
|
|
251
|
+
export function recordSecretChange(state, current, {bindings, present}) {
|
|
247
252
|
state.receipt.provider = {versionId:current.versionId, deploymentId:current.deploymentId, etag:current.etag};
|
|
248
253
|
const retired = new Set(state.retiredSecrets ?? []);
|
|
249
|
-
if (present) retired.delete(binding); else retired.add(binding);
|
|
254
|
+
for (const binding of bindings) if (present) retired.delete(binding); else retired.add(binding);
|
|
250
255
|
if (retired.size) state.retiredSecrets = [...retired].sort(); else delete state.retiredSecrets;
|
|
251
256
|
delete state.pendingSecret;
|
|
252
257
|
}
|
|
@@ -255,16 +260,19 @@ export function recordSecretChange(state, current, {binding, present}) {
|
|
|
255
260
|
* exactly one version after the recorded starting version and it is the live one, still running the receipt's
|
|
256
261
|
* exact script and build fingerprint, with the other secret names unchanged: adopt its version. A confirming PUT also records its
|
|
257
262
|
* own starting version before it writes; its immediate successor can be recovered by the
|
|
258
|
-
* same checks.
|
|
259
|
-
|
|
263
|
+
* same checks. A several-secret copy must also carry its marker; one uploaded but never deployed
|
|
264
|
+
* is deployed by `deployCopy` when given. Anything later is left to the identity check, which refuses it. */
|
|
265
|
+
export async function settlePendingSecret(api, worker, state, {preflight = false, observe, confirm, deployCopy} = {}) {
|
|
260
266
|
if (!state.pendingSecret || !state.receipt) return false;
|
|
261
267
|
const live = await activeWorker(api, worker);
|
|
262
268
|
if (sameDeployment(live, state.receipt.provider)) {
|
|
263
269
|
// Both deployment and newest version must corroborate an unapplied write.
|
|
264
270
|
// A stale deployment alone must not erase an accepted but unsettled intent.
|
|
265
271
|
const versions = (await api.request(`/workers/scripts/${worker}/versions`))?.items;
|
|
266
|
-
const
|
|
267
|
-
|
|
272
|
+
const listed = Array.isArray(versions) && versions.every(item => uuid(item?.id)) && new Set(versions.map(item => item.id)).size === versions.length;
|
|
273
|
+
const unchanged = listed && versions[0]?.id === live.versionId;
|
|
274
|
+
const copy = listed && !unchanged && deployCopy ? await undeployedCopy(api, worker, state, versions) : null;
|
|
275
|
+
if (copy) { await deployCopy(copy); return settlePendingSecret(api, worker, state, {preflight, observe, confirm}); }
|
|
268
276
|
observe?.(unchanged ? live : null);
|
|
269
277
|
if (!preflight || !unchanged) return false;
|
|
270
278
|
delete state.pendingSecret;
|
|
@@ -283,11 +291,12 @@ export async function settlePendingSecret(api, worker, state, {preflight = false
|
|
|
283
291
|
// Its starting version is saved before that PUT, so interruption can recover
|
|
284
292
|
// either the original immediate successor or the second write's successor.
|
|
285
293
|
if (ids[0] !== live.versionId || !(repeatVersionId ? repeated || preflight && immediate && live.versionId === repeatVersionId : immediate)) return false;
|
|
294
|
+
if (state.pendingSecret.copy && live.version?.annotations?.['workers/message'] !== copyMessage(state.pendingSecret.copy)) return false;
|
|
286
295
|
const rows = await api.request(`/workers/scripts/${worker}/secrets`);
|
|
287
|
-
const names = secretNames(rows);
|
|
288
|
-
if (!names || names.includes(
|
|
296
|
+
const names = secretNames(rows), {bindings, present} = state.pendingSecret;
|
|
297
|
+
if (!names || bindings.some(binding => names.includes(binding) !== present)) return false;
|
|
289
298
|
const priorNames = await pendingSecretNames(api, worker, state);
|
|
290
|
-
const otherNames = names.filter(name => name
|
|
299
|
+
const otherNames = names.filter(name => !bindings.includes(name));
|
|
291
300
|
if (!priorNames || priorNames.length !== otherNames.length || !priorNames.every(name => otherNames.includes(name))) return false;
|
|
292
301
|
if (confirm && !repeatVersionId) { await confirm(live); return false; }
|
|
293
302
|
recordSecretChange(state, live, state.pendingSecret);
|
|
@@ -9,7 +9,7 @@ import { providerResponse, transportOutput, transportReason } from './provider-t
|
|
|
9
9
|
// A gateway/server error can arrive after a write. An explicit API refusal cannot.
|
|
10
10
|
export const definiteProviderRefusal = error => error.status === 200 || error.status >= 400 && error.status < 500;
|
|
11
11
|
|
|
12
|
-
async function
|
|
12
|
+
async function boundedBytes(response, limit, onReadError) {
|
|
13
13
|
assert(response.body, 'empty-response');
|
|
14
14
|
const reader = response.body.getReader(); const chunks = []; let length = 0;
|
|
15
15
|
try { while (true) {
|
|
@@ -20,8 +20,9 @@ async function boundedText(response, limit = 4 * 1024 * 1024, onReadError) {
|
|
|
20
20
|
length += value.length; assert(length <= limit, 'response-too-large'); chunks.push(value);
|
|
21
21
|
} }
|
|
22
22
|
finally { await reader.cancel().catch(() => {}); }
|
|
23
|
-
return Buffer.concat(chunks)
|
|
23
|
+
return Buffer.concat(chunks);
|
|
24
24
|
}
|
|
25
|
+
const boundedText = async (response, limit = 4 * 1024 * 1024, onReadError) => (await boundedBytes(response, limit, onReadError)).toString('utf8');
|
|
25
26
|
export async function boundedJSON(response, limit) {
|
|
26
27
|
try { return JSON.parse(await boundedText(response,limit)); } catch (error) { if (error instanceof SyntaxError) throw new Error('malformed-response'); throw error; }
|
|
27
28
|
}
|
|
@@ -117,6 +118,22 @@ export function cloudflare({ accountId, token, fetch: request = globalThis.fetch
|
|
|
117
118
|
const shape = (!options.method || options.method === 'GET') && providerListShape(path);
|
|
118
119
|
return shape ? collect(path,{...shape,zone:options.zone,signal:options.signal}) : (await envelope(path,options)).result;
|
|
119
120
|
}
|
|
121
|
+
/** A Worker version's own modules, as Cloudflare keeps them: multipart parts and the entry module's name. */
|
|
122
|
+
async function workerContent(worker, versionId) {
|
|
123
|
+
assert(/^[a-z0-9-]{1,63}$/.test(worker) && /^[0-9a-f-]{36}$/.test(versionId), 'invalid-provider-path');
|
|
124
|
+
assert(++requests <= maxRequests, 'provider-request-budget');
|
|
125
|
+
const operation = 'GET /workers/scripts/[worker]/content/v2';
|
|
126
|
+
const {response,output} = await providerResponse({method:'GET',timeoutMs,reserveRetry:() => requests < maxRequests && (++requests, true),
|
|
127
|
+
send:signal => request(`https://api.cloudflare.com/client/v4/accounts/${accountId}/workers/scripts/${worker}/content/v2?version=${versionId}`, {method:'GET',redirect:'error',signal,headers:{Authorization:`Bearer ${token}`}}),
|
|
128
|
+
consume:response => response.body ? boundedBytes(response, 64 * 1024 * 1024) : Buffer.alloc(0),
|
|
129
|
+
failure:(cause,attempts) => Object.assign(new Error('provider-transport-failed'), {providerTransport:{operation,endpoint:`https://api.cloudflare.com/client/v4/accounts/[REDACTED]/workers/scripts/${worker}/content/v2`,attempts,status:null,reason:transportReason(cause)}})});
|
|
130
|
+
if (!response.ok) throw Object.assign(new Error(`provider-http-${response.status}`), {status:response.status,providerCall:{operation,reason:`provider-http-${response.status}`}});
|
|
131
|
+
const type = response.headers.get('content-type') ?? '', entry = response.headers.get('cf-entrypoint');
|
|
132
|
+
assert(type.startsWith('multipart/form-data') && typeof entry === 'string' && entry, 'invalid-worker-content');
|
|
133
|
+
const parts = await new Response(output, {headers:{'content-type':type}}).formData();
|
|
134
|
+
assert(parts.has(entry), 'invalid-worker-content');
|
|
135
|
+
return {parts, entry};
|
|
136
|
+
}
|
|
120
137
|
async function upload(url, bytes, etag) {
|
|
121
138
|
const destination = importUploadURL(url);
|
|
122
139
|
assert(++requests <= maxRequests, 'provider-request-budget');
|
|
@@ -130,6 +147,6 @@ export function cloudflare({ accountId, token, fetch: request = globalThis.fetch
|
|
|
130
147
|
assert(response.status === 200, 'd1-import-upload-failed');
|
|
131
148
|
assert(response.headers.get('etag')?.replace(/^"|"$/g, '') === etag, 'd1-import-upload-etag-mismatch');
|
|
132
149
|
}
|
|
133
|
-
return { accountId, envelope, list, importSql(id, sql) { return importD1({envelope,upload,redact:text => redactValues(text,[accountId,token])}, id, sql); }, request:requestResult,
|
|
150
|
+
return { accountId, envelope, list, importSql(id, sql) { return importD1({envelope,upload,redact:text => redactValues(text,[accountId,token])}, id, sql); }, request:requestResult, workerContent,
|
|
134
151
|
zoneRequest(path, options = {}) { return requestResult(path, { ...options, zone: true }); } };
|
|
135
152
|
}
|
|
@@ -8,9 +8,10 @@ function integer(value, defaultValue, min, max) {
|
|
|
8
8
|
const v = value ?? defaultValue;
|
|
9
9
|
check(Number.isSafeInteger(v) && v >= min && v <= max, 'oidc_invalid_configuration', 503); return v;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
// https always; with `allowLoopbackHttp` (an RER provider under `rer dev`) also http to a loopback host.
|
|
12
|
+
function httpsUrl(value, allowLoopbackHttp = false) {
|
|
12
13
|
const u = new URL(value);
|
|
13
|
-
check(typeof value === 'string' && u.protocol === 'https:' && !u.username && !u.password && !u.search && !u.hash && !/[\s\\]/.test(value));
|
|
14
|
+
check(typeof value === 'string' && (u.protocol === 'https:' || allowLoopbackHttp && u.protocol === 'http:' && isLoopbackHost(u.hostname)) && !u.username && !u.password && !u.search && !u.hash && !/[\s\\]/.test(value));
|
|
14
15
|
return u;
|
|
15
16
|
}
|
|
16
17
|
// A private JWK for private_key_jwt. Its public half is what the provider holds.
|
|
@@ -20,7 +21,7 @@ function privateKey(jwk, algorithm) {
|
|
|
20
21
|
return Object.freeze({ ...jwk });
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function provider(input, origin) {
|
|
24
|
+
function provider(input, origin, local) {
|
|
24
25
|
check(input && typeof input === 'object' && typeof input.id === 'string' && /^[a-z][a-z0-9-]{0,31}$/.test(input.id));
|
|
25
26
|
const preset = PRESETS[input.preset];
|
|
26
27
|
check(preset && Object.hasOwn(PRESETS, input.preset));
|
|
@@ -31,7 +32,8 @@ function provider(input, origin) {
|
|
|
31
32
|
issuer = preset.tenantIssuer(input.tenant);
|
|
32
33
|
}
|
|
33
34
|
check(input.issuer === undefined || input.issuer === issuer);
|
|
34
|
-
const
|
|
35
|
+
const loopbackHttp = local && !!preset.interface;
|
|
36
|
+
const issuerUrl = httpsUrl(issuer, loopbackHttp);
|
|
35
37
|
check(typeof input.clientId === 'string' && input.clientId.length > 0 && input.clientId.length <= 512 && !/[\x00-\x1f\x7f]/.test(input.clientId));
|
|
36
38
|
const tokenAuthMethod = input.tokenAuthMethod ?? preset.methods[0];
|
|
37
39
|
check(preset.methods.includes(tokenAuthMethod));
|
|
@@ -42,7 +44,7 @@ function provider(input, origin) {
|
|
|
42
44
|
const additionalAudiences = input.additionalAudiences ?? [];
|
|
43
45
|
check(Array.isArray(additionalAudiences) && additionalAudiences.length <= 10 && additionalAudiences.every(a => typeof a === 'string' && a.length > 0 && a.length <= 512));
|
|
44
46
|
const endpointOrigins = input.endpointOrigins ?? preset.endpointOrigins ?? [issuerUrl.origin];
|
|
45
|
-
check(Array.isArray(endpointOrigins) && endpointOrigins.length > 0 && endpointOrigins.every(o => { const u = new URL(o); return u.origin === o && u.protocol === 'https:'; }));
|
|
47
|
+
check(Array.isArray(endpointOrigins) && endpointOrigins.length > 0 && endpointOrigins.every(o => { const u = new URL(o); return u.origin === o && (u.protocol === 'https:' || loopbackHttp && u.protocol === 'http:' && isLoopbackHost(u.hostname)); }));
|
|
46
48
|
const subjectEmails = Object.fromEntries(Object.entries(input.subjectEmails ?? {}).map(([subject, email]) => {
|
|
47
49
|
check(subject.length > 0 && subject.length <= 255); return [subject, normalizeEmail(email)];
|
|
48
50
|
}));
|
|
@@ -69,7 +71,7 @@ function provider(input, origin) {
|
|
|
69
71
|
algorithms: Object.freeze([...preset.algorithms]), email: preset.email, scope: preset.scope, interface: preset.interface, minimumVersion,
|
|
70
72
|
additionalAudiences: Object.freeze([...new Set(additionalAudiences)]), endpointOrigins: Object.freeze([...new Set(endpointOrigins)]), subjectEmails: Object.freeze(subjectEmails),
|
|
71
73
|
// Each provider has its own redirect URI; its state is bound to it.
|
|
72
|
-
endpointPins, startPath: `/auth/oidc/${input.id}/start`, redirectUri });
|
|
74
|
+
endpointPins, local: loopbackHttp, startPath: `/auth/oidc/${input.id}/start`, redirectUri });
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
export function configure(input) {
|
|
@@ -81,7 +83,7 @@ export function configure(input) {
|
|
|
81
83
|
check(local ? isLoopbackHost(origin.hostname) && ['http:', 'https:'].includes(origin.protocol) : origin.protocol === 'https:');
|
|
82
84
|
check(typeof input.transactionSecret === 'string' && input.transactionSecret.length >= 32 && input.transactionSecret.length <= 1024);
|
|
83
85
|
check(Array.isArray(input.providers) && input.providers.length <= 8);
|
|
84
|
-
const providers = input.providers.map(entry => provider(entry, input.origin));
|
|
86
|
+
const providers = input.providers.map(entry => provider(entry, input.origin, local));
|
|
85
87
|
check(new Set(providers.map(p => p.id)).size === providers.length);
|
|
86
88
|
const callbacks = providers.map(p => new URL(p.redirectUri).pathname);
|
|
87
89
|
check(new Set(callbacks).size === providers.length);
|
|
@@ -99,6 +101,6 @@ export function configure(input) {
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
export function endpoint(value, provider) {
|
|
102
|
-
try { const u = new URL(value); check(typeof value === 'string' && u.href === value && u.protocol === 'https:' && !u.username && !u.password && !u.hash && !u.search && provider.endpointOrigins.includes(u.origin)); return u.href; }
|
|
104
|
+
try { const u = new URL(value); check(typeof value === 'string' && u.href === value && (u.protocol === 'https:' || provider.local === true && u.protocol === 'http:' && isLoopbackHost(u.hostname)) && !u.username && !u.password && !u.hash && !u.search && provider.endpointOrigins.includes(u.origin)); return u.href; }
|
|
103
105
|
catch { check(false, 'oidc_untrusted_endpoint', 503); }
|
|
104
106
|
}
|
|
@@ -15,10 +15,10 @@ const NOTICES = {
|
|
|
15
15
|
mail_unavailable: ['alert', 'Sign-in email is not available right now. Ask the person who runs this app to check its mail settings.'],
|
|
16
16
|
invalid_email: ['alert', 'Enter a complete email address.'],
|
|
17
17
|
invalid_input: ['alert', 'Enter a complete email address.'],
|
|
18
|
-
provider_required: ['alert', 'Your
|
|
19
|
-
oidc_provider_required: ['alert', 'Your
|
|
18
|
+
provider_required: ['alert', 'Your organization requires its own sign-in provider for this address.'],
|
|
19
|
+
oidc_provider_required: ['alert', 'Your organization requires its own sign-in provider for this address.'],
|
|
20
20
|
oidc_admission_denied: ['alert', 'That account cannot sign in here. Use the email link, or ask an owner of this app for an invitation.'],
|
|
21
|
-
oidc_provider_denied: ['alert', 'Sign-in was
|
|
21
|
+
oidc_provider_denied: ['alert', 'Sign-in was canceled at the provider.'],
|
|
22
22
|
};
|
|
23
23
|
const UNAVAILABLE = ['alert', 'That sign-in provider is not available right now. Use the email link instead.'];
|
|
24
24
|
const UNFINISHED = ['alert', 'Signing in with that provider did not finish. Try again, or use the email link.'];
|
|
@@ -42,7 +42,7 @@ export function catalogue(source, project, repository, gates, dryRun) {
|
|
|
42
42
|
if (typeof s[key] !== 'string' || !s[key]) throw Error('Incomplete seed listing metadata');
|
|
43
43
|
const contract = clauses(source.bytes('CONTRACT.md').toString());
|
|
44
44
|
const licence = source.bytes('LICENSE').toString();
|
|
45
|
-
if (!licence.includes('Permission is hereby granted, free of charge')) throw Error('Declare a supported listing
|
|
45
|
+
if (!licence.includes('Permission is hereby granted, free of charge')) throw Error('Declare a supported listing license');
|
|
46
46
|
const docs = ['seed.json', 'CONTRACT.md', 'AGENTS.md', 'LICENSE', 'RELEASE.json',
|
|
47
47
|
...['README.md', 'BASELINE.md', 'OPERATIONS.md', 'ACCEPTANCE.md'].filter(path => source.entries.has(path))];
|
|
48
48
|
const artifacts = docs.map(path => ({ path: `documents/${path}`, target: `agents/seeds/${s.id}/${path}`, sha256: sha256(source.bytes(path)) }));
|
|
@@ -28,7 +28,7 @@ export function validateSetupValue(field, value) {
|
|
|
28
28
|
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.href.includes('?') || url.href.includes('#')) throw Error();
|
|
29
29
|
} catch { throw Error(`Invalid URL for ${field.name}`); }
|
|
30
30
|
}
|
|
31
|
-
if (field.kind === 'colour' && !/^#[a-f\d]{6}$/i.test(value)) throw Error(`Invalid
|
|
31
|
+
if (field.kind === 'colour' && !/^#[a-f\d]{6}$/i.test(value)) throw Error(`Invalid color for ${field.name}`);
|
|
32
32
|
if (field.kind === 'timezone') {
|
|
33
33
|
try { new Intl.DateTimeFormat('en', {timeZone: value}); }
|
|
34
34
|
catch { throw Error(`Invalid timezone for ${field.name}`); }
|
package/onboarding/theme.mjs
CHANGED
|
@@ -87,7 +87,7 @@ export function readTheme(css, file = 'rer-theme.css') {
|
|
|
87
87
|
const kind = themeTokens[name];
|
|
88
88
|
if (!kind) throw Error(`${file}: ${name} is not a theme token. Use ${Object.keys(themeTokens).join(', ')}.`);
|
|
89
89
|
if (Object.hasOwn(tokens, name)) throw Error(`${file}: ${name} is declared twice.`);
|
|
90
|
-
if (kind === 'colour' && !colour.test(value)) throw Error(`${file}: ${name} must be a #rgb or #rrggbb
|
|
90
|
+
if (kind === 'colour' && !colour.test(value)) throw Error(`${file}: ${name} must be a #rgb or #rrggbb color.`);
|
|
91
91
|
if (kind === 'stack' && !stack.test(value)) throw Error(`${file}: ${name} must be a font stack of family names.`);
|
|
92
92
|
if (kind === 'radius' && !/^\d{1,2}(?:\.\d+)?(?:px|rem)$/.test(value)) throw Error(`${file}: ${name} must be a length in px or rem.`);
|
|
93
93
|
if (kind === 'logo') assets.add(asset(value, /\.(?:svg|png|webp)$/, name));
|
package/onboarding/ui/app.js
CHANGED
|
@@ -67,7 +67,7 @@ function inputFor(key, value) {
|
|
|
67
67
|
}
|
|
68
68
|
function appendInput(container, key, input, value) {
|
|
69
69
|
if (input.type === 'color') {
|
|
70
|
-
const wrap = node('div', 'colour-control'), selected = fields[key].valid(value), caption = node('span', 'colour-caption', selected ? value : 'Choose a
|
|
70
|
+
const wrap = node('div', 'colour-control'), selected = fields[key].valid(value), caption = node('span', 'colour-caption', selected ? value : 'Choose a color');
|
|
71
71
|
wrap.append(input, caption); input.addEventListener('input', () => { caption.textContent = input.value; });
|
|
72
72
|
container.append(wrap);
|
|
73
73
|
} else if (input.tagName === 'SELECT') { const wrap = node('div', 'select-wrap'); wrap.append(input); container.append(wrap); }
|