@fuzdev/fuz_app 0.161.0 → 0.163.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 +47 -36
- package/dist/auth/account_action_specs.d.ts +614 -150
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +56 -52
- package/dist/auth/account_route_schema.d.ts +401 -94
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +54 -39
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +531 -118
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +76 -58
- package/dist/auth/admin_action_specs.d.ts +1753 -240
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +28 -26
- package/dist/auth/admin_actions.d.ts +4 -4
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +3 -3
- package/dist/auth/all_cell_actions.d.ts +3 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token.d.ts +4 -4
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +3 -3
- 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_schema.d.ts +798 -291
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +192 -201
- package/dist/auth/bootstrap_route_schema.d.ts +173 -50
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +35 -16
- package/dist/auth/cell_grant_action_specs.d.ts +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_actions.d.ts +4 -4
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/credential_type_schema.d.ts +16 -29
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +14 -18
- package/dist/auth/grant_path_schema.d.ts +15 -29
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +13 -17
- 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 +28 -1
- package/dist/auth/name_schema.d.ts +7 -6
- package/dist/auth/name_schema.d.ts.map +1 -1
- package/dist/auth/name_schema.js +8 -9
- package/dist/auth/password.d.ts +15 -7
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +16 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +72 -72
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_actions.d.ts +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +3 -3
- package/dist/auth/role_grant_offer_notifications.d.ts +60 -60
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +8 -8
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +10 -10
- package/dist/auth/role_schema.d.ts +47 -55
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +29 -35
- package/dist/auth/scope_kind_schema.d.ts +22 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +19 -19
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +6 -6
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +7 -6
- package/dist/auth/signup_route_schema.d.ts +71 -21
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +18 -16
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.js +1 -1
- package/dist/auth/token_lifetime.d.ts +33 -9
- package/dist/auth/token_lifetime.d.ts.map +1 -1
- package/dist/auth/token_lifetime.js +8 -7
- package/dist/auth/token_scope.d.ts +99 -25
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +57 -35
- 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 +2 -22
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -24
- package/dist/primitive_schemas_fuz.d.ts +56 -2
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +54 -4
- package/dist/testing/CLAUDE.md +29 -8
- package/dist/testing/admin_integration.d.ts +3 -3
- 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 +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/default_spine_surface.d.ts +2 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +43 -8
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- 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/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +45 -42
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +4 -4
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- 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 +4 -3
- package/dist/testing/token_scope_fixtures.d.ts +24 -0
- package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
- package/dist/testing/token_scope_fixtures.js +49 -0
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +13 -12
- package/dist/ui/BootstrapForm.svelte +4 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +4 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- 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
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -39
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -37
- package/dist/auth/role_schema_fuz.d.ts +0 -30
- package/dist/auth/role_schema_fuz.d.ts.map +0 -1
- package/dist/auth/role_schema_fuz.js +0 -30
- package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
- package/dist/auth/scope_kind_schema_fuz.js +0 -31
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
* `BuiltinCredentialType` is the closed set middleware sets on the Hono
|
|
16
16
|
* context (`hono_context.ts`) and the audit log records — middleware only
|
|
17
17
|
* ever authenticates through a builtin. Consumer-declared types live in
|
|
18
|
-
* the registry `
|
|
18
|
+
* the registry `create_credential_type_registry` builds, consulted when
|
|
19
19
|
* validating `RoleSpec.required_credential_types`.
|
|
20
20
|
*
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
23
|
+
import { format_issue, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
24
24
|
import { create_name_schema } from './name_schema.js';
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Valid credential-type name strings: the shared name grammar
|
|
27
27
|
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
28
28
|
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
29
29
|
*/
|
|
@@ -46,15 +46,13 @@ export const BUILTIN_CREDENTIAL_TYPES = [
|
|
|
46
46
|
CREDENTIAL_TYPE_API_TOKEN,
|
|
47
47
|
CREDENTIAL_TYPE_DAEMON_TOKEN
|
|
48
48
|
];
|
|
49
|
-
/** Zod enum for builtin credential types only. */
|
|
50
|
-
export const BuiltinCredentialType = z.enum(BUILTIN_CREDENTIAL_TYPES);
|
|
51
49
|
/**
|
|
52
50
|
* Builtin credential-type metadata. Not overridable by consumers.
|
|
53
51
|
*
|
|
54
52
|
* Typed `ReadonlyMap` for the contract — but JS Maps don't honor
|
|
55
53
|
* `Object.freeze` for `.set` / `.delete` / `.clear` (they mutate
|
|
56
54
|
* internal slots, not own properties), so freeze adds no runtime guard
|
|
57
|
-
* here. Read once at startup by `
|
|
55
|
+
* here. Read once at startup by `create_credential_type_registry`;
|
|
58
56
|
* runtime mutation has no effect on already-built schemas.
|
|
59
57
|
*/
|
|
60
58
|
export const builtin_credential_type_meta = new Map([
|
|
@@ -72,39 +70,39 @@ export const builtin_credential_type_meta = new Map([
|
|
|
72
70
|
]
|
|
73
71
|
]);
|
|
74
72
|
/**
|
|
75
|
-
* Create a credential-type
|
|
73
|
+
* Create a credential-type registry from the builtin set plus optional
|
|
76
74
|
* consumer-declared additions.
|
|
77
75
|
*
|
|
78
76
|
* Builtins (`session`, `api_token`, `daemon_token`) are always present;
|
|
79
77
|
* consumer entries that collide with a builtin name throw at
|
|
80
|
-
* construction. Pass the result into `
|
|
78
|
+
* construction. Pass the result into `create_role_registry`'s optional
|
|
81
79
|
* `credential_types` parameter so each role's
|
|
82
80
|
* `required_credential_types` entries are validated against this set
|
|
83
81
|
* at construction time.
|
|
84
82
|
*
|
|
85
83
|
* @param consumer_types - optional consumer-declared credential-type set with optional metadata
|
|
86
|
-
* @returns `{
|
|
84
|
+
* @returns `{credential_types}` — the metadata map
|
|
87
85
|
*
|
|
88
86
|
* @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
|
|
89
87
|
*
|
|
90
88
|
* @example
|
|
91
89
|
* ```ts
|
|
92
90
|
* // simple — builtins only
|
|
93
|
-
* const {
|
|
91
|
+
* const {credential_types} = create_credential_type_registry();
|
|
94
92
|
*
|
|
95
93
|
* // with consumer extensions
|
|
96
|
-
* const {
|
|
94
|
+
* const {credential_types} = create_credential_type_registry({
|
|
97
95
|
* sso_assertion: {description: 'OIDC SSO assertion bound to an IdP-asserted account.'},
|
|
98
96
|
* });
|
|
99
97
|
* ```
|
|
100
98
|
*/
|
|
101
|
-
export const
|
|
99
|
+
export const create_credential_type_registry = (consumer_types = {}) => {
|
|
102
100
|
const consumer_names = Object.keys(consumer_types);
|
|
103
101
|
const seen = new Set();
|
|
104
102
|
for (const name of consumer_names) {
|
|
105
|
-
const parsed = CredentialTypeName
|
|
106
|
-
if (!parsed.
|
|
107
|
-
throw new Error(`Invalid credential-type name "${name}": ${parsed.
|
|
103
|
+
const parsed = parse(CredentialTypeName, name);
|
|
104
|
+
if (!parsed.ok) {
|
|
105
|
+
throw new Error(`Invalid credential-type name "${name}": ${format_issue(parsed.issues[0])}`);
|
|
108
106
|
}
|
|
109
107
|
if (builtin_credential_type_meta.has(name)) {
|
|
110
108
|
throw new Error(`Consumer credential-type "${name}" collides with builtin credential-type`);
|
|
@@ -114,11 +112,9 @@ export const create_credential_type_schema = (consumer_types = {}) => {
|
|
|
114
112
|
}
|
|
115
113
|
seen.add(name);
|
|
116
114
|
}
|
|
117
|
-
const all_names = [...BUILTIN_CREDENTIAL_TYPES, ...consumer_names];
|
|
118
|
-
const CredentialType = z.enum(all_names);
|
|
119
115
|
const credential_types = new Map(builtin_credential_type_meta);
|
|
120
116
|
for (const name of consumer_names) {
|
|
121
117
|
credential_types.set(name, consumer_types[name]);
|
|
122
118
|
}
|
|
123
|
-
return {
|
|
119
|
+
return { credential_types };
|
|
124
120
|
};
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
|
-
import {
|
|
27
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Valid grant-path name strings: the shared name grammar
|
|
30
30
|
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
31
31
|
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
32
32
|
*/
|
|
33
|
-
export declare const GrantPathName:
|
|
34
|
-
export type GrantPathName =
|
|
33
|
+
export declare const GrantPathName: 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>>>;
|
|
34
|
+
export type GrantPathName = Infer<typeof GrantPathName>;
|
|
35
35
|
/** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
|
|
36
36
|
export declare const GRANT_PATH_ADMIN = "admin";
|
|
37
37
|
/** Self-service grant — caller toggles their own role_grant via `self_service_role_set`. */
|
|
@@ -42,14 +42,8 @@ export declare const GRANT_PATH_SYSTEM = "system";
|
|
|
42
42
|
export declare const GRANT_PATH_BOOTSTRAP = "bootstrap";
|
|
43
43
|
/** The builtin grant-path names as a const tuple. */
|
|
44
44
|
export declare const BUILTIN_GRANT_PATHS: readonly ["admin", "self_service", "system", "bootstrap"];
|
|
45
|
-
/**
|
|
46
|
-
export
|
|
47
|
-
admin: "admin";
|
|
48
|
-
self_service: "self_service";
|
|
49
|
-
system: "system";
|
|
50
|
-
bootstrap: "bootstrap";
|
|
51
|
-
}>;
|
|
52
|
-
export type BuiltinGrantPath = z.infer<typeof BuiltinGrantPath>;
|
|
45
|
+
/** A builtin grant-path name. */
|
|
46
|
+
export type BuiltinGrantPath = (typeof BUILTIN_GRANT_PATHS)[number];
|
|
53
47
|
/**
|
|
54
48
|
* Per-grant-path metadata. `description` is admin-UI-facing copy
|
|
55
49
|
* (mirrors `RoleSpec.description` and `ScopeKindMeta.description`).
|
|
@@ -64,20 +58,12 @@ export interface GrantPathMeta {
|
|
|
64
58
|
* Typed `ReadonlyMap` for the contract — but JS Maps don't honor
|
|
65
59
|
* `Object.freeze` for `.set` / `.delete` / `.clear` (they mutate
|
|
66
60
|
* internal slots, not own properties), so freeze adds no runtime guard
|
|
67
|
-
* here. Read once at startup by `
|
|
61
|
+
* here. Read once at startup by `create_grant_path_registry`; runtime
|
|
68
62
|
* mutation has no effect on already-built schemas.
|
|
69
63
|
*/
|
|
70
64
|
export declare const builtin_grant_path_meta: ReadonlyMap<string, GrantPathMeta>;
|
|
71
|
-
/** The result of `
|
|
72
|
-
export interface
|
|
73
|
-
/**
|
|
74
|
-
* Zod schema that validates grant-path name strings against the
|
|
75
|
-
* registered set (builtins + consumer-declared). Use at I/O
|
|
76
|
-
* boundaries (admin UIs, codegen) and as the construction-time check
|
|
77
|
-
* inside `create_role_schema` for every `RoleSpec.grant_paths`
|
|
78
|
-
* entry.
|
|
79
|
-
*/
|
|
80
|
-
GrantPath: z.ZodType<string>;
|
|
65
|
+
/** The result of `create_grant_path_registry` — the metadata map. */
|
|
66
|
+
export interface GrantPathRegistry {
|
|
81
67
|
/**
|
|
82
68
|
* Map of every registered grant-path to its metadata. Keyed by
|
|
83
69
|
* name. Read at startup by admin / codegen surfaces.
|
|
@@ -85,30 +71,30 @@ export interface GrantPathSchemaResult {
|
|
|
85
71
|
grant_paths: ReadonlyMap<string, GrantPathMeta>;
|
|
86
72
|
}
|
|
87
73
|
/**
|
|
88
|
-
* Create a grant-path
|
|
74
|
+
* Create a grant-path registry from the builtin set plus optional
|
|
89
75
|
* consumer-declared additions.
|
|
90
76
|
*
|
|
91
77
|
* Builtins (`admin`, `self_service`, `system`, `bootstrap`) are always
|
|
92
78
|
* present; consumer entries that collide with a builtin name throw at
|
|
93
|
-
* construction. Pass the result into `
|
|
79
|
+
* construction. Pass the result into `create_role_registry`'s optional
|
|
94
80
|
* `grant_paths` parameter so each role's `grant_paths` entries are
|
|
95
81
|
* validated against this set at construction time.
|
|
96
82
|
*
|
|
97
83
|
* @param consumer_paths - optional consumer-declared grant-path set with optional metadata
|
|
98
|
-
* @returns `{
|
|
84
|
+
* @returns `{grant_paths}` — the metadata map
|
|
99
85
|
*
|
|
100
86
|
* @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
|
|
101
87
|
*
|
|
102
88
|
* @example
|
|
103
89
|
* ```ts
|
|
104
90
|
* // simple — builtins only
|
|
105
|
-
* const {
|
|
91
|
+
* const {grant_paths} = create_grant_path_registry();
|
|
106
92
|
*
|
|
107
93
|
* // with consumer extensions
|
|
108
|
-
* const {
|
|
94
|
+
* const {grant_paths} = create_grant_path_registry({
|
|
109
95
|
* invite_only: {description: 'Granted by claiming a consumer-issued invite.'},
|
|
110
96
|
* });
|
|
111
97
|
* ```
|
|
112
98
|
*/
|
|
113
|
-
export declare const
|
|
99
|
+
export declare const create_grant_path_registry: (consumer_paths?: Record<string, GrantPathMeta>) => GrantPathRegistry;
|
|
114
100
|
//# sourceMappingURL=grant_path_schema.d.ts.map
|
|
@@ -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,
|
|
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,EAAuB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAI/E;;;;GAIG;AACH,eAAO,MAAM,aAAa,0MAAmC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIxD,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,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;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,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,0BAA0B,GACtC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,iBAwBF,CAAC"}
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
|
-
import {
|
|
27
|
+
import { format_issue, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
28
28
|
import { create_name_schema } from './name_schema.js';
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Valid grant-path name strings: the shared name grammar
|
|
31
31
|
* (`auth/name_schema.ts`), runs of lowercase letters joined by single
|
|
32
32
|
* underscores, at most `NAME_LENGTH_MAX` characters.
|
|
33
33
|
*/
|
|
@@ -48,15 +48,13 @@ export const BUILTIN_GRANT_PATHS = [
|
|
|
48
48
|
GRANT_PATH_SYSTEM,
|
|
49
49
|
GRANT_PATH_BOOTSTRAP
|
|
50
50
|
];
|
|
51
|
-
/** Zod enum for builtin grant paths only. */
|
|
52
|
-
export const BuiltinGrantPath = z.enum(BUILTIN_GRANT_PATHS);
|
|
53
51
|
/**
|
|
54
52
|
* Builtin grant-path metadata. Not overridable by consumers.
|
|
55
53
|
*
|
|
56
54
|
* Typed `ReadonlyMap` for the contract — but JS Maps don't honor
|
|
57
55
|
* `Object.freeze` for `.set` / `.delete` / `.clear` (they mutate
|
|
58
56
|
* internal slots, not own properties), so freeze adds no runtime guard
|
|
59
|
-
* here. Read once at startup by `
|
|
57
|
+
* here. Read once at startup by `create_grant_path_registry`; runtime
|
|
60
58
|
* mutation has no effect on already-built schemas.
|
|
61
59
|
*/
|
|
62
60
|
export const builtin_grant_path_meta = new Map([
|
|
@@ -82,38 +80,38 @@ export const builtin_grant_path_meta = new Map([
|
|
|
82
80
|
]
|
|
83
81
|
]);
|
|
84
82
|
/**
|
|
85
|
-
* Create a grant-path
|
|
83
|
+
* Create a grant-path registry from the builtin set plus optional
|
|
86
84
|
* consumer-declared additions.
|
|
87
85
|
*
|
|
88
86
|
* Builtins (`admin`, `self_service`, `system`, `bootstrap`) are always
|
|
89
87
|
* present; consumer entries that collide with a builtin name throw at
|
|
90
|
-
* construction. Pass the result into `
|
|
88
|
+
* construction. Pass the result into `create_role_registry`'s optional
|
|
91
89
|
* `grant_paths` parameter so each role's `grant_paths` entries are
|
|
92
90
|
* validated against this set at construction time.
|
|
93
91
|
*
|
|
94
92
|
* @param consumer_paths - optional consumer-declared grant-path set with optional metadata
|
|
95
|
-
* @returns `{
|
|
93
|
+
* @returns `{grant_paths}` — the metadata map
|
|
96
94
|
*
|
|
97
95
|
* @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
|
|
98
96
|
*
|
|
99
97
|
* @example
|
|
100
98
|
* ```ts
|
|
101
99
|
* // simple — builtins only
|
|
102
|
-
* const {
|
|
100
|
+
* const {grant_paths} = create_grant_path_registry();
|
|
103
101
|
*
|
|
104
102
|
* // with consumer extensions
|
|
105
|
-
* const {
|
|
103
|
+
* const {grant_paths} = create_grant_path_registry({
|
|
106
104
|
* invite_only: {description: 'Granted by claiming a consumer-issued invite.'},
|
|
107
105
|
* });
|
|
108
106
|
* ```
|
|
109
107
|
*/
|
|
110
|
-
export const
|
|
108
|
+
export const create_grant_path_registry = (consumer_paths = {}) => {
|
|
111
109
|
const consumer_names = Object.keys(consumer_paths);
|
|
112
110
|
const seen = new Set();
|
|
113
111
|
for (const name of consumer_names) {
|
|
114
|
-
const parsed = GrantPathName
|
|
115
|
-
if (!parsed.
|
|
116
|
-
throw new Error(`Invalid grant-path name "${name}": ${parsed.
|
|
112
|
+
const parsed = parse(GrantPathName, name);
|
|
113
|
+
if (!parsed.ok) {
|
|
114
|
+
throw new Error(`Invalid grant-path name "${name}": ${format_issue(parsed.issues[0])}`);
|
|
117
115
|
}
|
|
118
116
|
if (builtin_grant_path_meta.has(name)) {
|
|
119
117
|
throw new Error(`Consumer grant-path "${name}" collides with builtin grant-path`);
|
|
@@ -123,11 +121,9 @@ export const create_grant_path_schema = (consumer_paths = {}) => {
|
|
|
123
121
|
}
|
|
124
122
|
seen.add(name);
|
|
125
123
|
}
|
|
126
|
-
const all_names = [...BUILTIN_GRANT_PATHS, ...consumer_names];
|
|
127
|
-
const GrantPath = z.enum(all_names);
|
|
128
124
|
const grant_paths = new Map(builtin_grant_path_meta);
|
|
129
125
|
for (const name of consumer_names) {
|
|
130
126
|
grant_paths.set(name, consumer_paths[name]);
|
|
131
127
|
}
|
|
132
|
-
return {
|
|
128
|
+
return { grant_paths };
|
|
133
129
|
};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { Uuid, Username
|
|
9
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
10
|
+
import { Email, Uuid, type Username } from '../primitive_schemas_fuz.js';
|
|
11
11
|
/** Invite row from the database. */
|
|
12
12
|
export interface Invite {
|
|
13
13
|
id: Uuid;
|
|
@@ -18,30 +18,102 @@ export interface Invite {
|
|
|
18
18
|
created_at: string;
|
|
19
19
|
created_by: Uuid | null;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
created_at:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
created_by:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Client-safe invite data, a `@fuzdev/fuz_schema` schema. Its `username` is
|
|
23
|
+
* `UsernameCanonical`, the lowercase every creation path stores.
|
|
24
|
+
*/
|
|
25
|
+
export declare const InviteJson: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
26
|
+
email: string | null;
|
|
27
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
|
|
28
|
+
created_at: string;
|
|
29
|
+
username: string | null;
|
|
30
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
31
|
+
claimed_at: string | null;
|
|
32
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
33
|
+
}, {
|
|
34
|
+
email: string | null;
|
|
35
|
+
id: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
username: string | null;
|
|
38
|
+
claimed_by: string | null;
|
|
39
|
+
claimed_at: string | null;
|
|
40
|
+
created_by: string | null;
|
|
41
|
+
}, "object", {
|
|
42
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
43
|
+
readonly '~types'?: {
|
|
44
|
+
readonly input: string;
|
|
45
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
49
|
+
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<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>>>>>;
|
|
50
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
51
|
+
readonly '~types'?: {
|
|
52
|
+
readonly input: string;
|
|
53
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
54
|
+
} | undefined;
|
|
55
|
+
}>>;
|
|
56
|
+
claimed_at: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
57
|
+
created_at: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
58
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
59
|
+
readonly '~types'?: {
|
|
60
|
+
readonly input: string;
|
|
61
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
62
|
+
} | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
}>;
|
|
65
|
+
export type InviteJson = Infer<typeof InviteJson>;
|
|
66
|
+
/**
|
|
67
|
+
* Invite data with resolved creator/claimer usernames, a `@fuzdev/fuz_schema`
|
|
68
|
+
* schema. The resolved names are plain strings.
|
|
69
|
+
*/
|
|
70
|
+
export declare const InviteWithUsernamesJson: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
71
|
+
email: string | null;
|
|
72
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
|
|
73
|
+
created_at: string;
|
|
74
|
+
username: string | null;
|
|
75
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
76
|
+
claimed_at: string | null;
|
|
77
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
78
|
+
created_by_username: string | null;
|
|
79
|
+
claimed_by_username: string | null;
|
|
80
|
+
}, {
|
|
81
|
+
email: string | null;
|
|
82
|
+
id: string;
|
|
83
|
+
created_at: string;
|
|
84
|
+
username: string | null;
|
|
85
|
+
claimed_by: string | null;
|
|
86
|
+
claimed_at: string | null;
|
|
87
|
+
created_by: string | null;
|
|
88
|
+
created_by_username: string | null;
|
|
89
|
+
claimed_by_username: string | null;
|
|
90
|
+
}, "object", {
|
|
91
|
+
created_by_username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
92
|
+
claimed_by_username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
93
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
94
|
+
readonly '~types'?: {
|
|
95
|
+
readonly input: string;
|
|
96
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
97
|
+
} | undefined;
|
|
98
|
+
};
|
|
99
|
+
email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
100
|
+
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<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>>>>>;
|
|
101
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
102
|
+
readonly '~types'?: {
|
|
103
|
+
readonly input: string;
|
|
104
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
105
|
+
} | undefined;
|
|
106
|
+
}>>;
|
|
107
|
+
claimed_at: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
108
|
+
created_at: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
109
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
110
|
+
readonly '~types'?: {
|
|
111
|
+
readonly input: string;
|
|
112
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
113
|
+
} | undefined;
|
|
114
|
+
}>>;
|
|
115
|
+
}>;
|
|
116
|
+
export type InviteWithUsernamesJson = Infer<typeof InviteWithUsernamesJson>;
|
|
45
117
|
/** Input for creating an invite. */
|
|
46
118
|
export interface CreateInviteInput {
|
|
47
119
|
email?: Email | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"invite_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,EACN,KAAK,EAGL,IAAI,EACJ,KAAK,QAAQ,EACb,MAAM,6BAA6B,CAAC;AAErC,oCAAoC;AACpC,MAAM,WAAW,MAAM;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE5E,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB"}
|
|
@@ -6,20 +6,27 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
/**
|
|
12
|
-
|
|
9
|
+
import { nullable, object, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
10
|
+
import { Email, Timestamp, UsernameCanonical, Uuid } from '../primitive_schemas_fuz.js';
|
|
11
|
+
/**
|
|
12
|
+
* Client-safe invite data, a `@fuzdev/fuz_schema` schema. Its `username` is
|
|
13
|
+
* `UsernameCanonical`, the lowercase every creation path stores.
|
|
14
|
+
*/
|
|
15
|
+
export const InviteJson = object({
|
|
13
16
|
id: Uuid,
|
|
14
|
-
email:
|
|
15
|
-
username:
|
|
16
|
-
claimed_by:
|
|
17
|
-
claimed_at:
|
|
18
|
-
created_at:
|
|
19
|
-
created_by:
|
|
17
|
+
email: nullable(Email),
|
|
18
|
+
username: nullable(UsernameCanonical),
|
|
19
|
+
claimed_by: nullable(Uuid),
|
|
20
|
+
claimed_at: nullable(Timestamp),
|
|
21
|
+
created_at: Timestamp,
|
|
22
|
+
created_by: nullable(Uuid)
|
|
20
23
|
});
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Invite data with resolved creator/claimer usernames, a `@fuzdev/fuz_schema`
|
|
26
|
+
* schema. The resolved names are plain strings.
|
|
27
|
+
*/
|
|
28
|
+
export const InviteWithUsernamesJson = object({
|
|
29
|
+
...InviteJson.def,
|
|
30
|
+
created_by_username: nullable(string),
|
|
31
|
+
claimed_by_username: nullable(string)
|
|
25
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAkQ1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
|
package/dist/auth/migrations.js
CHANGED
|
@@ -69,7 +69,7 @@ const AUTH_MIGRATION_NAMESPACE = 'fuz_auth';
|
|
|
69
69
|
* partial unique index is scoped by
|
|
70
70
|
* `(to_account, role, scope_kind, scope, from_actor)` so multiple
|
|
71
71
|
* grantors may coexist. `scope_kind` is informative-only in v1
|
|
72
|
-
* (registry-membership validation against `
|
|
72
|
+
* (registry-membership validation against `create_scope_kind_registry`);
|
|
73
73
|
* v2 may add INSERT-time `(role, scope_kind)` enforcement.
|
|
74
74
|
*/
|
|
75
75
|
const AUTH_MIGRATIONS = [
|
|
@@ -257,6 +257,33 @@ const AUTH_MIGRATIONS = [
|
|
|
257
257
|
AND superseded_at IS NULL
|
|
258
258
|
AND expire_audited_at IS NULL`);
|
|
259
259
|
}
|
|
260
|
+
},
|
|
261
|
+
// Every `account.username` lowercase, as `Username` canonicalizes every
|
|
262
|
+
// name production creates, so the wire's username (`UsernameCanonical`)
|
|
263
|
+
// is the stored one and the case-insensitive unique index reads the same
|
|
264
|
+
// value as the column.
|
|
265
|
+
//
|
|
266
|
+
// `ADD CONSTRAINT … CHECK` validates the rows already there: a database
|
|
267
|
+
// holding a username with an uppercase letter (one written outside the
|
|
268
|
+
// creation paths, by hand or by a harness) fails the migration on
|
|
269
|
+
// `check_violation`, and the chain's transaction rolls back. Lowercase
|
|
270
|
+
// those rows (`UPDATE account SET username = lower(username)`, which the
|
|
271
|
+
// unique index on `LOWER(username)` keeps from colliding) and migrate
|
|
272
|
+
// again. Idempotent without PL/pgSQL, as `role_grant_scope_kind_paired`:
|
|
273
|
+
// probe `information_schema.table_constraints`, then add only if absent.
|
|
274
|
+
{
|
|
275
|
+
name: 'account_username_lowercase',
|
|
276
|
+
up: async (db) => {
|
|
277
|
+
const existing = await db.query(`SELECT 1 FROM information_schema.table_constraints
|
|
278
|
+
WHERE table_schema = 'public'
|
|
279
|
+
AND table_name = 'account'
|
|
280
|
+
AND constraint_name = 'account_username_lowercase'`);
|
|
281
|
+
if (existing.length === 0) {
|
|
282
|
+
await db.query(`ALTER TABLE account
|
|
283
|
+
ADD CONSTRAINT account_username_lowercase
|
|
284
|
+
CHECK (username = lower(username))`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
260
287
|
}
|
|
261
288
|
];
|
|
262
289
|
/**
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type PipeSchema, type string } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
17
|
/**
|
|
18
18
|
* The longest name the grammar admits, in UTF-16 code units (what
|
|
19
19
|
* `String.length` measures; for a name on `NAME_REGEX` they are its
|
|
@@ -51,13 +51,14 @@ export declare const format_name_length_message: (label: string) => string;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare const format_name_pattern_message: (label: string) => string;
|
|
53
53
|
/**
|
|
54
|
-
* A
|
|
55
|
-
* `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
|
|
56
|
-
* string both too long and off the grammar gets
|
|
57
|
-
* first
|
|
54
|
+
* A `@fuzdev/fuz_schema` schema for a name of one domain: `bounded_string`
|
|
55
|
+
* at `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
|
|
56
|
+
* string both too long and off the grammar gets the one length issue, as the
|
|
57
|
+
* `pipe` stops at its first failing step; a value that is no string gets
|
|
58
|
+
* fuz_schema's message. Its JSON Schema is `maxLength` and `pattern`.
|
|
58
59
|
*
|
|
59
60
|
* @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
|
|
60
61
|
* @returns the name schema
|
|
61
62
|
*/
|
|
62
|
-
export declare const create_name_schema: (label: string) =>
|
|
63
|
+
export declare const create_name_schema: (label: string) => PipeSchema<string, PipeSchema<string, typeof string>>;
|
|
63
64
|
//# sourceMappingURL=name_schema.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"name_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/name_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAIlG;;;;;;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;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC9B,OAAO,MAAM,KACX,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC,CAIrD,CAAC"}
|