@fuzdev/fuz_app 0.160.0 → 0.161.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 +16 -14
- 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 +1051 -321
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +150 -166
- 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_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +14 -3
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +20 -7
- package/dist/auth/audit_log_schema_fuz.d.ts +39 -0
- package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
- package/dist/auth/audit_log_schema_fuz.js +37 -0
- package/dist/auth/credential_type_schema.d.ts +4 -7
- 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/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 +120 -120
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
- package/dist/auth/role_grant_offer_schema.d.ts +6 -6
- 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/primitive_schemas.d.ts +46 -0
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +39 -14
- package/dist/primitive_schemas_fuz.d.ts +35 -7
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +30 -6
- package/dist/testing/CLAUDE.md +4 -3
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +20 -11
- 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/package.json +1 -1
|
@@ -125,10 +125,20 @@ export declare const to_global_role_revocation: (event: AuditLogEvent) => {
|
|
|
125
125
|
/**
|
|
126
126
|
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
127
127
|
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
128
|
-
* separators, whitespace, and control characters.
|
|
128
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
129
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
130
|
+
* length cap `AuditEventTypeName` takes.
|
|
129
131
|
*/
|
|
130
132
|
export declare const AUDIT_EVENT_TYPE_NAME_REGEX: RegExp;
|
|
131
|
-
/**
|
|
133
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
134
|
+
export declare const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = "must be at most 64 characters";
|
|
135
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
136
|
+
export declare const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = "must start with a letter; only letters, digits, _ . / - allowed";
|
|
137
|
+
/**
|
|
138
|
+
* Zod schema for valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`,
|
|
139
|
+
* at most `NAME_LENGTH_MAX` UTF-16 code units. Twin of the Rust spine's
|
|
140
|
+
* `is_valid_audit_event_type_name`.
|
|
141
|
+
*/
|
|
132
142
|
export declare const AuditEventTypeName: z.ZodString;
|
|
133
143
|
export type AuditEventTypeName = z.infer<typeof AuditEventTypeName>;
|
|
134
144
|
/** Zod schema for audit event outcomes. */
|
|
@@ -478,7 +488,8 @@ export interface AuditLogListOptions {
|
|
|
478
488
|
/**
|
|
479
489
|
* Zod schema for client-safe audit log event.
|
|
480
490
|
*
|
|
481
|
-
* `event_type` is `AuditEventTypeName` (regex-validated string
|
|
491
|
+
* `event_type` is `AuditEventTypeName` (regex-validated string, at most
|
|
492
|
+
* `NAME_LENGTH_MAX` characters) — matches
|
|
482
493
|
* the `AuditLogEvent` row and the DB's `TEXT NOT NULL` column. Consumer
|
|
483
494
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
484
495
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/l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IG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;kBAY5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,+DAA+D;AAC/D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;kBAGzC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE5F,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;kBAGpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,uFAAuF;AACvF,eAAO,MAAM,gBAAgB;;;;;;kBAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
-
import { Uuid, Email } from '../primitive_schemas.js';
|
|
12
|
+
import { bounded_string, Uuid, Email } from '../primitive_schemas.js';
|
|
13
13
|
import { AuthSessionJson, SessionId } from './account_schema.js';
|
|
14
14
|
import { ApiTokenId } from './api_token.js';
|
|
15
15
|
import { BuiltinCredentialType } from './credential_type_schema.js';
|
|
16
|
+
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
16
17
|
/**
|
|
17
18
|
* Defense-in-depth audit field — records the credential channel
|
|
18
19
|
* (`session` / `api_token` / `daemon_token`) the request arrived on.
|
|
@@ -152,13 +153,24 @@ export const to_global_role_revocation = (event) => {
|
|
|
152
153
|
/**
|
|
153
154
|
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
154
155
|
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
155
|
-
* separators, whitespace, and control characters.
|
|
156
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
157
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
158
|
+
* length cap `AuditEventTypeName` takes.
|
|
156
159
|
*/
|
|
157
160
|
export const AUDIT_EVENT_TYPE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_./-]*$/;
|
|
158
|
-
/**
|
|
159
|
-
export const
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
162
|
+
export const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = `must be at most ${NAME_LENGTH_MAX} characters`;
|
|
163
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
164
|
+
export const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = 'must start with a letter; only letters, digits, _ . / - allowed';
|
|
165
|
+
/**
|
|
166
|
+
* Zod schema for valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`,
|
|
167
|
+
* at most `NAME_LENGTH_MAX` UTF-16 code units. Twin of the Rust spine's
|
|
168
|
+
* `is_valid_audit_event_type_name`.
|
|
169
|
+
*/
|
|
170
|
+
export const AuditEventTypeName = bounded_string({
|
|
171
|
+
max: NAME_LENGTH_MAX,
|
|
172
|
+
max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE
|
|
173
|
+
}).regex(AUDIT_EVENT_TYPE_NAME_REGEX, { message: AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE });
|
|
162
174
|
/** Zod schema for audit event outcomes. */
|
|
163
175
|
export const AuditOutcome = z.enum(['success', 'failure']);
|
|
164
176
|
/**
|
|
@@ -513,7 +525,8 @@ export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
|
513
525
|
/**
|
|
514
526
|
* Zod schema for client-safe audit log event.
|
|
515
527
|
*
|
|
516
|
-
* `event_type` is `AuditEventTypeName` (regex-validated string
|
|
528
|
+
* `event_type` is `AuditEventTypeName` (regex-validated string, at most
|
|
529
|
+
* `NAME_LENGTH_MAX` characters) — matches
|
|
517
530
|
* the `AuditLogEvent` row and the DB's `TEXT NOT NULL` column. Consumer
|
|
518
531
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
519
532
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@fuzdev/fuz_schema` twins of the Zod `AuditEventTypeName` and
|
|
3
|
+
* `AuditOutcome` (`auth/audit_log_schema.ts`), under the same names, for
|
|
4
|
+
* schemas written in fuz_schema.
|
|
5
|
+
*
|
|
6
|
+
* `AuditEventTypeName` is built from the constants the Zod one is, the
|
|
7
|
+
* grammar and the two messages of `audit_log_schema.ts` and the bound of
|
|
8
|
+
* `auth/name_schema.ts`, so the two can't drift apart. They give every input
|
|
9
|
+
* the same verdict and output, and write the same JSON Schema (`maxLength`
|
|
10
|
+
* and `pattern`); a string both too long and off the grammar gets the one
|
|
11
|
+
* length issue from this twin, as its `pipe` stops at the first failing step,
|
|
12
|
+
* where the Zod one adds the grammar issue after it.
|
|
13
|
+
*
|
|
14
|
+
* The exports are `@nodocs` while the Zod schemas of the same names stay, as
|
|
15
|
+
* the docs build refuses two exports of one name.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
22
|
+
* `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
|
|
23
|
+
* `AuditEventTypeName`. A string it refuses gets the Zod one's message; a
|
|
24
|
+
* value that is no string, fuz_schema's.
|
|
25
|
+
*
|
|
26
|
+
* @nodocs
|
|
27
|
+
*/
|
|
28
|
+
export declare const AuditEventTypeName: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
29
|
+
/** @nodocs */
|
|
30
|
+
export type AuditEventTypeName = Infer<typeof AuditEventTypeName>;
|
|
31
|
+
/**
|
|
32
|
+
* Audit event outcome, the twin of the Zod `AuditOutcome`.
|
|
33
|
+
*
|
|
34
|
+
* @nodocs
|
|
35
|
+
*/
|
|
36
|
+
export declare const AuditOutcome: import("@fuzdev/fuz_schema/schema.ts").Schema<"success" | "failure", "success" | "failure", "one_of", readonly ["success", "failure"]>;
|
|
37
|
+
/** @nodocs */
|
|
38
|
+
export type AuditOutcome = Infer<typeof AuditOutcome>;
|
|
39
|
+
//# sourceMappingURL=audit_log_schema_fuz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit_log_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAgC,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAUxF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0MAG9B,CAAC;AACF,cAAc;AACd,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,wIAAiC,CAAC;AAC3D,cAAc;AACd,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@fuzdev/fuz_schema` twins of the Zod `AuditEventTypeName` and
|
|
3
|
+
* `AuditOutcome` (`auth/audit_log_schema.ts`), under the same names, for
|
|
4
|
+
* schemas written in fuz_schema.
|
|
5
|
+
*
|
|
6
|
+
* `AuditEventTypeName` is built from the constants the Zod one is, the
|
|
7
|
+
* grammar and the two messages of `audit_log_schema.ts` and the bound of
|
|
8
|
+
* `auth/name_schema.ts`, so the two can't drift apart. They give every input
|
|
9
|
+
* the same verdict and output, and write the same JSON Schema (`maxLength`
|
|
10
|
+
* and `pattern`); a string both too long and off the grammar gets the one
|
|
11
|
+
* length issue from this twin, as its `pipe` stops at the first failing step,
|
|
12
|
+
* where the Zod one adds the grammar issue after it.
|
|
13
|
+
*
|
|
14
|
+
* The exports are `@nodocs` while the Zod schemas of the same names stay, as
|
|
15
|
+
* the docs build refuses two exports of one name.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { message, one_of, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
|
|
20
|
+
import { bounded_string } from '../primitive_schemas_fuz.js';
|
|
21
|
+
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
22
|
+
import { AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE, AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE, AUDIT_EVENT_TYPE_NAME_REGEX } from './audit_log_schema.js';
|
|
23
|
+
/**
|
|
24
|
+
* Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
25
|
+
* `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
|
|
26
|
+
* `AuditEventTypeName`. A string it refuses gets the Zod one's message; a
|
|
27
|
+
* value that is no string, fuz_schema's.
|
|
28
|
+
*
|
|
29
|
+
* @nodocs
|
|
30
|
+
*/
|
|
31
|
+
export const AuditEventTypeName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE }), message(regex(AUDIT_EVENT_TYPE_NAME_REGEX), AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE));
|
|
32
|
+
/**
|
|
33
|
+
* Audit event outcome, the twin of the Zod `AuditOutcome`.
|
|
34
|
+
*
|
|
35
|
+
* @nodocs
|
|
36
|
+
*/
|
|
37
|
+
export const AuditOutcome = one_of(['success', 'failure']);
|
|
@@ -22,13 +22,10 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { z } from 'zod';
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* digits.
|
|
25
|
+
* Zod schema for valid credential-type name strings: the shared name grammar
|
|
26
|
+
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
27
|
+
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
29
28
|
*/
|
|
30
|
-
export declare const CREDENTIAL_TYPE_NAME_REGEX: RegExp;
|
|
31
|
-
/** Zod schema for valid credential-type name strings. */
|
|
32
29
|
export declare const CredentialTypeName: z.ZodString;
|
|
33
30
|
export type CredentialTypeName = z.infer<typeof CredentialTypeName>;
|
|
34
31
|
/** Cookie-based session credential. */
|
|
@@ -99,7 +96,7 @@ export interface CredentialTypeSchemaResult {
|
|
|
99
96
|
* @param consumer_types - optional consumer-declared credential-type set with optional metadata
|
|
100
97
|
* @returns `{CredentialType, credential_types}` — Zod schema and metadata map
|
|
101
98
|
*
|
|
102
|
-
* @throws Error if any `consumer_types` key fails
|
|
99
|
+
* @throws Error if any `consumer_types` key fails `CredentialTypeName` (its grammar or its length cap), collides with a builtin name, or appears more than once
|
|
103
100
|
*
|
|
104
101
|
* @example
|
|
105
102
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAwC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
|
|
@@ -21,17 +21,13 @@
|
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
23
|
import { z } from 'zod';
|
|
24
|
+
import { create_name_schema } from './name_schema.js';
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* digits.
|
|
26
|
+
* Zod schema for valid credential-type name strings: the shared name grammar
|
|
27
|
+
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
28
|
+
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
29
29
|
*/
|
|
30
|
-
export const
|
|
31
|
-
/** Zod schema for valid credential-type name strings. */
|
|
32
|
-
export const CredentialTypeName = z
|
|
33
|
-
.string()
|
|
34
|
-
.regex(CREDENTIAL_TYPE_NAME_REGEX, 'Credential-type names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
|
|
30
|
+
export const CredentialTypeName = create_name_schema('Credential-type');
|
|
35
31
|
// Builtin credential types — provided by fuz_app, always available.
|
|
36
32
|
/** Cookie-based session credential. */
|
|
37
33
|
export const CREDENTIAL_TYPE_SESSION = 'session';
|
|
@@ -89,7 +85,7 @@ export const builtin_credential_type_meta = new Map([
|
|
|
89
85
|
* @param consumer_types - optional consumer-declared credential-type set with optional metadata
|
|
90
86
|
* @returns `{CredentialType, credential_types}` — Zod schema and metadata map
|
|
91
87
|
*
|
|
92
|
-
* @throws Error if any `consumer_types` key fails
|
|
88
|
+
* @throws Error if any `consumer_types` key fails `CredentialTypeName` (its grammar or its length cap), collides with a builtin name, or appears more than once
|
|
93
89
|
*
|
|
94
90
|
* @example
|
|
95
91
|
* ```ts
|
|
@@ -26,13 +26,10 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { z } from 'zod';
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* digits.
|
|
29
|
+
* Zod schema for valid grant-path name strings: the shared name grammar
|
|
30
|
+
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
31
|
+
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
33
32
|
*/
|
|
34
|
-
export declare const GRANT_PATH_NAME_REGEX: RegExp;
|
|
35
|
-
/** Zod schema for valid grant-path name strings. */
|
|
36
33
|
export declare const GrantPathName: z.ZodString;
|
|
37
34
|
export type GrantPathName = z.infer<typeof GrantPathName>;
|
|
38
35
|
/** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
|
|
@@ -100,7 +97,7 @@ export interface GrantPathSchemaResult {
|
|
|
100
97
|
* @param consumer_paths - optional consumer-declared grant-path set with optional metadata
|
|
101
98
|
* @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
|
|
102
99
|
*
|
|
103
|
-
* @throws Error if any `consumer_paths` key fails
|
|
100
|
+
* @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
|
|
104
101
|
*
|
|
105
102
|
* @example
|
|
106
103
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,aAAa,aAAmC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,wBAAwB,GACpC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,qBA2BF,CAAC"}
|
|
@@ -25,17 +25,13 @@
|
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
27
|
import { z } from 'zod';
|
|
28
|
+
import { create_name_schema } from './name_schema.js';
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* digits.
|
|
30
|
+
* Zod schema for valid grant-path name strings: the shared name grammar
|
|
31
|
+
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
32
|
+
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
33
33
|
*/
|
|
34
|
-
export const
|
|
35
|
-
/** Zod schema for valid grant-path name strings. */
|
|
36
|
-
export const GrantPathName = z
|
|
37
|
-
.string()
|
|
38
|
-
.regex(GRANT_PATH_NAME_REGEX, 'Grant-path names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
|
|
34
|
+
export const GrantPathName = create_name_schema('Grant-path');
|
|
39
35
|
// Builtin grant paths — provided by fuz_app, always available.
|
|
40
36
|
/** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
|
|
41
37
|
export const GRANT_PATH_ADMIN = 'admin';
|
|
@@ -98,7 +94,7 @@ export const builtin_grant_path_meta = new Map([
|
|
|
98
94
|
* @param consumer_paths - optional consumer-declared grant-path set with optional metadata
|
|
99
95
|
* @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
|
|
100
96
|
*
|
|
101
|
-
* @throws Error if any `consumer_paths` key fails
|
|
97
|
+
* @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
|
|
102
98
|
*
|
|
103
99
|
* @example
|
|
104
100
|
* ```ts
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name grammar the auth vocabularies share: runs of lowercase letters
|
|
3
|
+
* joined by single underscores, at most `NAME_LENGTH_MAX` characters.
|
|
4
|
+
*
|
|
5
|
+
* Role names (`RoleName`), scope kinds (`ScopeKindName`), grant paths
|
|
6
|
+
* (`GrantPathName`), credential types (`CredentialTypeName`) and a token's
|
|
7
|
+
* `surface:` name (`is_route_scope_capability`) all hold it, and the audit
|
|
8
|
+
* event type (`AuditEventTypeName`) takes its length cap over a grammar of its
|
|
9
|
+
* own. Each domain keeps its own label in its messages, so the rule is shared
|
|
10
|
+
* and the wording is not: `create_name_schema('Role')` says
|
|
11
|
+
* `Role names must …`. The Rust spine's `is_valid_name` and `NAME_LENGTH_MAX`
|
|
12
|
+
* are its twin.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import type { z } from 'zod';
|
|
17
|
+
/**
|
|
18
|
+
* The longest name the grammar admits, in UTF-16 code units (what
|
|
19
|
+
* `String.length` measures; for a name on `NAME_REGEX` they are its
|
|
20
|
+
* characters). A name is caller-chosen text until it passes the grammar, and
|
|
21
|
+
* some are copied into a row or an audit row where they enter, so the grammar
|
|
22
|
+
* bounds the length too. Same value as the Rust spine's `NAME_LENGTH_MAX`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const NAME_LENGTH_MAX = 64;
|
|
25
|
+
/**
|
|
26
|
+
* The grammar of a name: runs of lowercase letters (a-z) joined by single
|
|
27
|
+
* underscores. Rejects empty strings, leading, trailing or consecutive
|
|
28
|
+
* underscores, uppercase, digits, and the partial unique indexes' `'GLOBAL'`
|
|
29
|
+
* token.
|
|
30
|
+
*/
|
|
31
|
+
export declare const NAME_REGEX: RegExp;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `name` is on the grammar and within `NAME_LENGTH_MAX`.
|
|
34
|
+
*
|
|
35
|
+
* @param name - the name to check
|
|
36
|
+
* @returns `true` when `name` matches `NAME_REGEX` and is at most `NAME_LENGTH_MAX` long
|
|
37
|
+
*/
|
|
38
|
+
export declare const is_valid_name: (name: string) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The message of a name longer than `NAME_LENGTH_MAX`.
|
|
41
|
+
*
|
|
42
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
43
|
+
* @returns `<label> names must be at most 64 characters`
|
|
44
|
+
*/
|
|
45
|
+
export declare const format_name_length_message: (label: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* The message of a name off `NAME_REGEX`.
|
|
48
|
+
*
|
|
49
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
50
|
+
* @returns `<label> names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores`
|
|
51
|
+
*/
|
|
52
|
+
export declare const format_name_pattern_message: (label: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* A Zod schema for a name of one domain: `bounded_string` at
|
|
55
|
+
* `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
|
|
56
|
+
* string both too long and off the grammar gets both issues, the length one
|
|
57
|
+
* first.
|
|
58
|
+
*
|
|
59
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
60
|
+
* @returns the name schema
|
|
61
|
+
*/
|
|
62
|
+
export declare const create_name_schema: (label: string) => z.ZodString;
|
|
63
|
+
//# sourceMappingURL=name_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/name_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,MACI,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,MACuD,CAAC;AAEpH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,CAAC,CAAC,SAII,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name grammar the auth vocabularies share: runs of lowercase letters
|
|
3
|
+
* joined by single underscores, at most `NAME_LENGTH_MAX` characters.
|
|
4
|
+
*
|
|
5
|
+
* Role names (`RoleName`), scope kinds (`ScopeKindName`), grant paths
|
|
6
|
+
* (`GrantPathName`), credential types (`CredentialTypeName`) and a token's
|
|
7
|
+
* `surface:` name (`is_route_scope_capability`) all hold it, and the audit
|
|
8
|
+
* event type (`AuditEventTypeName`) takes its length cap over a grammar of its
|
|
9
|
+
* own. Each domain keeps its own label in its messages, so the rule is shared
|
|
10
|
+
* and the wording is not: `create_name_schema('Role')` says
|
|
11
|
+
* `Role names must …`. The Rust spine's `is_valid_name` and `NAME_LENGTH_MAX`
|
|
12
|
+
* are its twin.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
17
|
+
/**
|
|
18
|
+
* The longest name the grammar admits, in UTF-16 code units (what
|
|
19
|
+
* `String.length` measures; for a name on `NAME_REGEX` they are its
|
|
20
|
+
* characters). A name is caller-chosen text until it passes the grammar, and
|
|
21
|
+
* some are copied into a row or an audit row where they enter, so the grammar
|
|
22
|
+
* bounds the length too. Same value as the Rust spine's `NAME_LENGTH_MAX`.
|
|
23
|
+
*/
|
|
24
|
+
export const NAME_LENGTH_MAX = 64;
|
|
25
|
+
/**
|
|
26
|
+
* The grammar of a name: runs of lowercase letters (a-z) joined by single
|
|
27
|
+
* underscores. Rejects empty strings, leading, trailing or consecutive
|
|
28
|
+
* underscores, uppercase, digits, and the partial unique indexes' `'GLOBAL'`
|
|
29
|
+
* token.
|
|
30
|
+
*/
|
|
31
|
+
export const NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `name` is on the grammar and within `NAME_LENGTH_MAX`.
|
|
34
|
+
*
|
|
35
|
+
* @param name - the name to check
|
|
36
|
+
* @returns `true` when `name` matches `NAME_REGEX` and is at most `NAME_LENGTH_MAX` long
|
|
37
|
+
*/
|
|
38
|
+
export const is_valid_name = (name) => name.length <= NAME_LENGTH_MAX && NAME_REGEX.test(name);
|
|
39
|
+
/**
|
|
40
|
+
* The message of a name longer than `NAME_LENGTH_MAX`.
|
|
41
|
+
*
|
|
42
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
43
|
+
* @returns `<label> names must be at most 64 characters`
|
|
44
|
+
*/
|
|
45
|
+
export const format_name_length_message = (label) => `${label} names must be at most ${NAME_LENGTH_MAX} characters`;
|
|
46
|
+
/**
|
|
47
|
+
* The message of a name off `NAME_REGEX`.
|
|
48
|
+
*
|
|
49
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
50
|
+
* @returns `<label> names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores`
|
|
51
|
+
*/
|
|
52
|
+
export const format_name_pattern_message = (label) => `${label} names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores`;
|
|
53
|
+
/**
|
|
54
|
+
* A Zod schema for a name of one domain: `bounded_string` at
|
|
55
|
+
* `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
|
|
56
|
+
* string both too long and off the grammar gets both issues, the length one
|
|
57
|
+
* first.
|
|
58
|
+
*
|
|
59
|
+
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
60
|
+
* @returns the name schema
|
|
61
|
+
*/
|
|
62
|
+
export const create_name_schema = (label) => bounded_string({
|
|
63
|
+
max: NAME_LENGTH_MAX,
|
|
64
|
+
max_message: format_name_length_message(label)
|
|
65
|
+
}).regex(NAME_REGEX, format_name_pattern_message(label));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/request_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EACN,KAAK,O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
|
|
41
41
|
import { query_role_grant_find_active_for_actor } from './role_grant_queries.js';
|
|
42
42
|
import { has_test_context_preset, RESOLVED_AUTH_KEY, SESSION_COOKIE_EXPIRES_AT_KEY, SESSION_TOKEN_KEY } from '../hono_context.js';
|
|
43
43
|
import { credential_deadline_after } from './credential_deadline.js';
|
|
44
|
+
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
44
45
|
import { get_resolved_auth, resolved_auth_scope } from './resolved_auth.js';
|
|
45
46
|
import { is_route_scope_capability, token_scope_admits_non_rpc, token_scope_denied_body } from './token_scope.js';
|
|
46
47
|
import { is_public_auth, needs_actor, parse_acting } from '../http/auth_shape.js';
|
|
@@ -331,7 +332,7 @@ export const get_public_account_id = (c) => {
|
|
|
331
332
|
*/
|
|
332
333
|
export const require_token_scope = (capability) => {
|
|
333
334
|
if (!is_route_scope_capability(capability)) {
|
|
334
|
-
throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability for a route \u2014 expected 'surface:<name>', where a surface name is runs of lowercase letters joined by single underscores ('rpc:<method>' is the action dispatcher's per-method gate, which a route never reaches)`);
|
|
335
|
+
throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability for a route \u2014 expected 'surface:<name>', where a surface name is runs of lowercase letters joined by single underscores, at most ${NAME_LENGTH_MAX} characters ('rpc:<method>' is the action dispatcher's per-method gate, which a route never reaches)`);
|
|
335
336
|
}
|
|
336
337
|
return async (c, next) => {
|
|
337
338
|
const denied = token_scope_surface_denial(c, capability);
|