@fuzdev/fuz_app 0.160.0 → 0.162.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/auth/CLAUDE.md +31 -21
- package/dist/auth/account_action_specs.d.ts +173 -35
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +10 -7
- package/dist/auth/account_route_schema.d.ts +293 -46
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +5 -4
- package/dist/auth/account_schema.d.ts +489 -103
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +67 -47
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/admin_action_specs.d.ts +2748 -505
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +175 -187
- package/dist/auth/app_settings_schema.d.ts +46 -23
- package/dist/auth/app_settings_schema.d.ts.map +1 -1
- package/dist/auth/app_settings_schema.js +12 -15
- package/dist/auth/audit_emitter.d.ts +8 -3
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +32 -9
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +791 -253
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +198 -198
- package/dist/auth/audit_log_schema_fuz.d.ts +53 -0
- package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
- package/dist/auth/audit_log_schema_fuz.js +50 -0
- package/dist/auth/credential_type_schema.d.ts +5 -8
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +6 -10
- package/dist/auth/grant_path_schema.d.ts +4 -7
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +6 -10
- package/dist/auth/invite_schema.d.ts +98 -26
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +21 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +27 -0
- package/dist/auth/name_schema.d.ts +63 -0
- package/dist/auth/name_schema.d.ts.map +1 -0
- package/dist/auth/name_schema.js +65 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +2 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts +192 -192
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_notifications.d.ts +126 -126
- package/dist/auth/role_grant_offer_schema.d.ts +12 -12
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +8 -8
- package/dist/auth/role_schema.d.ts +14 -25
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +15 -29
- package/dist/auth/role_schema_fuz.d.ts +4 -3
- package/dist/auth/role_schema_fuz.d.ts.map +1 -1
- package/dist/auth/role_schema_fuz.js +7 -5
- package/dist/auth/scope_kind_schema.d.ts +13 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +15 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts +4 -3
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema_fuz.js +7 -5
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/token_scope.d.ts +7 -13
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +9 -14
- package/dist/dev/setup.d.ts +14 -7
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +11 -6
- package/dist/primitive_schemas.d.ts +47 -4
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +40 -19
- package/dist/primitive_schemas_fuz.d.ts +70 -8
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +62 -7
- package/dist/testing/CLAUDE.md +11 -6
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +6 -2
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +12 -13
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +24 -13
- package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_role_grammar.js +8 -15
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +4 -3
- package/dist/testing/db_entities.d.ts +3 -1
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +4 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +3 -2
- package/dist/zod.d.ts +2 -1
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +6 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_schemas_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas_fuz.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"primitive_schemas_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAUN,MAAM,EAIN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EASN,KAAK,oBAAoB,EACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAC1B,SAAS,oBAAoB,KAC3B,UAAU,CAAC,MAAM,EA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F,cAAc;AACd,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `
|
|
3
|
-
* `UuidWithDefault` (`primitive_schemas.ts`), and
|
|
4
|
-
* (`http/auth_shape.ts`), under the same names, for schemas
|
|
5
|
-
* fuz_schema
|
|
2
|
+
* `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
|
|
3
|
+
* `Email`, `Uuid`, `UuidWithDefault` (`primitive_schemas.ts`), and
|
|
4
|
+
* `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
|
|
5
|
+
* written in fuz_schema; `UsernameCanonical`, the username an output carries;
|
|
6
|
+
* `Timestamp`, a timestamp on the wire; and `Blake3Hash`, a BLAKE3 hex hash,
|
|
7
|
+
* which has no Zod twin.
|
|
6
8
|
*
|
|
7
9
|
* The output type is shared: the Zod `Uuid` outputs fuz_schema's
|
|
8
10
|
* `Branded<string, 'Uuid'>` too, so a value parsed by either twin goes where
|
|
@@ -12,14 +14,14 @@
|
|
|
12
14
|
* says, the max UUID included, and the Rust spine's: every input gets the same
|
|
13
15
|
* verdict and output from both, and their JSON Schema is the same.
|
|
14
16
|
*
|
|
15
|
-
* The
|
|
17
|
+
* The twins are `@nodocs` while the Zod schemas of the same names stay, as
|
|
16
18
|
* the docs build refuses two exports of one name.
|
|
17
19
|
*
|
|
18
20
|
* @module
|
|
19
21
|
*/
|
|
20
22
|
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
21
|
-
import { brand, max_length, message, min_length, optional, pipe, string, to_lower_case, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
|
|
22
|
-
import { create_uuid } from './primitive_schemas.js';
|
|
23
|
+
import { brand, check, iso_datetime, max_length, message, min_length, optional, pipe, regex, string, to_lower_case, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
|
|
24
|
+
import { create_uuid, EMAIL_LENGTH_MAX, EMAIL_LENGTH_MESSAGE, EMAIL_REGEX, is_email_within_length_max, USERNAME_LENGTH_MAX, USERNAME_LENGTH_MIN, USERNAME_REGEX } from './primitive_schemas.js';
|
|
23
25
|
/**
|
|
24
26
|
* A string schema whose length is bounded in UTF-16 code units, the twin of
|
|
25
27
|
* the Zod `bounded_string`: fuz_schema's `min_length` / `max_length` read
|
|
@@ -37,6 +39,43 @@ export const bounded_string = (options) => {
|
|
|
37
39
|
const max_step = max_message === undefined ? max_length(max) : message(max_length(max), max_message);
|
|
38
40
|
return min === undefined ? pipe(string, max_step) : pipe(string, min_length(min), max_step);
|
|
39
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Username for account creation, the twin of the Zod `Username`: the same
|
|
44
|
+
* bounds and grammar, output in lowercase. Every input gets the same verdict
|
|
45
|
+
* and output from both; a string outside the bounds and off the grammar gets
|
|
46
|
+
* the length issue alone, where Zod adds the grammar issue after it.
|
|
47
|
+
*
|
|
48
|
+
* @nodocs
|
|
49
|
+
*/
|
|
50
|
+
export const Username = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_REGEX), to_lower_case);
|
|
51
|
+
/**
|
|
52
|
+
* A username's canonical grammar, `USERNAME_REGEX` in lowercase: a lowercase
|
|
53
|
+
* letter, then lowercase letters, digits, `_` or `-`, ending in a lowercase
|
|
54
|
+
* letter or digit. What `Username` outputs, and what an `account` row holds
|
|
55
|
+
* (its `account_username_lowercase` CHECK).
|
|
56
|
+
*/
|
|
57
|
+
export const USERNAME_CANONICAL_REGEX = /^[a-z][0-9a-z_-]*[0-9a-z]$/;
|
|
58
|
+
/**
|
|
59
|
+
* A username as an account row holds it, the `username` of an output: the
|
|
60
|
+
* bounds of `Username` and `USERNAME_CANONICAL_REGEX`, no transform. A
|
|
61
|
+
* username in any other case fails, where the Zod `Username` lowercased it.
|
|
62
|
+
*/
|
|
63
|
+
export const UsernameCanonical = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_CANONICAL_REGEX));
|
|
64
|
+
/**
|
|
65
|
+
* Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
|
|
66
|
+
* `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
|
|
67
|
+
* grammar refuses a string past the bound in UTF-16 code units, which is past
|
|
68
|
+
* it in bytes too, before the regex reads it, and the `check` after it the
|
|
69
|
+
* multibyte address within the units but past the bytes, both with
|
|
70
|
+
* `EMAIL_LENGTH_MESSAGE`. Every input gets the same verdict and output from
|
|
71
|
+
* both; a string past the bound in code units gets the length issue as a
|
|
72
|
+
* `max_length`, where Zod gives a `check`, and one within the bound in code
|
|
73
|
+
* units but past it in bytes and off the grammar gets the grammar issue, where
|
|
74
|
+
* Zod gives the length one.
|
|
75
|
+
*
|
|
76
|
+
* @nodocs
|
|
77
|
+
*/
|
|
78
|
+
export const Email = pipe(string, message(max_length(EMAIL_LENGTH_MAX), EMAIL_LENGTH_MESSAGE), regex(EMAIL_REGEX), message(check(is_email_within_length_max), EMAIL_LENGTH_MESSAGE));
|
|
40
79
|
/**
|
|
41
80
|
* Branded UUID schema: a UUID of RFC 9562 in either case, output in
|
|
42
81
|
* lowercase, the form Postgres renders a `uuid` in and every id the server
|
|
@@ -52,6 +91,22 @@ export const Uuid = brand(pipe(string, uuid, to_lower_case), 'Uuid');
|
|
|
52
91
|
* @nodocs
|
|
53
92
|
*/
|
|
54
93
|
export const UuidWithDefault = with_default_fn(Uuid, create_uuid);
|
|
94
|
+
/**
|
|
95
|
+
* A timestamp on the wire: a date and time of RFC 3339 in UTC, fuz_schema's
|
|
96
|
+
* `iso_datetime`, which both spines' `YYYY-MM-DDTHH:MM:SSZ`
|
|
97
|
+
* (`iso8601_timestamp_column`) and a `toISOString()` stamp satisfy. Not
|
|
98
|
+
* branded, unlike the Zod `Datetime`.
|
|
99
|
+
*/
|
|
100
|
+
export const Timestamp = pipe(string, iso_datetime);
|
|
101
|
+
/** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
|
|
102
|
+
export const BLAKE3_HASH_REGEX = /^[0-9a-f]{64}$/;
|
|
103
|
+
/** The message of a string off `BLAKE3_HASH_REGEX`. */
|
|
104
|
+
export const BLAKE3_HASH_MESSAGE = 'Expected a 64-character lowercase hex blake3 hash';
|
|
105
|
+
/**
|
|
106
|
+
* A BLAKE3 hex hash: `BLAKE3_HASH_REGEX`, whose issue carries
|
|
107
|
+
* `BLAKE3_HASH_MESSAGE`. A value that is no string gets fuz_schema's message.
|
|
108
|
+
*/
|
|
109
|
+
export const Blake3Hash = pipe(string, message(regex(BLAKE3_HASH_REGEX), BLAKE3_HASH_MESSAGE));
|
|
55
110
|
/** The `description` both `ActingActor` twins carry. */
|
|
56
111
|
export const ACTING_ACTOR_DESCRIPTION = 'Actor on the authenticated account that this request acts as. Omit on single-actor accounts; required on multi-actor.';
|
|
57
112
|
/**
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -77,7 +77,9 @@ harness's `connect`, `create_bearer_auth_test_app`'s `pre_context`.
|
|
|
77
77
|
### `db_entities.ts` — DB-backed entity factories
|
|
78
78
|
|
|
79
79
|
`create_test_account_with_actor(db, {username, password_hash?})` wraps
|
|
80
|
-
`query_create_account_with_actor` with default `password_hash` (`'hash'`)
|
|
80
|
+
`query_create_account_with_actor` with default `password_hash` (`'hash'`),
|
|
81
|
+
storing the username lowercased, as every production creation path does and
|
|
82
|
+
the `account_username_lowercase` CHECK requires.
|
|
81
83
|
Returns `{account, actor}`. Replaces the per-file `create_user` /
|
|
82
84
|
`create_test_actor` / `create_test_account` helpers that had accumulated
|
|
83
85
|
across the auth test suite. Use for query-level tests needing real DB rows
|
|
@@ -120,7 +122,7 @@ mismatch.
|
|
|
120
122
|
### `audit_drift_guard.ts` — audit-emission validation
|
|
121
123
|
|
|
122
124
|
- `install_audit_drift_guard()` — `beforeEach` resets + `afterEach` zero-checks the `audit_metadata_validation_failures` + `audit_unknown_event_type_failures` counters from `auth/audit_log_queries.ts` and the emitter's write-failure counter (`get_audit_write_failures` in `auth/audit_emitter.ts`). Call once at the top of any `describe_db` block firing audit emits — production validation and the emitter's write are fail-open, so without this any regression shipping a typo'd `event_type` or undeclared metadata field, or losing a row the database refused, is silent. A test that fails a write on purpose resets the counter (`reset_audit_write_failures`) once it has asserted it.
|
|
123
|
-
- `assert_audit_event_metadata(event, {reject_unknown_keys?})` — the wire-side twin: parses a read audit row's `metadata` against its builtin event type's `audit_metadata_schemas` entry as declared, so a mistyped, `null`, or missing field fails while a consumer-added key passes (the schemas are `
|
|
125
|
+
- `assert_audit_event_metadata(event, {reject_unknown_keys?})` — the wire-side twin: parses a read audit row's `metadata` against its builtin event type's `audit_metadata_schemas` entry as declared, so a mistyped, `null`, or missing field fails while a consumer-added key passes (the schemas are fuz_schema `loose_object`s, and a builtin's schema can't be overridden, so added keys are a consumer's only extension path). `reject_unknown_keys` closes the world, each `loose_object`'s `def` spread into an `object`: an undeclared key fails too, for a suite whose backend adds none. The wire schema leaves `metadata` a loose record and only the TS spine validates it, at insert and fail-open, so this is what holds every spine's rows to their event's contract. A consumer-registered event type passes unexamined. `list_audit_events` and the admin suite run it on every row they read, with `reject_unknown_keys` from the fixture's `reject_unknown_audit_metadata_keys` (a setup option on `default_cross_process_setup`, `default_in_process_setup` and `default_in_process_suite_options`); fuz_app's own spine wiring turns it on.
|
|
124
126
|
- `assert_no_audit_drift()` — the zero-check itself, for a test that manages the counters. Pair with `await_pending_effects: true` (the `create_test_app` default) so fire-and-forget audit writes complete by response time.
|
|
125
127
|
- `create_recording_audit_emitter(calls_ref?)` — no-op `AuditEmitter` pushing every `emit` and `emit_pool` call into `calls`. Pass `calls_ref` to write into a caller-owned array; omit to let the helper allocate. Returns `{emitter, calls}` — destructure `emitter` as the `audit` dep and read `calls` to assert. `add_listener` records (never fires) and returns a remover with the production semantics, so `listener_count` tracks what a server registered and released. Replaces per-file capturing emitters previously duplicated across `password_change.test.ts`, `audit_log.test.ts`, etc.
|
|
126
128
|
- `RecordingAuditEmitter` — `{emitter: AuditEmitter; calls: Array<AuditLogInput>}`.
|
|
@@ -183,7 +185,9 @@ cookie" flow, split by intent:
|
|
|
183
185
|
- `create_test_account_with_credentials(options)` — general path used by `TestApp.create_account` for additional non-keeper accounts. Same body, no lock interaction (additional accounts aren't bootstraps).
|
|
184
186
|
|
|
185
187
|
Both take `{db, keyring, session_options, password, username?, password_value?, roles?}`
|
|
186
|
-
(shared `CreateTestAccountWithCredentialsOptions` / `BootstrapTestKeeperOptions`)
|
|
188
|
+
(shared `CreateTestAccountWithCredentialsOptions` / `BootstrapTestKeeperOptions`),
|
|
189
|
+
and store the username lowercased, as the Rust spine's `_testing_reset` seeds
|
|
190
|
+
do, so the returned `account.username` is its lowercase.
|
|
187
191
|
|
|
188
192
|
Types:
|
|
189
193
|
|
|
@@ -2711,10 +2715,11 @@ USERNAME_LENGTH_MAX]` = `[3, 39]` boundary edges (just-outside → 400,
|
|
|
2711
2715
|
`_`/`-` accepted), catching an off-by-one or position bug in the TS Zod
|
|
2712
2716
|
`.min/.max/.regex` vs the Rust byte-scan `is_valid_username_for_creation`.
|
|
2713
2717
|
- **Email format (creation)** — the optional signup `email` validated to the
|
|
2714
|
-
loose `local@domain.tld` shape (TS `Email`
|
|
2718
|
+
loose `local@domain.tld` shape (TS `Email`, `EMAIL_REGEX` + 254-byte
|
|
2715
2719
|
bound, Rust `is_valid_email`): malformed (no `@` / no domain dot / empty
|
|
2716
|
-
side / dot at a domain edge
|
|
2717
|
-
403 no-invite. Accepted siblings include
|
|
2720
|
+
side / dot at a domain edge, beside another dot inside it too / whitespace /
|
|
2721
|
+
over-length) → 400, well-formed → 403 no-invite. Accepted siblings include
|
|
2722
|
+
the single-char-TLD `a@b.c` and the consecutive dots inside a domain that
|
|
2718
2723
|
Zod's `z.email()` rejects — the deliberately-looser shared rule. **Closed a
|
|
2719
2724
|
real divergence**: the Rust spine previously length-checked the email only,
|
|
2720
2725
|
accepting any non-empty string TS rejected.
|
|
@@ -62,7 +62,9 @@ export type BootstrapTestKeeperOptions = CreateTestAccountWithCredentialsOptions
|
|
|
62
62
|
* having happened.
|
|
63
63
|
*
|
|
64
64
|
* Creates an account with actor, grants roles, creates an API token,
|
|
65
|
-
* creates a session, and signs a session cookie.
|
|
65
|
+
* creates a session, and signs a session cookie. The username is stored
|
|
66
|
+
* lowercased, as every production creation path stores it, so the returned
|
|
67
|
+
* `account.username` is the lowercase of `options.username`.
|
|
66
68
|
*
|
|
67
69
|
* @mutates the underlying `options.db` — inserts rows into `account`, `actor`,
|
|
68
70
|
* `role_grant` (one per role), `api_token`, and `auth_session`.
|
|
@@ -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;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAU5D,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3E,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,yBAAyB,CAAC;AACjC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CAAC,CAAC;IACnF,gEAAgE;IAChE,qBAAqB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClF,iEAAiE;IACjE,2BAA2B,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,qDAAqD;IACrD,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7E,2PAA2P;IAC3P,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,QAAO,IAAI,CACzD,gBAAgB,EAChB,iBAAiB,GAAG,OAAO,GAAG,YAAY,CAa1C,CAAC;AAgCF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAqFpF,CAAC"}
|
|
@@ -77,7 +77,9 @@ const resolve_fallback_factory = (migration_namespaces) => {
|
|
|
77
77
|
* having happened.
|
|
78
78
|
*
|
|
79
79
|
* Creates an account with actor, grants roles, creates an API token,
|
|
80
|
-
* creates a session, and signs a session cookie.
|
|
80
|
+
* creates a session, and signs a session cookie. The username is stored
|
|
81
|
+
* lowercased, as every production creation path stores it, so the returned
|
|
82
|
+
* `account.username` is the lowercase of `options.username`.
|
|
81
83
|
*
|
|
82
84
|
* @mutates the underlying `options.db` — inserts rows into `account`, `actor`,
|
|
83
85
|
* `role_grant` (one per role), `api_token`, and `auth_session`.
|
|
@@ -86,8 +88,10 @@ export const create_test_account_with_credentials = async (options) => {
|
|
|
86
88
|
const { db, keyring, session_options, password, username = 'keeper', password_value = DEFAULT_TEST_PASSWORD, roles = [], email } = options;
|
|
87
89
|
const deps = { db };
|
|
88
90
|
const password_hash = await password.hash_password(password_value);
|
|
91
|
+
// lowercase, as `Username` stores every name production creates, and as the
|
|
92
|
+
// `account_username_lowercase` CHECK requires
|
|
89
93
|
const { account, actor } = await query_create_account_with_actor(deps, {
|
|
90
|
-
username,
|
|
94
|
+
username: username.toLowerCase(),
|
|
91
95
|
password_hash,
|
|
92
96
|
...(email !== undefined && { email })
|
|
93
97
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_drift_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/audit_drift_guard.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"audit_drift_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/audit_drift_guard.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,yBAAyB,QAAO,IAO5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAgBxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,YAAY,KAAK,CAAC,aAAa,CAAC,KAC9B,qBAwCF,CAAC;AA4BF,iDAAiD;AACjD,MAAM,WAAW,+BAA+B;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B,GACvC,OAAO,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC,EACrE,UAAU,+BAA+B,KACvC,IAYF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import { assert, beforeEach, afterEach } from 'vitest';
|
|
3
|
-
import {
|
|
3
|
+
import { format_issue, nullable, object, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
4
4
|
import { get_audit_metadata_validation_failures, get_audit_unknown_event_type_failures, reset_audit_metadata_validation_failures, reset_audit_unknown_event_type_failures } from '../auth/audit_log_queries.js';
|
|
5
5
|
import { get_audit_write_failures, reset_audit_write_failures } from '../auth/audit_emitter.js';
|
|
6
6
|
import { audit_metadata_schemas } from '../auth/audit_log_schema.js';
|
|
@@ -128,16 +128,17 @@ export const create_recording_audit_emitter = (calls_ref) => {
|
|
|
128
128
|
};
|
|
129
129
|
/**
|
|
130
130
|
* The closed-world twin of a builtin event's `audit_metadata_schemas` entry:
|
|
131
|
-
* the same fields, with unknown keys refused
|
|
132
|
-
*
|
|
133
|
-
*
|
|
131
|
+
* the same fields, with unknown keys refused — its `loose_object`'s `def`
|
|
132
|
+
* spread into an `object`, under the `nullable` it may have. The registry's
|
|
133
|
+
* schemas are `loose_object`s so a consumer can add fields to a builtin event
|
|
134
|
+
* (a builtin's schema can't be overridden), so this is opt-in.
|
|
134
135
|
*/
|
|
135
136
|
const to_closed_metadata_schema = (schema) => {
|
|
136
|
-
if (schema
|
|
137
|
-
return to_closed_metadata_schema(schema.
|
|
137
|
+
if (schema.kind === 'nullable') {
|
|
138
|
+
return nullable(to_closed_metadata_schema(schema.def.schema));
|
|
138
139
|
}
|
|
139
|
-
if (schema
|
|
140
|
-
return
|
|
140
|
+
if (schema.kind === 'loose_object')
|
|
141
|
+
return object({ ...schema.def });
|
|
141
142
|
return schema;
|
|
142
143
|
};
|
|
143
144
|
const declared_metadata_schemas = new Map(Object.entries(audit_metadata_schemas));
|
|
@@ -165,12 +166,10 @@ export const assert_audit_event_metadata = (event, options) => {
|
|
|
165
166
|
const schema = (options?.reject_unknown_keys ? closed_metadata_schemas : declared_metadata_schemas).get(event.event_type);
|
|
166
167
|
if (!schema)
|
|
167
168
|
return;
|
|
168
|
-
const parsed = schema
|
|
169
|
-
if (parsed.
|
|
169
|
+
const parsed = parse(schema, event.metadata);
|
|
170
|
+
if (parsed.ok)
|
|
170
171
|
return;
|
|
171
172
|
assert.fail(`audit row ${event.event_type} (outcome=${event.outcome}) carries metadata outside its ` +
|
|
172
173
|
`audit_metadata_schemas entry: ${JSON.stringify(event.metadata)} — ` +
|
|
173
|
-
parsed.
|
|
174
|
-
.map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`)
|
|
175
|
-
.join('; '));
|
|
174
|
+
parsed.issues.map(format_issue).join('; '));
|
|
176
175
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqH9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyB5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAsKD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IAmeF,CAAC"}
|
|
@@ -75,9 +75,10 @@ import '../assert_dev_env.js';
|
|
|
75
75
|
* bootstrap completed.
|
|
76
76
|
*
|
|
77
77
|
* **Email format (creation):** the optional signup `email` is validated to a
|
|
78
|
-
* loose `local@domain.tld` shape on both spines — TS `Email`
|
|
79
|
-
*
|
|
80
|
-
*
|
|
78
|
+
* loose `local@domain.tld` shape on both spines — TS `Email` (`EMAIL_REGEX`:
|
|
79
|
+
* a non-empty local part, one `@`, a domain holding a `.` at neither of its
|
|
80
|
+
* edges, no whitespace — `White_Space ∪ {U+FEFF}` — plus a 254-byte (RFC 5321
|
|
81
|
+
* octet) length bound), Rust the hand-rolled `is_valid_email`. A malformed email → 400, a well-formed one →
|
|
81
82
|
* 403 no-matching-invite (the same accept/reject settle the username tables
|
|
82
83
|
* use). The accepted siblings include the single-char-TLD `a@b.c` that Zod's
|
|
83
84
|
* `z.email()` would reject — the deliberately-looser rule both spines now
|
|
@@ -195,14 +196,15 @@ const USERNAME_FORMAT_CASES = [
|
|
|
195
196
|
];
|
|
196
197
|
/**
|
|
197
198
|
* Signup email-format cases for the loose `Email` shape `local@domain.tld`
|
|
198
|
-
* (TS
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* backend policing only one of them is caught.
|
|
203
|
-
* don't-over-reject control and include the
|
|
204
|
-
* but our looser rule accepts — single-char
|
|
205
|
-
* `a..b@c.d` — pinning the
|
|
199
|
+
* (TS `EMAIL_REGEX` plus the 254 length bound; Rust the hand-rolled
|
|
200
|
+
* `is_valid_email`). The rejected cases each violate the shape at a different
|
|
201
|
+
* point — no `@`, no dot in the domain, empty local/domain, a dot at a domain
|
|
202
|
+
* edge (beside another dot inside the domain too), surrounding whitespace,
|
|
203
|
+
* over the length bound — so a backend policing only one of them is caught.
|
|
204
|
+
* The accepted siblings are the don't-over-reject control and include the
|
|
205
|
+
* shapes Zod's `z.email()` rejects but our looser rule accepts — single-char
|
|
206
|
+
* TLD `a@b.c` and consecutive dots `a..b@c.d` and `a@b..c` — pinning the
|
|
207
|
+
* deliberately-looser shared rule in both directions.
|
|
206
208
|
* Every case rides a valid username so the rejection (or the 403 no-invite
|
|
207
209
|
* settle) isolates the email.
|
|
208
210
|
*/
|
|
@@ -213,6 +215,8 @@ const SIGNUP_EMAIL_CASES = [
|
|
|
213
215
|
{ email: 'user@', label: 'empty domain', status: 400 },
|
|
214
216
|
{ email: 'user@.com', label: 'domain starts with a dot', status: 400 },
|
|
215
217
|
{ email: 'user@com.', label: 'domain ends with a dot', status: 400 },
|
|
218
|
+
{ email: 'user@.example.com', label: 'multi-label domain starts with a dot', status: 400 },
|
|
219
|
+
{ email: 'user@example.com.', label: 'multi-label domain ends with a dot', status: 400 },
|
|
216
220
|
{ email: 'a@@b.c', label: 'two @', status: 400 },
|
|
217
221
|
{ email: ' user@example.com', label: 'leading whitespace', status: 400 },
|
|
218
222
|
{ email: 'user@example.com ', label: 'trailing whitespace', status: 400 },
|
|
@@ -251,6 +255,11 @@ const SIGNUP_EMAIL_CASES = [
|
|
|
251
255
|
label: 'consecutive dots (looser than z.email)',
|
|
252
256
|
status: VALID_USERNAME_NO_INVITE_STATUS
|
|
253
257
|
},
|
|
258
|
+
{
|
|
259
|
+
email: 'user@example..com',
|
|
260
|
+
label: 'consecutive dots inside the domain (looser than z.email)',
|
|
261
|
+
status: VALID_USERNAME_NO_INVITE_STATUS
|
|
262
|
+
},
|
|
254
263
|
{
|
|
255
264
|
email: 'user+tag@example.co.uk',
|
|
256
265
|
label: 'plus-tag + multi-label',
|
|
@@ -328,8 +337,10 @@ export const describe_identity_parity_cross_tests = (options) => {
|
|
|
328
337
|
test('case-insensitive login — uppercase submission matches a mixed-case account', async () => {
|
|
329
338
|
const fixture = await setup_test();
|
|
330
339
|
// Mixed-case ASCII username (valid per the `Username` regex), stored
|
|
331
|
-
// lowercase
|
|
332
|
-
//
|
|
340
|
+
// lowercase on every fixture: through signup's `Username` across
|
|
341
|
+
// processes, by the harness in process, and held there by the
|
|
342
|
+
// `account_username_lowercase` CHECK. An all-uppercase submission
|
|
343
|
+
// matches only if the lookup folds case on this backend.
|
|
333
344
|
await fixture.create_account({ username: 'Canon_Mixed_User' });
|
|
334
345
|
assert_attempt(await login(fixture, 'CANON_MIXED_USER'), 200, 'uppercase login');
|
|
335
346
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_role_grammar.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/role_grant_role_grammar.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiD9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG3D,8EAA8E;AAC9E,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"role_grant_role_grammar.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/role_grant_role_grammar.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiD9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG3D,8EAA8E;AAC9E,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AA4D5E,eAAO,MAAM,4CAA4C,GACxD,SAAS,oCAAoC,KAC3C,IAqKF,CAAC"}
|
|
@@ -47,14 +47,15 @@ import { cross_rpc_call, error_reason } from './cross_rpc.js';
|
|
|
47
47
|
import { SPINE_RPC_PATH } from './spine_surface_constants.js';
|
|
48
48
|
const NIL_UUID = '00000000-0000-0000-0000-000000000000';
|
|
49
49
|
/**
|
|
50
|
-
* The longest role name the grammar admits — an independent
|
|
51
|
-
* producers' `
|
|
50
|
+
* The longest role name or scope kind the grammar admits — an independent
|
|
51
|
+
* copy of the producers' `NAME_LENGTH_MAX`, so a cap moved on one spine fails
|
|
52
|
+
* here.
|
|
52
53
|
*/
|
|
53
|
-
const
|
|
54
|
+
const NAME_LENGTH_MAX = 64;
|
|
54
55
|
/** All lowercase letters, so only its length is off the grammar. */
|
|
55
|
-
const OVER_LENGTH_ROLE = 'a'.repeat(
|
|
56
|
+
const OVER_LENGTH_ROLE = 'a'.repeat(NAME_LENGTH_MAX + 1);
|
|
56
57
|
/** On the grammar at exactly the length cap, held by no registry. */
|
|
57
|
-
const AT_LENGTH_ROLE = 'a'.repeat(
|
|
58
|
+
const AT_LENGTH_ROLE = 'a'.repeat(NAME_LENGTH_MAX);
|
|
58
59
|
/** Each breaks one rule of the `RoleName` grammar. */
|
|
59
60
|
const OFF_GRAMMAR_ROLES = [
|
|
60
61
|
'Admin', // uppercase
|
|
@@ -70,11 +71,6 @@ const OFF_GRAMMAR_ROLES = [
|
|
|
70
71
|
];
|
|
71
72
|
/** On the grammar, held by no registry. */
|
|
72
73
|
const UNREGISTERED_ROLE = 'not_a_registered_role';
|
|
73
|
-
/**
|
|
74
|
-
* The longest scope kind the grammar admits — an independent copy of the
|
|
75
|
-
* producers' `SCOPE_KIND_LENGTH_MAX`.
|
|
76
|
-
*/
|
|
77
|
-
const SCOPE_KIND_LENGTH_MAX = 64;
|
|
78
74
|
/** Each breaks one rule of the `ScopeKindName` grammar. */
|
|
79
75
|
const OFF_GRAMMAR_SCOPE_KINDS = [
|
|
80
76
|
'GLOBAL', // the partial unique indexes' token for a global grant
|
|
@@ -84,13 +80,10 @@ const OFF_GRAMMAR_SCOPE_KINDS = [
|
|
|
84
80
|
'a_', // trailing underscore
|
|
85
81
|
'a1', // digit
|
|
86
82
|
'', // empty
|
|
87
|
-
'a'.repeat(
|
|
83
|
+
'a'.repeat(NAME_LENGTH_MAX + 1) // on the alphabet, one past the length cap
|
|
88
84
|
];
|
|
89
85
|
/** On the grammar, the second exactly at the length cap. */
|
|
90
|
-
const ON_GRAMMAR_SCOPE_KINDS = [
|
|
91
|
-
'classroom',
|
|
92
|
-
'a'.repeat(SCOPE_KIND_LENGTH_MAX)
|
|
93
|
-
];
|
|
86
|
+
const ON_GRAMMAR_SCOPE_KINDS = ['classroom', 'a'.repeat(NAME_LENGTH_MAX)];
|
|
94
87
|
const GRANT_METHODS = ['role_grant_assign', 'role_grant_offer_create'];
|
|
95
88
|
/** What each grant verb refuses an unregistered role with, past validation. */
|
|
96
89
|
const NOT_GRANTABLE_REASONS = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_cap.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/session_cap.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"session_cap.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/session_cap.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,gDAAgD;AAChD,MAAM,WAAW,0BAA0B;IAC1C,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IAwMtF,CAAC"}
|
|
@@ -52,6 +52,7 @@ import '../assert_dev_env.js';
|
|
|
52
52
|
* @module
|
|
53
53
|
*/
|
|
54
54
|
import { describe, test, assert } from 'vitest';
|
|
55
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
55
56
|
import { heartbeat_action_spec } from '../../actions/heartbeat.js';
|
|
56
57
|
import { WS_CLOSE_SESSION_REVOKED } from '../../actions/transports.js';
|
|
57
58
|
import { DEFAULT_MAX_SESSIONS } from '../../auth/account_route_schema.js';
|
|
@@ -151,9 +152,9 @@ export const describe_session_cap_cross_tests = (options) => {
|
|
|
151
152
|
});
|
|
152
153
|
try {
|
|
153
154
|
const result = await client.request(1, 'account_session_list', undefined);
|
|
154
|
-
const parsed = SessionListOutput
|
|
155
|
-
assert.ok(parsed.
|
|
156
|
-
const current = parsed.
|
|
155
|
+
const parsed = parse(SessionListOutput, result);
|
|
156
|
+
assert.ok(parsed.ok, `the socket's session list parses (got ${JSON.stringify(result)})`);
|
|
157
|
+
const current = parsed.value.sessions.filter((s) => s.is_current).map((s) => s.id);
|
|
157
158
|
assert.deepStrictEqual(current, on_first.current, "the first login's socket sees exactly its own session as current");
|
|
158
159
|
}
|
|
159
160
|
finally {
|
|
@@ -13,7 +13,9 @@ export interface TestAccountWithActor {
|
|
|
13
13
|
* so suites that don't exercise password verification can stay terse.
|
|
14
14
|
* Replaces the per-file `create_user` / `create_test_actor` /
|
|
15
15
|
* `create_test_account` helpers that had accumulated across the auth
|
|
16
|
-
* test suite.
|
|
16
|
+
* test suite. The username is stored lowercased, as every production
|
|
17
|
+
* creation path stores it and the `account_username_lowercase` CHECK
|
|
18
|
+
* requires.
|
|
17
19
|
*/
|
|
18
20
|
export declare const create_test_account_with_actor: (db: Db, options: {
|
|
19
21
|
username: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_entities.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/db_entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA0B7B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACb;AAED
|
|
1
|
+
{"version":3,"file":"db_entities.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/db_entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA0B7B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAC1C,IAAI,EAAE,EACN,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,KACnD,OAAO,CAAC,oBAAoB,CAI7B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACzC,IAAI,EAAE,EACN,OAAO,oBAAoB,KACzB,OAAO,CAAC,SAAS,CAA2C,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,EAAE,EACN,YAAY,MAAM,EAClB,MAAM,MAAM,KACV,OAAO,CAAC,KAAK,CAWf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAU,IAAI,EAAE,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CACvC,CAAC"}
|
|
@@ -25,9 +25,11 @@ import { query_create_role_grant } from '../auth/role_grant_queries.js';
|
|
|
25
25
|
* so suites that don't exercise password verification can stay terse.
|
|
26
26
|
* Replaces the per-file `create_user` / `create_test_actor` /
|
|
27
27
|
* `create_test_account` helpers that had accumulated across the auth
|
|
28
|
-
* test suite.
|
|
28
|
+
* test suite. The username is stored lowercased, as every production
|
|
29
|
+
* creation path stores it and the `account_username_lowercase` CHECK
|
|
30
|
+
* requires.
|
|
29
31
|
*/
|
|
30
|
-
export const create_test_account_with_actor = async (db, options) => query_create_account_with_actor({ db }, { username: options.username, password_hash: options.password_hash ?? 'hash' });
|
|
32
|
+
export const create_test_account_with_actor = async (db, options) => query_create_account_with_actor({ db }, { username: options.username.toLowerCase(), password_hash: options.password_hash ?? 'hash' });
|
|
31
33
|
/**
|
|
32
34
|
* Materialize a `role_grant` directly via `query_create_role_grant`,
|
|
33
35
|
* bypassing the production offer/accept consent flow.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAuB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,mCAAmC,GAC/C,SAAS,8BAA8B,KACrC,IA28CF,CAAC"}
|
|
@@ -17,6 +17,7 @@ import './assert_dev_env.js';
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { describe, test, assert, afterAll } from 'vitest';
|
|
20
|
+
import { parse_or_throw } from '@fuzdev/fuz_schema/schema.ts';
|
|
20
21
|
import { find_auth_route, assert_response_matches_spec, assert_no_error_info_leakage } from './integration_helpers.js';
|
|
21
22
|
import { find_rpc_action, rpc_call_for_spec, require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup } from './rpc_helpers.js';
|
|
22
23
|
import { ErrorCoverageCollector, assert_error_coverage, DEFAULT_INTEGRATION_ERROR_COVERAGE } from './error_coverage.js';
|
|
@@ -329,11 +330,11 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
329
330
|
`capability but doesn't mount the route.`);
|
|
330
331
|
const body = await res.json();
|
|
331
332
|
// Throws on any extra/missing field across account/actor/role_grants.
|
|
332
|
-
const parsed = AccountStatusOutput
|
|
333
|
+
const parsed = parse_or_throw(AccountStatusOutput, body);
|
|
333
334
|
// Single-actor keeper: actor resolved, role_grants populated.
|
|
334
335
|
assert.ok(parsed.actor, 'single-actor keeper must resolve a non-null actor');
|
|
335
336
|
assert.ok(parsed.role_grants.length > 0, 'single-actor keeper must have populated role_grants');
|
|
336
|
-
// Byte-shape gate: `
|
|
337
|
+
// Byte-shape gate: `iso_datetime` accepts a millisecond stamp too,
|
|
337
338
|
// so the schema parse above can't tell the two spines apart.
|
|
338
339
|
assert_iso8601_seconds(parsed.account.created_at, 'account.created_at');
|
|
339
340
|
for (const grant of parsed.role_grants) {
|
package/dist/zod.d.ts
CHANGED
|
@@ -48,7 +48,8 @@ export declare const zod_get_schema_layers: (schema: z.ZodType) => Array<z.ZodTy
|
|
|
48
48
|
export declare const zod_get_schema_keys: <T extends z.ZodType>(schema: T) => Array<keyof z.infer<T> & string>;
|
|
49
49
|
/**
|
|
50
50
|
* Get the field schema for a key in an object schema, returning `undefined` if
|
|
51
|
-
* the schema is not an object or the key is
|
|
51
|
+
* the schema is not an object or the key is not one of its own fields (a name
|
|
52
|
+
* the shape only inherits, such as `constructor` or `toString`, included).
|
|
52
53
|
*
|
|
53
54
|
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
54
55
|
* @param key - the property name
|
package/dist/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/zod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgC7B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,IAAI,CAAC,WAOzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAqC,CAAC;AAgC5F;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,OA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SAGd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,OAIvE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,SAAS,GAAG,IAUtE,CAAC;AAIF;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,6GAA6G;IAC7G,QAAQ,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,eAAe,CAa7E,CAAC"}
|
package/dist/zod.js
CHANGED
|
@@ -136,13 +136,17 @@ export const zod_get_schema_keys = (schema) => {
|
|
|
136
136
|
};
|
|
137
137
|
/**
|
|
138
138
|
* Get the field schema for a key in an object schema, returning `undefined` if
|
|
139
|
-
* the schema is not an object or the key is
|
|
139
|
+
* the schema is not an object or the key is not one of its own fields (a name
|
|
140
|
+
* the shape only inherits, such as `constructor` or `toString`, included).
|
|
140
141
|
*
|
|
141
142
|
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
142
143
|
* @param key - the property name
|
|
143
144
|
* @returns the field's schema, or `undefined`
|
|
144
145
|
*/
|
|
145
|
-
export const zod_maybe_get_field_schema = (schema, key) =>
|
|
146
|
+
export const zod_maybe_get_field_schema = (schema, key) => {
|
|
147
|
+
const shape = zod_unwrap_to_object(schema)?.shape;
|
|
148
|
+
return shape && Object.hasOwn(shape, key) ? shape[key] : undefined;
|
|
149
|
+
};
|
|
146
150
|
/**
|
|
147
151
|
* Get the field schema for a key in an object schema.
|
|
148
152
|
*
|