@rehearsal-db/core 0.1.0-beta.10 → 0.1.0-beta.12
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/CHANGELOG.md +64 -1
- package/COMPATIBILITY.md +9 -0
- package/README.md +27 -7
- package/docs/README.md +25 -16
- package/docs/commands.md +11 -4
- package/docs/configuration.md +116 -20
- package/docs/getting-started.md +22 -4
- package/docs/index.md +47 -0
- package/docs/runtime-policies.md +67 -5
- package/docs/sanitization.md +104 -3
- package/docs/standalone-workflow.md +2 -0
- package/docs/troubleshooting.md +39 -3
- package/package.json +12 -3
- package/scripts/install/create_root_config.mjs +36 -0
- package/src/baseline/privacy_engine.mjs +358 -30
- package/src/cli/init_command.mjs +94 -0
- package/src/cli/rehearsal.mjs +6 -51
- package/src/cli/renderers.mjs +31 -2
- package/src/identity/claim.mjs +232 -44
- package/src/identity/provider_configuration.mjs +177 -0
- package/src/project/configuration.d.mts +11 -0
- package/src/project/configuration.mjs +159 -21
- package/src/project/install_scaffold.mjs +291 -0
- package/src/project/setup.mjs +157 -52
- package/src/runtime/plan.mjs +33 -0
- package/src/targets/supabase.mjs +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,67 @@ a Changelog, and versions will follow Semantic Versioning after the package exis
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## [0.1.0-beta.12] - 2026-10-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Supabase projects can declaratively configure local Google or GitHub OAuth in
|
|
13
|
+
`rehearsal.config.mjs`. Rehearsal derives the credential allowlist, injects only the
|
|
14
|
+
ignored owner-only environment values, and generates the exact loopback callback in
|
|
15
|
+
the disposable runtime without tracking secrets. Local signup requires an explicit
|
|
16
|
+
acknowledgment and is enabled only in that generated runtime copy.
|
|
17
|
+
- Branded, responsive documentation is now hosted on GitHub Pages with searchable
|
|
18
|
+
navigation, light and dark themes, and automatic deployment from `main`.
|
|
19
|
+
- The documentation home page and packaged README show the live monthly npm download
|
|
20
|
+
count and link directly to the npm package.
|
|
21
|
+
- Packed-package onboarding acceptance now proves both fresh root-config creation and a
|
|
22
|
+
real beta.11 upgrade that preserves the user's existing configuration byte for byte.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- The packaged README now links prominently to the hosted documentation, npm package,
|
|
27
|
+
and issue tracker. Package homepage metadata also points to the hosted documentation.
|
|
28
|
+
- GitHub Pages publishing uses the current Node.js 24 action generations without legacy
|
|
29
|
+
runtime warnings.
|
|
30
|
+
- `rehearsal init` now calls out important optional settings that are available but not
|
|
31
|
+
enabled before showing the current installed-release template.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Existing Google or GitHub provider sections can transition to declarative ownership
|
|
36
|
+
without editing the tracked Supabase template. Rehearsal replaces only a compatible
|
|
37
|
+
section in the disposable runtime copy, while `doctor` refuses ambiguous or
|
|
38
|
+
safety-weakening provider settings before reset.
|
|
39
|
+
- Multi-target plain-text plans now print each declarative OAuth callback, and `init`
|
|
40
|
+
advertises the declarative replacement even when a project still uses legacy provider
|
|
41
|
+
fields.
|
|
42
|
+
|
|
43
|
+
## [0.1.0-beta.11] - 2026-10-03
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Privacy policy version 2 now supports hashed approved-owner bindings, conditional
|
|
48
|
+
approved/other-owner transformations, bounded JSON arrays, nested recipes, and
|
|
49
|
+
explicitly optional object fields without consumer sanitizer callbacks.
|
|
50
|
+
- Local npm installs now create a validated, commented project-root
|
|
51
|
+
`rehearsal.config.mjs`, dedicated local runtime configuration, and additive safe ignore
|
|
52
|
+
entries when exactly one consumer application can be proven. Guided setup remains the
|
|
53
|
+
tested recovery path when lifecycle scripts are disabled or a workspace is ambiguous.
|
|
54
|
+
- Copied-account association accepts explicit verified-email provider allowlists and
|
|
55
|
+
hashed provider-subject matchers for supported Supabase identities. Google, GitHub,
|
|
56
|
+
and email sign-in now share one review-and-confirm claim workflow.
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- Setup is idempotent, supported custom config paths are preserved, `.gitignore` updates
|
|
61
|
+
use an exclusive lock and atomic replacement, and `rehearsal init` shows the current
|
|
62
|
+
release template without replacing an existing config.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- Identity plan JSON no longer serializes the raw approved email or provider subject;
|
|
67
|
+
only the environment-variable name and reviewed SHA-256 receipt leave the process.
|
|
68
|
+
|
|
8
69
|
## [0.1.0-beta.10] - 2026-10-03
|
|
9
70
|
|
|
10
71
|
### Added
|
|
@@ -288,7 +349,9 @@ a Changelog, and versions will follow Semantic Versioning after the package exis
|
|
|
288
349
|
publication uses short-lived trusted OIDC, and every release tag must already exist on
|
|
289
350
|
protected `main`.
|
|
290
351
|
|
|
291
|
-
[Unreleased]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.
|
|
352
|
+
[Unreleased]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.12...HEAD
|
|
353
|
+
[0.1.0-beta.12]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.11...v0.1.0-beta.12
|
|
354
|
+
[0.1.0-beta.11]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.10...v0.1.0-beta.11
|
|
292
355
|
[0.1.0-beta.10]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.9...v0.1.0-beta.10
|
|
293
356
|
[0.1.0-beta.9]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.8...v0.1.0-beta.9
|
|
294
357
|
[0.1.0-beta.8]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.7...v0.1.0-beta.8
|
package/COMPATIBILITY.md
CHANGED
|
@@ -21,6 +21,15 @@ The first stable `1.0.0` requires external beta evidence, a support policy, and
|
|
|
21
21
|
public API. Supporting additional database families, package managers, or operating
|
|
22
22
|
systems is not implied by the 0.x contract.
|
|
23
23
|
|
|
24
|
+
The npm install hook may create project scaffolding only when it proves one application
|
|
25
|
+
root. Ordinary npm application installs are covered. A workspace is automatic only when
|
|
26
|
+
one declaring consumer is already visible in its manifest or lockfile; npm can save a
|
|
27
|
+
new `--workspace` declaration after dependency hooks run, so a first workspace install
|
|
28
|
+
may use the guided fallback. pnpm and Yarn install layouts are not yet an
|
|
29
|
+
automatic-generation contract. Run `npx rehearsal` from the application directory for
|
|
30
|
+
all skipped cases. Global, cache, temporary `npx`, and ambiguous multi-application
|
|
31
|
+
workspace installs do not receive files.
|
|
32
|
+
|
|
24
33
|
The PostgreSQL target covers timestamped SQL migrations running in a dedicated local
|
|
25
34
|
`postgres` Docker image. Runtime commands reject hosted connection strings and existing
|
|
26
35
|
unmanaged servers. The separately opted-in PostgreSQL preparation boundary may use a
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Rehearsal
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@rehearsal-db/core)
|
|
4
|
+
|
|
5
|
+
[Read the documentation](https://ddupasquier.github.io/rehearsal-db/) · [View on npm](https://www.npmjs.com/package/@rehearsal-db/core) · [Report a problem](https://github.com/Ddupasquier/rehearsal-db/issues)
|
|
6
|
+
|
|
3
7
|
Rehearsal tests PostgreSQL and Supabase migrations on your computer before you run them
|
|
4
8
|
anywhere important. It restores safe test data into a disposable local database, applies
|
|
5
9
|
only the migrations you approve, and runs your project's own test command.
|
|
@@ -37,11 +41,15 @@ npm install --save-dev @rehearsal-db/core@beta
|
|
|
37
41
|
npx rehearsal
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
`rehearsal.config.mjs`
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
overwritten.
|
|
44
|
+
For an ordinary npm application install, Rehearsal safely creates a commented
|
|
45
|
+
`rehearsal.config.mjs` in the project root, adds only its local-artifact entries to
|
|
46
|
+
`.gitignore`, and prepares the isolated local runtime configuration. It detects the
|
|
47
|
+
project name, database target, migration paths, commands, and free ports. Review lines
|
|
48
|
+
marked `CHECK`, then open the guide. Existing files are never overwritten.
|
|
49
|
+
|
|
50
|
+
If install scripts are disabled or the workspace root is ambiguous, installation makes
|
|
51
|
+
no guess. Run `npx rehearsal` inside the application and choose **Set the stage** for the
|
|
52
|
+
same previewed setup.
|
|
45
53
|
|
|
46
54
|
For PostgreSQL, download the reviewed local image once before running the guide:
|
|
47
55
|
|
|
@@ -51,6 +59,11 @@ docker pull postgres:17-alpine
|
|
|
51
59
|
|
|
52
60
|
Rehearsal itself never downloads a database image during a rehearsal.
|
|
53
61
|
|
|
62
|
+
For local Google or GitHub sign-in, the generated config includes a commented
|
|
63
|
+
`supabase.authentication` example. It names an ignored owner-only credential file;
|
|
64
|
+
Rehearsal generates the provider block and local callback inside the disposable runtime.
|
|
65
|
+
See [Supabase authentication](docs/configuration.md#supabase-authentication).
|
|
66
|
+
|
|
54
67
|
## Three terms you will see
|
|
55
68
|
|
|
56
69
|
- **Baseline:** a locked, safe starting copy of your schema and test data.
|
|
@@ -64,7 +77,8 @@ source-owner approval; see [Standalone workflow](docs/standalone-workflow.md).
|
|
|
64
77
|
## The normal workflow
|
|
65
78
|
|
|
66
79
|
1. Run `npx rehearsal`.
|
|
67
|
-
2.
|
|
80
|
+
2. Review the generated local-only configuration, or let the guide create it when the
|
|
81
|
+
install hook safely skipped it.
|
|
68
82
|
3. Review the sanitization policy and create the baseline.
|
|
69
83
|
4. Review the exact candidate migration list.
|
|
70
84
|
5. Run the rehearsal and your application proof.
|
|
@@ -119,7 +133,7 @@ See [COMPATIBILITY.md](COMPATIBILITY.md) for the exact support contract.
|
|
|
119
133
|
|
|
120
134
|
Start here:
|
|
121
135
|
|
|
122
|
-
- [Documentation
|
|
136
|
+
- [Documentation home](docs/index.md) — choose the shortest path for your goal
|
|
123
137
|
- [Getting started](docs/getting-started.md) — set up your own project
|
|
124
138
|
- [Safe hands-on tutorial](docs/tutorial.md) — try the full flow in a disposable project
|
|
125
139
|
- [Troubleshooting](docs/troubleshooting.md) — fix common setup problems
|
|
@@ -166,3 +180,9 @@ npm run test:fixture
|
|
|
166
180
|
|
|
167
181
|
The fixture commands install the packed package into clean synthetic projects. They do
|
|
168
182
|
not connect to hosted services. See [CONTRIBUTING.md](CONTRIBUTING.md) for the full rules.
|
|
183
|
+
|
|
184
|
+
Preview the styled documentation site locally with:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm run docs:preview
|
|
188
|
+
```
|
package/docs/README.md
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Rehearsal documentation
|
|
2
|
+
|
|
3
|
+
Welcome. You do not need to read this documentation from top to bottom. Choose what you
|
|
4
|
+
want to accomplish and follow that path.
|
|
2
5
|
|
|
3
6
|
## Start here
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
| Your goal | Best next page |
|
|
9
|
+
| ----------------------------------- | ------------------------------------- |
|
|
10
|
+
| Add Rehearsal to a project | [Getting started](getting-started.md) |
|
|
11
|
+
| Try it in a disposable project | [Hands-on tutorial](tutorial.md) |
|
|
12
|
+
| Fix a setup or runtime problem | [Troubleshooting](troubleshooting.md) |
|
|
13
|
+
| Browse the friendlier web-docs home | [Documentation home](index.md) |
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## Work safely
|
|
10
16
|
|
|
11
|
-
- [Baselines](baselines.md)
|
|
12
|
-
- [Sanitization](sanitization.md)
|
|
13
|
-
- [Production
|
|
14
|
-
- [Security model](security-model.md)
|
|
17
|
+
- [Baselines](baselines.md) — the verified starting copy
|
|
18
|
+
- [Sanitization](sanitization.md) — what may enter that copy
|
|
19
|
+
- [Production-shaped preparation](production-source.md) — the optional source boundary
|
|
20
|
+
- [Security model](security-model.md) — the independent safety barriers
|
|
21
|
+
- [Standalone workflow](standalone-workflow.md) — the complete declarative contract
|
|
15
22
|
|
|
16
|
-
##
|
|
23
|
+
## Look something up
|
|
17
24
|
|
|
25
|
+
- [CLI commands](commands.md)
|
|
18
26
|
- [Configuration](configuration.md)
|
|
19
|
-
- [
|
|
20
|
-
- [Runtime policies](runtime-policies.md)
|
|
27
|
+
- [Runtime and identity policies](runtime-policies.md)
|
|
21
28
|
- [Database adapters](adapters.md)
|
|
22
|
-
- [
|
|
29
|
+
- [Glossary](glossary.md)
|
|
23
30
|
|
|
24
|
-
##
|
|
31
|
+
## Follow the project
|
|
25
32
|
|
|
33
|
+
- [Roadmap](roadmap.md)
|
|
26
34
|
- [Repository architecture](architecture.md)
|
|
27
35
|
- [Release process](releasing.md)
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
|
|
37
|
+
To preview the styled documentation locally, run `npm run docs:preview`, then open the
|
|
38
|
+
address it prints.
|
package/docs/commands.md
CHANGED
|
@@ -23,7 +23,7 @@ bare `npx rehearsal` prints help instead of waiting for input.
|
|
|
23
23
|
| `npx rehearsal setup --target=supabase` | Preview Supabase setup files. |
|
|
24
24
|
| `npx rehearsal setup --target=postgresql` | Preview PostgreSQL setup files. |
|
|
25
25
|
| Add `--write` to either setup command | Create the previewed files without overwriting. |
|
|
26
|
-
| `npx rehearsal init` | Preview
|
|
26
|
+
| `npx rehearsal init` | Preview the current config template without writing. |
|
|
27
27
|
| `npx rehearsal init --write` | Create only `rehearsal.config.mjs`. |
|
|
28
28
|
| `npx rehearsal baseline prepare --records=<path> --ledger=<path>` | Preview a sanitization-policy draft. |
|
|
29
29
|
| Add `--write` to `baseline prepare` | Write the draft for human review. |
|
|
@@ -32,6 +32,12 @@ bare `npx rehearsal` prints help instead of waiting for input.
|
|
|
32
32
|
Add `--assets=<manifest.json>` to `baseline create` only for approved local Supabase
|
|
33
33
|
Storage files. `baseline create` and `baseline prepare` are local-only.
|
|
34
34
|
|
|
35
|
+
`setup --write` is idempotent: supported existing config files and completed runtime
|
|
36
|
+
files remain unchanged, while missing safe ignore entries may be appended. On upgrades,
|
|
37
|
+
`init` first lists important optional settings that are available but not enabled, then
|
|
38
|
+
prints the installed release's template for comparison. `init --write` never replaces an
|
|
39
|
+
existing config.
|
|
40
|
+
|
|
35
41
|
## Optional source preparation
|
|
36
42
|
|
|
37
43
|
These commands are separate from ordinary rehearsals. Configure `preparation` only after
|
|
@@ -67,7 +73,7 @@ In short: `refresh` gets a new source copy; `reset` restores the copy you alread
|
|
|
67
73
|
|
|
68
74
|
## Local identity association
|
|
69
75
|
|
|
70
|
-
For a reviewed Google identity, use this sequence:
|
|
76
|
+
For a reviewed Google, GitHub, or email identity, use this sequence:
|
|
71
77
|
|
|
72
78
|
1. Run a successful rehearsal, then start the persistent app:
|
|
73
79
|
|
|
@@ -75,9 +81,10 @@ For a reviewed Google identity, use this sequence:
|
|
|
75
81
|
npx rehearsal open
|
|
76
82
|
```
|
|
77
83
|
|
|
78
|
-
2. Open the printed local URL and complete the normal
|
|
84
|
+
2. Open the printed local URL and complete the normal provider sign-in. Press `Ctrl+C`
|
|
79
85
|
after the callback returns. This closes only the app; the databases and Storage stay
|
|
80
|
-
running with their current data.
|
|
86
|
+
running with their current data. Provider setup and credentials belong to the local
|
|
87
|
+
Supabase runtime, not the identity policy.
|
|
81
88
|
|
|
82
89
|
3. Preview and confirm the reviewed association:
|
|
83
90
|
|
package/docs/configuration.md
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An ordinary npm application install creates this file in the application root when the
|
|
4
|
+
root can be identified safely:
|
|
4
5
|
|
|
5
6
|
```bash
|
|
6
|
-
|
|
7
|
+
npm install --save-dev @rehearsal-db/core@beta
|
|
7
8
|
```
|
|
8
9
|
|
|
9
|
-
The
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
The install hook detects the database type, project name, migration folder,
|
|
11
|
+
package-manager commands, and free local ports. It also creates the dedicated local
|
|
12
|
+
runtime config and appends the two Rehearsal local-artifact entries to `.gitignore`.
|
|
13
|
+
Existing configs and existing ignore content are never rewritten.
|
|
14
|
+
|
|
15
|
+
When lifecycle scripts are disabled or the application root is not provable, run
|
|
16
|
+
`npx rehearsal` inside the application. The guide provides the same setup with a preview
|
|
17
|
+
and confirmation. Automatic root generation is tested with npm. pnpm and Yarn users
|
|
18
|
+
should use this guided fallback because their lifecycle and workspace layouts vary.
|
|
13
19
|
|
|
14
20
|
Review lines marked `CHECK`, especially the application proof command. Optional settings
|
|
15
21
|
are present as commented examples, and secrets never belong in this file. Rehearsal will
|
|
@@ -36,9 +42,21 @@ export default defineRehearsalConfig({
|
|
|
36
42
|
rehearsalConfig: "infrastructure/rehearsal/supabase/config.toml",
|
|
37
43
|
runtimeWorkdir: ".rehearsal/runtime",
|
|
38
44
|
|
|
39
|
-
// Optional
|
|
40
|
-
//
|
|
41
|
-
//
|
|
45
|
+
// Optional local OAuth connection. Secrets stay in the ignored owner-only file.
|
|
46
|
+
// Register http://127.0.0.1:58321/auth/v1/callback with the provider.
|
|
47
|
+
// authentication: {
|
|
48
|
+
// enableLocalSignup: true,
|
|
49
|
+
// environmentFile: ".env.rehearsal-service.local",
|
|
50
|
+
// providers: [
|
|
51
|
+
// {
|
|
52
|
+
// name: "google",
|
|
53
|
+
// clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
|
|
54
|
+
// clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
|
|
55
|
+
// skipNonceCheck: false,
|
|
56
|
+
// emailOptional: false,
|
|
57
|
+
// },
|
|
58
|
+
// ],
|
|
59
|
+
// },
|
|
42
60
|
},
|
|
43
61
|
baseline: {
|
|
44
62
|
artifactDirectory: ".rehearsal",
|
|
@@ -54,7 +72,8 @@ export default defineRehearsalConfig({
|
|
|
54
72
|
// diskHeadroomBytes: 67108864,
|
|
55
73
|
// },
|
|
56
74
|
// runtimePolicy: "infrastructure/rehearsal/runtime-policy.json",
|
|
57
|
-
// Optional
|
|
75
|
+
// Optional copied-account association. The JSON stores reviewed matcher hashes only;
|
|
76
|
+
// raw emails/subjects and provider credentials stay in ignored environment files.
|
|
58
77
|
// identityPolicy: "infrastructure/rehearsal/identity-policy.json",
|
|
59
78
|
containerRuntime: {
|
|
60
79
|
autoStartColima: true,
|
|
@@ -114,6 +133,27 @@ All paths resolve inside the consuming project. The artifact directory must be n
|
|
|
114
133
|
Rehearsal never overwrites this config. To start over, move the existing file somewhere
|
|
115
134
|
safe, run setup again, and compare the two files before deleting either one.
|
|
116
135
|
|
|
136
|
+
After upgrading, run `npx rehearsal init` to print the current release's generated
|
|
137
|
+
template beside the path of your existing config. This comparison is read-only; adding a
|
|
138
|
+
new optional key remains your decision. `npx rehearsal init --write` still refuses to
|
|
139
|
+
replace an existing config. Rehearsal lists important optional settings that are
|
|
140
|
+
available but not enabled before printing the template, so they are easier to find.
|
|
141
|
+
|
|
142
|
+
### Workspaces and custom paths
|
|
143
|
+
|
|
144
|
+
For an npm workspace, automatic creation proceeds only when exactly one application
|
|
145
|
+
package already declares `@rehearsal-db/core` in the manifest or lockfile visible to the
|
|
146
|
+
install hook. npm can save a new `--workspace` dependency after that hook runs, so a
|
|
147
|
+
first workspace install may safely skip creation. If several applications declare it,
|
|
148
|
+
Rehearsal also refuses to choose. Run `npx rehearsal` inside each intended application.
|
|
149
|
+
Global installs, package caches, temporary `npx` installs, and Rehearsal's own source
|
|
150
|
+
checkout never receive project files.
|
|
151
|
+
|
|
152
|
+
Supported existing config paths—including
|
|
153
|
+
`infrastructure/rehearsal/rehearsal.config.mjs`—are preserved, and a second root config
|
|
154
|
+
is not created. Use `--config=<project-relative-path>` for other explicit paths when
|
|
155
|
+
running commands.
|
|
156
|
+
|
|
117
157
|
`preparation.privacyKey` must stay inside `.rehearsal`; it is ignored and owner-readable
|
|
118
158
|
only. Source, runtime, and identity policy files are declarations that may be reviewed in
|
|
119
159
|
source control. They must never contain passwords, tokens, production URLs, raw owner
|
|
@@ -135,8 +175,11 @@ approval sequence.
|
|
|
135
175
|
|
|
136
176
|
`runtimePolicy` replaces common restore adapters with reviewed schemas, allowlisted
|
|
137
177
|
extensions, managed triggers, local-only singleton rows, and structural expectations.
|
|
138
|
-
`identityPolicy` declares a hashed verified
|
|
139
|
-
defaults, required role/reference transfers, Storage path
|
|
178
|
+
`identityPolicy` declares a hashed verified-email or provider-subject matcher, copied
|
|
179
|
+
placeholder, safe signup defaults, required role/reference transfers, Storage path
|
|
180
|
+
rewrites, and token checks. Provider credentials stay in the local Supabase runtime
|
|
181
|
+
environment; association values stay in named environment variables and only their
|
|
182
|
+
SHA-256 receipts are tracked. See
|
|
140
183
|
[Runtime and identity policies](runtime-policies.md).
|
|
141
184
|
|
|
142
185
|
## Container runtime and cleanup
|
|
@@ -217,19 +260,72 @@ negative controls, such as unauthorized, malformed, withheld, or missing records
|
|
|
217
260
|
response that merely avoids a server error does not prove that eligible data was
|
|
218
261
|
published or can be found.
|
|
219
262
|
|
|
220
|
-
## Supabase
|
|
263
|
+
## Supabase authentication
|
|
221
264
|
|
|
222
|
-
|
|
223
|
-
|
|
265
|
+
Rehearsal can configure a Google or GitHub OAuth connection in its disposable local
|
|
266
|
+
Supabase runtime. Declare the provider and the names of its credential variables:
|
|
224
267
|
|
|
225
268
|
```ts
|
|
226
|
-
|
|
227
|
-
|
|
269
|
+
authentication: {
|
|
270
|
+
enableLocalSignup: true,
|
|
271
|
+
environmentFile: ".env.rehearsal-service.local",
|
|
272
|
+
providers: [
|
|
273
|
+
{
|
|
274
|
+
name: "google",
|
|
275
|
+
clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
|
|
276
|
+
clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
|
|
277
|
+
skipNonceCheck: false,
|
|
278
|
+
emailOptional: false,
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Create the ignored file, add the values, then restrict it to your account:
|
|
285
|
+
|
|
286
|
+
```dotenv
|
|
287
|
+
REHEARSAL_GOOGLE_CLIENT_ID=your-local-oauth-client-id
|
|
288
|
+
REHEARSAL_GOOGLE_CLIENT_SECRET=your-local-oauth-client-secret
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
chmod 600 .env.rehearsal-service.local
|
|
228
293
|
```
|
|
229
294
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
295
|
+
Register `http://127.0.0.1:<apiPort>/auth/v1/callback` with the provider, using the
|
|
296
|
+
`runtime.apiPort` value from this config. `rehearsal explain` also prints the exact URL.
|
|
297
|
+
Rehearsal writes that callback and `env(...)` references into the disposable runtime; it
|
|
298
|
+
never copies credential values into tracked configuration. Use `name: "github"` and
|
|
299
|
+
distinct GitHub variable names for GitHub. Duplicate providers, reused variable names,
|
|
300
|
+
unsupported providers, extra keys, and a template that already owns the same provider
|
|
301
|
+
are refused. This follows Supabase's documented
|
|
302
|
+
[`env()` configuration pattern](https://supabase.com/docs/guides/local-development/managing-config).
|
|
303
|
+
|
|
304
|
+
`enableLocalSignup: true` explicitly acknowledges that disposable local Auth may create
|
|
305
|
+
the temporary user returned by OAuth. Rehearsal changes the generated runtime copy only;
|
|
306
|
+
the tracked Supabase template and every hosted project remain unchanged.
|
|
307
|
+
|
|
308
|
+
The older `serviceEnvironmentFile`, `serviceEnvironmentVariables`, and
|
|
309
|
+
`safety.authenticationProviders` fields remain compatible for projects that manually
|
|
310
|
+
own their Supabase provider TOML. Do not combine those fields with the declarative
|
|
311
|
+
`authentication` block.
|
|
312
|
+
|
|
313
|
+
To migrate a manual Google or GitHub setup, replace those three legacy config fields
|
|
314
|
+
with the `authentication` block together. The tracked Supabase template may keep its
|
|
315
|
+
existing provider section: Rehearsal replaces a compatible legacy section only in the
|
|
316
|
+
generated disposable runtime copy. The section may contain `enabled`, `client_id`,
|
|
317
|
+
`secret`, `redirect_uri`, `skip_nonce_check`, and `email_optional`. The latter two must
|
|
318
|
+
match the explicit `skipNonceCheck` and `emailOptional` declarations, which default to
|
|
319
|
+
`false`. Keep them false unless the provider integration has a reviewed need; Supabase
|
|
320
|
+
warns in its [CLI configuration reference](https://supabase.com/docs/guides/local-development/cli/config#auth.external.provider.skip_nonce_check)
|
|
321
|
+
that skipping nonce validation reduces replay protection. Unknown settings,
|
|
322
|
+
duplicate sections, nested provider tables, or mismatched options fail
|
|
323
|
+
`rehearsal doctor` before reset. Rehearsal never edits the tracked template during this
|
|
324
|
+
transition.
|
|
325
|
+
|
|
326
|
+
Provider connection and copied-account association are separate. This block lets the
|
|
327
|
+
ordinary application sign-in reach local Auth. An optional `identityPolicy` decides
|
|
328
|
+
whether that verified local identity may claim a reviewed copied account.
|
|
233
329
|
|
|
234
330
|
## Safety fields
|
|
235
331
|
|
package/docs/getting-started.md
CHANGED
|
@@ -38,18 +38,30 @@ npm install --save-dev @rehearsal-db/core@beta
|
|
|
38
38
|
npx rehearsal
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
With npm, a normal application install creates `rehearsal.config.mjs`, the dedicated
|
|
42
|
+
local runtime config, and the required `.gitignore` entries when Rehearsal can prove the
|
|
43
|
+
application root. It never replaces an existing file. Review the generated config,
|
|
44
|
+
especially:
|
|
45
45
|
|
|
46
46
|
- the migration directory;
|
|
47
47
|
- the application start and proof commands;
|
|
48
48
|
- the local ports.
|
|
49
49
|
|
|
50
|
+
If lifecycle scripts were disabled, a global/cache install was used, or a workspace has
|
|
51
|
+
more than one possible application, no project files are created automatically. Run
|
|
52
|
+
`npx rehearsal` inside the intended application, choose **Set the stage**, select
|
|
53
|
+
Supabase or PostgreSQL, and approve the same safe setup preview.
|
|
54
|
+
|
|
50
55
|
The proof command should check behavior changed by the migration. A test that only checks
|
|
51
56
|
whether the home page loads is usually too weak.
|
|
52
57
|
|
|
58
|
+
If the sandbox needs Google or GitHub sign-in, uncomment
|
|
59
|
+
`supabase.authentication` in `rehearsal.config.mjs`. Add the named credentials to
|
|
60
|
+
`.env.rehearsal-service.local`, run `chmod 600 .env.rehearsal-service.local`, and
|
|
61
|
+
register the local callback printed in the config. See
|
|
62
|
+
[Supabase authentication](configuration.md#supabase-authentication). Rehearsal keeps the
|
|
63
|
+
values out of tracked files and generates the disposable provider configuration for you.
|
|
64
|
+
|
|
53
65
|
## 3. Prepare safe baseline inputs
|
|
54
66
|
|
|
55
67
|
A **baseline** is the locked starting point restored before each rehearsal. Start with a
|
|
@@ -161,6 +173,12 @@ npx rehearsal run --confirm-candidates=PASTE_DIGEST_HERE
|
|
|
161
173
|
Replace `postgresql` with `supabase` when needed. See [CLI commands](commands.md) for the
|
|
162
174
|
complete reference and [Troubleshooting](troubleshooting.md) when a check fails.
|
|
163
175
|
|
|
176
|
+
Running setup again is safe: existing configuration and runtime files are reported as
|
|
177
|
+
unchanged. Rehearsal only adds missing ignore entries. It never refreshes an existing
|
|
178
|
+
config during an upgrade. After upgrading, run `npx rehearsal init` to see important
|
|
179
|
+
optional settings you have not enabled and compare your file with the installed
|
|
180
|
+
release's current template.
|
|
181
|
+
|
|
164
182
|
## Files Rehearsal creates
|
|
165
183
|
|
|
166
184
|
- `rehearsal.config.mjs` — reviewed project configuration
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Rehearsal documentation
|
|
2
|
+
|
|
3
|
+
## Pick the path that fits today
|
|
4
|
+
|
|
5
|
+
You do not need to read everything before your first rehearsal. Start with the outcome
|
|
6
|
+
you want, then follow the links when a term or safety check is new.
|
|
7
|
+
|
|
8
|
+
| I want to… | Go here |
|
|
9
|
+
| ------------------------------------- | ----------------------------------------------------------------- |
|
|
10
|
+
| Set up my own project | [Getting started](getting-started.md) |
|
|
11
|
+
| Try Rehearsal without touching my app | [Hands-on tutorial](tutorial.md) |
|
|
12
|
+
| Understand what makes a copy safe | [Baselines](baselines.md) and [Sanitization](sanitization.md) |
|
|
13
|
+
| Look up a command or setting | [CLI commands](commands.md) and [Configuration](configuration.md) |
|
|
14
|
+
| Fix something that did not work | [Troubleshooting](troubleshooting.md) |
|
|
15
|
+
|
|
16
|
+
## The short version
|
|
17
|
+
|
|
18
|
+
Rehearsal restores an approved local baseline, applies only the migration files you
|
|
19
|
+
reviewed, and runs the application checks your project owns. The normal workflow stays
|
|
20
|
+
on your computer and does not deploy anything.
|
|
21
|
+
|
|
22
|
+
1. **Prepare** a safe baseline.
|
|
23
|
+
2. **Review** the exact candidate migrations.
|
|
24
|
+
3. **Run** them in a disposable local database.
|
|
25
|
+
4. **Prove** the application behavior that matters.
|
|
26
|
+
5. **Open** the sandbox for hands-on testing.
|
|
27
|
+
|
|
28
|
+
## Safety is part of the workflow
|
|
29
|
+
|
|
30
|
+
Rehearsal does not ask you to trust one giant switch. Baseline checksums, local-only
|
|
31
|
+
networking, exact confirmation digests, project-owned proofs, and narrowly owned cleanup
|
|
32
|
+
each protect a different boundary.
|
|
33
|
+
|
|
34
|
+
Start with synthetic data when you can. If a project needs a production-shaped copy,
|
|
35
|
+
read [Production-shaped preparation](production-source.md) before providing any source
|
|
36
|
+
access.
|
|
37
|
+
|
|
38
|
+
## Still unsure where to begin?
|
|
39
|
+
|
|
40
|
+
Run the interactive guide from the project you want to test:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx rehearsal
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
It reads the project state, explains the next safe step, and keeps the full command
|
|
47
|
+
reference available when you need it.
|
package/docs/runtime-policies.md
CHANGED
|
@@ -77,9 +77,12 @@ graph without an application callback patch:
|
|
|
77
77
|
"identities": [
|
|
78
78
|
{
|
|
79
79
|
"name": "approved-owner",
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
"matcher": {
|
|
81
|
+
"type": "verified-email",
|
|
82
|
+
"providers": ["google"],
|
|
83
|
+
"emailEnvironmentVariable": "REHEARSAL_APPROVED_OWNER_EMAIL",
|
|
84
|
+
"approvedEmailSha256": "<sha256 of the lowercase approved email>"
|
|
85
|
+
},
|
|
83
86
|
"placeholderUserId": "11111111-1111-4111-8111-111111111111",
|
|
84
87
|
"references": [
|
|
85
88
|
{
|
|
@@ -152,9 +155,20 @@ graph without an application callback patch:
|
|
|
152
155
|
}
|
|
153
156
|
```
|
|
154
157
|
|
|
158
|
+
Authentication has three separate parts:
|
|
159
|
+
|
|
160
|
+
1. `config.supabase.authentication` can enable a Google or GitHub connection in local
|
|
161
|
+
Supabase and reads its credentials from the ignored owner-only environment file.
|
|
162
|
+
Existing projects may still own that local provider TOML manually. Email sign-in does
|
|
163
|
+
not use an OAuth credential declaration.
|
|
164
|
+
2. The application completes the ordinary sign-in and receives a normal Supabase
|
|
165
|
+
session. Rehearsal does not intercept the callback.
|
|
166
|
+
3. The identity policy matches that verified local identity and transfers only the
|
|
167
|
+
reviewed copied-account graph.
|
|
168
|
+
|
|
155
169
|
The email stays in an environment variable; only its reviewed hash is committed. Run
|
|
156
|
-
`rehearsal open`, complete the ordinary local
|
|
157
|
-
|
|
170
|
+
`rehearsal open`, complete the ordinary local sign-in, and stop the app with `Ctrl+C`.
|
|
171
|
+
Then preview and confirm the association:
|
|
158
172
|
|
|
159
173
|
```bash
|
|
160
174
|
npx rehearsal identity plan --identity=approved-owner
|
|
@@ -166,6 +180,50 @@ Rehearsal requires exactly one verified matching local provider identity. Every
|
|
|
166
180
|
`required` reference must exist after transfer. Declare application role tables as
|
|
167
181
|
references; `claims` alone is not a replacement for a database-backed token hook.
|
|
168
182
|
|
|
183
|
+
### Supported identity matchers
|
|
184
|
+
|
|
185
|
+
Rehearsal currently supports the Supabase provider values `email`, `google`, and
|
|
186
|
+
`github`. Other provider names fail closed until their Auth representation has package
|
|
187
|
+
coverage. Two matcher types are supported:
|
|
188
|
+
|
|
189
|
+
- `verified-email` accepts one or more supported providers. It lowercases the email from
|
|
190
|
+
the named environment variable and compares its SHA-256 receipt before querying Auth.
|
|
191
|
+
- `provider-subject` accepts one OAuth provider (`google` or `github`). It compares the
|
|
192
|
+
reviewed SHA-256 to Supabase's stable provider ID/subject without placing the raw
|
|
193
|
+
subject in the policy, baseline, command output, SQL parameters, or receipt.
|
|
194
|
+
|
|
195
|
+
Google by verified email:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
"matcher": {
|
|
199
|
+
"type": "verified-email",
|
|
200
|
+
"providers": ["google"],
|
|
201
|
+
"emailEnvironmentVariable": "REHEARSAL_APPROVED_OWNER_EMAIL",
|
|
202
|
+
"approvedEmailSha256": "<sha256 of the lowercase email>"
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Supabase email/password or magic-link sign-in uses the same matcher with
|
|
207
|
+
`"providers": ["email"]`. An account intentionally allowed to use either ordinary
|
|
208
|
+
email or Google can declare `"providers": ["email", "google"]`; the claim still refuses
|
|
209
|
+
zero or multiple matching identities.
|
|
210
|
+
|
|
211
|
+
GitHub by stable provider subject:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
"matcher": {
|
|
215
|
+
"type": "provider-subject",
|
|
216
|
+
"provider": "github",
|
|
217
|
+
"subjectEnvironmentVariable": "REHEARSAL_APPROVED_OWNER_SUBJECT",
|
|
218
|
+
"approvedSubjectSha256": "<sha256 of the exact GitHub subject>"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Set the raw value only in the local shell or an ignored environment file. Existing
|
|
223
|
+
policies using the older top-level `provider`, `emailEnvironmentVariable`, and
|
|
224
|
+
`approvedEmailSha256` fields remain accepted as a single-provider verified-email
|
|
225
|
+
matcher. New policies should use the explicit `matcher` object.
|
|
226
|
+
|
|
169
227
|
References use `"strategy": "transfer"` by default. Use `"preserve-audit"` only for
|
|
170
228
|
immutable historical authorship, such as a completed review. Rehearsal leaves that row
|
|
171
229
|
and its synthetic Auth actor unchanged, but still transfers the active profile, roles,
|
|
@@ -185,6 +243,10 @@ configured `tokenHook` must return the declared claim subset before commit. The
|
|
|
185
243
|
refresh its session or sign in again because Rehearsal cannot rewrite an issued JWT.
|
|
186
244
|
Run `rehearsal open` again for that fresh-session check; runtime data is preserved.
|
|
187
245
|
|
|
246
|
+
After a claim, sign out and sign in again (or otherwise force a full token refresh) before
|
|
247
|
+
judging application roles. This preserves normal RLS, account blocks, role checks, and
|
|
248
|
+
MFA; identity association is not an authentication bypass.
|
|
249
|
+
|
|
188
250
|
The transaction does not import production passwords, sessions, refresh tokens,
|
|
189
251
|
cookies, MFA secrets, or provider credentials. Local MFA and authorization rules remain
|
|
190
252
|
real.
|