@fuzdev/fuz_app 0.87.0 → 0.88.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/action_rpc.js +1 -1
- package/dist/actions/register_action_ws.js +1 -1
- package/dist/auth/CLAUDE.md +15 -0
- package/dist/auth/account_actions.js +1 -1
- package/dist/auth/account_route_schema.d.ts +146 -0
- package/dist/auth/account_route_schema.d.ts.map +1 -0
- package/dist/auth/account_route_schema.js +141 -0
- package/dist/auth/account_routes.d.ts +0 -79
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +15 -110
- package/dist/auth/audit_log_route_schema.d.ts +32 -0
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -0
- package/dist/auth/audit_log_route_schema.js +36 -0
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +2 -12
- package/dist/auth/bearer_auth.js +1 -1
- package/dist/auth/bootstrap_route_schema.d.ts +85 -0
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -0
- package/dist/auth/bootstrap_route_schema.js +56 -0
- package/dist/auth/bootstrap_routes.d.ts +0 -20
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +4 -35
- package/dist/auth/signup_route_schema.d.ts +53 -0
- package/dist/auth/signup_route_schema.d.ts.map +1 -0
- package/dist/auth/signup_route_schema.js +59 -0
- package/dist/auth/signup_routes.d.ts +0 -26
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +8 -40
- package/dist/http/CLAUDE.md +2 -1
- package/dist/http/client_ip.d.ts +15 -0
- package/dist/http/client_ip.d.ts.map +1 -0
- package/dist/http/client_ip.js +13 -0
- package/dist/http/proxy.d.ts +0 -7
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +0 -7
- package/dist/realtime/sse.d.ts +0 -2
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +1 -2
- package/dist/realtime/sse_constants.d.ts +17 -0
- package/dist/realtime/sse_constants.d.ts.map +1 -0
- package/dist/realtime/sse_constants.js +16 -0
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +1 -1
- package/dist/testing/app_server.d.ts +0 -15
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +1 -15
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts +143 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -0
- package/dist/testing/cross_backend/in_process_setup.js +166 -0
- package/dist/testing/cross_backend/setup.d.ts +31 -140
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +11 -171
- package/dist/testing/cross_backend/sse_round_trip.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +2 -1
- package/dist/testing/integration.js +2 -2
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -1
- package/dist/testing/sse_round_trip.d.ts +1 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +1 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +7 -9
- package/dist/testing/test_credentials.d.ts +23 -0
- package/dist/testing/test_credentials.d.ts.map +1 -0
- package/dist/testing/test_credentials.js +22 -0
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the resolved client IP off the Hono context.
|
|
3
|
+
*
|
|
4
|
+
* Split from `proxy.ts` (which pulls `hono/utils/ipaddr` for trusted-proxy
|
|
5
|
+
* CIDR matching) so dispatch + route modules that only need to *read* the IP
|
|
6
|
+
* stay free of that value import — and the cross-process test surface that
|
|
7
|
+
* imports them stays free of the optional `hono` peer. The IP itself is set on
|
|
8
|
+
* the context by the trusted-proxy middleware in `proxy.ts`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** Client IP resolved by the trusted-proxy middleware, or `'unknown'` if unset. */
|
|
13
|
+
export const get_client_ip = (c) => c.get('client_ip') || 'unknown';
|
package/dist/http/proxy.d.ts
CHANGED
|
@@ -154,11 +154,4 @@ export declare const create_proxy_middleware: (options: ProxyOptions) => Middlew
|
|
|
154
154
|
* @param options - trusted proxy configuration
|
|
155
155
|
*/
|
|
156
156
|
export declare const create_proxy_middleware_spec: (options: ProxyOptions) => MiddlewareSpec;
|
|
157
|
-
/**
|
|
158
|
-
* Read the resolved client IP from the Hono context.
|
|
159
|
-
*
|
|
160
|
-
* Returns `'unknown'` if the proxy middleware has not run or no IP is available.
|
|
161
|
-
* Set by `create_proxy_middleware`.
|
|
162
|
-
*/
|
|
163
|
-
export declare const get_client_ip: (c: Context) => string;
|
|
164
157
|
//# sourceMappingURL=proxy.d.ts.map
|
package/dist/http/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAGzD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,MAA6B,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,sFAAsF;IACtF,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,CAA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I,SAAS,YAAY,KAAG,iBAyC/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,YAAY,KAAG,cAInE,CAAC"}
|
package/dist/http/proxy.js
CHANGED
|
@@ -298,10 +298,3 @@ export const create_proxy_middleware_spec = (options) => ({
|
|
|
298
298
|
path: '*',
|
|
299
299
|
handler: create_proxy_middleware(options),
|
|
300
300
|
});
|
|
301
|
-
/**
|
|
302
|
-
* Read the resolved client IP from the Hono context.
|
|
303
|
-
*
|
|
304
|
-
* Returns `'unknown'` if the proxy middleware has not run or no IP is available.
|
|
305
|
-
* Set by `create_proxy_middleware`.
|
|
306
|
-
*/
|
|
307
|
-
export const get_client_ip = (c) => c.get('client_ip') || 'unknown';
|
package/dist/realtime/sse.d.ts
CHANGED
|
@@ -53,8 +53,6 @@ export declare const create_sse_response: <T = unknown>(c: Context, log: Logger)
|
|
|
53
53
|
response: Response;
|
|
54
54
|
stream: SseStream<T>;
|
|
55
55
|
};
|
|
56
|
-
/** SSE comment sent on connect to flush headers through proxies. Exported for test assertions. */
|
|
57
|
-
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
58
56
|
/** Spec for a push event — declares params schema, description, and channel. */
|
|
59
57
|
export interface EventSpec {
|
|
60
58
|
/** Event method name, used as the JSON-RPC notification `method`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;A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I,EAAE,CAAC,KAAK,IAAI,CAAA;CAAC,EAC5D,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,KAAK,MAAM,KACT;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAmBhD,CAAC"}
|
package/dist/realtime/sse.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { streamSSE } from 'hono/streaming';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
import { DEV } from 'esm-env';
|
|
12
|
+
import { SSE_CONNECTED_COMMENT } from './sse_constants.js';
|
|
12
13
|
/**
|
|
13
14
|
* Create an SSE response for a Hono context.
|
|
14
15
|
*
|
|
@@ -74,8 +75,6 @@ export const create_sse_response = (c, log) => {
|
|
|
74
75
|
});
|
|
75
76
|
return { response, stream: sse_stream };
|
|
76
77
|
};
|
|
77
|
-
/** SSE comment sent on connect to flush headers through proxies. Exported for test assertions. */
|
|
78
|
-
export const SSE_CONNECTED_COMMENT = `: connected\n\n`;
|
|
79
78
|
/**
|
|
80
79
|
* Create a broadcaster that validates events in DEV mode.
|
|
81
80
|
*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hono-free SSE wire constants.
|
|
3
|
+
*
|
|
4
|
+
* Split from `sse.ts` (which pulls `hono/streaming` via `streamSSE`) so the
|
|
5
|
+
* stream-framing constants are importable by cross-process test suites
|
|
6
|
+
* asserting on the wire without dragging in the in-process Hono SSE
|
|
7
|
+
* implementation.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The comment line written immediately on SSE stream open. Flushes headers +
|
|
13
|
+
* confirms the connection is live before the first real event. Cross-process
|
|
14
|
+
* SSE tests assert the stream emits this on connect.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
17
|
+
//# sourceMappingURL=sse_constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse_constants.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse_constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hono-free SSE wire constants.
|
|
3
|
+
*
|
|
4
|
+
* Split from `sse.ts` (which pulls `hono/streaming` via `streamSSE`) so the
|
|
5
|
+
* stream-framing constants are importable by cross-process test suites
|
|
6
|
+
* asserting on the wire without dragging in the in-process Hono SSE
|
|
7
|
+
* implementation.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The comment line written immediately on SSE stream open. Flushes headers +
|
|
13
|
+
* confirms the connection is live before the first real event. Cross-process
|
|
14
|
+
* SSE tests assert the stream emits this on connect.
|
|
15
|
+
*/
|
|
16
|
+
export const SSE_CONNECTED_COMMENT = `: connected\n\n`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgC7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAa,KAAK,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgC7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAa,KAAK,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAWzE,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAC,SAAS,EAAc,MAAM,0BAA0B,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,uCAAuC;IACvC,YAAY,EAAE,mBAAmB,CAAC;IAClC,uFAAuF;IACvF,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,4GAA4G;IAC5G,KAAK,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,mCAAmC,KAC1C,IAi3BF,CAAC"}
|
|
@@ -28,7 +28,7 @@ import './assert_dev_env.js';
|
|
|
28
28
|
import { describe, test, assert, afterAll } from 'vitest';
|
|
29
29
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
30
30
|
import { GRANT_PATH_ADMIN } from '../auth/grant_path_schema.js';
|
|
31
|
-
import { DEFAULT_TEST_PASSWORD } from './
|
|
31
|
+
import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
|
|
32
32
|
import { role_grant_offer_and_accept } from './role_grant_helpers.js';
|
|
33
33
|
import { find_auth_route } from './integration_helpers.js';
|
|
34
34
|
import { ErrorCoverageCollector, assert_error_coverage, DEFAULT_INTEGRATION_ERROR_COVERAGE, } from './error_coverage.js';
|
|
@@ -34,21 +34,6 @@ import type { RpcEndpointsSuiteOption } from './rpc_helpers.js';
|
|
|
34
34
|
export declare const stub_password_deps: PasswordHashDeps;
|
|
35
35
|
/** 64-hex-char test cookie secret — deterministic, never used in production. */
|
|
36
36
|
export declare const TEST_COOKIE_SECRET: string;
|
|
37
|
-
/**
|
|
38
|
-
* Default password for bootstrapped test accounts. Shared between the
|
|
39
|
-
* in-process keeper bootstrap (`bootstrap_test_keeper`,
|
|
40
|
-
* `create_test_account_with_credentials`, `create_test_app_server`,
|
|
41
|
-
* `TestApp.create_account`) and the cross-process bootstrap
|
|
42
|
-
* (`cross_backend/setup.ts`). The two paths MUST agree — when they
|
|
43
|
-
* diverged during the 3d cross-process lift, ~20 login tests 401'd
|
|
44
|
-
* silently against the cross-process backend because the per-test
|
|
45
|
-
* fixture minted accounts under a different default than the
|
|
46
|
-
* integration suite's hardcoded login bodies expected. Consumers
|
|
47
|
-
* hardcoding the literal string in test bodies should import this
|
|
48
|
-
* constant instead so a future divergence becomes a typecheck miss
|
|
49
|
-
* rather than a runtime password mismatch.
|
|
50
|
-
*/
|
|
51
|
-
export declare const DEFAULT_TEST_PASSWORD = "test-password-123";
|
|
52
37
|
/**
|
|
53
38
|
* Options for `bootstrap_test_keeper` and `create_test_account_with_credentials`.
|
|
54
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,KAAK,EAAC,IAAI,EAAC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W,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,sBAAsB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,4EAA4E;IAC5E,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GACzC,SAAS,gCAAgC,KACvC,OAAO,CAAC,mBAAmB,CAuE7B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Logger } from '@fuzdev/fuz_util/log.js';
|
|
4
|
+
import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
|
|
4
5
|
import { ROLE_KEEPER } from '../auth/role_schema.js';
|
|
5
6
|
import { create_validated_keyring } from '../auth/keyring.js';
|
|
6
7
|
import { generate_api_token } from '../auth/api_token.js';
|
|
@@ -28,21 +29,6 @@ export const stub_password_deps = {
|
|
|
28
29
|
};
|
|
29
30
|
/** 64-hex-char test cookie secret — deterministic, never used in production. */
|
|
30
31
|
export const TEST_COOKIE_SECRET = 'a'.repeat(64);
|
|
31
|
-
/**
|
|
32
|
-
* Default password for bootstrapped test accounts. Shared between the
|
|
33
|
-
* in-process keeper bootstrap (`bootstrap_test_keeper`,
|
|
34
|
-
* `create_test_account_with_credentials`, `create_test_app_server`,
|
|
35
|
-
* `TestApp.create_account`) and the cross-process bootstrap
|
|
36
|
-
* (`cross_backend/setup.ts`). The two paths MUST agree — when they
|
|
37
|
-
* diverged during the 3d cross-process lift, ~20 login tests 401'd
|
|
38
|
-
* silently against the cross-process backend because the per-test
|
|
39
|
-
* fixture minted accounts under a different default than the
|
|
40
|
-
* integration suite's hardcoded login bodies expected. Consumers
|
|
41
|
-
* hardcoding the literal string in test bodies should import this
|
|
42
|
-
* constant instead so a future divergence becomes a typecheck miss
|
|
43
|
-
* rather than a runtime password mismatch.
|
|
44
|
-
*/
|
|
45
|
-
export const DEFAULT_TEST_PASSWORD = 'test-password-123';
|
|
46
32
|
// Module-level PGlite factory for create_test_app_server when no db is provided.
|
|
47
33
|
// Shares the WASM instance cache from test_db.ts, avoiding redundant cold starts
|
|
48
34
|
// within the same vitest worker thread. Schema is reset on each create() call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_completeness.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/audit_completeness.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA4B7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"audit_completeness.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/audit_completeness.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA4B7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAU9D,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AA2B1B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAC,SAAS,EAAc,MAAM,0BAA0B,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;OAMG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,uCAAuC;IACvC,YAAY,EAAE,mBAAmB,CAAC;IAClC,yEAAyE;IACzE,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;CACvC;AA8FD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,4BAA4B,KAAG,IAomBzF,CAAC"}
|
|
@@ -25,7 +25,7 @@ import './assert_dev_env.js';
|
|
|
25
25
|
import { describe, test, assert } from 'vitest';
|
|
26
26
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
27
27
|
import { AUDIT_EVENT_TYPES, } from '../auth/audit_log_schema.js';
|
|
28
|
-
import { DEFAULT_TEST_PASSWORD } from './
|
|
28
|
+
import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
|
|
29
29
|
import { find_auth_route } from './integration_helpers.js';
|
|
30
30
|
import { rpc_call_for_spec, require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup, } from './rpc_helpers.js';
|
|
31
31
|
import { role_grant_offer_and_accept } from './role_grant_helpers.js';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import type { RouteSpec } from '../../http/route_spec.js';
|
|
3
|
+
import type { AppSurfaceSpec } from '../../http/surface.js';
|
|
4
|
+
import type { BootstrapServerOptions } from '../../server/app_server.js';
|
|
5
|
+
import type { AppServerContext } from '../../server/app_server_context.js';
|
|
6
|
+
import type { SessionOptions } from '../../auth/session_cookie.js';
|
|
7
|
+
import { type CreateTestAppOptions, type SuiteAppOptions } from '../app_server.js';
|
|
8
|
+
import { type RpcEndpointsSuiteOption } from '../rpc_helpers.js';
|
|
9
|
+
import { type BackendCapabilities } from './capabilities.js';
|
|
10
|
+
import { type SetupTest, type ExtraAccountSpec } from './setup.js';
|
|
11
|
+
/**
|
|
12
|
+
* Options for `default_in_process_setup`. Extends `CreateTestAppOptions`
|
|
13
|
+
* with the same `extra_accounts` slot the cross-process variant accepts
|
|
14
|
+
* — both transports observe the same bootstrap-time secondary set so
|
|
15
|
+
* suite bodies can read `fixture.extra_accounts[username]` uniformly.
|
|
16
|
+
*/
|
|
17
|
+
export interface InProcessSetupOptions extends CreateTestAppOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Additional accounts seeded at this transport's bootstrap-equivalent
|
|
20
|
+
* step. See `ExtraAccountSpec` for the cradle-only-bypass rationale.
|
|
21
|
+
* Most suites pass `undefined` / `[]`; the `ROLE_KEEPER` probe (in
|
|
22
|
+
* `describe_standard_admin_integration_tests`) is the primary user.
|
|
23
|
+
*/
|
|
24
|
+
readonly extra_accounts?: ReadonlyArray<ExtraAccountSpec>;
|
|
25
|
+
/**
|
|
26
|
+
* Additional actor names to seed on the bootstrapped keeper — exposed on
|
|
27
|
+
* `fixture.extra_actors`. See `CrossProcessSetupOptions.extra_actors` /
|
|
28
|
+
* `TestFixtureBase.extra_actors`. Seeded directly against the live backend
|
|
29
|
+
* DB (in-process has no wire hop).
|
|
30
|
+
*/
|
|
31
|
+
readonly extra_actors?: ReadonlyArray<string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build a `SetupTest` that creates a fresh `TestApp` per call via
|
|
35
|
+
* `create_test_app` and projects it into the `TestFixture` shape.
|
|
36
|
+
*
|
|
37
|
+
* Same factory inputs `create_test_app` already takes — this helper
|
|
38
|
+
* is a projection layer, not a new lifecycle. fuz_app's own `src/test/`
|
|
39
|
+
* and consumer suites pass `default_in_process_setup({...factory_inputs})`
|
|
40
|
+
* in place of the old per-suite factory-input bundle. The `extra_accounts`
|
|
41
|
+
* slot (see `InProcessSetupOptions`) seeds bootstrap-time secondaries
|
|
42
|
+
* directly via `create_test_account_with_credentials` against the same
|
|
43
|
+
* DB the keeper just landed on — mirrors the cross-process
|
|
44
|
+
* `_testing_reset` cradle so suite bodies read
|
|
45
|
+
* `fixture.extra_accounts[username]` uniformly regardless of transport.
|
|
46
|
+
*
|
|
47
|
+
* The describe-level `auth_integration_truncate_tables` / pglite WASM
|
|
48
|
+
* cache lifecycle stays in `create_pglite_factory` / `create_describe_db`
|
|
49
|
+
* (`testing/db.ts`) — `default_in_process_setup` doesn't manage db state
|
|
50
|
+
* beyond what `create_test_app` already does.
|
|
51
|
+
*/
|
|
52
|
+
export declare const default_in_process_setup: (options: InProcessSetupOptions) => SetupTest;
|
|
53
|
+
/**
|
|
54
|
+
* Consumer-facing options for `default_in_process_suite_options` — the
|
|
55
|
+
* minimal factory inputs both `default_in_process_setup` and
|
|
56
|
+
* `create_test_app_surface_spec` consume to produce the
|
|
57
|
+
* `{setup_test, surface_source, capabilities}` bundle.
|
|
58
|
+
*/
|
|
59
|
+
export interface DefaultInProcessSuiteOptions {
|
|
60
|
+
session_options: SessionOptions<string>;
|
|
61
|
+
create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
|
|
62
|
+
rpc_endpoints?: RpcEndpointsSuiteOption;
|
|
63
|
+
/**
|
|
64
|
+
* Bootstrap config — top-level slot, single source of truth for both
|
|
65
|
+
* surface generation and live dispatch. Same precedent as
|
|
66
|
+
* `rpc_endpoints`. Discriminated by `mode`; omit for the default (no
|
|
67
|
+
* bootstrap route mounted).
|
|
68
|
+
*/
|
|
69
|
+
bootstrap?: BootstrapServerOptions;
|
|
70
|
+
app_options?: SuiteAppOptions;
|
|
71
|
+
/**
|
|
72
|
+
* Additional roles to grant the bootstrapped keeper alongside
|
|
73
|
+
* `ROLE_KEEPER` — additive, never replaces. The keeper account
|
|
74
|
+
* always holds `ROLE_KEEPER` (otherwise daemon-token auth breaks);
|
|
75
|
+
* pass extras here for suites that need additional role coverage.
|
|
76
|
+
*
|
|
77
|
+
* Admin-suite consumers pass `[ROLE_ADMIN]` so the default keeper
|
|
78
|
+
* can hit admin-gated RPC methods.
|
|
79
|
+
* `describe_standard_admin_integration_tests` and
|
|
80
|
+
* `describe_audit_completeness_tests` need this.
|
|
81
|
+
*/
|
|
82
|
+
extra_keeper_roles?: Array<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Bootstrap-time secondary accounts seeded alongside the keeper. See
|
|
85
|
+
* `ExtraAccountSpec` for the cradle-only-bypass rationale. Same shape
|
|
86
|
+
* as the cross-process `extra_accounts` option — suites read seeded
|
|
87
|
+
* accounts from `fixture.extra_accounts[username]` regardless of
|
|
88
|
+
* transport.
|
|
89
|
+
*/
|
|
90
|
+
extra_accounts?: ReadonlyArray<ExtraAccountSpec>;
|
|
91
|
+
/**
|
|
92
|
+
* Additional actor names to seed on the bootstrapped keeper — exposed on
|
|
93
|
+
* `fixture.extra_actors`. See `TestFixtureBase.extra_actors`.
|
|
94
|
+
*/
|
|
95
|
+
extra_actors?: ReadonlyArray<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Pre-built `AppSurfaceSpec` — overrides the default which calls
|
|
98
|
+
* `create_test_app_surface_spec` against the same factory inputs.
|
|
99
|
+
* Pass when surface assembly needs fields outside the shared subset
|
|
100
|
+
* (e.g. `env_schema`, `event_specs`, `ws_endpoints`, `transform_middleware`).
|
|
101
|
+
*/
|
|
102
|
+
surface_source?: AppSurfaceSpec;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build the full in-process suite bundle in a single helper invocation.
|
|
106
|
+
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
107
|
+
* factory input the Tier 1 suites read at their top level
|
|
108
|
+
* (`session_options`, `create_route_specs`, `rpc_endpoints`) — so the
|
|
109
|
+
* call site spreads once and adds only suite-specific extras
|
|
110
|
+
* (`roles`, `skip_routes`, `input_overrides`, `db_factories`, ...).
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* // Suite-extras-free call: helper output is the entire options bag.
|
|
114
|
+
* describe_round_trip_validation(default_in_process_suite_options({
|
|
115
|
+
* session_options,
|
|
116
|
+
* create_route_specs,
|
|
117
|
+
* rpc_endpoints: [rpc_endpoint_spec],
|
|
118
|
+
* }));
|
|
119
|
+
*
|
|
120
|
+
* // With suite-specific extras: spread and add.
|
|
121
|
+
* describe_standard_admin_integration_tests({
|
|
122
|
+
* ...default_in_process_suite_options({
|
|
123
|
+
* session_options, create_route_specs, rpc_endpoints,
|
|
124
|
+
* extra_keeper_roles: [ROLE_ADMIN],
|
|
125
|
+
* }),
|
|
126
|
+
* roles,
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* Suites that don't read `session_options` / `rpc_endpoints` at their
|
|
131
|
+
* top level (`round_trip`, `data_exposure`) accept the spread anyway —
|
|
132
|
+
* excess properties on spread sources aren't checked by TS, and the
|
|
133
|
+
* uniform shape keeps consumer call sites mechanical.
|
|
134
|
+
*/
|
|
135
|
+
export declare const default_in_process_suite_options: <const O extends DefaultInProcessSuiteOptions>(options: O) => {
|
|
136
|
+
setup_test: SetupTest;
|
|
137
|
+
surface_source: AppSurfaceSpec;
|
|
138
|
+
capabilities: BackendCapabilities;
|
|
139
|
+
session_options: O["session_options"];
|
|
140
|
+
create_route_specs: O["create_route_specs"];
|
|
141
|
+
rpc_endpoints: O["rpc_endpoints"];
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=in_process_setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA0B,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEpF,OAAO,EAGN,KAAK,SAAS,EAE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C;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;CA2BjC,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { ROLE_KEEPER } from '../../auth/role_schema.js';
|
|
3
|
+
import { query_create_actor } from '../../auth/account_queries.js';
|
|
4
|
+
import { create_test_app, create_test_account_with_credentials, mint_test_session, } from '../app_server.js';
|
|
5
|
+
import { create_test_app_surface_spec } from '../stubs.js';
|
|
6
|
+
import { http_transport, } from '../rpc_helpers.js';
|
|
7
|
+
import { in_process_capabilities } from './capabilities.js';
|
|
8
|
+
import { build_extra_account_fixture, EXPIRED_SESSION_OFFSET_SECONDS, } from './setup.js';
|
|
9
|
+
/**
|
|
10
|
+
* Wrap a Hono-style app into a `FetchTransport`-shaped object so the
|
|
11
|
+
* shared `TestFixtureBase.transport` type holds for both in-process and
|
|
12
|
+
* cross-process setups. In-process has no real cookie jar — the no-op
|
|
13
|
+
* `cookies()` returns `[]`; in-process tests build cookies via
|
|
14
|
+
* `fixture.create_session_headers()` instead.
|
|
15
|
+
*/
|
|
16
|
+
const in_process_fetch_transport = (app) => {
|
|
17
|
+
const call = http_transport(app);
|
|
18
|
+
const transport = ((url, init) => call(url, init));
|
|
19
|
+
return Object.assign(transport, { cookies: () => [] });
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Build a `SetupTest` that creates a fresh `TestApp` per call via
|
|
23
|
+
* `create_test_app` and projects it into the `TestFixture` shape.
|
|
24
|
+
*
|
|
25
|
+
* Same factory inputs `create_test_app` already takes — this helper
|
|
26
|
+
* is a projection layer, not a new lifecycle. fuz_app's own `src/test/`
|
|
27
|
+
* and consumer suites pass `default_in_process_setup({...factory_inputs})`
|
|
28
|
+
* in place of the old per-suite factory-input bundle. The `extra_accounts`
|
|
29
|
+
* slot (see `InProcessSetupOptions`) seeds bootstrap-time secondaries
|
|
30
|
+
* directly via `create_test_account_with_credentials` against the same
|
|
31
|
+
* DB the keeper just landed on — mirrors the cross-process
|
|
32
|
+
* `_testing_reset` cradle so suite bodies read
|
|
33
|
+
* `fixture.extra_accounts[username]` uniformly regardless of transport.
|
|
34
|
+
*
|
|
35
|
+
* The describe-level `auth_integration_truncate_tables` / pglite WASM
|
|
36
|
+
* cache lifecycle stays in `create_pglite_factory` / `create_describe_db`
|
|
37
|
+
* (`testing/db.ts`) — `default_in_process_setup` doesn't manage db state
|
|
38
|
+
* beyond what `create_test_app` already does.
|
|
39
|
+
*/
|
|
40
|
+
export const default_in_process_setup = (options) => async () => {
|
|
41
|
+
// Per-test fresh db. When `options.migration_namespaces` is set,
|
|
42
|
+
// `create_test_app` provisions an auth+extras PGlite (e.g. the cell
|
|
43
|
+
// layer); otherwise the auth-only default. Either way the factory
|
|
44
|
+
// resets + re-migrates on each `create`, so the per-test keeper
|
|
45
|
+
// bootstrap below lands on a clean DB.
|
|
46
|
+
const test_app = await create_test_app(options);
|
|
47
|
+
// Seed bootstrap-time secondaries against the same DB the keeper
|
|
48
|
+
// just landed on. Direct-insert is the only path for roles whose
|
|
49
|
+
// `grant_paths` excludes `'admin'` (e.g. `ROLE_KEEPER`) — see
|
|
50
|
+
// `ExtraAccountSpec` for why this bypass is bootstrap-cradle-only.
|
|
51
|
+
const extra_accounts = {};
|
|
52
|
+
const { cookie_name } = options.session_options;
|
|
53
|
+
for (const spec of options.extra_accounts ?? []) {
|
|
54
|
+
const seeded = await create_test_account_with_credentials({
|
|
55
|
+
db: test_app.backend.deps.db,
|
|
56
|
+
keyring: test_app.backend.keyring,
|
|
57
|
+
session_options: options.session_options,
|
|
58
|
+
password: test_app.backend.deps.password,
|
|
59
|
+
username: spec.username,
|
|
60
|
+
password_value: spec.password_value,
|
|
61
|
+
roles: [...spec.roles],
|
|
62
|
+
});
|
|
63
|
+
extra_accounts[spec.username] = build_extra_account_fixture(seeded, cookie_name);
|
|
64
|
+
}
|
|
65
|
+
// Seed additional keeper actors directly against the same DB. Mirrors
|
|
66
|
+
// the cross-process `_testing_reset` `extra_actors` path; no production
|
|
67
|
+
// wire mints a second actor, so this bootstrap-cradle insert is the
|
|
68
|
+
// only way into a multi-actor keeper state.
|
|
69
|
+
const extra_actors = [];
|
|
70
|
+
for (const name of options.extra_actors ?? []) {
|
|
71
|
+
const seeded_actor = await query_create_actor({ db: test_app.backend.deps.db }, test_app.backend.account.id, name);
|
|
72
|
+
extra_actors.push({ id: seeded_actor.id, name: seeded_actor.name });
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
transport: in_process_fetch_transport(test_app.app),
|
|
76
|
+
// In-process the wrapper is stateless and never auto-adds Origin —
|
|
77
|
+
// `options` is accepted for API symmetry with cross-process but
|
|
78
|
+
// has no observable effect.
|
|
79
|
+
fresh_transport: () => in_process_fetch_transport(test_app.app),
|
|
80
|
+
account: test_app.backend.account,
|
|
81
|
+
actor: test_app.backend.actor,
|
|
82
|
+
create_session_headers: test_app.create_session_headers,
|
|
83
|
+
create_bearer_headers: test_app.create_bearer_headers,
|
|
84
|
+
create_daemon_token_headers: test_app.create_daemon_token_headers,
|
|
85
|
+
create_account: test_app.create_account,
|
|
86
|
+
extra_accounts,
|
|
87
|
+
extra_actors,
|
|
88
|
+
// Forge directly against the live backend's DB + keyring — no wire
|
|
89
|
+
// hop needed in-process.
|
|
90
|
+
mint_expired_session: async () => {
|
|
91
|
+
const { session_cookie } = await mint_test_session({
|
|
92
|
+
db: test_app.backend.deps.db,
|
|
93
|
+
keyring: test_app.backend.keyring,
|
|
94
|
+
session_options: options.session_options,
|
|
95
|
+
account_id: test_app.backend.account.id,
|
|
96
|
+
expires_in_seconds: EXPIRED_SESSION_OFFSET_SECONDS,
|
|
97
|
+
});
|
|
98
|
+
return `${cookie_name}=${session_cookie}`;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
// NOTE: bootstrap config is read from `options.bootstrap` — top-level slot,
|
|
103
|
+
// single source of truth for both the surface spec (so the route appears in
|
|
104
|
+
// `expected_public_routes` / attack-surface iteration) AND the live
|
|
105
|
+
// `create_test_app` (so the route exists at dispatch time and returns 403
|
|
106
|
+
// `ERROR_ALREADY_BOOTSTRAPPED` matching its declared 403 schema). Same
|
|
107
|
+
// precedent as `rpc_endpoints`. Discriminated union shape (`mode: 'disabled'`
|
|
108
|
+
// | `'surface_only'` | `'live'`) replaces the old `token_path: string | null`
|
|
109
|
+
// overload that conflated three deployment intents on one channel.
|
|
110
|
+
/**
|
|
111
|
+
* Build the full in-process suite bundle in a single helper invocation.
|
|
112
|
+
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
113
|
+
* factory input the Tier 1 suites read at their top level
|
|
114
|
+
* (`session_options`, `create_route_specs`, `rpc_endpoints`) — so the
|
|
115
|
+
* call site spreads once and adds only suite-specific extras
|
|
116
|
+
* (`roles`, `skip_routes`, `input_overrides`, `db_factories`, ...).
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* // Suite-extras-free call: helper output is the entire options bag.
|
|
120
|
+
* describe_round_trip_validation(default_in_process_suite_options({
|
|
121
|
+
* session_options,
|
|
122
|
+
* create_route_specs,
|
|
123
|
+
* rpc_endpoints: [rpc_endpoint_spec],
|
|
124
|
+
* }));
|
|
125
|
+
*
|
|
126
|
+
* // With suite-specific extras: spread and add.
|
|
127
|
+
* describe_standard_admin_integration_tests({
|
|
128
|
+
* ...default_in_process_suite_options({
|
|
129
|
+
* session_options, create_route_specs, rpc_endpoints,
|
|
130
|
+
* extra_keeper_roles: [ROLE_ADMIN],
|
|
131
|
+
* }),
|
|
132
|
+
* roles,
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* Suites that don't read `session_options` / `rpc_endpoints` at their
|
|
137
|
+
* top level (`round_trip`, `data_exposure`) accept the spread anyway —
|
|
138
|
+
* excess properties on spread sources aren't checked by TS, and the
|
|
139
|
+
* uniform shape keeps consumer call sites mechanical.
|
|
140
|
+
*/
|
|
141
|
+
export const default_in_process_suite_options = (options) => ({
|
|
142
|
+
setup_test: default_in_process_setup({
|
|
143
|
+
session_options: options.session_options,
|
|
144
|
+
create_route_specs: options.create_route_specs,
|
|
145
|
+
rpc_endpoints: options.rpc_endpoints,
|
|
146
|
+
bootstrap: options.bootstrap,
|
|
147
|
+
app_options: options.app_options,
|
|
148
|
+
roles: [ROLE_KEEPER, ...(options.extra_keeper_roles ?? [])],
|
|
149
|
+
extra_accounts: options.extra_accounts,
|
|
150
|
+
extra_actors: options.extra_actors,
|
|
151
|
+
}),
|
|
152
|
+
surface_source: options.surface_source ??
|
|
153
|
+
create_test_app_surface_spec({
|
|
154
|
+
session_options: options.session_options,
|
|
155
|
+
create_route_specs: options.create_route_specs,
|
|
156
|
+
rpc_endpoints: options.rpc_endpoints,
|
|
157
|
+
// Mirror what `create_test_app` → `create_app_server` will mount.
|
|
158
|
+
// Both helpers read from the top-level `bootstrap` slot so surface
|
|
159
|
+
// and live app stay in sync by construction.
|
|
160
|
+
bootstrap: options.bootstrap,
|
|
161
|
+
}),
|
|
162
|
+
capabilities: in_process_capabilities,
|
|
163
|
+
session_options: options.session_options,
|
|
164
|
+
create_route_specs: options.create_route_specs,
|
|
165
|
+
rpc_endpoints: options.rpc_endpoints,
|
|
166
|
+
});
|