@fuzdev/fuz_app 0.185.0 → 0.187.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.
- package/dist/actions/CLAUDE.md +14 -2
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +36 -5
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +3 -1
- package/dist/auth/CLAUDE.md +17 -6
- package/dist/auth/account_queries.d.ts +60 -44
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +64 -54
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +59 -25
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +26 -9
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_queries.d.ts +11 -3
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -4
- package/dist/auth/audit_log_schema.js +1 -1
- package/dist/auth/auth_ddl.d.ts.map +1 -1
- package/dist/auth/auth_ddl.js +4 -0
- package/dist/auth/cleanup.js +1 -1
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +35 -0
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +2 -1
- package/dist/auth/role_grant_offer_actions.d.ts +12 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +48 -20
- package/dist/auth/role_grant_offer_queries.d.ts +28 -15
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +35 -16
- package/dist/auth/role_grant_queries.d.ts +118 -20
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +145 -24
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +15 -0
- package/dist/auth/session_queries.d.ts +24 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +28 -0
- package/dist/db/CLAUDE.md +3 -3
- package/dist/db/cell_ddl.d.ts +8 -3
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +10 -5
- package/dist/db/migrate.d.ts +46 -22
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +103 -85
- package/dist/http/body_limit.d.ts +4 -4
- package/dist/http/body_limit.js +4 -4
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -4
- package/dist/testing/CLAUDE.md +161 -27
- package/dist/testing/app_server.d.ts +5 -7
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +5 -7
- package/dist/testing/auth_apps.d.ts +3 -1
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +22 -5
- package/dist/testing/cross_backend/backend_both_live.d.ts +47 -0
- package/dist/testing/cross_backend/backend_both_live.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_both_live.js +566 -0
- package/dist/testing/cross_backend/backend_config.d.ts +8 -0
- package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/backend_log.d.ts +71 -0
- package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_log.js +134 -0
- package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
- package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_swap.js +267 -0
- package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
- package/dist/testing/cross_backend/bootstrap_backend.js +4 -4
- package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +4 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_principal.js +27 -10
- package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +50 -15
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +52 -30
- package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +36 -8
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
- package/dist/testing/cross_backend/setup.d.ts +44 -43
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +64 -62
- package/dist/testing/cross_backend/shared_database_backends.d.ts +175 -0
- package/dist/testing/cross_backend/shared_database_backends.d.ts.map +1 -0
- package/dist/testing/cross_backend/shared_database_backends.js +298 -0
- package/dist/testing/cross_backend/spawn_backend.d.ts +7 -3
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +86 -7
- package/dist/testing/cross_backend/spine_suites.d.ts +1 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +5 -2
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +7 -6
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +10 -8
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +7 -31
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +4 -3
- package/dist/testing/data_exposure.d.ts +4 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +93 -25
- package/dist/testing/db_invariants.d.ts +5 -5
- package/dist/testing/db_invariants.js +5 -5
- package/dist/testing/logged_errors.d.ts +61 -0
- package/dist/testing/logged_errors.d.ts.map +1 -0
- package/dist/testing/logged_errors.js +285 -0
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
- package/dist/testing/middleware_gate_probes.js +15 -8
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +41 -16
- package/dist/testing/stubs.d.ts +5 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +6 -3
- package/dist/testing/test_app.d.ts +40 -11
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +66 -9
- package/dist/testing/transports/fetch_transport.d.ts +10 -0
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +13 -0
- package/package.json +5 -3
|
@@ -101,9 +101,9 @@ export declare const to_test_account: (seeded: {
|
|
|
101
101
|
* Transport-agnostic: in-process and cross-process producers return the
|
|
102
102
|
* same shape. Behaviors that once needed raw backend access (keyring for
|
|
103
103
|
* forging cookies) are reached through wire-shaped seams instead —
|
|
104
|
-
* `mint_expired_session()`
|
|
105
|
-
* cross-process and
|
|
106
|
-
* the transport.
|
|
104
|
+
* `mint_expired_session()` expires a session over the
|
|
105
|
+
* `_testing_shorten_credential_expiry` channel cross-process and with its
|
|
106
|
+
* statement in-process, so suite bodies never branch on the transport.
|
|
107
107
|
*
|
|
108
108
|
* **Keeper ≠ admin.** `fixture.account` / `fixture.actor` refer to the
|
|
109
109
|
* **fresh keeper** seeded per test. The keeper account holds
|
|
@@ -194,15 +194,16 @@ export interface TestFixture {
|
|
|
194
194
|
readonly name: string;
|
|
195
195
|
}>;
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* (`
|
|
202
|
-
*
|
|
203
|
-
* `
|
|
204
|
-
*
|
|
205
|
-
*
|
|
197
|
+
* Return the ready-to-send `Cookie` header value (`name=value`) of a
|
|
198
|
+
* session that authenticated and whose row is now past its `expires_at`:
|
|
199
|
+
* the signed cookie still verifies, so resolution clears the cookie gate
|
|
200
|
+
* (`parse_session_from_cookies`) and is refused at the authoritative
|
|
201
|
+
* DB-row gate (`query_session_get_valid` — `WHERE expires_at > NOW()`).
|
|
202
|
+
* Backs the `expired_session` conformance principal. The shape of
|
|
203
|
+
* `mint_expired_token`: a fresh account (`create_account`, so the keeper's
|
|
204
|
+
* own credentials live on) whose session is proven live, then expired as a
|
|
205
|
+
* real one is — `_testing_shorten_credential_expiry` and a wait
|
|
206
|
+
* cross-process, its statement and a backdate in-process.
|
|
206
207
|
*/
|
|
207
208
|
readonly mint_expired_session: () => Promise<string>;
|
|
208
209
|
/**
|
|
@@ -231,14 +232,16 @@ export interface TestFixture {
|
|
|
231
232
|
* `expires_at`. Backs the `expired_token` conformance principal. Both
|
|
232
233
|
* fixtures mint an account (`create_account`, so the keeper's own
|
|
233
234
|
* credentials live on), prove its eternal token authenticates, then pull
|
|
234
|
-
* the account's credential expiries in to `
|
|
235
|
+
* the account's credential expiries in to `EXPIRED_CREDENTIAL_SHORTEN_SECONDS`
|
|
235
236
|
* from now with the statement behind `_testing_shorten_credential_expiry`
|
|
236
|
-
* (`query_shorten_credential_expiry`),
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
237
|
+
* (`query_shorten_credential_expiry`), so the row expires as a real one
|
|
238
|
+
* does: `expires_at` after `created_at`, then passed. Cross-process the
|
|
239
|
+
* statement runs through the backdoor, which the backend must mount, and
|
|
240
|
+
* the fixture waits `EXPIRED_CREDENTIAL_WAIT_MS`. In-process it runs directly
|
|
241
|
+
* and, holding the database, moves the account's credential rows back by
|
|
242
|
+
* that wait instead — every timestamp of each row, so `expires_at` stays
|
|
243
|
+
* after `created_at`, a row a lifetime writes. `mint_expired_session` is
|
|
244
|
+
* the same mint over the account's session.
|
|
242
245
|
*/
|
|
243
246
|
readonly mint_expired_token: () => Promise<string>;
|
|
244
247
|
/**
|
|
@@ -329,7 +332,6 @@ export interface RpcPathCapabilityGatedCrossSuiteOptions extends RpcPathCrossSui
|
|
|
329
332
|
* keeper_transport,
|
|
330
333
|
* keeper_daemon_transport: create_fetch_transport({
|
|
331
334
|
* base_url: config.base_url,
|
|
332
|
-
* initial_cookies: keeper.cookies,
|
|
333
335
|
* origin: null,
|
|
334
336
|
* }),
|
|
335
337
|
* keeper_account: keeper.account,
|
|
@@ -348,9 +350,10 @@ export interface BootstrappedBackendHandle extends BackendHandle {
|
|
|
348
350
|
/** Transport carrying the keeper session cookie + cookie jar. */
|
|
349
351
|
readonly keeper_transport: FetchTransport;
|
|
350
352
|
/**
|
|
351
|
-
* Daemon-token transport for the keeper —
|
|
352
|
-
*
|
|
353
|
-
*
|
|
353
|
+
* Daemon-token transport for the keeper — no cookie jar, so a daemon-token
|
|
354
|
+
* call carries that credential alone (a cookie beside it would authenticate
|
|
355
|
+
* as the keeper's session if the token failed), and `origin: null` so it
|
|
356
|
+
* sends no `Origin` header. The daemon-token middleware discards the credential in a
|
|
354
357
|
* browser context (any `Origin` / `Referer`), so the `_testing_*`
|
|
355
358
|
* daemon-token calls (`_testing_reset` / `_testing_schema_snapshot` /
|
|
356
359
|
* `_testing_action_manifest` / `_testing_mint_session`) must route
|
|
@@ -542,29 +545,25 @@ export declare const capture_action_manifest: (handle: ReconstructedBootstrapped
|
|
|
542
545
|
*/
|
|
543
546
|
export declare const capture_migration_tracker: (handle: ReconstructedBootstrappedBackendHandle) => Promise<MigrationTracker>;
|
|
544
547
|
/**
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* comfortably past `NOW()` for the DB-row expiry gate without depending on
|
|
548
|
-
* clock precision.
|
|
549
|
-
*/
|
|
550
|
-
export declare const EXPIRED_SESSION_OFFSET_SECONDS = -60;
|
|
551
|
-
/**
|
|
552
|
-
* The seconds `mint_expired_token` pulls a token's expiry in to — over
|
|
548
|
+
* The seconds `mint_expired_token` and `mint_expired_session` pull a
|
|
549
|
+
* credential's expiry in to — over
|
|
553
550
|
* `_testing_shorten_credential_expiry` cross-process, with its statement
|
|
554
551
|
* in-process — the backdoor's floor
|
|
555
552
|
* (`TESTING_SHORTEN_CREDENTIAL_EXPIRY_MIN_SECONDS`, which this module does not
|
|
556
553
|
* import: its module carries the in-process backend), so the wait is as short
|
|
557
554
|
* as the backdoor allows; a floor raised past it fails the call loud.
|
|
558
555
|
*/
|
|
559
|
-
export declare const
|
|
556
|
+
export declare const EXPIRED_CREDENTIAL_SHORTEN_SECONDS = 1;
|
|
560
557
|
/**
|
|
561
|
-
* How long `mint_expired_token`
|
|
562
|
-
*
|
|
558
|
+
* How long the cross-process `mint_expired_token` and `mint_expired_session`
|
|
559
|
+
* wait after the shorten answers: the row's `expires_at` is
|
|
560
|
+
* `EXPIRED_CREDENTIAL_SHORTEN_SECONDS` past the
|
|
563
561
|
* database's `NOW()` of a statement that ran before the answer, so once this
|
|
564
562
|
* much has passed on the same clock the row is expired when the token is sent.
|
|
565
|
-
* The margin covers the timer firing early by its rounding.
|
|
563
|
+
* The margin covers the timer firing early by its rounding. The in-process
|
|
564
|
+
* fixture moves the rows back by it rather than waiting.
|
|
566
565
|
*/
|
|
567
|
-
export declare const
|
|
566
|
+
export declare const EXPIRED_CREDENTIAL_WAIT_MS: number;
|
|
568
567
|
/** What `assert_credential_authenticates` sends and expects. */
|
|
569
568
|
export interface AssertCredentialAuthenticatesOptions {
|
|
570
569
|
/**
|
|
@@ -572,7 +571,7 @@ export interface AssertCredentialAuthenticatesOptions {
|
|
|
572
571
|
* otherwise, since a cookie it carried would answer for the credential.
|
|
573
572
|
*/
|
|
574
573
|
readonly transport: FetchTransport;
|
|
575
|
-
/** The RPC endpoint `account_verify` is mounted on. */
|
|
574
|
+
/** The RPC endpoint `account_verify` (`account_verify_action_spec`) is mounted on. */
|
|
576
575
|
readonly rpc_path: string;
|
|
577
576
|
/** The credential, alone: a `cookie`, an `authorization`, or a daemon token. */
|
|
578
577
|
readonly headers: Readonly<Record<string, string>>;
|
|
@@ -582,12 +581,14 @@ export interface AssertCredentialAuthenticatesOptions {
|
|
|
582
581
|
readonly accessor: string;
|
|
583
582
|
}
|
|
584
583
|
/**
|
|
585
|
-
* Prove a credential authenticates — `account_verify` answers 200
|
|
586
|
-
* expected account — before a fixture
|
|
587
|
-
*
|
|
588
|
-
* a `mint_revoked_*` that minted nothing
|
|
589
|
-
*
|
|
590
|
-
*
|
|
584
|
+
* Prove a credential authenticates — `account_verify` answers 200 naming the
|
|
585
|
+
* expected account — before a fixture relies on it. A refusal reaches the same
|
|
586
|
+
* answer whether the credential was killed, never worked, or belongs to
|
|
587
|
+
* another account, so without this a `mint_revoked_*` that minted nothing, an
|
|
588
|
+
* expiry over a token that never worked, or a `scoped_token` minted on the
|
|
589
|
+
* wrong account would pass every row its principal backs; with it, the
|
|
590
|
+
* principal's refusal can only come from the state the fixture put it in (the
|
|
591
|
+
* revocation, the expiry, the scope).
|
|
591
592
|
*
|
|
592
593
|
* @param options - the transport, endpoint, credential and expected account
|
|
593
594
|
* @throws Error naming the accessor when the credential does not answer as the account
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAQN,KAAK,KAAK,EACV,KAAK,SAAS,EACd,MAAM,8BAA8B,CAAC;AA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;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GACrC,QAAQ,SAAS;IAAE,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAEpE,cAAc,MAAM,EACpB,WAAW;IACV,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC5C,EACD,QAAQ;IACP,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE,KACC,wBAAwB,CAAC,QAAQ,CAuDnC,CAAC;AA8TF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,2BAA2B,GACvC,QAAQ,sCAAsC,EAC9C,UAAU,wBAAwB,KAChC,SAwRF,CAAC"}
|
|
@@ -24,6 +24,7 @@ import '../assert_dev_env.js';
|
|
|
24
24
|
import { array, boolean, literal, number, parse, string, strip_object } from '@fuzdev/fuz_schema/schema.ts';
|
|
25
25
|
import { USERNAME_LENGTH_MAX, Uuid } from '../../primitive_schemas.js';
|
|
26
26
|
import { format_issues } from '../../schema_issues.js';
|
|
27
|
+
import { account_verify_action_spec } from '../../auth/account_action_specs.js';
|
|
27
28
|
import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
|
|
28
29
|
import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
|
|
29
30
|
import { create_fetch_transport } from '../transports/fetch_transport.js';
|
|
@@ -89,13 +90,13 @@ export const reconstruct_bootstrapped_handle = (serialized) => ({
|
|
|
89
90
|
base_url: serialized.config.base_url,
|
|
90
91
|
initial_cookies: serialized.keeper_cookies
|
|
91
92
|
}),
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
93
|
+
// Cookie-free and Origin-free, so a daemon-token call carries that
|
|
94
|
+
// credential alone and the daemon-token middleware doesn't discard it as
|
|
95
|
+
// browser-context — used by the `_testing_*` daemon-token calls
|
|
96
|
+
// (`_testing_reset` / `_testing_schema_snapshot` /
|
|
95
97
|
// `_testing_action_manifest` / `_testing_mint_session`).
|
|
96
98
|
keeper_daemon_transport: create_fetch_transport({
|
|
97
99
|
base_url: serialized.config.base_url,
|
|
98
|
-
initial_cookies: serialized.keeper_cookies,
|
|
99
100
|
origin: null
|
|
100
101
|
})
|
|
101
102
|
});
|
|
@@ -251,40 +252,36 @@ export const capture_action_manifest = async (handle) => capture_via_daemon(hand
|
|
|
251
252
|
*/
|
|
252
253
|
export const capture_migration_tracker = async (handle) => capture_via_daemon(handle, '_testing_migration_tracker', MigrationTracker);
|
|
253
254
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* comfortably past `NOW()` for the DB-row expiry gate without depending on
|
|
257
|
-
* clock precision.
|
|
258
|
-
*/
|
|
259
|
-
export const EXPIRED_SESSION_OFFSET_SECONDS = -60;
|
|
260
|
-
/** Structural subset of `_testing_mint_session`'s output. */
|
|
261
|
-
const MintSessionResponseShape = strip_object({ session_cookie: string });
|
|
262
|
-
/**
|
|
263
|
-
* The seconds `mint_expired_token` pulls a token's expiry in to — over
|
|
255
|
+
* The seconds `mint_expired_token` and `mint_expired_session` pull a
|
|
256
|
+
* credential's expiry in to — over
|
|
264
257
|
* `_testing_shorten_credential_expiry` cross-process, with its statement
|
|
265
258
|
* in-process — the backdoor's floor
|
|
266
259
|
* (`TESTING_SHORTEN_CREDENTIAL_EXPIRY_MIN_SECONDS`, which this module does not
|
|
267
260
|
* import: its module carries the in-process backend), so the wait is as short
|
|
268
261
|
* as the backdoor allows; a floor raised past it fails the call loud.
|
|
269
262
|
*/
|
|
270
|
-
export const
|
|
263
|
+
export const EXPIRED_CREDENTIAL_SHORTEN_SECONDS = 1;
|
|
271
264
|
/**
|
|
272
|
-
* How long `mint_expired_token`
|
|
273
|
-
*
|
|
265
|
+
* How long the cross-process `mint_expired_token` and `mint_expired_session`
|
|
266
|
+
* wait after the shorten answers: the row's `expires_at` is
|
|
267
|
+
* `EXPIRED_CREDENTIAL_SHORTEN_SECONDS` past the
|
|
274
268
|
* database's `NOW()` of a statement that ran before the answer, so once this
|
|
275
269
|
* much has passed on the same clock the row is expired when the token is sent.
|
|
276
|
-
* The margin covers the timer firing early by its rounding.
|
|
270
|
+
* The margin covers the timer firing early by its rounding. The in-process
|
|
271
|
+
* fixture moves the rows back by it rather than waiting.
|
|
277
272
|
*/
|
|
278
|
-
export const
|
|
273
|
+
export const EXPIRED_CREDENTIAL_WAIT_MS = EXPIRED_CREDENTIAL_SHORTEN_SECONDS * 1000 + 50;
|
|
279
274
|
/** The account id an `account_verify` answer names, all a liveness check reads of it. */
|
|
280
275
|
const VerifyResponseShape = strip_object({ id: string });
|
|
281
276
|
/**
|
|
282
|
-
* Prove a credential authenticates — `account_verify` answers 200
|
|
283
|
-
* expected account — before a fixture
|
|
284
|
-
*
|
|
285
|
-
* a `mint_revoked_*` that minted nothing
|
|
286
|
-
*
|
|
287
|
-
*
|
|
277
|
+
* Prove a credential authenticates — `account_verify` answers 200 naming the
|
|
278
|
+
* expected account — before a fixture relies on it. A refusal reaches the same
|
|
279
|
+
* answer whether the credential was killed, never worked, or belongs to
|
|
280
|
+
* another account, so without this a `mint_revoked_*` that minted nothing, an
|
|
281
|
+
* expiry over a token that never worked, or a `scoped_token` minted on the
|
|
282
|
+
* wrong account would pass every row its principal backs; with it, the
|
|
283
|
+
* principal's refusal can only come from the state the fixture put it in (the
|
|
284
|
+
* revocation, the expiry, the scope).
|
|
288
285
|
*
|
|
289
286
|
* @param options - the transport, endpoint, credential and expected account
|
|
290
287
|
* @throws Error naming the accessor when the credential does not answer as the account
|
|
@@ -298,13 +295,17 @@ export const assert_credential_authenticates = async (options) => {
|
|
|
298
295
|
const response = await transport(rpc_path, {
|
|
299
296
|
method: 'POST',
|
|
300
297
|
headers: { 'Content-Type': 'application/json', ...headers },
|
|
301
|
-
body: JSON.stringify({
|
|
298
|
+
body: JSON.stringify({
|
|
299
|
+
jsonrpc: '2.0',
|
|
300
|
+
method: account_verify_action_spec.method,
|
|
301
|
+
id: account_verify_action_spec.method
|
|
302
|
+
})
|
|
302
303
|
});
|
|
303
304
|
const body = (await response.json().catch(() => undefined));
|
|
304
305
|
const parsed = parse(VerifyResponseShape, body?.result);
|
|
305
306
|
if (response.status !== 200 || !parsed.ok || parsed.value.id !== account_id) {
|
|
306
|
-
throw new Error(`${accessor}: the credential did not authenticate as account ${account_id}
|
|
307
|
-
|
|
307
|
+
throw new Error(`${accessor}: the credential did not authenticate as account ${account_id} — ` +
|
|
308
|
+
`${account_verify_action_spec.method} answered ${response.status} ${JSON.stringify(body)}`);
|
|
308
309
|
}
|
|
309
310
|
};
|
|
310
311
|
/** Structural subset of `account_token_create`'s output that the revoked-token mint reads. */
|
|
@@ -316,7 +317,7 @@ const SessionListResponseShape = strip_object({
|
|
|
316
317
|
/** Structural subset of `account_*_revoke`'s output. */
|
|
317
318
|
const RevokeResponseShape = strip_object({ revoked: literal(true) });
|
|
318
319
|
/** Structural subset of `_testing_shorten_credential_expiry`'s output. */
|
|
319
|
-
const ShortenResponseShape = strip_object({ api_tokens: number });
|
|
320
|
+
const ShortenResponseShape = strip_object({ sessions: number, api_tokens: number });
|
|
320
321
|
/** Structural subset of `_testing_reset`'s output. */
|
|
321
322
|
const TestingResetResponseShape = strip_object({
|
|
322
323
|
account: strip_object({ id: Uuid, username: string }),
|
|
@@ -583,14 +584,14 @@ const create_keeper_transport = (handle, cookie_name, session_cookie) => create_
|
|
|
583
584
|
initial_cookies: [`${cookie_name}=${session_cookie}`]
|
|
584
585
|
});
|
|
585
586
|
/**
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* credential as browser-context.
|
|
589
|
-
* daemon-token calls (the rebuilt handle's
|
|
587
|
+
* The daemon-token twin of `create_keeper_transport`: no cookie jar, so a
|
|
588
|
+
* daemon-token call carries that credential alone, and `origin: null` so the
|
|
589
|
+
* daemon-token middleware doesn't discard the credential as browser-context.
|
|
590
|
+
* Used for the per-test `_testing_*` daemon-token calls (the rebuilt handle's
|
|
591
|
+
* `keeper_daemon_transport`).
|
|
590
592
|
*/
|
|
591
|
-
const create_keeper_daemon_transport = (handle
|
|
593
|
+
const create_keeper_daemon_transport = (handle) => create_fetch_transport({
|
|
592
594
|
base_url: handle.config.base_url,
|
|
593
|
-
initial_cookies: [`${cookie_name}=${session_cookie}`],
|
|
594
595
|
origin: null
|
|
595
596
|
});
|
|
596
597
|
/**
|
|
@@ -649,10 +650,8 @@ export const default_cross_process_setup = (handle, options) => {
|
|
|
649
650
|
// `session_cookie` for any keeper-acting calls this test makes
|
|
650
651
|
// (e.g. `fixture.create_account()`'s `invite_create` step).
|
|
651
652
|
const keeper_transport = create_keeper_transport(handle, cookie_name, keeper.session_cookie);
|
|
652
|
-
//
|
|
653
|
-
|
|
654
|
-
// cookie, so rebuild it against the freshly re-seeded keeper.
|
|
655
|
-
const keeper_daemon_transport = create_keeper_daemon_transport(handle, cookie_name, keeper.session_cookie);
|
|
653
|
+
// a fresh cookie-free daemon-token transport per test
|
|
654
|
+
const keeper_daemon_transport = create_keeper_daemon_transport(handle);
|
|
656
655
|
const refreshed_handle = {
|
|
657
656
|
...handle,
|
|
658
657
|
keeper_transport,
|
|
@@ -692,6 +691,25 @@ export const default_cross_process_setup = (handle, options) => {
|
|
|
692
691
|
for (const [username, seeded] of Object.entries(seeded_extras)) {
|
|
693
692
|
extra_accounts[username] = to_test_account(seeded, cookie_name);
|
|
694
693
|
}
|
|
694
|
+
// The expired-credential mints' shared shape: a fresh account, its
|
|
695
|
+
// credential proven live, then every credential of the account pulled
|
|
696
|
+
// in through the backdoor and waited out — refused for the expiry alone.
|
|
697
|
+
const mint_expired_account = async (accessor, kind, credential) => {
|
|
698
|
+
const other = await create_account();
|
|
699
|
+
await assert_credential_authenticates({
|
|
700
|
+
transport: create_fetch_transport({ base_url: handle.config.base_url, origin: null }),
|
|
701
|
+
rpc_path: handle.config.rpc_path,
|
|
702
|
+
headers: credential(other),
|
|
703
|
+
account_id: other.account.id,
|
|
704
|
+
accessor
|
|
705
|
+
});
|
|
706
|
+
const shortened = parse_capture_answer('_testing_shorten_credential_expiry', ShortenResponseShape, await rpc_via_transport(refreshed_handle.keeper_daemon_transport, handle.config.rpc_path, '_testing_shorten_credential_expiry', { account_id: other.account.id, seconds: EXPIRED_CREDENTIAL_SHORTEN_SECONDS }, handle.config.name, { [DAEMON_TOKEN_HEADER]: handle.daemon_token }));
|
|
707
|
+
if (shortened[kind] < 1) {
|
|
708
|
+
throw new Error(`${accessor}: _testing_shorten_credential_expiry(${handle.config.name}) shortened no ${kind}`);
|
|
709
|
+
}
|
|
710
|
+
await new Promise((resolve) => setTimeout(resolve, EXPIRED_CREDENTIAL_WAIT_MS));
|
|
711
|
+
return other;
|
|
712
|
+
};
|
|
695
713
|
// Per-test transport — fresh jar carrying the new keeper's cookie
|
|
696
714
|
// so requests authenticate as the keeper without callers having to
|
|
697
715
|
// thread cookies manually. Tests acting as the fresh keeper use
|
|
@@ -724,17 +742,11 @@ export const default_cross_process_setup = (handle, options) => {
|
|
|
724
742
|
const answer = await capture_via_daemon(refreshed_handle, '_testing_db_invariants', DbInvariantRows);
|
|
725
743
|
assert_db_invariant_rows(answer.rows, handle.config.name, exclude_db_invariants);
|
|
726
744
|
},
|
|
727
|
-
// Forge over the wire — the cross-process driver has no keyring,
|
|
728
|
-
// so `_testing_mint_session` mints the backdated row + signs the
|
|
729
|
-
// cookie server-side over the keeper's daemon-token channel.
|
|
730
745
|
mint_expired_session: async () => {
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
`${JSON.stringify(raw)} (${format_issues(parsed.issues)})`);
|
|
736
|
-
}
|
|
737
|
-
return `${cookie_name}=${parsed.value.session_cookie}`;
|
|
746
|
+
const other = await mint_expired_account('mint_expired_session', 'sessions', (account) => ({
|
|
747
|
+
cookie: `${cookie_name}=${account.session_cookie}`
|
|
748
|
+
}));
|
|
749
|
+
return `${cookie_name}=${other.session_cookie}`;
|
|
738
750
|
},
|
|
739
751
|
mint_revoked_session: async () => {
|
|
740
752
|
// a second keeper session over the production login, so the
|
|
@@ -786,19 +798,9 @@ export const default_cross_process_setup = (handle, options) => {
|
|
|
786
798
|
return minted.token;
|
|
787
799
|
},
|
|
788
800
|
mint_expired_token: async () => {
|
|
789
|
-
const other = await
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
rpc_path: handle.config.rpc_path,
|
|
793
|
-
headers: { authorization: `Bearer ${other.api_token}` },
|
|
794
|
-
account_id: other.account.id,
|
|
795
|
-
accessor: 'mint_expired_token'
|
|
796
|
-
});
|
|
797
|
-
const shortened = parse_capture_answer('_testing_shorten_credential_expiry', ShortenResponseShape, await rpc_via_transport(refreshed_handle.keeper_daemon_transport, handle.config.rpc_path, '_testing_shorten_credential_expiry', { account_id: other.account.id, seconds: EXPIRED_TOKEN_SHORTEN_SECONDS }, handle.config.name, { [DAEMON_TOKEN_HEADER]: handle.daemon_token }));
|
|
798
|
-
if (shortened.api_tokens < 1) {
|
|
799
|
-
throw new Error(`mint_expired_token: _testing_shorten_credential_expiry(${handle.config.name}) shortened no token`);
|
|
800
|
-
}
|
|
801
|
-
await new Promise((resolve) => setTimeout(resolve, EXPIRED_TOKEN_WAIT_MS));
|
|
801
|
+
const other = await mint_expired_account('mint_expired_token', 'api_tokens', (account) => ({
|
|
802
|
+
authorization: `Bearer ${account.api_token}`
|
|
803
|
+
}));
|
|
802
804
|
return other.api_token;
|
|
803
805
|
}
|
|
804
806
|
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { type Schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
|
+
import type { Db } from '../../db/db.js';
|
|
4
|
+
import { type FetchTransport } from '../transports/fetch_transport.js';
|
|
5
|
+
import type { BackendConfig } from './backend_config.js';
|
|
6
|
+
import { type RpcResult } from './cross_rpc.js';
|
|
7
|
+
import { type BackendHandle } from './spawn_backend.js';
|
|
8
|
+
/** The backdoors every shared-database suite drives: the drain and the invariants. */
|
|
9
|
+
export declare const SHARED_DATABASE_BACKDOORS: readonly ["_testing_drain_effects", "_testing_db_invariants"];
|
|
10
|
+
/** One table's content: its row count and a digest of its rows as text, in order. */
|
|
11
|
+
export interface SharedDatabaseTableContent {
|
|
12
|
+
readonly rows: number;
|
|
13
|
+
readonly digest: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The migrations a database holds (with when each was applied) and every
|
|
17
|
+
* table's content, keyed `schema.table` — a row written, deleted or rewritten
|
|
18
|
+
* in place changes its table's digest.
|
|
19
|
+
*/
|
|
20
|
+
export interface SharedDatabaseSnapshot {
|
|
21
|
+
readonly schema_version: ReadonlyArray<Record<string, unknown>>;
|
|
22
|
+
readonly tables: Readonly<Record<string, SharedDatabaseTableContent>>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Read the migrations and every table's content over `db`. Read it after the
|
|
26
|
+
* backends' drains (`drain_backend_effects`), or a detached write may land
|
|
27
|
+
* after it.
|
|
28
|
+
*
|
|
29
|
+
* @param db - a direct connection to the shared database
|
|
30
|
+
* @returns the snapshot
|
|
31
|
+
*/
|
|
32
|
+
export declare const read_shared_database_snapshot: (db: Db) => Promise<SharedDatabaseSnapshot>;
|
|
33
|
+
/**
|
|
34
|
+
* The tables whose content differs between two snapshots, sorted — a table
|
|
35
|
+
* present in only one counts as changed.
|
|
36
|
+
*
|
|
37
|
+
* @param before - the earlier snapshot
|
|
38
|
+
* @param after - the later snapshot
|
|
39
|
+
* @returns the changed tables' `schema.table` keys
|
|
40
|
+
*/
|
|
41
|
+
export declare const to_changed_tables: (before: SharedDatabaseSnapshot, after: SharedDatabaseSnapshot) => Array<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Each way `configs` can't share `database_url`: they must name it in
|
|
44
|
+
* `DATABASE_URL` (compared as exact strings, so two spellings of one database
|
|
45
|
+
* are refused), share the session cookie name and a set
|
|
46
|
+
* `SECRET_FUZ_COOKIE_KEYS` (a cookie one spine signs, another must verify),
|
|
47
|
+
* keep a startup reset off (`FUZ_TESTING_RESET_DB_ON_STARTUP` unset or a false
|
|
48
|
+
* stringbool, as the Rust spine parses it), and declare the
|
|
49
|
+
* `SHARED_DATABASE_BACKDOORS`.
|
|
50
|
+
*
|
|
51
|
+
* @param configs - the backends that run over the database
|
|
52
|
+
* @param database_url - the `postgres://` database they share
|
|
53
|
+
* @returns the problems, empty when they can share it
|
|
54
|
+
*/
|
|
55
|
+
export declare const to_shared_database_problems: (configs: ReadonlyArray<BackendConfig>, database_url: string) => Array<string>;
|
|
56
|
+
/**
|
|
57
|
+
* A spawned backend, held where an `afterEach` or `afterAll` can reach it: a
|
|
58
|
+
* test that times out abandons its body, which never tears down, and the next
|
|
59
|
+
* spawn would find the port taken.
|
|
60
|
+
*/
|
|
61
|
+
export interface LiveBackend {
|
|
62
|
+
handle: BackendHandle | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Spawn `config`, run `body`, then tear down — a teardown failure (an exit
|
|
66
|
+
* other than `0`, an unexpected error in the log) fails the caller. A failed
|
|
67
|
+
* body's teardown is logged beside the body's error rather than replacing it.
|
|
68
|
+
* The handle sits in `live` while the backend runs.
|
|
69
|
+
*
|
|
70
|
+
* @param config - the backend to spawn
|
|
71
|
+
* @param live - where the running handle is held
|
|
72
|
+
* @param body - what to run against it
|
|
73
|
+
* @returns what `body` returned
|
|
74
|
+
*/
|
|
75
|
+
export declare const with_live_backend: <T>(config: BackendConfig, live: LiveBackend, body: (handle: BackendHandle) => Promise<T>) => Promise<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Tear down a backend left running — one whose test timed out — logging a
|
|
78
|
+
* failed teardown rather than throwing.
|
|
79
|
+
*
|
|
80
|
+
* @param live - the holder, cleared
|
|
81
|
+
*/
|
|
82
|
+
export declare const teardown_live_backend: (live: LiveBackend) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* A transport on `config`'s backend, holding `cookies` when given. `origin:
|
|
85
|
+
* null` sends no `Origin`, as a bearer or daemon token requires.
|
|
86
|
+
*
|
|
87
|
+
* @param config - the backend
|
|
88
|
+
* @param cookies - `Set-Cookie` lines to start the jar with
|
|
89
|
+
* @param origin - `null` for an Origin-free transport
|
|
90
|
+
* @returns the transport
|
|
91
|
+
*/
|
|
92
|
+
export declare const backend_transport: (config: BackendConfig, cookies?: ReadonlyArray<string>, origin?: null) => FetchTransport;
|
|
93
|
+
/**
|
|
94
|
+
* `method` on `config`'s RPC endpoint over `transport`.
|
|
95
|
+
*
|
|
96
|
+
* @param config - the backend
|
|
97
|
+
* @param transport - the transport carrying the credential
|
|
98
|
+
* @param method - the RPC method
|
|
99
|
+
* @param params - its params
|
|
100
|
+
* @param headers - extra request headers
|
|
101
|
+
* @returns the answer
|
|
102
|
+
*/
|
|
103
|
+
export declare const backend_rpc: (config: BackendConfig, transport: FetchTransport, method: string, params: unknown, headers?: Record<string, string>) => Promise<RpcResult>;
|
|
104
|
+
/**
|
|
105
|
+
* `method` on a fresh transport holding `cookies`, its output parsed.
|
|
106
|
+
*
|
|
107
|
+
* @param config - the backend
|
|
108
|
+
* @param cookies - the session's `Set-Cookie` lines
|
|
109
|
+
* @param method - the RPC method
|
|
110
|
+
* @param params - its params
|
|
111
|
+
* @param output - the output schema it must answer
|
|
112
|
+
* @returns the parsed output
|
|
113
|
+
*/
|
|
114
|
+
export declare const backend_rpc_as: <T>(config: BackendConfig, cookies: ReadonlyArray<string>, method: string, params: unknown, output: Schema<T, any>) => Promise<T>;
|
|
115
|
+
/**
|
|
116
|
+
* A daemon-token backdoor call: Origin-free and cookie-free, as the daemon
|
|
117
|
+
* token requires.
|
|
118
|
+
*
|
|
119
|
+
* @param handle - the backend, whose daemon token authenticates
|
|
120
|
+
* @param method - the backdoor method
|
|
121
|
+
* @returns the answer
|
|
122
|
+
*/
|
|
123
|
+
export declare const backend_daemon_rpc: (handle: BackendHandle, method: string) => Promise<RpcResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Await the backend's detached writes (`_testing_drain_effects`), so what it
|
|
126
|
+
* did is all on disk before a snapshot or teardown.
|
|
127
|
+
*
|
|
128
|
+
* @param handle - the backend
|
|
129
|
+
*/
|
|
130
|
+
export declare const drain_backend_effects: (handle: BackendHandle) => Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Assert no database invariant is broken, as `handle`'s backend reads them
|
|
133
|
+
* (`_testing_db_invariants`).
|
|
134
|
+
*
|
|
135
|
+
* @param handle - the backend
|
|
136
|
+
*/
|
|
137
|
+
export declare const assert_backend_invariants: (handle: BackendHandle) => Promise<void>;
|
|
138
|
+
/** A REST answer: its status, parsed body (`null` when empty) and `Set-Cookie` lines. */
|
|
139
|
+
export interface BackendJsonAnswer {
|
|
140
|
+
readonly status: number;
|
|
141
|
+
readonly body: unknown;
|
|
142
|
+
readonly set_cookies: Array<string>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A JSON `POST` to a REST route.
|
|
146
|
+
*
|
|
147
|
+
* @param transport - the transport carrying the credential
|
|
148
|
+
* @param path - the route path
|
|
149
|
+
* @param body - the JSON body
|
|
150
|
+
* @returns the answer
|
|
151
|
+
*/
|
|
152
|
+
export declare const backend_post_json: (transport: FetchTransport, path: string, body: unknown) => Promise<BackendJsonAnswer>;
|
|
153
|
+
/**
|
|
154
|
+
* Who a credential authenticates as on `config`'s backend (`account_verify`):
|
|
155
|
+
* an account id, or `null` on a 401 `authentication_required`.
|
|
156
|
+
*
|
|
157
|
+
* @param config - the backend
|
|
158
|
+
* @param credential - a session's `Set-Cookie` lines or a bearer token
|
|
159
|
+
* @returns the account id, or `null` when refused
|
|
160
|
+
*/
|
|
161
|
+
export declare const verified_account_id: (config: BackendConfig, credential: {
|
|
162
|
+
cookies: ReadonlyArray<string>;
|
|
163
|
+
} | {
|
|
164
|
+
bearer: string;
|
|
165
|
+
}) => Promise<string | null>;
|
|
166
|
+
/**
|
|
167
|
+
* Whether a session passes the admin gate: `invite_list` answered (`true`) or
|
|
168
|
+
* refused 403 `insufficient_permissions` (`false`).
|
|
169
|
+
*
|
|
170
|
+
* @param config - the backend
|
|
171
|
+
* @param cookies - the session's `Set-Cookie` lines
|
|
172
|
+
* @returns whether the gate passes
|
|
173
|
+
*/
|
|
174
|
+
export declare const passes_admin_gate: (config: BackendConfig, cookies: ReadonlyArray<string>) => Promise<boolean>;
|
|
175
|
+
//# sourceMappingURL=shared_database_backends.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared_database_backends.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/shared_database_backends.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAc9B,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAQzC,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAA+C,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWvE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,+DAG5B,CAAC;AAEX,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAA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