@fuzdev/fuz_app 0.184.0 → 0.186.0

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.
Files changed (174) hide show
  1. package/dist/actions/CLAUDE.md +18 -3
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/register_action_ws.d.ts +14 -7
  5. package/dist/actions/register_action_ws.d.ts.map +1 -1
  6. package/dist/actions/ws_socket_session.d.ts +17 -4
  7. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  8. package/dist/actions/ws_socket_session.js +41 -7
  9. package/dist/auth/CLAUDE.md +18 -9
  10. package/dist/auth/account_queries.d.ts +53 -40
  11. package/dist/auth/account_queries.d.ts.map +1 -1
  12. package/dist/auth/account_queries.js +57 -50
  13. package/dist/auth/account_routes.d.ts.map +1 -1
  14. package/dist/auth/account_routes.js +59 -25
  15. package/dist/auth/admin_actions.d.ts.map +1 -1
  16. package/dist/auth/admin_actions.js +26 -9
  17. package/dist/auth/audit_emitter.js +2 -2
  18. package/dist/auth/audit_log_queries.d.ts +11 -3
  19. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  20. package/dist/auth/audit_log_queries.js +4 -4
  21. package/dist/auth/audit_log_routes.d.ts +1 -1
  22. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  23. package/dist/auth/audit_log_routes.js +3 -2
  24. package/dist/auth/audit_log_schema.js +1 -1
  25. package/dist/auth/auth_ddl.d.ts.map +1 -1
  26. package/dist/auth/auth_ddl.js +4 -0
  27. package/dist/auth/cleanup.d.ts +34 -3
  28. package/dist/auth/cleanup.d.ts.map +1 -1
  29. package/dist/auth/cleanup.js +12 -4
  30. package/dist/auth/migrations.d.ts.map +1 -1
  31. package/dist/auth/migrations.js +35 -0
  32. package/dist/auth/role_grant_offer_queries.d.ts +13 -13
  33. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  34. package/dist/auth/role_grant_offer_queries.js +12 -13
  35. package/dist/auth/role_grant_queries.d.ts +16 -9
  36. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  37. package/dist/auth/role_grant_queries.js +16 -9
  38. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  39. package/dist/auth/self_service_role_actions.js +15 -0
  40. package/dist/auth/session_queries.d.ts +24 -0
  41. package/dist/auth/session_queries.d.ts.map +1 -1
  42. package/dist/auth/session_queries.js +28 -0
  43. package/dist/db/CLAUDE.md +3 -3
  44. package/dist/db/cell_ddl.d.ts +8 -3
  45. package/dist/db/cell_ddl.d.ts.map +1 -1
  46. package/dist/db/cell_ddl.js +10 -5
  47. package/dist/http/CLAUDE.md +1 -1
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/http/pending_effects.d.ts +8 -4
  51. package/dist/http/pending_effects.d.ts.map +1 -1
  52. package/dist/http/route_spec.d.ts +3 -3
  53. package/dist/http/route_spec.d.ts.map +1 -1
  54. package/dist/realtime/audit_log_sse.d.ts +1 -1
  55. package/dist/realtime/sse.d.ts +2 -2
  56. package/dist/realtime/sse.d.ts.map +1 -1
  57. package/dist/realtime/sse_constants.d.ts +1 -1
  58. package/dist/realtime/sse_constants.js +1 -1
  59. package/dist/server/app_server.d.ts +59 -71
  60. package/dist/server/app_server.d.ts.map +1 -1
  61. package/dist/server/app_server.js +52 -60
  62. package/dist/server/shutdown_drain.d.ts +69 -0
  63. package/dist/server/shutdown_drain.d.ts.map +1 -0
  64. package/dist/server/shutdown_drain.js +77 -0
  65. package/dist/testing/CLAUDE.md +197 -66
  66. package/dist/testing/admin_integration.d.ts +2 -2
  67. package/dist/testing/admin_integration.d.ts.map +1 -1
  68. package/dist/testing/admin_integration.js +36 -20
  69. package/dist/testing/app_server.d.ts +5 -7
  70. package/dist/testing/app_server.d.ts.map +1 -1
  71. package/dist/testing/app_server.js +5 -7
  72. package/dist/testing/auth_apps.d.ts +3 -1
  73. package/dist/testing/auth_apps.d.ts.map +1 -1
  74. package/dist/testing/auth_apps.js +22 -5
  75. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  76. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  78. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/backend_log.js +134 -0
  80. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  81. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  82. package/dist/testing/cross_backend/backend_swap.js +431 -0
  83. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  84. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  85. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  86. package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
  87. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  88. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/conformance_case.js +4 -0
  90. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  91. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  93. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  94. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  96. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  97. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +53 -31
  102. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  103. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  105. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  107. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  108. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  110. package/dist/testing/cross_backend/setup.d.ts +44 -43
  111. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  112. package/dist/testing/cross_backend/setup.js +64 -62
  113. package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
  114. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  115. package/dist/testing/cross_backend/spawn_backend.js +138 -11
  116. package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
  117. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  118. package/dist/testing/cross_backend/spine_suites.js +37 -15
  119. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  121. package/dist/testing/cross_backend/standard.d.ts +18 -82
  122. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  123. package/dist/testing/cross_backend/standard.js +6 -21
  124. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  125. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  126. package/dist/testing/cross_backend/standard_auth.js +28 -0
  127. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  128. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  129. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  130. package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
  131. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  132. package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
  133. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/testing_server_bun.js +7 -30
  135. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  136. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  137. package/dist/testing/cross_backend/testing_server_core.js +20 -4
  138. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  139. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  143. package/dist/testing/data_exposure.d.ts +4 -1
  144. package/dist/testing/data_exposure.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.js +93 -25
  146. package/dist/testing/db_invariants.d.ts +5 -5
  147. package/dist/testing/db_invariants.js +5 -5
  148. package/dist/testing/error_coverage.d.ts +5 -0
  149. package/dist/testing/error_coverage.d.ts.map +1 -1
  150. package/dist/testing/error_coverage.js +2 -1
  151. package/dist/testing/integration.d.ts +4 -20
  152. package/dist/testing/integration.d.ts.map +1 -1
  153. package/dist/testing/integration.js +49 -79
  154. package/dist/testing/integration_helpers.d.ts +16 -0
  155. package/dist/testing/integration_helpers.d.ts.map +1 -1
  156. package/dist/testing/integration_helpers.js +29 -1
  157. package/dist/testing/logged_errors.d.ts +61 -0
  158. package/dist/testing/logged_errors.d.ts.map +1 -0
  159. package/dist/testing/logged_errors.js +285 -0
  160. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  161. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  162. package/dist/testing/middleware_gate_probes.js +76 -3
  163. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  164. package/dist/testing/rpc_attack_surface.js +41 -16
  165. package/dist/testing/stubs.d.ts +5 -1
  166. package/dist/testing/stubs.d.ts.map +1 -1
  167. package/dist/testing/stubs.js +6 -3
  168. package/dist/testing/test_app.d.ts +39 -9
  169. package/dist/testing/test_app.d.ts.map +1 -1
  170. package/dist/testing/test_app.js +70 -12
  171. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  172. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  173. package/dist/testing/transports/fetch_transport.js +13 -0
  174. package/package.json +4 -3
@@ -0,0 +1,431 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * The backend swap: two spines, one database, one at a time. The first
4
+ * mints credentials and writes rows through its real routes, stops, and the
5
+ * second boots over the database as the first left it and honors every one;
6
+ * then the first boots again and honors what the second wrote. It is what
7
+ * makes the TS and Rust spines twins in deployment, not only on the wire: a
8
+ * consumer swaps one for the other without re-bootstrapping, and every
9
+ * session, token, password, invite and offer carries over.
10
+ *
11
+ * Nothing is seeded behind the spines' backs — no `_testing_reset`, no
12
+ * minted session. Per order, mint on the first, use on the second, check on
13
+ * the first again:
14
+ *
15
+ * - **First** — the keeper bootstrap, a second keeper session and a keeper
16
+ * API token, an invite, the member's signup and login, a member API token,
17
+ * two pending offers to the member — `admin`, and `declined_role` to its
18
+ * actor (one role each: a second offer of a role still pending answers the
19
+ * first); the schema-version rows and a digest of every table's content
20
+ * read over Postgres.
21
+ * - **Second** — before any request, the migrations and every table's
22
+ * content as the first left them (its boot applied no migration and
23
+ * rewrote no row); bootstrap closed on `/status` and refused on
24
+ * `POST /bootstrap`; every cookie and both tokens authenticate; the
25
+ * member's password logs in and a wrong one is refused (an Argon2id hash
26
+ * verified by the other spine's verifier); both offers listed pending, one
27
+ * declined, one accepted, after which the member passes the admin gate;
28
+ * no database invariant broken; then the revocations — the second keeper
29
+ * session logged out and the keeper token revoked, each refused there, and
30
+ * the member's password changed.
31
+ * - **First again** — the migrations unchanged; the logged-out keeper
32
+ * session and the revoked keeper token refused while the first keeper
33
+ * cookie still authenticates (the revocations the second wrote, which
34
+ * nothing else ended); the member's sessions on both spines and its token
35
+ * refused (the password change ends them all); only the new password logs
36
+ * in, and its session passes the admin gate; the accepted offer bound to
37
+ * the grant the second made and the declined offer declined; no invariant
38
+ * broken.
39
+ *
40
+ * Every phase drains the backend's detached writes before its teardown,
41
+ * which holds the backend to exit `0` with no unexpected error in its log
42
+ * (`spawn_backend`).
43
+ *
44
+ * **What the configs must share.** One Postgres database — each config's
45
+ * `DATABASE_URL` env names `database_url`, compared as exact strings, so two
46
+ * spellings of one database are refused — the session cookie name and a
47
+ * `SECRET_FUZ_COOKIE_KEYS` both set: a cookie one spine signs, the other must
48
+ * verify. A backend that resets its database at boot must have it off, or
49
+ * it drops what the other wrote: `FUZ_TESTING_RESET_DB_ON_STARTUP` (the Rust
50
+ * family's `reset_db_on_startup`) unset or a false stringbool, read as the
51
+ * Rust spine reads it (`EnvStringbool`). Both mount `_testing_drain_effects`
52
+ * and `_testing_db_invariants`, and `declined_role` is not `admin`. The
53
+ * suite checks all of it first. Per-process state — rate limiters, socket
54
+ * registries, the daemon token — is not carried over, by design.
55
+ *
56
+ * @module
57
+ */
58
+ import { afterAll, afterEach, assert, beforeAll, describe, test } from 'vitest';
59
+ import { parse } from '@fuzdev/fuz_schema/schema.ts';
60
+ import { TokenCreateOutput, TokenRevokeOutput } from '../../auth/account_action_specs.js';
61
+ import { SessionAccountJson } from '../../auth/account_schema.js';
62
+ import { InviteCreateOutput, InviteListOutput } from '../../auth/admin_action_specs.js';
63
+ import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
64
+ import { RoleGrantOfferAcceptOutput, RoleGrantOfferCreateOutput, RoleGrantOfferDeclineOutput, RoleGrantOfferHistoryOutput, RoleGrantOfferListOutput } from '../../auth/role_grant_offer_action_specs.js';
65
+ import { ROLE_ADMIN } from '../../auth/role_schema.js';
66
+ import { create_db } from '../../db/create_db.js';
67
+ import { EnvStringbool } from '../../env/env_schemas.js';
68
+ import { ERROR_ALREADY_BOOTSTRAPPED, ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_INVALID_CREDENTIALS } from '../../http/error_schemas.js';
69
+ import { DbInvariantRows } from '../db_invariant_queries.js';
70
+ import { assert_db_invariant_rows } from '../db_invariants.js';
71
+ import { bootstrap } from '../transports/bootstrap.js';
72
+ import { create_fetch_transport } from '../transports/fetch_transport.js';
73
+ import { cross_rpc_call, error_reason, expect_output } from './cross_rpc.js';
74
+ import { spawn_backend } from './spawn_backend.js';
75
+ import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_LOGOUT_PATH, SPINE_ACCOUNT_PASSWORD_PATH, SPINE_ACCOUNT_SIGNUP_PATH, SPINE_ACCOUNT_STATUS_PATH, SPINE_PARTICIPANT_ROLE } from './spine_surface_constants.js';
76
+ /** The env var a backend's database URL rides in on both spine families. */
77
+ const DATABASE_URL_ENV = 'DATABASE_URL';
78
+ /** The cookie-signing keys env var both spine families read. */
79
+ const COOKIE_KEYS_ENV = 'SECRET_FUZ_COOKIE_KEYS';
80
+ /** The Rust family's startup-reset gate (`make_default_rust_backend_config`). */
81
+ const RESET_DB_ON_STARTUP_ENV = 'FUZ_TESTING_RESET_DB_ON_STARTUP';
82
+ /** The backdoors the suite drives. */
83
+ const SWAP_BACKDOORS = ['_testing_drain_effects', '_testing_db_invariants'];
84
+ /** The member account the first backend signs up. */
85
+ const SWAP_MEMBER_USERNAME = 'swap_member';
86
+ const SWAP_PASSWORD = 'swap-password-before';
87
+ const SWAP_PASSWORD_CHANGED = 'swap-password-after';
88
+ const SWAP_PASSWORD_WRONG = 'swap-password-wrong';
89
+ /** What a phase may take past its backend's startup window (ms). */
90
+ const SWAP_PHASE_WORK_MS = 30_000;
91
+ const read_snapshot = async (db) => {
92
+ const schema_version = await db.query('SELECT namespace, name, sequence, applied_at::text AS applied_at FROM schema_version ' +
93
+ 'ORDER BY namespace, sequence');
94
+ const tables = await db.query('SELECT schemaname, tablename FROM pg_tables ' +
95
+ "WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY schemaname, tablename");
96
+ const content = {};
97
+ for (const { schemaname, tablename } of tables) {
98
+ const [row] = await db.query('SELECT count(*)::int AS rows, ' +
99
+ "md5(coalesce(string_agg(t::text, E'\\n' ORDER BY t::text), '')) AS digest " +
100
+ `FROM "${schemaname}"."${tablename}" t`);
101
+ content[`${schemaname}.${tablename}`] = row;
102
+ }
103
+ return { schema_version, tables: content };
104
+ };
105
+ /**
106
+ * Spawn `config`, run `body`, then tear down — a teardown failure (an exit
107
+ * other than `0`, an unexpected error in the log) fails the phase. A failed
108
+ * body's teardown is logged beside the body's error rather than replacing it.
109
+ * The handle sits in `live` while the backend runs.
110
+ */
111
+ const with_backend = async (config, live, body) => {
112
+ const handle = await spawn_backend(config);
113
+ live.handle = handle;
114
+ let result;
115
+ try {
116
+ result = await body(handle);
117
+ }
118
+ catch (err) {
119
+ live.handle = null;
120
+ await handle.teardown().catch((teardown_error) => console.error(teardown_error));
121
+ throw err;
122
+ }
123
+ live.handle = null;
124
+ await handle.teardown();
125
+ return result;
126
+ };
127
+ /** Tear down a backend a phase left running — one that timed out — logging a failed teardown. */
128
+ const teardown_left_running = async (live) => {
129
+ const { handle } = live;
130
+ if (!handle)
131
+ return;
132
+ live.handle = null;
133
+ await handle.teardown().catch((err) => console.error(err));
134
+ };
135
+ /** A transport on `config`'s backend, holding `cookies` when given. */
136
+ const transport_for = (config, cookies, origin) => create_fetch_transport({
137
+ base_url: config.base_url,
138
+ ...(cookies && { initial_cookies: cookies }),
139
+ ...(origin === null && { origin: null })
140
+ });
141
+ const rpc = (config, transport, method, params, headers = {}) => cross_rpc_call(transport, config.rpc_path, method, params, headers);
142
+ /** `method` on a fresh transport holding `cookies`, its output parsed. */
143
+ const rpc_as = async (config, cookies, method, params, output) => expect_output(await rpc(config, transport_for(config, cookies), method, params), output);
144
+ /** A daemon-token backdoor call: Origin-free and cookie-free, as the daemon token requires. */
145
+ const backdoor = (handle, method) => rpc(handle.config, transport_for(handle.config, undefined, null), method, undefined, {
146
+ [DAEMON_TOKEN_HEADER]: handle.daemon_token
147
+ });
148
+ /** Await the backend's detached writes, so what the phase did is all on disk before teardown. */
149
+ const drain = async (handle) => {
150
+ const drained = await backdoor(handle, '_testing_drain_effects');
151
+ assert.deepStrictEqual(drained.result, { ok: true }, `${handle.config.name}: the drain answers`);
152
+ };
153
+ const assert_invariants = async (handle) => {
154
+ const answer = expect_output(await backdoor(handle, '_testing_db_invariants'), DbInvariantRows);
155
+ assert_db_invariant_rows(answer.rows, handle.config.name);
156
+ };
157
+ /** A JSON `POST` to a REST route: its status, body and `Set-Cookie` lines. */
158
+ const post_json = async (transport, path, body) => {
159
+ const res = await transport(path, {
160
+ method: 'POST',
161
+ headers: { 'content-type': 'application/json' },
162
+ body: JSON.stringify(body)
163
+ });
164
+ const text = await res.text();
165
+ return {
166
+ status: res.status,
167
+ body: text ? JSON.parse(text) : null,
168
+ set_cookies: res.headers.getSetCookie()
169
+ };
170
+ };
171
+ const login = (config, password) => post_json(transport_for(config), SPINE_ACCOUNT_LOGIN_PATH, {
172
+ username: SWAP_MEMBER_USERNAME,
173
+ password
174
+ });
175
+ /** Who a credential authenticates as on `config`'s backend: an account id, or `null` on a 401. */
176
+ const verified_account_id = async (config, credential) => {
177
+ const res = 'cookies' in credential
178
+ ? await rpc(config, transport_for(config, credential.cookies), 'account_verify', undefined)
179
+ : // Origin-free: a bearer beside an `Origin` is discarded as browser context
180
+ await rpc(config, transport_for(config, undefined, null), 'account_verify', undefined, {
181
+ authorization: `Bearer ${credential.bearer}`
182
+ });
183
+ if (res.status === 401) {
184
+ assert.strictEqual(error_reason(res), ERROR_AUTHENTICATION_REQUIRED);
185
+ return null;
186
+ }
187
+ return expect_output(res, SessionAccountJson).id;
188
+ };
189
+ /** The member's admin gate: `invite_list` answered (`true`) or refused 403 (`false`). */
190
+ const passes_admin_gate = async (config, cookies) => {
191
+ const res = await rpc(config, transport_for(config, cookies), 'invite_list', undefined);
192
+ if (res.status === 403) {
193
+ assert.strictEqual(error_reason(res), ERROR_INSUFFICIENT_PERMISSIONS);
194
+ return false;
195
+ }
196
+ expect_output(res, InviteListOutput);
197
+ return true;
198
+ };
199
+ /** The first backend: bootstrap, then everything the second must honor. */
200
+ const mint_swap_credentials = async (handle, db, declined_role) => {
201
+ const { config } = handle;
202
+ const keeper = await bootstrap({ transport: transport_for(config), config });
203
+ const keeper_spare = await post_json(transport_for(config), SPINE_ACCOUNT_LOGIN_PATH, {
204
+ username: config.bootstrap.username,
205
+ password: config.bootstrap.password
206
+ });
207
+ assert.strictEqual(keeper_spare.status, 200, 'the keeper logs in again');
208
+ assert.strictEqual(keeper_spare.set_cookies.length, 1, 'a login sets exactly the session cookie');
209
+ const keeper_token = await rpc_as(config, keeper.cookies, 'account_token_create', { scope: { kind: 'full' }, lifetime: { kind: 'eternal' } }, TokenCreateOutput);
210
+ expect_output(await rpc(config, transport_for(config, keeper.cookies), 'invite_create', {
211
+ username: SWAP_MEMBER_USERNAME
212
+ }), InviteCreateOutput);
213
+ const signup = await post_json(transport_for(config), SPINE_ACCOUNT_SIGNUP_PATH, {
214
+ username: SWAP_MEMBER_USERNAME,
215
+ password: SWAP_PASSWORD
216
+ });
217
+ assert.strictEqual(signup.status, 200, `signup: ${JSON.stringify(signup.body)}`);
218
+ const member = signup.body;
219
+ const logged_in = await login(config, SWAP_PASSWORD);
220
+ assert.strictEqual(logged_in.status, 200, 'the member logs in');
221
+ assert.strictEqual(logged_in.set_cookies.length, 1, 'a login sets exactly the session cookie');
222
+ const member_cookies = logged_in.set_cookies;
223
+ const token = await rpc_as(config, member_cookies, 'account_token_create', { scope: { kind: 'full' }, lifetime: { kind: 'eternal' } }, TokenCreateOutput);
224
+ const offer = async (params) => (await rpc_as(config, keeper.cookies, 'role_grant_offer_create', { to_account_id: member.account.id, ...params }, RoleGrantOfferCreateOutput)).offer.id;
225
+ const offer_accepted_id = await offer({ role: ROLE_ADMIN });
226
+ const offer_declined_id = await offer({ role: declined_role, to_actor_id: member.actor.id });
227
+ const { offers } = await rpc_as(config, member_cookies, 'role_grant_offer_list', undefined, RoleGrantOfferListOutput);
228
+ assert.sameMembers(offers.map((o) => o.id), [offer_accepted_id, offer_declined_id]);
229
+ await drain(handle);
230
+ return {
231
+ keeper_id: keeper.account.id,
232
+ keeper_cookies: keeper.cookies,
233
+ keeper_spare_cookies: keeper_spare.set_cookies,
234
+ keeper_token: keeper_token.token,
235
+ keeper_token_id: keeper_token.id,
236
+ member_id: member.account.id,
237
+ member_cookies,
238
+ token: token.token,
239
+ token_id: token.id,
240
+ offer_accepted_id,
241
+ offer_declined_id,
242
+ snapshot: await read_snapshot(db)
243
+ };
244
+ };
245
+ /** The second backend: honor everything the first minted, then write over it. */
246
+ const use_swap_credentials = async (handle, db, minted) => {
247
+ const { config } = handle;
248
+ // before any request but the health probe: nothing migrated, nothing written
249
+ assert.deepStrictEqual(await read_snapshot(db), minted.snapshot, 'the boot applied no migration and wrote or rewrote no row');
250
+ const status = await transport_for(config)(SPINE_ACCOUNT_STATUS_PATH, { method: 'GET' });
251
+ const status_body = (await status.json());
252
+ assert.strictEqual(status.status, 401, 'an anonymous status is refused');
253
+ assert.notStrictEqual(status_body.bootstrap_available, true, 'bootstrap is closed');
254
+ const rebootstrap = await post_json(transport_for(config), config.bootstrap_path, {
255
+ token: config.bootstrap.token,
256
+ username: config.bootstrap.username,
257
+ password: config.bootstrap.password
258
+ });
259
+ assert.strictEqual(rebootstrap.status, 403, 'a second bootstrap is refused');
260
+ assert.strictEqual(rebootstrap.body.error, ERROR_ALREADY_BOOTSTRAPPED);
261
+ assert.strictEqual(await verified_account_id(config, { cookies: minted.keeper_cookies }), minted.keeper_id, "the keeper's cookie authenticates");
262
+ assert.strictEqual(await verified_account_id(config, { cookies: minted.keeper_spare_cookies }), minted.keeper_id, "the keeper's second cookie authenticates");
263
+ assert.strictEqual(await verified_account_id(config, { bearer: minted.keeper_token }), minted.keeper_id, "the keeper's API token authenticates");
264
+ assert.strictEqual(await verified_account_id(config, { cookies: minted.member_cookies }), minted.member_id, "the member's cookie authenticates");
265
+ assert.strictEqual(await verified_account_id(config, { bearer: minted.token }), minted.member_id, "the member's API token authenticates");
266
+ const logged_in = await login(config, SWAP_PASSWORD);
267
+ assert.strictEqual(logged_in.status, 200, "the other spine's password hash verifies");
268
+ const member_cookies = logged_in.set_cookies;
269
+ const wrong = await login(config, SWAP_PASSWORD_WRONG);
270
+ assert.strictEqual(wrong.status, 401, 'a wrong password is refused');
271
+ assert.strictEqual(wrong.body.error, ERROR_INVALID_CREDENTIALS);
272
+ const { offers } = await rpc_as(config, member_cookies, 'role_grant_offer_list', undefined, RoleGrantOfferListOutput);
273
+ assert.sameMembers(offers.filter((o) => o.accepted_at === null && o.declined_at === null).map((o) => o.id), [minted.offer_accepted_id, minted.offer_declined_id], 'both offers are pending');
274
+ assert.isFalse(await passes_admin_gate(config, member_cookies), 'no admin before the accept');
275
+ const declined = await rpc_as(config, member_cookies, 'role_grant_offer_decline', { offer_id: minted.offer_declined_id }, RoleGrantOfferDeclineOutput);
276
+ assert.isNotNull(declined.offer.declined_at);
277
+ const accepted = await rpc_as(config, member_cookies, 'role_grant_offer_accept', { offer_id: minted.offer_accepted_id }, RoleGrantOfferAcceptOutput);
278
+ assert.isTrue(await passes_admin_gate(config, member_cookies), 'the accepted grant confers');
279
+ await assert_invariants(handle);
280
+ // the revocations of what the first spine minted: the keeper's, which
281
+ // nothing else ends, and the member's password change, which ends every
282
+ // session and token of the member's
283
+ const logout = await post_json(transport_for(config, minted.keeper_spare_cookies), SPINE_ACCOUNT_LOGOUT_PATH, {});
284
+ assert.strictEqual(logout.status, 200, "the first spine's keeper session logs out");
285
+ const revoked = await rpc_as(config, minted.keeper_cookies, 'account_token_revoke', { token_id: minted.keeper_token_id }, TokenRevokeOutput);
286
+ assert.isTrue(revoked.revoked, "the first spine's keeper token is revoked");
287
+ assert.isNull(await verified_account_id(config, { cookies: minted.keeper_spare_cookies }), 'the logged-out keeper session is refused');
288
+ assert.isNull(await verified_account_id(config, { bearer: minted.keeper_token }), 'the revoked keeper token is refused');
289
+ const changed = await post_json(transport_for(config, member_cookies), SPINE_ACCOUNT_PASSWORD_PATH, { current_password: SWAP_PASSWORD, new_password: SWAP_PASSWORD_CHANGED });
290
+ assert.strictEqual(changed.status, 200, `password change: ${JSON.stringify(changed.body)}`);
291
+ await drain(handle);
292
+ return { member_cookies, role_grant_id: accepted.role_grant_id };
293
+ };
294
+ /** The first backend again: what the second wrote holds. */
295
+ const check_swap_writes = async (handle, db, minted, written) => {
296
+ const { config } = handle;
297
+ assert.deepStrictEqual((await read_snapshot(db)).schema_version, minted.snapshot.schema_version, 'the migrations are as the first boot left them');
298
+ // the revocations the second spine wrote, which nothing else ended
299
+ assert.isNull(await verified_account_id(config, { cookies: minted.keeper_spare_cookies }), 'the keeper session the other spine logged out is refused');
300
+ assert.isNull(await verified_account_id(config, { bearer: minted.keeper_token }), 'the keeper token the other spine revoked is refused');
301
+ assert.strictEqual(await verified_account_id(config, { cookies: minted.keeper_cookies }), minted.keeper_id, "the keeper's first cookie still authenticates");
302
+ // the other spine's password change ended every session and token of the member's
303
+ assert.isNull(await verified_account_id(config, { cookies: minted.member_cookies }), "the password change ended the member's session on this spine");
304
+ assert.isNull(await verified_account_id(config, { cookies: written.member_cookies }), "the password change ended the member's session on the other spine");
305
+ assert.isNull(await verified_account_id(config, { bearer: minted.token }), "the password change ended the member's token");
306
+ const old_password = await login(config, SWAP_PASSWORD);
307
+ assert.strictEqual(old_password.status, 401, 'the old password is refused');
308
+ const new_password = await login(config, SWAP_PASSWORD_CHANGED);
309
+ assert.strictEqual(new_password.status, 200, 'the new password logs in');
310
+ assert.isTrue(await passes_admin_gate(config, new_password.set_cookies), 'the grant the other spine made confers');
311
+ const { offers } = await rpc_as(config, minted.keeper_cookies, 'role_grant_offer_history', {}, RoleGrantOfferHistoryOutput);
312
+ const accepted = offers.find((o) => o.id === minted.offer_accepted_id);
313
+ const declined = offers.find((o) => o.id === minted.offer_declined_id);
314
+ assert.ok(accepted && declined, "the keeper's history lists both offers");
315
+ assert.isNotNull(accepted.accepted_at, 'the accepted offer is accepted');
316
+ assert.strictEqual(accepted.resulting_role_grant_id, written.role_grant_id);
317
+ assert.isNotNull(declined.declined_at, 'the declined offer is declined');
318
+ assert.isNull(declined.accepted_at);
319
+ await assert_invariants(handle);
320
+ await drain(handle);
321
+ };
322
+ /**
323
+ * Why a config's startup-reset env doesn't leave the reset off, or `null` when
324
+ * it does — read as the Rust spine reads it: unset or a false stringbool is
325
+ * off, a true one resets, and any other value fails its boot. A config that
326
+ * leaves it out reads the harness process's own, which `spawn_backend` passes
327
+ * to the child.
328
+ */
329
+ const to_reset_problem = (config) => {
330
+ const value = config.env[RESET_DB_ON_STARTUP_ENV] ?? process.env[RESET_DB_ON_STARTUP_ENV];
331
+ if (value === undefined)
332
+ return null;
333
+ const parsed = parse(EnvStringbool, value);
334
+ if (!parsed.ok) {
335
+ return `${config.name}'s ${RESET_DB_ON_STARTUP_ENV} is no stringbool (${JSON.stringify(value)})`;
336
+ }
337
+ return parsed.value
338
+ ? `${config.name} resets its database at startup (${RESET_DB_ON_STARTUP_ENV})`
339
+ : null;
340
+ };
341
+ /**
342
+ * Throw naming each way `order`'s configs can't swap over `database_url`.
343
+ * Database URLs compare as exact strings.
344
+ */
345
+ const assert_swappable = (order, database_url, declined_role) => {
346
+ const { first, second } = order;
347
+ const problems = [];
348
+ if (declined_role === ROLE_ADMIN) {
349
+ problems.push(`declined_role is ${ROLE_ADMIN}, the accepted offer's role — a second offer of a ` +
350
+ 'role still pending answers the first, so the two offers would be one');
351
+ }
352
+ if (first.cookie_name !== second.cookie_name) {
353
+ problems.push(`cookie names differ (${first.cookie_name}, ${second.cookie_name})`);
354
+ }
355
+ if (first.env[COOKIE_KEYS_ENV] === undefined && second.env[COOKIE_KEYS_ENV] === undefined) {
356
+ problems.push(`neither config sets ${COOKIE_KEYS_ENV}`);
357
+ }
358
+ else if (first.env[COOKIE_KEYS_ENV] !== second.env[COOKIE_KEYS_ENV]) {
359
+ problems.push(`${COOKIE_KEYS_ENV} differs`);
360
+ }
361
+ for (const config of [first, second]) {
362
+ const url = config.env[DATABASE_URL_ENV];
363
+ if (url === undefined) {
364
+ problems.push(`${config.name} sets no ${DATABASE_URL_ENV}`);
365
+ }
366
+ else if (url !== database_url) {
367
+ problems.push(`${config.name}'s ${DATABASE_URL_ENV} is not the swap's database`);
368
+ }
369
+ const reset_problem = to_reset_problem(config);
370
+ if (reset_problem !== null)
371
+ problems.push(reset_problem);
372
+ for (const method of SWAP_BACKDOORS) {
373
+ if (!config.capabilities.testing_backdoors.includes(method)) {
374
+ problems.push(`${config.name} doesn't declare ${method}`);
375
+ }
376
+ }
377
+ }
378
+ if (problems.length > 0) {
379
+ throw new Error(`backend swap '${order.label}': ${problems.join('; ')}`);
380
+ }
381
+ };
382
+ /**
383
+ * Describe the backend swap over each order (§module doc): three tests per
384
+ * order, run in turn, each phase spawning and stopping its own backend. A
385
+ * phase whose predecessor failed fails naming it.
386
+ *
387
+ * @param options - the orders, the shared database, and how to empty it
388
+ */
389
+ export const describe_backend_swap_tests = (options) => {
390
+ const { orders, database_url, empty_database, declined_role = SPINE_PARTICIPANT_ROLE } = options;
391
+ describe('backend swap', () => {
392
+ let db = null;
393
+ let close_db = null;
394
+ beforeAll(async () => {
395
+ const created = await create_db(database_url);
396
+ db = created.db;
397
+ close_db = created.close;
398
+ });
399
+ afterAll(async () => {
400
+ await close_db?.();
401
+ });
402
+ const get_db = () => {
403
+ assert.ok(db, 'the snapshot connection is open');
404
+ return db;
405
+ };
406
+ for (const order of orders) {
407
+ const { label, first, second } = order;
408
+ const timeout = Math.max(first.startup_timeout_ms, second.startup_timeout_ms) + SWAP_PHASE_WORK_MS;
409
+ const state = {};
410
+ const live = { handle: null };
411
+ describe(label, () => {
412
+ afterEach(() => teardown_left_running(live));
413
+ test(`${first.name} mints credentials over an empty database`, async () => {
414
+ assert_swappable(order, database_url, declined_role);
415
+ await empty_database();
416
+ state.minted = await with_backend(first, live, (handle) => mint_swap_credentials(handle, get_db(), declined_role));
417
+ }, timeout);
418
+ test(`${second.name} boots over them and honors each`, async () => {
419
+ const { minted } = state;
420
+ assert.ok(minted, `${first.name}'s mint phase did not complete`);
421
+ state.written = await with_backend(second, live, (handle) => use_swap_credentials(handle, get_db(), minted));
422
+ }, timeout);
423
+ test(`${first.name} boots again and honors what ${second.name} wrote`, async () => {
424
+ const { minted, written } = state;
425
+ assert.ok(minted && written, `${second.name}'s phase did not complete`);
426
+ await with_backend(first, live, (handle) => check_swap_writes(handle, get_db(), minted, written));
427
+ }, timeout);
428
+ });
429
+ }
430
+ });
431
+ };
@@ -20,9 +20,9 @@ import '../assert_dev_env.js';
20
20
  * - **Node** closes at once with the body unread — `create_app_server`'s body
21
21
  * limit (`http/body_limit.ts`) refuses on the header and answers
22
22
  * `Connection: close`, which is what makes `@hono/node-server` close.
23
- * - **Bun** closes at once too, honouring that header. Bun 1.4.3 is the tested
24
- * floor: an older Bun kept the connection after the 413 and served the next
25
- * request (correctly framed), which fails this suite.
23
+ * - **Bun** closes at once too, honouring that header. Bun 1.4.4 is the tested
24
+ * floor: a Bun older than 1.4.3 kept the connection after the 413 and served
25
+ * the next request (correctly framed), which fails this suite.
26
26
  * - **hyper** (the Rust spine) closes at once.
27
27
  *
28
28
  * The oversized body is rejected *with* a 413 on every backend — pinned
@@ -19,7 +19,9 @@ import '../assert_dev_env.js';
19
19
  *
20
20
  * If `bootstrap()` throws — typically a bad token, port collision, or
21
21
  * keeper-username mismatch — the spawned binary is torn down before the
22
- * error propagates so vitest doesn't strand the port.
22
+ * error propagates so vitest doesn't strand the port. The returned handle's
23
+ * `teardown` rejects unless the binary exits `0` (`BackendHandle.teardown`),
24
+ * so a global setup that awaits it fails the run on an unclean shutdown.
23
25
  *
24
26
  * @module
25
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/bootstrap_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,uCAAuC;AACvC,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,UAAU,uBAAuB,KAC/B,OAAO,CAAC,yBAAyB,CAyBnC,CAAC"}
1
+ {"version":3,"file":"bootstrap_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/bootstrap_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,uCAAuC;AACvC,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,UAAU,uBAAuB,KAC/B,OAAO,CAAC,yBAAyB,CA6BnC,CAAC"}
@@ -23,12 +23,12 @@ export const bootstrap_backend = async (config, options) => {
23
23
  return {
24
24
  ...handle,
25
25
  keeper_transport,
26
- // Origin-free twin carrying the same keeper cookie jar — the
27
- // daemon-token middleware discards the credential in a browser
28
- // context, so the `_testing_*` daemon-token calls route through this.
26
+ // cookie-free, so a daemon-token call carries that credential alone,
27
+ // and Origin-free — the daemon-token middleware discards the
28
+ // credential in a browser context, so the `_testing_*` daemon-token
29
+ // calls route through this
29
30
  keeper_daemon_transport: create_fetch_transport({
30
31
  base_url: config.base_url,
31
- initial_cookies: keeper.cookies,
32
32
  origin: null
33
33
  }),
34
34
  keeper_account: keeper.account,
@@ -37,7 +37,11 @@ export const bootstrap_backend = async (config, options) => {
37
37
  };
38
38
  }
39
39
  catch (err) {
40
- await handle.teardown();
40
+ // the bootstrap's error is the report; a teardown that also failed is
41
+ // logged beside it rather than replacing it
42
+ await handle.teardown().catch((teardown_error) => {
43
+ console.error(teardown_error);
44
+ });
41
45
  throw err;
42
46
  }
43
47
  };
@@ -78,8 +78,9 @@ import type { SessionCookieEffect } from './session_cookie_effect.js';
78
78
  * [SCOPED_TOKEN_ADMITTED_METHOD]}`), non-browser context. Minted through the
79
79
  * production `account_token_create` path over the keeper's session, not
80
80
  * seeded — `_testing_reset` deliberately seeds a `full` token, and a harness
81
- * that narrowed the seed would silently re-scope every other bearer case.
82
- * The scope gate sits between the credential gate and the role gate, so this
81
+ * that narrowed the seed would silently re-scope every other bearer case —
82
+ * and proven to authenticate as the keeper on `SCOPED_TOKEN_ADMITTED_METHOD`
83
+ * before any case is sent as it. The scope gate sits between the credential gate and the role gate, so this
83
84
  * principal is what distinguishes `token_scope_required` from the
84
85
  * credential-type and role denials on either side of it.
85
86
  * - `anonymous` — no credential, fresh cookie jar.
@@ -91,10 +92,6 @@ import type { SessionCookieEffect } from './session_cookie_effect.js';
91
92
  * - `wrong_role` — a seeded `extra_accounts` principal holding a role
92
93
  * other than the one a route requires; named via
93
94
  * `ConformanceTableOptions.principals.wrong_role`.
94
- * - `expired_session` — the keeper account presented via an *expired
95
- * server-side session* cookie (minted by `fixture.mint_expired_session()`:
96
- * a backdated `auth_session` row behind a still-valid signed cookie
97
- * payload, so the authoritative DB-row expiry gate is what refuses it).
98
95
  *
99
96
  * The dead credentials — each presented alone, on a fresh jar, so the request
100
97
  * carries that credential and nothing else; each arrives anonymous, so a row
@@ -112,6 +109,10 @@ import type { SessionCookieEffect } from './session_cookie_effect.js';
112
109
  * - `revoked_session` — a session cookie that verifies, whose `auth_session`
113
110
  * row has been revoked (`fixture.mint_revoked_session()`). The cookie alone
114
111
  * shows nothing wrong, so it is not cleared.
112
+ * - `expired_session` — a session cookie that authenticated and whose
113
+ * `auth_session` row has since expired (`fixture.mint_expired_session()`):
114
+ * the signed cookie payload still verifies, so the authoritative DB-row
115
+ * expiry gate is what refuses it.
115
116
  * - `revoked_token` — an API token that was minted and then revoked
116
117
  * (`fixture.mint_revoked_token()`), with no `Origin`.
117
118
  * - `expired_token` — an API token whose row is past its `expires_at`
@@ -127,6 +128,10 @@ export type ConformancePrincipal = 'keeper' | 'daemon' | 'invalid_daemon' | 'dae
127
128
  * credential gate a bearer must pass first, and holds no role gate that could
128
129
  * shadow the scope denial — so a case naming any *other* method isolates the
129
130
  * scope gate and nothing else.
131
+ *
132
+ * It is also the method the principal's liveness proof sends
133
+ * (`assert_credential_authenticates` calls `account_verify_action_spec`), so
134
+ * the narrowed token can be proven live only while the two are one method.
130
135
  */
131
136
  export declare const SCOPED_TOKEN_ADMITTED_METHOD = "account_verify";
132
137
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"conformance_case.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_case.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,MAAM,MAAM,oBAAoB,GAC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AAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC/B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,sBAAsB,CAAC;IAChC,MAAM,EAAE,0BAA0B,CAAC;IACnC,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB"}
1
+ {"version":3,"file":"conformance_case.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_case.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAM,MAAM,oBAAoB,GAC7B,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,gBAAgB,GAChB,OAAO,GACP,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,eAAe,CAAC;AAEnB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,4BAA4B,mBAAmB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,M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AAC,EAAE,WAAW,CAAC;CACpB"}
@@ -8,5 +8,9 @@ import '../assert_dev_env.js';
8
8
  * credential gate a bearer must pass first, and holds no role gate that could
9
9
  * shadow the scope denial — so a case naming any *other* method isolates the
10
10
  * scope gate and nothing else.
11
+ *
12
+ * It is also the method the principal's liveness proof sends
13
+ * (`assert_credential_authenticates` calls `account_verify_action_spec`), so
14
+ * the narrowed token can be proven live only while the two are one method.
11
15
  */
12
16
  export const SCOPED_TOKEN_ADMITTED_METHOD = 'account_verify';
@@ -2,7 +2,7 @@ import '../assert_dev_env.js';
2
2
  import { type resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
3
3
  import type { FetchTransport } from '../transports/fetch_transport.js';
4
4
  import { type ConformancePrincipal } from './conformance_case.js';
5
- import type { TestFixture } from './setup.js';
5
+ import { type TestFixture } from './setup.js';
6
6
  /**
7
7
  * Names a seeded `extra_accounts` username for the `role_holder` /
8
8
  * `wrong_role` principals — the only two that aren't backed by an
@@ -27,7 +27,7 @@ export interface ResolvedConformancePrincipal {
27
27
  readonly suppress_default_origin?: boolean;
28
28
  /**
29
29
  * The actor of the account the credential names — what the `principal`
30
- * acting binding writes. Absent for principals that present no account.
30
+ * acting binding writes. Absent for principals that present no live account.
31
31
  */
32
32
  readonly actor_id?: string;
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"conformance_principal.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_principal.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiB9B,OAAO,EAAmB,KAAK,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAgC,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IAC1C,iEAAi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AS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AA8GD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GACzC,SAAS,WAAW,EACpB,IAAI,oBAAoB,EACxB,aAAa,0BAA0B,EACvC,yBAAwB,UAAU,CAAC,OAAO,+BAA+B,CAAM,KAC7E,OAAO,CAAC,4BAA4B,CA0KtC,CAAC"}