@runeditrun/rer 0.2.76 → 0.2.78
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 +32 -0
- package/cli/README.md +55 -0
- package/cli/contract.mjs +1 -1
- package/cli/deploy-command.mjs +4 -2
- package/cli/deploy-inputs.mjs +15 -3
- package/cli/deploy-installation-key.mjs +71 -0
- package/cli/deploy-secrets.mjs +2 -0
- package/cli/deploy.mjs +13 -2
- package/cli/deployment-record.mjs +2 -0
- package/cli/export.mjs +1 -1
- package/cli/main.mjs +1 -1
- package/cli/parse.mjs +3 -2
- package/cli/portability-migrations.mjs +35 -14
- package/cli/portability-worker.mjs +2 -2
- package/cli/portability.mjs +2 -2
- package/cli/runtime-front-door.mjs +1 -1
- package/global/CHANGELOG.md +14 -0
- package/global/README.md +32 -0
- package/modules/dependencies/README.md +71 -1
- package/modules/dependencies/auth.mjs +4 -4
- package/modules/dependencies/crypto.mjs +6 -1
- package/modules/dependencies/custody.mjs +16 -0
- package/modules/dependencies/index.d.mts +1 -1
- package/modules/dependencies/index.mjs +6 -5
- package/modules/dependencies/schema/keys-sealed.sql +4 -0
- package/modules/dependencies/sealing.mjs +55 -0
- package/modules/dependencies/store.mjs +62 -9
- package/modules/deploy-kit/README.md +1 -0
- package/modules/deploy-kit/owner-cli.mjs +19 -7
- package/modules/deploy-kit/owner-rekey.mjs +69 -0
- package/modules/deploy-kit/provider.mjs +9 -4
- package/modules/import-kit/src/d1/README.md +1322 -0
- package/modules/import-kit/src/d1/apply.ts +115 -0
- package/modules/import-kit/src/d1/budget.ts +89 -0
- package/modules/import-kit/src/d1/compressed-plan.ts +63 -0
- package/modules/import-kit/src/d1/creation.ts +95 -0
- package/modules/import-kit/src/d1/custody-fence.ts +27 -0
- package/modules/import-kit/src/d1/custody-state-schema.ts +67 -0
- package/modules/import-kit/src/d1/database.ts +163 -0
- package/modules/import-kit/src/d1/entry-locator.ts +61 -0
- package/modules/import-kit/src/d1/erased-artifacts.ts +38 -0
- package/modules/import-kit/src/d1/erased-custody.ts +36 -0
- package/modules/import-kit/src/d1/erased-plan.ts +47 -0
- package/modules/import-kit/src/d1/erased-reversal.ts +19 -0
- package/modules/import-kit/src/d1/erasure-bounded.ts +22 -0
- package/modules/import-kit/src/d1/erasure-claims.ts +27 -0
- package/modules/import-kit/src/d1/erasure-compiler.ts +67 -0
- package/modules/import-kit/src/d1/erasure-disposition.ts +16 -0
- package/modules/import-kit/src/d1/erasure-fragments.ts +86 -0
- package/modules/import-kit/src/d1/erasure-index.ts +53 -0
- package/modules/import-kit/src/d1/erasure-pages.ts +62 -0
- package/modules/import-kit/src/d1/erasure-progress-schema.ts +8 -0
- package/modules/import-kit/src/d1/erasure-progress.ts +61 -0
- package/modules/import-kit/src/d1/erasure-related.ts +124 -0
- package/modules/import-kit/src/d1/erasure-report.ts +31 -0
- package/modules/import-kit/src/d1/erasure-schema.ts +24 -0
- package/modules/import-kit/src/d1/erasure-selection.ts +77 -0
- package/modules/import-kit/src/d1/erasure-snapshot.ts +15 -0
- package/modules/import-kit/src/d1/erasure-stage.ts +146 -0
- package/modules/import-kit/src/d1/erasure-step.ts +12 -0
- package/modules/import-kit/src/d1/erasure-superseded.ts +98 -0
- package/modules/import-kit/src/d1/erasure-values.ts +83 -0
- package/modules/import-kit/src/d1/erasure-writes.ts +46 -0
- package/modules/import-kit/src/d1/erasure.ts +170 -0
- package/modules/import-kit/src/d1/evolutions/0001-preserved-undo.ts +13 -0
- package/modules/import-kit/src/d1/expected-state.ts +91 -0
- package/modules/import-kit/src/d1/field-redaction.ts +86 -0
- package/modules/import-kit/src/d1/guards.ts +37 -0
- package/modules/import-kit/src/d1/history.ts +71 -0
- package/modules/import-kit/src/d1/index.ts +88 -0
- package/modules/import-kit/src/d1/integrity.ts +127 -0
- package/modules/import-kit/src/d1/inventory-snapshot.ts +84 -0
- package/modules/import-kit/src/d1/jobs.ts +97 -0
- package/modules/import-kit/src/d1/native-set.ts +48 -0
- package/modules/import-kit/src/d1/native-staging-admission.ts +19 -0
- package/modules/import-kit/src/d1/native-staging-context.ts +44 -0
- package/modules/import-kit/src/d1/native-staging-lifecycle.ts +33 -0
- package/modules/import-kit/src/d1/native-staging-offset.ts +74 -0
- package/modules/import-kit/src/d1/native-staging-publication.ts +18 -0
- package/modules/import-kit/src/d1/native-staging-rows.ts +72 -0
- package/modules/import-kit/src/d1/native-staging-schema.ts +28 -0
- package/modules/import-kit/src/d1/native-staging-state.ts +22 -0
- package/modules/import-kit/src/d1/native-staging.ts +64 -0
- package/modules/import-kit/src/d1/original-copies.ts +53 -0
- package/modules/import-kit/src/d1/original-storage.ts +56 -0
- package/modules/import-kit/src/d1/originals.ts +74 -0
- package/modules/import-kit/src/d1/plan-dictionary.ts +80 -0
- package/modules/import-kit/src/d1/plans.ts +121 -0
- package/modules/import-kit/src/d1/preparation-fingerprint.ts +57 -0
- package/modules/import-kit/src/d1/preparation-header.ts +33 -0
- package/modules/import-kit/src/d1/preparation-reader.ts +98 -0
- package/modules/import-kit/src/d1/preparation-schema.ts +16 -0
- package/modules/import-kit/src/d1/preparation-state.ts +56 -0
- package/modules/import-kit/src/d1/preparation-step-combine.ts +80 -0
- package/modules/import-kit/src/d1/preparation-step-control.ts +48 -0
- package/modules/import-kit/src/d1/preparation-step-hash.ts +131 -0
- package/modules/import-kit/src/d1/preparation-step-pages.ts +77 -0
- package/modules/import-kit/src/d1/preparation-steps-schema.ts +11 -0
- package/modules/import-kit/src/d1/preparation-steps.ts +102 -0
- package/modules/import-kit/src/d1/preparations.ts +87 -0
- package/modules/import-kit/src/d1/preserved-preview.ts +89 -0
- package/modules/import-kit/src/d1/preserved-reverse.ts +91 -0
- package/modules/import-kit/src/d1/provenance-set.ts +87 -0
- package/modules/import-kit/src/d1/publication-fence.ts +22 -0
- package/modules/import-kit/src/d1/publication-receipt-schema.ts +15 -0
- package/modules/import-kit/src/d1/published-stream.ts +11 -0
- package/modules/import-kit/src/d1/read-fence.ts +64 -0
- package/modules/import-kit/src/d1/read-results.ts +16 -0
- package/modules/import-kit/src/d1/redacted-custody.ts +76 -0
- package/modules/import-kit/src/d1/redaction-step.ts +125 -0
- package/modules/import-kit/src/d1/referenced-plans.ts +136 -0
- package/modules/import-kit/src/d1/retained-values.ts +35 -0
- package/modules/import-kit/src/d1/retirement-bounded.ts +71 -0
- package/modules/import-kit/src/d1/retirement-door.ts +105 -0
- package/modules/import-kit/src/d1/retirement-schema.ts +39 -0
- package/modules/import-kit/src/d1/retirement-scope.ts +94 -0
- package/modules/import-kit/src/d1/retirement-steps.ts +76 -0
- package/modules/import-kit/src/d1/retirement-tally.ts +74 -0
- package/modules/import-kit/src/d1/retirement.ts +136 -0
- package/modules/import-kit/src/d1/reversal-conversion-record.ts +19 -0
- package/modules/import-kit/src/d1/reversal-conversion-schema.ts +11 -0
- package/modules/import-kit/src/d1/reversal-conversion.ts +40 -0
- package/modules/import-kit/src/d1/reversal-fence-schema.ts +14 -0
- package/modules/import-kit/src/d1/reversal-fence.ts +106 -0
- package/modules/import-kit/src/d1/reversal-journal.ts +24 -0
- package/modules/import-kit/src/d1/reverse.ts +103 -0
- package/modules/import-kit/src/d1/reviewed-source.ts +23 -0
- package/modules/import-kit/src/d1/sets.ts +78 -0
- package/modules/import-kit/src/d1/staged-creation.ts +201 -0
- package/modules/import-kit/src/d1/staging-admission.ts +45 -0
- package/modules/import-kit/src/d1/staging-control.ts +43 -0
- package/modules/import-kit/src/d1/staging-erasure.ts +28 -0
- package/modules/import-kit/src/d1/staging-lifecycle.ts +49 -0
- package/modules/import-kit/src/d1/staging-plan.ts +15 -0
- package/modules/import-kit/src/d1/staging-privacy.ts +22 -0
- package/modules/import-kit/src/d1/staging-publication.ts +79 -0
- package/modules/import-kit/src/d1/staging-schema.ts +37 -0
- package/modules/import-kit/src/d1/staging-statements.ts +8 -0
- package/modules/import-kit/src/d1/staging-transport.ts +70 -0
- package/modules/import-kit/src/d1/stream-boundary.ts +11 -0
- package/modules/import-kit/src/d1/stream-create.ts +55 -0
- package/modules/import-kit/src/d1/stream-identity-admission.ts +37 -0
- package/modules/import-kit/src/d1/stream-input.ts +18 -0
- package/modules/import-kit/src/d1/stream-layout.ts +43 -0
- package/modules/import-kit/src/d1/stream-origin.ts +44 -0
- package/modules/import-kit/src/d1/stream-page-integrity.ts +18 -0
- package/modules/import-kit/src/d1/stream-partition.ts +50 -0
- package/modules/import-kit/src/d1/stream-plan.ts +133 -0
- package/modules/import-kit/src/d1/stream-receipt.ts +45 -0
- package/modules/import-kit/src/d1/stream-revision-schema.ts +35 -0
- package/modules/import-kit/src/d1/stream-snapshot.ts +26 -0
- package/modules/import-kit/src/d1/stream-stage.ts +79 -0
- package/modules/import-kit/src/d1/stream-state.ts +25 -0
- package/modules/import-kit/src/d1/stream-working-set.ts +30 -0
- package/modules/import-kit/src/d1/streams.ts +39 -0
- package/modules/import-kit/src/d1/target-guards.ts +9 -0
- package/modules/import-kit/src/d1/target-identities.ts +17 -0
- package/modules/import-kit/src/d1/transport.ts +10 -0
- package/modules/import-kit/src/d1/types.ts +162 -0
- package/modules/import-kit/src/d1/undo-observations.ts +39 -0
- package/modules/import-kit/src/d1/undo-report.ts +22 -0
- package/modules/import-kit/src/d1/undo-snapshot.ts +87 -0
- package/modules/import-kit/src/d1/undo-state.ts +84 -0
- package/modules/import-kit/src/d1/undo-types.ts +110 -0
- package/modules/import-kit/src/journal/authority.ts +12 -0
- package/modules/import-kit/src/plan/budget.ts +60 -0
- package/modules/import-kit/src/plan/index.ts +123 -0
- package/modules/import-kit/src/plan/size.ts +122 -0
- package/modules/import-kit/src/provenance/canonical-hash.ts +130 -0
- package/modules/import-kit/src/provenance/canonical-stream.ts +85 -0
- package/modules/import-kit/src/provenance/credential-names.ts +131 -0
- package/modules/import-kit/src/provenance/credentials.ts +317 -0
- package/modules/import-kit/src/provenance/identity.ts +51 -0
- package/modules/import-kit/src/provenance/json-snapshot.ts +21 -0
- package/modules/import-kit/src/provenance/resumable-sha256.ts +75 -0
- package/modules/import-kit/src/provenance/validate-json.ts +19 -0
- package/modules/import-kit/src/storage/originals.ts +87 -0
- package/modules/import-kit/src/storage/provenance.ts +64 -0
- package/modules/import-kit/src/storage/schema.ts +42 -0
- package/modules/import-kit/src/types.ts +47 -0
- package/modules/operator-auth/docs/native-accounts.md +4 -1
- package/modules/operator-auth/identity/oidc/aes-gcm.mjs +21 -0
- package/modules/operator-auth/identity/oidc/crypto.mjs +5 -12
- package/modules/operator-auth/index.d.mts +1 -1
- package/modules/portability/README.md +98 -2
- package/modules/portability/backfills.mjs +42 -15
- package/modules/portability/ledgers.mjs +7 -1
- package/modules/portability/transient-tables.mjs +40 -0
- package/onboarding/local/environment.mjs +2 -2
- package/package.json +3 -1
- package/scripts/publish-check/reviewed.py +3 -1
package/README.md
CHANGED
|
@@ -291,6 +291,7 @@ line that still names it. A later refresh is a version bump:
|
|
|
291
291
|
| `@runeditrun/rer/adapter` | `commandAdapter` | `scripts/base-cli/cli/adapter.mjs` |
|
|
292
292
|
| `@runeditrun/rer/deploy` | `ownerDeploy` | `scripts/base-cli/cli/deploy.mjs` |
|
|
293
293
|
| `@runeditrun/rer/portability` | `localPortability` | `scripts/base-cli/cli/portability.mjs` |
|
|
294
|
+
| `@runeditrun/rer/portability-migrations` | `nativeMigrationPreflight`, before an adapter's Wrangler apply (contract in `modules/portability/README.md`) | `scripts/base-cli/cli/portability-migrations.mjs` |
|
|
294
295
|
| `@runeditrun/rer/errors` | the CLI's error helpers | `scripts/base-cli/cli/errors.mjs` |
|
|
295
296
|
| `@runeditrun/rer/jsonc` | JSONC reading | `scripts/base-cli/cli/jsonc.mjs` |
|
|
296
297
|
| `@runeditrun/rer/parse`, `/scheduled` | CLI argument parsing, scheduled-job helpers | `scripts/base-cli/cli/parse.mjs`, `scheduled.mjs` |
|
|
@@ -321,10 +322,41 @@ line that still names it. A later refresh is a version bump:
|
|
|
321
322
|
| `@runeditrun/rer/modules/release/export`, `/publication-scan`, `/source`, `/signature` | release export, publication scan and shared signature verifier | `scripts/base-cli/modules/release/*.mjs` |
|
|
322
323
|
| `@runeditrun/rer/modules/deploy-kit/owner`, `/owner-cli`, `/prepare`, `/provider` | deploy kit | `scripts/base-cli/modules/deploy-kit/*.mjs` |
|
|
323
324
|
| `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev-admission`, `/accounts/native`, `/identity/email-link` | operator auth | `scripts/base-cli/modules/operator-auth/index.mjs`, `dev/index.mjs`, `dev-admission.mjs`, `accounts/native.mjs`, `identity/email-link/index.mjs` |
|
|
325
|
+
| `@runeditrun/rer/modules/import-kit/d1` | asynchronous D1 import, reviewed reversal-policy conversion and preserved-undo preview (TypeScript Worker entry) | `scripts/base-cli/modules/import-kit/src/d1/index.ts` |
|
|
324
326
|
| `@runeditrun/rer/modules/erasure/fence` | erasure fence statements | `scripts/base-cli/modules/erasure/fence.mjs` |
|
|
325
327
|
| `@runeditrun/rer/modules/owner-claim`, `/modules/dependencies` | owner claim, dependency links | `scripts/base-cli/modules/owner-claim/index.mjs`, `dependencies/index.mjs` |
|
|
326
328
|
| `@runeditrun/rer/internal/PATH` | any other package file, for tests | `scripts/base-cli/PATH`, and `scripts/base-onboarding/PATH` with PATH under `onboarding/` |
|
|
327
329
|
|
|
330
|
+
### D1 import kit
|
|
331
|
+
|
|
332
|
+
In a TypeScript Worker with `nodejs_compat`, import the D1 API from the package:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import {
|
|
336
|
+
convertD1ReversalPolicy,
|
|
337
|
+
previewD1PreservedUndo,
|
|
338
|
+
d1ReversalPolicyConversionSchema,
|
|
339
|
+
} from '@runeditrun/rer/modules/import-kit/d1';
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
This is a TypeScript source entry for the Worker's bundler. Node's built-in type
|
|
343
|
+
stripping does not compile TypeScript dependencies inside `node_modules`; a Node
|
|
344
|
+
consumer must compile or bundle the entry with TypeScript support too. The package
|
|
345
|
+
includes its shared D1 transport and D1 runtime dependencies, without the synchronous
|
|
346
|
+
SQLite engine, optional readers or import UI.
|
|
347
|
+
|
|
348
|
+
Apply the additive `d1ReversalPolicyConversionSchema` in a new numbered migration
|
|
349
|
+
before converting an existing strict job; never rewrite an applied migration.
|
|
350
|
+
Preview the completed or undoing job with its current authorized context, review
|
|
351
|
+
the dispositions, then pass that preview's `reviewedFingerprint` to
|
|
352
|
+
`convertD1ReversalPolicy(jobId, context, { to: 'preserve-conflicts',
|
|
353
|
+
reviewedFingerprint })`. Preview is read-only. Conversion requires current undo
|
|
354
|
+
authority and preserves custody; repeated conversion refuses. Native adapters must
|
|
355
|
+
supply the complete dependency observations and guards described in the packaged
|
|
356
|
+
`modules/import-kit/src/d1/README.md`. Use `readD1ImportUndoReport().outcome` for the
|
|
357
|
+
later result (`undone` or `compensated`). This entry first ships in a supplying
|
|
358
|
+
release after rer 0.2.77; adopters still need their own public-door proof.
|
|
359
|
+
|
|
328
360
|
## Verbs
|
|
329
361
|
|
|
330
362
|
In a checkout, every verb runs that checkout's own pinned `rer`; `rer VERB --help`
|
package/cli/README.md
CHANGED
|
@@ -455,3 +455,58 @@ contain only the filename, path, size and modification time. Sensitive-looking
|
|
|
455
455
|
outbound names are dropped entirely and counted in `withheld`. Symlinks, build
|
|
456
456
|
outputs and dependency trees are skipped. Unsupported syntax yields no signal;
|
|
457
457
|
an empty result is not proof that a repository has no business dependencies.
|
|
458
|
+
|
|
459
|
+
`INSTALLATION_KEY` has a dedicated rotation path: `rer deploy --rotate-secret INSTALLATION_KEY`
|
|
460
|
+
saves current and previous values privately before publishing both as one Worker
|
|
461
|
+
version, reseals and verifies all dependency keys in the recorded D1, then retires
|
|
462
|
+
the previous binding. Routine rotation uses only the current/previous pair;
|
|
463
|
+
older retired keys require explicit reopen. By default, every retired key remains
|
|
464
|
+
in the same private 0600,
|
|
465
|
+
Git-ignored `.rer/deploy/<environment>.secrets.env` custody as `SESSION_SECRET`,
|
|
466
|
+
in `INSTALLATION_KEY_RETIRED=<kid>:<value>[,<kid>:<value>...]`. Retired values
|
|
467
|
+
never enter routine Worker bindings or installation archives. Back up this file
|
|
468
|
+
securely and copy it when moving the deployment to another checkout. If rotation
|
|
469
|
+
stops, run the same command again; it resumes the saved pair. Manual set/unset of
|
|
470
|
+
these bindings is refused.
|
|
471
|
+
|
|
472
|
+
Retain each retired key until no D1 Time Travel recovery point or exported backup
|
|
473
|
+
predates the completed rotation that retired it or otherwise needs that key.
|
|
474
|
+
After any rotation or reopen has finished, edit
|
|
475
|
+
`.rer/deploy/<environment>.secrets.env` and remove only its `<kid>:<value>` entry
|
|
476
|
+
from `INSTALLATION_KEY_RETIRED`, keeping valid comma separators; remove the
|
|
477
|
+
assignment if no entries remain. Preserve the current key, all other entries
|
|
478
|
+
and the file's owned 0600 permissions. There is no per-key removal command;
|
|
479
|
+
reopening a removed ID refuses before provider writes unless its custody is restored.
|
|
480
|
+
|
|
481
|
+
A D1 backup or Time Travel restore from before a rotation can restore ciphertext
|
|
482
|
+
that needs retired keys. Select a retained key explicitly:
|
|
483
|
+
|
|
484
|
+
```sh
|
|
485
|
+
rer deploy --reopen-installation-key KID
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Use the envelope's installation `kid` or its entry in private retired custody;
|
|
489
|
+
this ID is different from the signing JWK's ID. Include the original deployment's
|
|
490
|
+
`--environment` and `--env-file` when applicable. This command publishes the
|
|
491
|
+
current key and selected retired key as `INSTALLATION_KEY_PREVIOUS`, reseals all
|
|
492
|
+
dependency keys through the recorded D1, verifies them under the current key,
|
|
493
|
+
then removes the previous binding while retaining all retired custody. It skips
|
|
494
|
+
the build and upload hook. CLI-side reopen rekey receives every validated retired key
|
|
495
|
+
in custody, allowing a mid-rotation snapshot with multiple retired envelope IDs
|
|
496
|
+
to reopen with either ID; these additional keys are never Worker bindings.
|
|
497
|
+
Reopen/rekey prints the D1 `key_ids` tail and custody availability for each history
|
|
498
|
+
ID before opening rows, even when the tail is unavailable. A whole pre-rotation
|
|
499
|
+
restore whose history tail is unavailable reports `installation_key_unavailable`;
|
|
500
|
+
`installation_key_version_unknown` applies to a known row ID only after that
|
|
501
|
+
history custody check succeeds.
|
|
502
|
+
A failure preserves the exact pair and reopen marker;
|
|
503
|
+
repeat the same command before other deploy changes. Missing retired custody
|
|
504
|
+
refuses with `installation_key_unavailable` before any provider write: recover
|
|
505
|
+
the private file before reopening. For backups spanning several rotations,
|
|
506
|
+
retain every historical key they need; unrelated ciphertext never silently regenerates keys.
|
|
507
|
+
|
|
508
|
+
Base versions before #367 cannot open sealed dependency keys. Roll forward to a
|
|
509
|
+
sealing-capable Base version after restoring D1; rolling code back cannot decrypt
|
|
510
|
+
the rows. The CLI has no old-Base capability receipt or code rollback command,
|
|
511
|
+
so it cannot preflight an out-of-band provider rollback. Current Base rejects a
|
|
512
|
+
sealed key passed to its plaintext signing path with `installation_key_sealed_rollback`.
|
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: [['--owner-name', '--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 validates/builds locally and reads target secret bindings with Cloudflare credentials, without provider writes. Missing required secrets fail as in deploy; missing credentials or unreadable target secrets also fail. 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 saved setup owner name and the one-time setup token, then removes the token. If the installer declares an owner-name field and no name is saved, deploy asks once and saves it; --non-interactive requires --owner-name NAME before any upload. --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.'],
|
|
14
|
+
deploy: [['--owner-name', '--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret', '--rotate-secret', '--reopen-installation-key'], 'Owner-account deployment and health; dry run validates/builds locally and reads target secret bindings with Cloudflare credentials, without provider writes. Missing required secrets fail as in deploy; missing credentials or unreadable target secrets also fail. 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 saved setup owner name and the one-time setup token, then removes the token. If the installer declares an owner-name field and no name is saved, deploy asks once and saves it; --non-interactive requires --owner-name NAME before any upload. --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. --reopen-installation-key KID temporarily binds a retired installation key from private custody, reseals restored dependency keys under the current key, verifies them and removes the previous binding. --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'], 'For owner move-in, run rer dev and open /app/import: export people there, then upload through the destination door. Developer-only installation backup: 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'], 'For owner move-in, run rer dev and open /app/import: upload, review and apply through the door. Developer-only installation recovery: 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-command.mjs
CHANGED
|
@@ -26,7 +26,7 @@ import { withoutLocalSettings, refuseLocalEnvOutput } from './local-env.mjs';
|
|
|
26
26
|
import { deployProductDirectory, deployProductArguments, DeployProductError } from './deploy-product.mjs';
|
|
27
27
|
|
|
28
28
|
export function validateDeployOptions(options) {
|
|
29
|
-
const changes = [options.remove && '--remove', options.setSecret && '--set-secret', options.unsetSecret && '--unset-secret', options.rotateSecret && '--rotate-secret'].filter(Boolean);
|
|
29
|
+
const changes = [options.remove && '--remove', options.setSecret && '--set-secret', options.unsetSecret && '--unset-secret', options.rotateSecret && '--rotate-secret', options.reopenInstallationKey && '--reopen-installation-key'].filter(Boolean);
|
|
30
30
|
if (changes.length > 1 || changes.length && options.dryRun) throw invalid(`Use ${changes.join(', ')}${options.dryRun ? ' and --dry-run' : ''} on separate runs.`);
|
|
31
31
|
if (options.remove && !options.yes) throw invalid(`${deployAgain(options)} --remove deletes this environment's Worker and every D1, R2, KV and queue rer created for it, with their data. Add --yes to confirm.`);
|
|
32
32
|
}
|
|
@@ -86,11 +86,13 @@ export async function deployCommand(context) {
|
|
|
86
86
|
const { signIn } = await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed: context.setupSeed, adapter, declarationPath: path, options }) ?? {};
|
|
87
87
|
const needed = neededForRealDeploy({ declaration, env: production.env, signIn, secretsChecked: true });
|
|
88
88
|
reportNeeded(store, needed);
|
|
89
|
+
if (declaration.secrets?.some(item => item.binding === 'INSTALLATION_KEY')) store.report('deploy: INSTALLATION_KEY is a private generated binding; INSTALLATION_KEY_PREVIOUS is optional and managed only during rotation or an explicit retired-key reopen. Values are withheld.');
|
|
89
90
|
return needed.length && result && typeof result === 'object' ? { ...result, neededForRealDeploy: needed } : result;
|
|
90
91
|
};
|
|
91
92
|
// Custom hooks historically ignored these flags. Only the ownership controller
|
|
92
93
|
// may perform them; neither a build nor a custom upload runs here.
|
|
93
|
-
if (options.remove || options.setSecret || options.unsetSecret) return ownerDeploy(path, adapter)(context);
|
|
94
|
+
if (options.remove || options.setSecret || options.unsetSecret || options.reopenInstallationKey) return ownerDeploy(path, adapter)(context);
|
|
95
|
+
if (options.rotateSecret?.split(',').includes('INSTALLATION_KEY')) return ownerDeploy(path, adapter)(context);
|
|
94
96
|
// A hook that deployed through the kit keeps what its Worker holds: rotate there as a secret change.
|
|
95
97
|
if (options.rotateSecret && !adapter.deploy.managesHostedOwner && await hookState(root, options.environment ?? 'production')) return ownerDeploy(path, adapter)(context);
|
|
96
98
|
if (adapter.deploy.managesHostedOwner) { const result = await adapter.deploy(context); return options.dryRun ? dryRun(result) : result; }
|
package/cli/deploy-inputs.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
2
|
import { relative } from 'node:path';
|
|
3
3
|
import { shared } from './shared.mjs';
|
|
4
|
-
import { invalid } from './errors.mjs';
|
|
4
|
+
import { invalid, refuse } from './errors.mjs';
|
|
5
5
|
import { readDeployEnvFile } from '../modules/deploy-kit/env-file.mjs';
|
|
6
6
|
import { publicOrigin } from '../modules/deploy-kit/public-origin.mjs';
|
|
7
7
|
import { keptSecrets, rotations, savedSecrets } from './deploy-secrets.mjs';
|
|
@@ -39,12 +39,24 @@ export async function deployEnvironment({ root, options, declaration, setupManif
|
|
|
39
39
|
}
|
|
40
40
|
// withDeployEnvironment reads only the --env-file, with no declaration to rotate in.
|
|
41
41
|
const kept = keptSecrets(declaration, setupManifest), rotate = setupManifest || declaration.project ? rotations(options, kept, env) : [];
|
|
42
|
-
const saved = kept.some(absent) ? await savedSecrets(root, options.environment ?? 'production') : {};
|
|
42
|
+
const saved = kept.some(absent) || kept.some(item => item.binding === 'INSTALLATION_KEY') ? await savedSecrets(root, options.environment ?? 'production') : {};
|
|
43
|
+
if (kept.some(item => item.binding === 'INSTALLATION_KEY')) {
|
|
44
|
+
const installation = kept.find(item => item.binding === 'INSTALLATION_KEY'), previous = secrets.find(item => item.binding === 'INSTALLATION_KEY_PREVIOUS');
|
|
45
|
+
if (previous && env[previous.environment]?.trim()) throw refuse('INSTALLATION_KEY_PREVIOUS is managed by --rotate-secret INSTALLATION_KEY; leave it unset in the environment and --env-file.');
|
|
46
|
+
if (saved.INSTALLATION_KEY && env[installation.environment]?.trim() && env[installation.environment] !== saved.INSTALLATION_KEY) throw refuse('A supplied INSTALLATION_KEY differs from this environment\'s private custody. Use --rotate-secret INSTALLATION_KEY to change it safely.');
|
|
47
|
+
if ((options.setSecret ?? options.unsetSecret ?? '').split(',').some(name => ['INSTALLATION_KEY', 'INSTALLATION_KEY_PREVIOUS'].includes(name))) throw refuse('Installation keys cannot be set or removed manually. Use --rotate-secret INSTALLATION_KEY to publish both keys, reseal dependency keys and retire the previous key safely.');
|
|
48
|
+
if (saved.INSTALLATION_KEY_PREVIOUS && !options.remove) {
|
|
49
|
+
if (saved.INSTALLATION_KEY_REOPEN && options.reopenInstallationKey !== saved.INSTALLATION_KEY_REOPEN) throw refuse(`Installation key reopen is unfinished. Run the same deploy command with --reopen-installation-key ${saved.INSTALLATION_KEY_REOPEN} to resume before another deployment or secret change.`);
|
|
50
|
+
if (!saved.INSTALLATION_KEY_REOPEN && !rotate.includes('INSTALLATION_KEY')) throw refuse('Installation key rotation is unfinished. Run the same deploy command with --rotate-secret INSTALLATION_KEY to resume before another deployment or secret change.');
|
|
51
|
+
}
|
|
52
|
+
if (rotate.includes('INSTALLATION_KEY') && !saved.INSTALLATION_KEY) throw refuse('Installation key rotation requires the current key in the private deployment secrets file. Restore that file from the checkout that deployed this environment; generating a replacement would lose access to dependency keys.');
|
|
53
|
+
}
|
|
43
54
|
const generated = [], reused = [];
|
|
44
55
|
for (const field of setupManifest?.fields ?? []) {
|
|
45
56
|
const item = field.kind === 'secret' && field.generate ? secrets.find(entry => entry?.binding === field.name) : undefined;
|
|
46
57
|
if (!absent(item)) continue;
|
|
47
|
-
const keep = kept.includes(item),
|
|
58
|
+
const keep = kept.includes(item), resuming = item.binding === 'INSTALLATION_KEY' && saved.INSTALLATION_KEY_PREVIOUS;
|
|
59
|
+
const value = keep && (!rotate.includes(item.binding) || resuming) ? saved[item.binding] : undefined;
|
|
48
60
|
env[item.environment] = value ?? randomBytes(32).toString(field.generate);
|
|
49
61
|
supplied.push(item.binding);
|
|
50
62
|
if (value) reused.push(item.binding); else if (keep) generated.push(item.binding);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { savedSecrets, saveSecrets, savedSecretsFile, liveSecretNames } from './deploy-secrets.mjs';
|
|
2
|
+
import { refuse, RerError } from './errors.mjs';
|
|
3
|
+
import { installationKeyId } from '../modules/dependencies/sealing.mjs';
|
|
4
|
+
import { retiredInstallationKeys as parseRetiredKeys } from '../modules/dependencies/custody.mjs';
|
|
5
|
+
import { shared } from './shared.mjs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
/** Save the first deployment key before a Worker can receive it, including when
|
|
9
|
+
* its upload answer is lost. Never confuse a newly generated value with a live key. */
|
|
10
|
+
export async function keepInstallationKey({ root, environment, declaration, env, generated }) {
|
|
11
|
+
const secret = declaration.secrets?.find(item => item.binding === 'INSTALLATION_KEY');
|
|
12
|
+
if (!secret || (await savedSecrets(root, environment)).INSTALLATION_KEY) return;
|
|
13
|
+
if (generated.includes(secret.binding) && (await liveSecretNames(env, declaration, environment)).includes(secret.binding)) throw refuse('The Worker already holds INSTALLATION_KEY, but this checkout has no current key. Restore the private deployment secrets file before continuing.');
|
|
14
|
+
if (env[secret.environment]) await saveSecrets(root, environment, { INSTALLATION_KEY: env[secret.environment] });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Persist both keys before publishing either; a retry always uses this exact pair. */
|
|
18
|
+
export async function rotateInstallationKey({ root, environment, declaration, env, owner, state, report, addSecrets }) {
|
|
19
|
+
const current = declaration.secrets?.find(item => item.binding === 'INSTALLATION_KEY');
|
|
20
|
+
const previous = declaration.secrets?.find(item => item.binding === 'INSTALLATION_KEY_PREVIOUS');
|
|
21
|
+
if (!current || !previous?.optional) throw refuse('Installation key rotation requires declared INSTALLATION_KEY and optional INSTALLATION_KEY_PREVIOUS bindings.');
|
|
22
|
+
const saved = await savedSecrets(root, environment);
|
|
23
|
+
if (!saved.INSTALLATION_KEY) throw refuse('Restore the current installation key in the private deployment secrets file before rotating it.');
|
|
24
|
+
if (saved.INSTALLATION_KEY_REOPEN) throw refuse('Installation key reopen is unfinished. Resume --reopen-installation-key with the saved key ID before rotating.');
|
|
25
|
+
const pair = { INSTALLATION_KEY: saved.INSTALLATION_KEY_PREVIOUS ? saved.INSTALLATION_KEY : env[current.environment], INSTALLATION_KEY_PREVIOUS: saved.INSTALLATION_KEY_PREVIOUS ?? saved.INSTALLATION_KEY };
|
|
26
|
+
if (!pair.INSTALLATION_KEY || pair.INSTALLATION_KEY === pair.INSTALLATION_KEY_PREVIOUS) throw refuse('Installation key rotation requires distinct current and previous keys.');
|
|
27
|
+
const retired = await retiredInstallationKeys(saved);
|
|
28
|
+
retired.set(await installationKeyId(pair.INSTALLATION_KEY_PREVIOUS), pair.INSTALLATION_KEY_PREVIOUS);
|
|
29
|
+
addSecrets([...Object.values(pair), ...retired.values()]);
|
|
30
|
+
await saveSecrets(root, environment, { ...pair, INSTALLATION_KEY_RETIRED: serializeRetired(retired) });
|
|
31
|
+
// Routine rotation must not revive envelopes from older retired eras.
|
|
32
|
+
await resealAndRetire({root, environment, current, previous, pair, retired:new Map(), env, state, owner, report});
|
|
33
|
+
report('Rotated INSTALLATION_KEY, resealed every dependency key, and removed INSTALLATION_KEY_PREVIOUS after verifying the owned Worker. Retired keys remain in private custody for older D1 restores.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Explicitly reopen one retained historical key without changing current custody. */
|
|
37
|
+
export async function reopenInstallationKey({ root, environment, declaration, env, owner, state, kid, report, addSecrets }) {
|
|
38
|
+
const current = declaration.secrets?.find(item => item.binding === 'INSTALLATION_KEY');
|
|
39
|
+
const previous = declaration.secrets?.find(item => item.binding === 'INSTALLATION_KEY_PREVIOUS');
|
|
40
|
+
if (!current || !previous?.optional) throw refuse('Installation key reopen requires declared INSTALLATION_KEY and optional INSTALLATION_KEY_PREVIOUS bindings.');
|
|
41
|
+
const saved = await savedSecrets(root, environment), retired = await retiredInstallationKeys(saved);
|
|
42
|
+
if (!saved.INSTALLATION_KEY || !retired.has(kid)) throw unavailable('The requested retired installation key is not in this environment\'s private custody. Restore the private deployment secrets file from the deploying checkout, or relink dependencies. Nothing was uploaded.');
|
|
43
|
+
if (saved.INSTALLATION_KEY_PREVIOUS && (saved.INSTALLATION_KEY_REOPEN !== kid || saved.INSTALLATION_KEY_PREVIOUS !== retired.get(kid))) throw refuse('Another installation key operation is unfinished. Resume its recorded rotation or reopen first.');
|
|
44
|
+
const pair = { INSTALLATION_KEY: saved.INSTALLATION_KEY, INSTALLATION_KEY_PREVIOUS: retired.get(kid) };
|
|
45
|
+
addSecrets([...Object.values(pair), ...retired.values()]);
|
|
46
|
+
await saveSecrets(root, environment, {...pair, INSTALLATION_KEY_REOPEN:kid});
|
|
47
|
+
await resealAndRetire({root, environment, current, previous, pair, retired, env, state, owner, report});
|
|
48
|
+
report(`Reopened retired installation key ${kid}, resealed and verified every dependency key with the current key, and removed INSTALLATION_KEY_PREVIOUS. Retired custody is retained.`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const unavailable = message => new RerError('installation_key_unavailable', message, 4);
|
|
52
|
+
const serializeRetired = retired => [...retired].map(([kid, value]) => `${kid}:${value}`).join(',');
|
|
53
|
+
|
|
54
|
+
async function retiredInstallationKeys(saved) {
|
|
55
|
+
try { return await parseRetiredKeys(saved.INSTALLATION_KEY_RETIRED); }
|
|
56
|
+
catch { throw unavailable('Retired installation key custody is invalid. Restore the private deployment secrets file before rotating or reopening. Nothing was uploaded.'); }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function resealAndRetire({root, environment, current, previous, pair, retired, env, state, owner, report}) {
|
|
60
|
+
const values = { ...env, [current.environment]: pair.INSTALLATION_KEY, [previous.environment]: pair.INSTALLATION_KEY_PREVIOUS };
|
|
61
|
+
const extra = state ? ['--state', state] : [];
|
|
62
|
+
await owner('secret', ['--set', current.binding, '--set', previous.binding, ...extra], values);
|
|
63
|
+
await owner('rekey', extra, {...values, INSTALLATION_KEY_RETIRED:serializeRetired(retired)}, {notice:report});
|
|
64
|
+
await owner('secret', ['--unset', previous.binding, ...extra], values);
|
|
65
|
+
// The retired key stays private after its binding is read back absent.
|
|
66
|
+
const retained = await savedSecrets(root, environment);
|
|
67
|
+
delete retained.INSTALLATION_KEY_PREVIOUS;
|
|
68
|
+
delete retained.INSTALLATION_KEY_REOPEN;
|
|
69
|
+
const { writePrivateFile } = await shared('private-files.mjs');
|
|
70
|
+
await writePrivateFile(join(root, savedSecretsFile(environment)), Object.entries(retained).map(([name, value]) => `${name}=${value}\n`).join(''));
|
|
71
|
+
}
|
package/cli/deploy-secrets.mjs
CHANGED
|
@@ -87,6 +87,8 @@ export async function keepHookSecrets({ root, environment, declaration, setupMan
|
|
|
87
87
|
const held = kept.filter(item => fresh.includes(item.binding) && live.includes(item.binding));
|
|
88
88
|
if (held.length) throw refuseRotation({ worker: ownerWorkerName(declaration.project, environment), held, environment, again });
|
|
89
89
|
}
|
|
90
|
+
const { keepInstallationKey } = await import('./deploy-installation-key.mjs');
|
|
91
|
+
await keepInstallationKey({ root, environment, declaration, env, generated });
|
|
90
92
|
await keepSecrets({ root, environment, kept, env, generated, reused, report });
|
|
91
93
|
}
|
|
92
94
|
|
package/cli/deploy.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import { cloudflareCredentials, missingCredentialsMessage } from './deploy-needs
|
|
|
20
20
|
import { keptSecrets, keepSecrets, forgetSecrets } from './deploy-secrets.mjs';
|
|
21
21
|
import { withoutLocalSettings, refuseLocalEnvOutput } from './local-env.mjs';
|
|
22
22
|
import { deployProductDirectory, deployProductArguments } from './deploy-product.mjs';
|
|
23
|
+
import { rotateInstallationKey, reopenInstallationKey, keepInstallationKey } from './deploy-installation-key.mjs';
|
|
23
24
|
|
|
24
25
|
export function ownerDeploy(declarationPath, lifecycle) {
|
|
25
26
|
// rer verify serves the build with this declaration's vars and secrets.
|
|
@@ -31,9 +32,9 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
31
32
|
if (local) throw refuse(`${declarationPath} names the local-only key ${local} as a deploy binding or secret. Remove it; local dev keys never reach a deployment.`);
|
|
32
33
|
const environment = options.environment ?? 'production';
|
|
33
34
|
const again = deployAgain(options);
|
|
34
|
-
const change = [options.remove && '--remove', options.setSecret && '--set-secret', options.unsetSecret && '--unset-secret', options.rotateSecret && '--rotate-secret'].filter(Boolean);
|
|
35
|
+
const change = [options.remove && '--remove', options.setSecret && '--set-secret', options.unsetSecret && '--unset-secret', options.rotateSecret && '--rotate-secret', options.reopenInstallationKey && '--reopen-installation-key'].filter(Boolean);
|
|
35
36
|
// The command that finishes what this run started: the same verb, never a plain deploy in its place.
|
|
36
|
-
const retry = options.remove ? `${again} --remove --yes` : options.setSecret ? `${again} --set-secret ${options.setSecret}` : options.unsetSecret ? `${again} --unset-secret ${options.unsetSecret}` : options.rotateSecret ? `${again} --rotate-secret ${options.rotateSecret}` : again;
|
|
37
|
+
const retry = options.remove ? `${again} --remove --yes` : options.setSecret ? `${again} --set-secret ${options.setSecret}` : options.unsetSecret ? `${again} --unset-secret ${options.unsetSecret}` : options.rotateSecret ? `${again} --rotate-secret ${options.rotateSecret}` : options.reopenInstallationKey ? `${again} --reopen-installation-key ${options.reopenInstallationKey}` : again;
|
|
37
38
|
if (change.length > 1 || change.length && options.dryRun) throw invalid(`Use ${change.join(', ')}${options.dryRun ? ' and --dry-run' : ''} on separate runs.`);
|
|
38
39
|
if (options.remove && !options.yes) throw invalid(`${again} --remove deletes this environment's Worker and every D1, R2, KV and queue rer created for it, with their data. Add --yes to confirm.`);
|
|
39
40
|
const productDirectory = change.length ? undefined : deployProductDirectory(declaration);
|
|
@@ -81,10 +82,19 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
81
82
|
store.report(`Removed ${result.removed.join(', ') || 'nothing (already gone)'}; read back: none of them remains.`);
|
|
82
83
|
return { removed: result.removed, deployed: false };
|
|
83
84
|
}
|
|
85
|
+
if (options.reopenInstallationKey) {
|
|
86
|
+
step = 'secrets';
|
|
87
|
+
await reopenInstallationKey({ root, environment, declaration, env, owner, state, kid: options.reopenInstallationKey, report: line => store.report(line), addSecrets: values => { redaction.addSecrets(values); store.addSecrets?.(values); } });
|
|
88
|
+
return { reopened: options.reopenInstallationKey, deployed: false };
|
|
89
|
+
}
|
|
84
90
|
if (options.rotateSecret) {
|
|
85
91
|
// The kit never replaces a secret its Worker holds: rotation is this explicit change, kept once it is live.
|
|
86
92
|
step = 'secrets';
|
|
87
93
|
for (const binding of rotated) {
|
|
94
|
+
if (binding === 'INSTALLATION_KEY') {
|
|
95
|
+
await rotateInstallationKey({ root, environment, declaration, env, owner, state, report: line => store.report(line), addSecrets: values => { redaction.addSecrets(values); store.addSecrets?.(values); } });
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
88
98
|
await owner('secret', ['--set', binding, ...(state ? ['--state', state] : [])]);
|
|
89
99
|
await keepSecrets({ root, environment, kept, env, generated: [binding], reused: [], report: () => {} });
|
|
90
100
|
store.report(`Rotated ${binding} on this environment's Worker to a fresh value kept in .rer/deploy/${environment}.secrets.env, recorded its new version and verified hosted readiness.`);
|
|
@@ -99,6 +109,7 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
99
109
|
return { bindings, present: Boolean(options.setSecret), deployed: false };
|
|
100
110
|
}
|
|
101
111
|
store.report(`Deploying the ${environment} environment to your Cloudflare account.`);
|
|
112
|
+
await keepInstallationKey({ root, environment, declaration, env, generated });
|
|
102
113
|
deployed = await owner('deploy', [], env, { notice: line => store.report(line), onCreated: resource => created.push(redaction.redact(resource)) });
|
|
103
114
|
// A generated value the kit did not send stays unknown: the Worker kept its own.
|
|
104
115
|
const sent = supplied.filter(name => deployed.sentSecrets.includes(name)), keptSent = [...generated, ...reused].filter(name => sent.includes(name));
|
|
@@ -48,6 +48,8 @@ function commandFor(options, environment) {
|
|
|
48
48
|
if (options.verb === 'signin') return again.replace(/^rer deploy/, 'rer signin');
|
|
49
49
|
if (options.remove) return `${again} --remove --yes`;
|
|
50
50
|
if (options.setSecret) return `${again} --set-secret ${options.setSecret}`;
|
|
51
|
+
if (options.reopenInstallationKey) return `${again} --reopen-installation-key ${options.reopenInstallationKey}`;
|
|
52
|
+
if (options.rotateSecret) return `${again} --rotate-secret ${options.rotateSecret}`;
|
|
51
53
|
if (options.unsetSecret) return `${again} --unset-secret ${options.unsetSecret}`;
|
|
52
54
|
return again;
|
|
53
55
|
}
|
package/cli/export.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
|
|
|
6
6
|
|
|
7
7
|
// Copy whole maintained source/tooling directories. Python publication scans
|
|
8
8
|
// load sibling modules and data dynamically; they belong in the inventory too.
|
|
9
|
-
export const sourceRoots = ['default-seed/public/rer-theme.css', 'default-seed/public/brand/mark.svg', 'default-seed/public/fonts/outfit', 'bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/site', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs', 'foundation/runtime/seed-contract.mjs'];
|
|
9
|
+
export const sourceRoots = ['default-seed/public/rer-theme.css', 'default-seed/public/brand/mark.svg', 'default-seed/public/fonts/outfit', 'bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/site', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/import-kit/src/d1', 'modules/import-kit/src/types.ts', 'modules/import-kit/src/plan', 'modules/import-kit/src/provenance/canonical-hash.ts', 'modules/import-kit/src/provenance/canonical-stream.ts', 'modules/import-kit/src/provenance/credential-names.ts', 'modules/import-kit/src/provenance/credentials.ts', 'modules/import-kit/src/provenance/identity.ts', 'modules/import-kit/src/provenance/json-snapshot.ts', 'modules/import-kit/src/provenance/resumable-sha256.ts', 'modules/import-kit/src/provenance/validate-json.ts', 'modules/import-kit/src/journal/authority.ts', 'modules/import-kit/src/storage/originals.ts', 'modules/import-kit/src/storage/provenance.ts', 'modules/import-kit/src/storage/schema.ts', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs', 'foundation/runtime/seed-contract.mjs'];
|
|
10
10
|
export async function inventory(base, roots = sourceRoots) {
|
|
11
11
|
const files = [];
|
|
12
12
|
async function walk(path) {
|
package/cli/main.mjs
CHANGED
|
@@ -64,7 +64,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
64
64
|
}
|
|
65
65
|
// A hosted address never exports this computer's copy under its name.
|
|
66
66
|
if (options.verb === 'export' && project.profile === 'first-party') await (await import('./hosted-export.mjs')).refuseHostedExport(project, options);
|
|
67
|
-
if (options.verb === 'deploy' && !options.site && !options.demo && !options.remove && !options.setSecret && !options.unsetSecret) {
|
|
67
|
+
if (options.verb === 'deploy' && !options.site && !options.demo && !options.remove && !options.setSecret && !options.unsetSecret && !options.reopenInstallationKey) {
|
|
68
68
|
const { deliveryDeclarationClauses } = await import('./delivery-declarations.mjs');
|
|
69
69
|
const failures = (await deliveryDeclarationClauses(project.root)).filter(clause => !clause.ok);
|
|
70
70
|
if (failures.length) throw new RerError('invalid_deployment_declaration', failures.map(clause => clause.message).join('\n'), 1);
|
package/cli/parse.mjs
CHANGED
|
@@ -94,9 +94,10 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
94
94
|
options[key] = names.join(',');
|
|
95
95
|
}
|
|
96
96
|
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.');
|
|
97
|
-
if(
|
|
97
|
+
if (options.reopenInstallationKey !== undefined && !/^[A-Za-z0-9_-]{43}$/.test(options.reopenInstallationKey)) throw invalid('--reopen-installation-key takes the installation key ID from a sealed envelope or private retired custody.');
|
|
98
|
+
if(verb==='deploy'&&options.demo&&(options.site||['platform','image','bindAddress','httpPort','httpsPort','envFile','host','setSecret','unsetSecret','rotateSecret','reopenInstallationKey'].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>.');
|
|
98
99
|
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.');
|
|
99
|
-
if ((options.remove || options.setSecret || options.unsetSecret || options.rotateSecret) && options.site) throw invalid('--remove, --set-secret, --unset-secret
|
|
100
|
+
if ((options.remove || options.setSecret || options.unsetSecret || options.rotateSecret || options.reopenInstallationKey) && options.site) throw invalid('--remove, --set-secret, --unset-secret, --rotate-secret and --reopen-installation-key act on the application Worker, not the run site.');
|
|
100
101
|
if (options.origin !== undefined) {
|
|
101
102
|
let url; try { url = new URL(options.origin); } catch { throw invalid('Provide a valid credential-free origin.'); }
|
|
102
103
|
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== '/') throw invalid('Provide a credential-free HTTP origin without a path.');
|
|
@@ -2,8 +2,8 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { readFile, readdir } from 'node:fs/promises';
|
|
4
4
|
import { migrationStatements } from '../modules/portability/migration-sql.mjs';
|
|
5
|
-
import { destinationLedger, matchMigrationLedger } from '../modules/portability/ledgers.mjs';
|
|
6
|
-
import { all, insist } from '../modules/portability/storage.mjs';
|
|
5
|
+
import { destinationLedger, ledgerNames, matchMigrationLedger } from '../modules/portability/ledgers.mjs';
|
|
6
|
+
import { all, insist, PortabilityError } from '../modules/portability/storage.mjs';
|
|
7
7
|
import { parseJsonc } from './jsonc.mjs';
|
|
8
8
|
|
|
9
9
|
// Seed-owned declarations, never archive metadata: the deploymentSpec prefix
|
|
@@ -20,10 +20,12 @@ export function platformMigrationDeclaration(input={}) {
|
|
|
20
20
|
// boundaries (migration-sql.mjs).
|
|
21
21
|
async function inventory(root,binding,{prefix},split) {
|
|
22
22
|
const config=parseJsonc(await readFile(join(root,'wrangler.jsonc'),'utf8'));
|
|
23
|
-
const
|
|
23
|
+
const bindings=config.d1_databases?.filter(entry=>entry.binding===binding) ?? [];
|
|
24
|
+
insist(bindings.length===1,'migration_ledger:binding',409);
|
|
25
|
+
const directory=join(root,bindings[0].migrations_dir ?? 'migrations');
|
|
24
26
|
return Promise.all((await readdir(directory)).filter(name=>name.endsWith('.sql')).sort().map(async name=>{
|
|
25
27
|
const bytes=await readFile(join(directory,name));
|
|
26
|
-
return {name
|
|
28
|
+
return {name,...(split?{statements:migrationStatements(bytes.toString('utf8'),split)}:{}),sha256:createHash('sha256').update(bytes).digest('hex'),...(prefix===undefined?{}:{aliases:[prefix+name]})};
|
|
27
29
|
}));
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -33,14 +35,33 @@ export async function appliedMigrations(root,db,binding,declaration,split) {
|
|
|
33
35
|
return matchMigrationLedger(ledger,files,declaration).map(name=>files.find(file=>file.name===name));
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return {
|
|
38
|
+
// Adapter entry point, before *any* native Wrangler apply. The caller supplies
|
|
39
|
+
// the real target binding and keeps its writers stopped through apply/transfer.
|
|
40
|
+
// This only reads: it never repairs history or creates a second ledger.
|
|
41
|
+
export async function nativeMigrationPreflight({root,db,binding='DB',platformMigrations}) {
|
|
42
|
+
const declaration=platformMigrationDeclaration(platformMigrations);
|
|
43
|
+
const tables=await all(db,`SELECT type,name FROM sqlite_master WHERE lower(name) IN (${ledgerNames.map(name=>`'${name}'`).join(',')})`);
|
|
44
|
+
insist(tables.length<=1,'migration_ledger:multiple',409);
|
|
45
|
+
insist(tables.every(row=>row.type==='table' && ledgerNames.includes(row.name)),'migration_ledger:incompatible',409);
|
|
46
|
+
const table=tables[0]?.name;
|
|
47
|
+
if(!table)return {nativeApply:true};
|
|
48
|
+
// This runner's history cannot authorize Wrangler to apply the same files.
|
|
49
|
+
insist(table!=='_rer_deploy_migrations','migration_ledger:runner',409);
|
|
50
|
+
const files=await inventory(root,binding,declaration);
|
|
51
|
+
try {
|
|
52
|
+
const ledger=await destinationLedger(db),applied=matchMigrationLedger(ledger,files,declaration);
|
|
53
|
+
// Wrangler skips only literal filenames, not transfer aliases or hashes.
|
|
54
|
+
if(table==='d1_migrations')insist(ledger.every(row=>files.some(file=>file.name===row.name)),'migration_ledger:incompatible',409);
|
|
55
|
+
if(table==='rer_migrations')for(const file of files)insist(applied.includes(file.name),'migration_ledger:unapplied',409);
|
|
56
|
+
} catch(error) {
|
|
57
|
+
// Ledger contents can contain private values. Report constant categories,
|
|
58
|
+
// retaining the transfer's canonical compatibility and hash-matching policy.
|
|
59
|
+
if(error instanceof PortabilityError) {
|
|
60
|
+
const code=error.code.startsWith('migration_ledger:')?error.code.split(':').slice(0,2).join(':')
|
|
61
|
+
:error.code==='schema_mismatch:uncertain_migrations'?'migration_ledger:uncertain':'migration_ledger:incompatible';
|
|
62
|
+
throw new PortabilityError(code,409);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
return {nativeApply:table==='d1_migrations'};
|
|
46
67
|
}
|
|
@@ -12,7 +12,7 @@ import { transferProgress } from '../modules/portability/progress.mjs';
|
|
|
12
12
|
import { nativeFailure, stateBytes } from './portability-progress.mjs';
|
|
13
13
|
import { parseJsonc } from './jsonc.mjs';
|
|
14
14
|
import { loadPolicy } from './portability-policy.mjs';
|
|
15
|
-
import { appliedMigrations, platformMigrationDeclaration,
|
|
15
|
+
import { appliedMigrations, platformMigrationDeclaration, nativeMigrationPreflight } from './portability-migrations.mjs';
|
|
16
16
|
|
|
17
17
|
// Transfers read only the D1 database and R2 buckets. A configuration with just
|
|
18
18
|
// those keeps the app's other bindings out of the proxy: a Durable Object class
|
|
@@ -45,7 +45,7 @@ async function run(direction, { root, path, journal, binding, buckets, policy, p
|
|
|
45
45
|
let proxy;
|
|
46
46
|
try {
|
|
47
47
|
proxy = await getPlatformProxy({ configPath, persist: { path: join(root, '.wrangler/state/v3') }, remoteBindings: false });
|
|
48
|
-
if(direction==='migration-preflight')return await
|
|
48
|
+
if(direction==='migration-preflight')return await nativeMigrationPreflight({root,db:proxy.env[binding],binding,platformMigrations});
|
|
49
49
|
const migrations=async()=>migrationReplay(await appliedMigrations(root,proxy.env[binding],binding,declaration,unstable_splitSqlQuery),policy,declaration);
|
|
50
50
|
const options={ db: proxy.env[binding], buckets: Object.fromEntries(Object.entries(buckets).map(([name, binding]) => [name, proxy.env[binding]])), policy, migrations };
|
|
51
51
|
if(direction==='legacy-preflight') {
|
package/cli/portability.mjs
CHANGED
|
@@ -53,12 +53,12 @@ export function localPortability({ database, binding = 'DB', buckets = {}, polic
|
|
|
53
53
|
// Do not apply pending product migrations to a populated recovery target.
|
|
54
54
|
// Check real existing bindings first; finalize repeats this under the lock.
|
|
55
55
|
if(legacyRecovery)await nativeWorker(store,'legacy-preflight',input,signal);
|
|
56
|
-
const {
|
|
56
|
+
const {nativeApply}=await nativeWorker(store,'migration-preflight',input,signal);
|
|
57
57
|
// Local migrations need no provider account: wrangler runs without credentials.
|
|
58
58
|
// Its info lines (the local location and "Use --remote if you want to access
|
|
59
59
|
// the remote instance") only confuse a local backup; warnings and errors print.
|
|
60
60
|
const { dependencyEnvironment } = await shared('dependency-environment.mjs');
|
|
61
|
-
if(
|
|
61
|
+
if(nativeApply)await store.run('Applying local data migrations', 'pnpm', ['exec', 'wrangler', 'd1', 'migrations', 'apply', database, '--local', '--persist-to', '.wrangler/state', '--config', 'wrangler.jsonc'], {
|
|
62
62
|
cwd: root, signal, env: { ...dependencyEnvironment(), RER_LOCAL_OPERATION: operationToken, WRANGLER_SEND_METRICS: 'false', WRANGLER_LOG: 'warn' },
|
|
63
63
|
});
|
|
64
64
|
const receipt=await nativeWorker(store,direction,input,signal);
|
|
@@ -21,7 +21,7 @@ export async function runtimeFrontDoor({ host, port, activity, door, devKey, ori
|
|
|
21
21
|
// ports to every other socket (the runtime's own listeners, outbound requests),
|
|
22
22
|
// so the runtime's bind could find it taken. Choose a free port the OS never
|
|
23
23
|
// assigns on its own instead.
|
|
24
|
-
async function runtimeLoopbackPort(publicPort) {
|
|
24
|
+
export async function runtimeLoopbackPort(publicPort) {
|
|
25
25
|
const [first, last] = await ephemeralRange();
|
|
26
26
|
const candidates = [[10000, first - 1], [last + 1, 65535]].filter(([low, high]) => low <= high);
|
|
27
27
|
if (!candidates.length) throw Error(`The OS assigns every local port from 10000 (ephemeral range ${first}-${last}); leave part of that space outside the range for the local runtime.`);
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.78
|
|
4
|
+
|
|
5
|
+
- Add signed seed test delivery to the optional mail relay, with public Worker routing, bounded target checks and invocation logs.
|
|
6
|
+
- Restore transient migration tables when replaying installation archives.
|
|
7
|
+
- Expose native migration preflight and refuse replay through relocated ledger identities.
|
|
8
|
+
- Convert reviewed completed D1 import jobs to preserve-conflicts reversal with a durable journal; ordinary previews stay SELECT-only.
|
|
9
|
+
- Package the D1 import kit at `@runeditrun/rer/modules/import-kit/d1` for adopting Workers.
|
|
10
|
+
|
|
11
|
+
## 0.2.77
|
|
12
|
+
|
|
13
|
+
- **Dependency signing keys are sealed at rest with a rotatable installation key (#367, #382).** Each interface's private signing key is stored as an AES-256-GCM envelope under a key derived from the generated `INSTALLATION_KEY` setting, which setup and hosted deploys keep beside `SESSION_SECRET` and archives never carry. Legacy plaintext keys upgrade once. `rer deploy --rotate-secret INSTALLATION_KEY` re-seals every row and retires the previous binding; `rer deploy --reopen-installation-key KID` reopens a D1 restore from before a rotation with retained private custody, reporting the D1 key history first. Missing or wrong keys fail closed with `installation_key_missing` or `installation_key_unavailable`.
|
|
14
|
+
- **The Run page keeps its install command whole at the shell pipe.** At phone widths the command wraps before the URL, or after its last slash, never beside `| sh`; Copy still copies the exact command.
|
|
15
|
+
- **The misbound-port startup check no longer races the app's own sockets.** Its test picks the wrong port the way rer picks its internal one, outside the OS ephemeral range, so the app's Miniflare sockets cannot take it before Vite binds.
|
|
16
|
+
|
|
3
17
|
## 0.2.76
|
|
4
18
|
|
|
5
19
|
- **Patch the maintained TanStack Start security closure (#386).** The default seed and foundation carry the patched Start and server-core dependencies for GHSA-qx66-fv34-fjm8.
|
package/global/README.md
CHANGED
|
@@ -291,6 +291,7 @@ line that still names it. A later refresh is a version bump:
|
|
|
291
291
|
| `@runeditrun/rer/adapter` | `commandAdapter` | `scripts/base-cli/cli/adapter.mjs` |
|
|
292
292
|
| `@runeditrun/rer/deploy` | `ownerDeploy` | `scripts/base-cli/cli/deploy.mjs` |
|
|
293
293
|
| `@runeditrun/rer/portability` | `localPortability` | `scripts/base-cli/cli/portability.mjs` |
|
|
294
|
+
| `@runeditrun/rer/portability-migrations` | `nativeMigrationPreflight`, before an adapter's Wrangler apply (contract in `modules/portability/README.md`) | `scripts/base-cli/cli/portability-migrations.mjs` |
|
|
294
295
|
| `@runeditrun/rer/errors` | the CLI's error helpers | `scripts/base-cli/cli/errors.mjs` |
|
|
295
296
|
| `@runeditrun/rer/jsonc` | JSONC reading | `scripts/base-cli/cli/jsonc.mjs` |
|
|
296
297
|
| `@runeditrun/rer/parse`, `/scheduled` | CLI argument parsing, scheduled-job helpers | `scripts/base-cli/cli/parse.mjs`, `scheduled.mjs` |
|
|
@@ -321,10 +322,41 @@ line that still names it. A later refresh is a version bump:
|
|
|
321
322
|
| `@runeditrun/rer/modules/release/export`, `/publication-scan`, `/source`, `/signature` | release export, publication scan and shared signature verifier | `scripts/base-cli/modules/release/*.mjs` |
|
|
322
323
|
| `@runeditrun/rer/modules/deploy-kit/owner`, `/owner-cli`, `/prepare`, `/provider` | deploy kit | `scripts/base-cli/modules/deploy-kit/*.mjs` |
|
|
323
324
|
| `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev-admission`, `/accounts/native`, `/identity/email-link` | operator auth | `scripts/base-cli/modules/operator-auth/index.mjs`, `dev/index.mjs`, `dev-admission.mjs`, `accounts/native.mjs`, `identity/email-link/index.mjs` |
|
|
325
|
+
| `@runeditrun/rer/modules/import-kit/d1` | asynchronous D1 import, reviewed reversal-policy conversion and preserved-undo preview (TypeScript Worker entry) | `scripts/base-cli/modules/import-kit/src/d1/index.ts` |
|
|
324
326
|
| `@runeditrun/rer/modules/erasure/fence` | erasure fence statements | `scripts/base-cli/modules/erasure/fence.mjs` |
|
|
325
327
|
| `@runeditrun/rer/modules/owner-claim`, `/modules/dependencies` | owner claim, dependency links | `scripts/base-cli/modules/owner-claim/index.mjs`, `dependencies/index.mjs` |
|
|
326
328
|
| `@runeditrun/rer/internal/PATH` | any other package file, for tests | `scripts/base-cli/PATH`, and `scripts/base-onboarding/PATH` with PATH under `onboarding/` |
|
|
327
329
|
|
|
330
|
+
### D1 import kit
|
|
331
|
+
|
|
332
|
+
In a TypeScript Worker with `nodejs_compat`, import the D1 API from the package:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import {
|
|
336
|
+
convertD1ReversalPolicy,
|
|
337
|
+
previewD1PreservedUndo,
|
|
338
|
+
d1ReversalPolicyConversionSchema,
|
|
339
|
+
} from '@runeditrun/rer/modules/import-kit/d1';
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
This is a TypeScript source entry for the Worker's bundler. Node's built-in type
|
|
343
|
+
stripping does not compile TypeScript dependencies inside `node_modules`; a Node
|
|
344
|
+
consumer must compile or bundle the entry with TypeScript support too. The package
|
|
345
|
+
includes its shared D1 transport and D1 runtime dependencies, without the synchronous
|
|
346
|
+
SQLite engine, optional readers or import UI.
|
|
347
|
+
|
|
348
|
+
Apply the additive `d1ReversalPolicyConversionSchema` in a new numbered migration
|
|
349
|
+
before converting an existing strict job; never rewrite an applied migration.
|
|
350
|
+
Preview the completed or undoing job with its current authorized context, review
|
|
351
|
+
the dispositions, then pass that preview's `reviewedFingerprint` to
|
|
352
|
+
`convertD1ReversalPolicy(jobId, context, { to: 'preserve-conflicts',
|
|
353
|
+
reviewedFingerprint })`. Preview is read-only. Conversion requires current undo
|
|
354
|
+
authority and preserves custody; repeated conversion refuses. Native adapters must
|
|
355
|
+
supply the complete dependency observations and guards described in the packaged
|
|
356
|
+
`modules/import-kit/src/d1/README.md`. Use `readD1ImportUndoReport().outcome` for the
|
|
357
|
+
later result (`undone` or `compensated`). This entry first ships in a supplying
|
|
358
|
+
release after rer 0.2.77; adopters still need their own public-door proof.
|
|
359
|
+
|
|
328
360
|
## Verbs
|
|
329
361
|
|
|
330
362
|
In a checkout, every verb runs that checkout's own pinned `rer`; `rer VERB --help`
|