cauthy-auth 0.5.2 → 0.8.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/README.md +68 -3
- package/dist/{cauthy-BCTCqubt.d.ts → cauthy-Bn3iv50y.d.ts} +1 -1
- package/dist/{cauthy-hswMoS7B.d.mts → cauthy-C29HCvag.d.mts} +1 -1
- package/dist/cli.js +490 -25
- package/dist/client.d.mts +236 -0
- package/dist/client.d.ts +236 -0
- package/dist/client.js +331 -0
- package/dist/client.js.map +1 -0
- package/dist/client.mjs +297 -0
- package/dist/client.mjs.map +1 -0
- package/dist/express.d.mts +24 -0
- package/dist/express.d.ts +24 -0
- package/dist/express.js +102 -0
- package/dist/express.js.map +1 -0
- package/dist/express.mjs +76 -0
- package/dist/express.mjs.map +1 -0
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/fastify.js +3 -1
- package/dist/fastify.js.map +1 -1
- package/dist/fastify.mjs +3 -1
- package/dist/fastify.mjs.map +1 -1
- package/dist/hono.d.mts +23 -0
- package/dist/hono.d.ts +23 -0
- package/dist/hono.js +50 -0
- package/dist/hono.js.map +1 -0
- package/dist/hono.mjs +24 -0
- package/dist/hono.mjs.map +1 -0
- package/dist/index.d.mts +44 -6
- package/dist/index.d.ts +44 -6
- package/dist/index.js +668 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +656 -37
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +24 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.js +77 -0
- package/dist/next.js.map +1 -0
- package/dist/next.mjs +52 -0
- package/dist/next.mjs.map +1 -0
- package/dist/react.d.mts +546 -7
- package/dist/react.d.ts +546 -7
- package/dist/react.js +925 -14
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +913 -10
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +271 -0
- package/dist/svelte.d.mts +26 -0
- package/dist/svelte.d.ts +26 -0
- package/dist/svelte.js +402 -0
- package/dist/svelte.js.map +1 -0
- package/dist/svelte.mjs +373 -0
- package/dist/svelte.mjs.map +1 -0
- package/dist/{system-DvcQjORr.d.ts → system-DhRr_WxR.d.ts} +139 -1
- package/dist/{system-CR8p4BjB.d.mts → system-ZD_Wa8Bm.d.mts} +139 -1
- package/dist/theme.d.mts +56 -1
- package/dist/theme.d.ts +56 -1
- package/dist/theme.js +181 -5
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +176 -4
- package/dist/theme.mjs.map +1 -1
- package/dist/validate-B_iC-4y8.d.mts +19 -0
- package/dist/validate-B_iC-4y8.d.ts +19 -0
- package/dist/vue.d.mts +28 -0
- package/dist/vue.d.ts +28 -0
- package/dist/vue.js +420 -0
- package/dist/vue.js.map +1 -0
- package/dist/vue.mjs +391 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +68 -7
- package/dist/permissions-B-a3eN0h.d.mts +0 -52
- package/dist/permissions-B-a3eN0h.d.ts +0 -52
|
@@ -1,6 +1,113 @@
|
|
|
1
1
|
import { JWK } from 'jose';
|
|
2
2
|
import { CauthyTheme } from './theme.js';
|
|
3
3
|
|
|
4
|
+
/** The part of an organization that says what its member may do. */
|
|
5
|
+
interface Permitted {
|
|
6
|
+
/** "resource:action" entries the person is allowed; "*" is any. Absent when the system keeps no catalog in Cauthy. */
|
|
7
|
+
permissions?: string[];
|
|
8
|
+
/** Entries the person is denied whatever else allows them. */
|
|
9
|
+
denied?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether the person may do an action on a resource in an organization:
|
|
13
|
+
* allowed by some entry, and denied by none. A denial wins.
|
|
14
|
+
*
|
|
15
|
+
* An organization of a system that keeps no catalog in Cauthy carries no
|
|
16
|
+
* permissions, and the answer is `false`: decide by its `role` instead.
|
|
17
|
+
*
|
|
18
|
+
* if (!can(organization, 'invoicing', 'write')) return forbidden()
|
|
19
|
+
*/
|
|
20
|
+
declare function can(organization: Permitted | null | undefined, resource: string, action: string): boolean;
|
|
21
|
+
/** Something a role may do: an action on a resource, in organizations of a kind ("*", the default, is every kind). */
|
|
22
|
+
interface PolicyPermission {
|
|
23
|
+
kind?: string;
|
|
24
|
+
resource: string;
|
|
25
|
+
action: string;
|
|
26
|
+
}
|
|
27
|
+
interface PolicyRole {
|
|
28
|
+
role: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
/** Roles whose permissions this one has as well. */
|
|
32
|
+
inherits?: string[];
|
|
33
|
+
permissions?: PolicyPermission[];
|
|
34
|
+
}
|
|
35
|
+
/** A role as `definePolicy` reads it: any `PolicyRole`, kept as written. */
|
|
36
|
+
type RoleShape = {
|
|
37
|
+
readonly role: string;
|
|
38
|
+
readonly name?: string;
|
|
39
|
+
readonly description?: string;
|
|
40
|
+
readonly inherits?: readonly string[];
|
|
41
|
+
readonly permissions?: readonly {
|
|
42
|
+
readonly kind?: string;
|
|
43
|
+
readonly resource: string;
|
|
44
|
+
readonly action: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
type Named<S extends string> = S extends '*' ? string : S;
|
|
48
|
+
type PermissionsIn<R> = R extends {
|
|
49
|
+
readonly permissions: readonly (infer P)[];
|
|
50
|
+
} ? P extends {
|
|
51
|
+
readonly resource: infer Res extends string;
|
|
52
|
+
readonly action: infer Act extends string;
|
|
53
|
+
} ? `${Named<Res>}:${Named<Act>}` : never : never;
|
|
54
|
+
/** The roles a catalog names: `RoleOf<typeof policy>`. */
|
|
55
|
+
type RoleOf<P> = P extends Policy<infer R, string> ? R : never;
|
|
56
|
+
/** The "resource:action" permissions a catalog names: `PermissionOf<typeof policy>`. */
|
|
57
|
+
type PermissionOf<P> = P extends Policy<string, infer X> ? X : never;
|
|
58
|
+
interface Policy<Role extends string = string, Permission extends string = string> {
|
|
59
|
+
/** The catalog as Cauthy takes it: `pushPolicy({ roles: policy.roles })`. */
|
|
60
|
+
roles: PolicyRole[];
|
|
61
|
+
/** Every role's name. */
|
|
62
|
+
roleNames: Role[];
|
|
63
|
+
/** Every permission some role has, as "resource:action". */
|
|
64
|
+
permissions: Permission[];
|
|
65
|
+
/**
|
|
66
|
+
* Whether the person may do this in the organization: `can(org, 'ledger:write')`.
|
|
67
|
+
* It reads what Cauthy sent with the session, so a catalog edited in Cauthy
|
|
68
|
+
* since this file was written is still what decides.
|
|
69
|
+
*/
|
|
70
|
+
can(organization: Permitted | null | undefined, permission: Permission): boolean;
|
|
71
|
+
/** Whether the person's role in the organization is one of these. */
|
|
72
|
+
hasRole(organization: {
|
|
73
|
+
role: string;
|
|
74
|
+
} | null | undefined, ...roles: Role[]): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* What a role may do by this catalog, with what it inherits: for showing a
|
|
77
|
+
* role, never for deciding about a person (their exceptions are not here).
|
|
78
|
+
*/
|
|
79
|
+
permissionsOf(role: Role): Permission[];
|
|
80
|
+
}
|
|
81
|
+
/** Gives a catalog of roles its types. See the top of this section. */
|
|
82
|
+
declare function definePolicy<const T extends readonly RoleShape[]>(roles: T): Policy<T[number]['role'], PermissionsIn<T[number]>>;
|
|
83
|
+
/**
|
|
84
|
+
* A TypeScript module that defines the catalog given, for `cauthy-auth policy
|
|
85
|
+
* --pull` to write: the application's types then come from the catalog
|
|
86
|
+
* Cauthy has.
|
|
87
|
+
*/
|
|
88
|
+
declare function policySource(system: string, roles: PolicyRole[]): string;
|
|
89
|
+
/** Reads a system's catalog of roles from Cauthy, with a personal access token. */
|
|
90
|
+
declare function pullPolicy(o?: Omit<PushPolicyOptions, 'roles'>): Promise<PolicyRole[]>;
|
|
91
|
+
interface PushPolicyOptions {
|
|
92
|
+
/** The system whose catalog this is. Default: `CAUTHY_SYSTEM`. */
|
|
93
|
+
system?: string;
|
|
94
|
+
roles: PolicyRole[];
|
|
95
|
+
/** Cauthy's address. Default: `CAUTHY_ISSUER`. */
|
|
96
|
+
issuer?: string;
|
|
97
|
+
/** The workspace's slug. Default: `CAUTHY_TENANT`. */
|
|
98
|
+
tenant?: string;
|
|
99
|
+
/** A personal access token with `organizations:manage`. Default: `CAUTHY_TOKEN`. */
|
|
100
|
+
token?: string;
|
|
101
|
+
fetch?: typeof fetch;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gives Cauthy a system's catalog of roles, replacing the one it has. It is
|
|
105
|
+
* the way to load a first catalog from what a system already had; from then on
|
|
106
|
+
* the catalog is Cauthy's, edited in its dashboard, and pushing again would
|
|
107
|
+
* overwrite what was edited there.
|
|
108
|
+
*/
|
|
109
|
+
declare function pushPolicy(o: PushPolicyOptions): Promise<void>;
|
|
110
|
+
|
|
4
111
|
/** How an application is set up to sign its people in with Cauthy. */
|
|
5
112
|
interface CauthyOptions {
|
|
6
113
|
/** Cauthy's public address, e.g. `https://id.example.com`. Default: `CAUTHY_ISSUER`. */
|
|
@@ -20,6 +127,12 @@ interface CauthyOptions {
|
|
|
20
127
|
* system's. Default: `CAUTHY_SYSTEM`.
|
|
21
128
|
*/
|
|
22
129
|
system?: string;
|
|
130
|
+
/**
|
|
131
|
+
* The workspace's slug in Cauthy. Needed for the application's own sign-in
|
|
132
|
+
* screens (`signIn.email`, `signUp.email`…), which sign people in through
|
|
133
|
+
* the application's server instead of Cauthy's page. Default: `CAUTHY_TENANT`.
|
|
134
|
+
*/
|
|
135
|
+
tenant?: string;
|
|
23
136
|
/** Where the routes are mounted. Default: `/api/auth`. */
|
|
24
137
|
basePath?: string;
|
|
25
138
|
/**
|
|
@@ -40,6 +153,27 @@ interface CauthyOptions {
|
|
|
40
153
|
* `CAUTHY_SYSTEM_KEY_ID`.
|
|
41
154
|
*/
|
|
42
155
|
systemKey?: SystemKey;
|
|
156
|
+
/**
|
|
157
|
+
* The application's own pages for what arrives by mail. A link Cauthy mails
|
|
158
|
+
* opens the page named here, with a `token` to give back; with none, it
|
|
159
|
+
* opens Cauthy's own page.
|
|
160
|
+
*
|
|
161
|
+
* signIn where `<SignIn />` is: a sign-in link opens it
|
|
162
|
+
* resetPassword where `<ResetPassword />` is
|
|
163
|
+
* verifyEmail where `<VerifyEmail />` is
|
|
164
|
+
*/
|
|
165
|
+
pages?: {
|
|
166
|
+
signIn?: string;
|
|
167
|
+
resetPassword?: string;
|
|
168
|
+
verifyEmail?: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* The address of the person a request comes from, passed on to Cauthy so
|
|
172
|
+
* its limits on attempts count the person and not this server. Default: the
|
|
173
|
+
* last address in `X-Forwarded-For`, which is the one the proxy in front of
|
|
174
|
+
* the application wrote. With several proxies, or none, give your own.
|
|
175
|
+
*/
|
|
176
|
+
clientIp?: (request: Request) => string | undefined;
|
|
43
177
|
/** `fetch` to reach Cauthy with. Default: the global one. */
|
|
44
178
|
fetch?: typeof fetch;
|
|
45
179
|
}
|
|
@@ -231,6 +365,10 @@ interface CauthySystem {
|
|
|
231
365
|
theme: {
|
|
232
366
|
get(clientId?: string): Promise<CauthyTheme>;
|
|
233
367
|
};
|
|
368
|
+
/** The catalog of roles of one of the application's systems, as Cauthy has it. */
|
|
369
|
+
policy: {
|
|
370
|
+
get(system: string): Promise<PolicyRole[]>;
|
|
371
|
+
};
|
|
234
372
|
/** The public half of `key`, to serve at the address Cauthy was given (`jwks_uri`). Empty with a secret. */
|
|
235
373
|
publicJwks(): Promise<{
|
|
236
374
|
keys: JWK[];
|
|
@@ -238,4 +376,4 @@ interface CauthySystem {
|
|
|
238
376
|
}
|
|
239
377
|
declare function createSystem(given?: SystemOptions): CauthySystem;
|
|
240
378
|
|
|
241
|
-
export { CauthyApiError as C, type JsonValue as J, type NewMember as N, type Organization as O, type
|
|
379
|
+
export { CauthyApiError as C, type JsonValue as J, type NewMember as N, type Organization as O, type PermissionOf as P, type RoleOf as R, type Session as S, CauthyConfigError as a, type CauthyOptions as b, type CauthySystem as c, type OrganizationMember as d, type Permitted as e, type Policy as f, type PolicyPermission as g, type PolicyRole as h, type PublicSession as i, type PushPolicyOptions as j, type SessionOrganization as k, type SessionStatus as l, type SessionUser as m, type SystemKey as n, type SystemOptions as o, can as p, createSystem as q, definePolicy as r, policySource as s, pullPolicy as t, pushPolicy as u };
|
|
@@ -1,6 +1,113 @@
|
|
|
1
1
|
import { JWK } from 'jose';
|
|
2
2
|
import { CauthyTheme } from './theme.mjs';
|
|
3
3
|
|
|
4
|
+
/** The part of an organization that says what its member may do. */
|
|
5
|
+
interface Permitted {
|
|
6
|
+
/** "resource:action" entries the person is allowed; "*" is any. Absent when the system keeps no catalog in Cauthy. */
|
|
7
|
+
permissions?: string[];
|
|
8
|
+
/** Entries the person is denied whatever else allows them. */
|
|
9
|
+
denied?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether the person may do an action on a resource in an organization:
|
|
13
|
+
* allowed by some entry, and denied by none. A denial wins.
|
|
14
|
+
*
|
|
15
|
+
* An organization of a system that keeps no catalog in Cauthy carries no
|
|
16
|
+
* permissions, and the answer is `false`: decide by its `role` instead.
|
|
17
|
+
*
|
|
18
|
+
* if (!can(organization, 'invoicing', 'write')) return forbidden()
|
|
19
|
+
*/
|
|
20
|
+
declare function can(organization: Permitted | null | undefined, resource: string, action: string): boolean;
|
|
21
|
+
/** Something a role may do: an action on a resource, in organizations of a kind ("*", the default, is every kind). */
|
|
22
|
+
interface PolicyPermission {
|
|
23
|
+
kind?: string;
|
|
24
|
+
resource: string;
|
|
25
|
+
action: string;
|
|
26
|
+
}
|
|
27
|
+
interface PolicyRole {
|
|
28
|
+
role: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
/** Roles whose permissions this one has as well. */
|
|
32
|
+
inherits?: string[];
|
|
33
|
+
permissions?: PolicyPermission[];
|
|
34
|
+
}
|
|
35
|
+
/** A role as `definePolicy` reads it: any `PolicyRole`, kept as written. */
|
|
36
|
+
type RoleShape = {
|
|
37
|
+
readonly role: string;
|
|
38
|
+
readonly name?: string;
|
|
39
|
+
readonly description?: string;
|
|
40
|
+
readonly inherits?: readonly string[];
|
|
41
|
+
readonly permissions?: readonly {
|
|
42
|
+
readonly kind?: string;
|
|
43
|
+
readonly resource: string;
|
|
44
|
+
readonly action: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
type Named<S extends string> = S extends '*' ? string : S;
|
|
48
|
+
type PermissionsIn<R> = R extends {
|
|
49
|
+
readonly permissions: readonly (infer P)[];
|
|
50
|
+
} ? P extends {
|
|
51
|
+
readonly resource: infer Res extends string;
|
|
52
|
+
readonly action: infer Act extends string;
|
|
53
|
+
} ? `${Named<Res>}:${Named<Act>}` : never : never;
|
|
54
|
+
/** The roles a catalog names: `RoleOf<typeof policy>`. */
|
|
55
|
+
type RoleOf<P> = P extends Policy<infer R, string> ? R : never;
|
|
56
|
+
/** The "resource:action" permissions a catalog names: `PermissionOf<typeof policy>`. */
|
|
57
|
+
type PermissionOf<P> = P extends Policy<string, infer X> ? X : never;
|
|
58
|
+
interface Policy<Role extends string = string, Permission extends string = string> {
|
|
59
|
+
/** The catalog as Cauthy takes it: `pushPolicy({ roles: policy.roles })`. */
|
|
60
|
+
roles: PolicyRole[];
|
|
61
|
+
/** Every role's name. */
|
|
62
|
+
roleNames: Role[];
|
|
63
|
+
/** Every permission some role has, as "resource:action". */
|
|
64
|
+
permissions: Permission[];
|
|
65
|
+
/**
|
|
66
|
+
* Whether the person may do this in the organization: `can(org, 'ledger:write')`.
|
|
67
|
+
* It reads what Cauthy sent with the session, so a catalog edited in Cauthy
|
|
68
|
+
* since this file was written is still what decides.
|
|
69
|
+
*/
|
|
70
|
+
can(organization: Permitted | null | undefined, permission: Permission): boolean;
|
|
71
|
+
/** Whether the person's role in the organization is one of these. */
|
|
72
|
+
hasRole(organization: {
|
|
73
|
+
role: string;
|
|
74
|
+
} | null | undefined, ...roles: Role[]): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* What a role may do by this catalog, with what it inherits: for showing a
|
|
77
|
+
* role, never for deciding about a person (their exceptions are not here).
|
|
78
|
+
*/
|
|
79
|
+
permissionsOf(role: Role): Permission[];
|
|
80
|
+
}
|
|
81
|
+
/** Gives a catalog of roles its types. See the top of this section. */
|
|
82
|
+
declare function definePolicy<const T extends readonly RoleShape[]>(roles: T): Policy<T[number]['role'], PermissionsIn<T[number]>>;
|
|
83
|
+
/**
|
|
84
|
+
* A TypeScript module that defines the catalog given, for `cauthy-auth policy
|
|
85
|
+
* --pull` to write: the application's types then come from the catalog
|
|
86
|
+
* Cauthy has.
|
|
87
|
+
*/
|
|
88
|
+
declare function policySource(system: string, roles: PolicyRole[]): string;
|
|
89
|
+
/** Reads a system's catalog of roles from Cauthy, with a personal access token. */
|
|
90
|
+
declare function pullPolicy(o?: Omit<PushPolicyOptions, 'roles'>): Promise<PolicyRole[]>;
|
|
91
|
+
interface PushPolicyOptions {
|
|
92
|
+
/** The system whose catalog this is. Default: `CAUTHY_SYSTEM`. */
|
|
93
|
+
system?: string;
|
|
94
|
+
roles: PolicyRole[];
|
|
95
|
+
/** Cauthy's address. Default: `CAUTHY_ISSUER`. */
|
|
96
|
+
issuer?: string;
|
|
97
|
+
/** The workspace's slug. Default: `CAUTHY_TENANT`. */
|
|
98
|
+
tenant?: string;
|
|
99
|
+
/** A personal access token with `organizations:manage`. Default: `CAUTHY_TOKEN`. */
|
|
100
|
+
token?: string;
|
|
101
|
+
fetch?: typeof fetch;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gives Cauthy a system's catalog of roles, replacing the one it has. It is
|
|
105
|
+
* the way to load a first catalog from what a system already had; from then on
|
|
106
|
+
* the catalog is Cauthy's, edited in its dashboard, and pushing again would
|
|
107
|
+
* overwrite what was edited there.
|
|
108
|
+
*/
|
|
109
|
+
declare function pushPolicy(o: PushPolicyOptions): Promise<void>;
|
|
110
|
+
|
|
4
111
|
/** How an application is set up to sign its people in with Cauthy. */
|
|
5
112
|
interface CauthyOptions {
|
|
6
113
|
/** Cauthy's public address, e.g. `https://id.example.com`. Default: `CAUTHY_ISSUER`. */
|
|
@@ -20,6 +127,12 @@ interface CauthyOptions {
|
|
|
20
127
|
* system's. Default: `CAUTHY_SYSTEM`.
|
|
21
128
|
*/
|
|
22
129
|
system?: string;
|
|
130
|
+
/**
|
|
131
|
+
* The workspace's slug in Cauthy. Needed for the application's own sign-in
|
|
132
|
+
* screens (`signIn.email`, `signUp.email`…), which sign people in through
|
|
133
|
+
* the application's server instead of Cauthy's page. Default: `CAUTHY_TENANT`.
|
|
134
|
+
*/
|
|
135
|
+
tenant?: string;
|
|
23
136
|
/** Where the routes are mounted. Default: `/api/auth`. */
|
|
24
137
|
basePath?: string;
|
|
25
138
|
/**
|
|
@@ -40,6 +153,27 @@ interface CauthyOptions {
|
|
|
40
153
|
* `CAUTHY_SYSTEM_KEY_ID`.
|
|
41
154
|
*/
|
|
42
155
|
systemKey?: SystemKey;
|
|
156
|
+
/**
|
|
157
|
+
* The application's own pages for what arrives by mail. A link Cauthy mails
|
|
158
|
+
* opens the page named here, with a `token` to give back; with none, it
|
|
159
|
+
* opens Cauthy's own page.
|
|
160
|
+
*
|
|
161
|
+
* signIn where `<SignIn />` is: a sign-in link opens it
|
|
162
|
+
* resetPassword where `<ResetPassword />` is
|
|
163
|
+
* verifyEmail where `<VerifyEmail />` is
|
|
164
|
+
*/
|
|
165
|
+
pages?: {
|
|
166
|
+
signIn?: string;
|
|
167
|
+
resetPassword?: string;
|
|
168
|
+
verifyEmail?: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* The address of the person a request comes from, passed on to Cauthy so
|
|
172
|
+
* its limits on attempts count the person and not this server. Default: the
|
|
173
|
+
* last address in `X-Forwarded-For`, which is the one the proxy in front of
|
|
174
|
+
* the application wrote. With several proxies, or none, give your own.
|
|
175
|
+
*/
|
|
176
|
+
clientIp?: (request: Request) => string | undefined;
|
|
43
177
|
/** `fetch` to reach Cauthy with. Default: the global one. */
|
|
44
178
|
fetch?: typeof fetch;
|
|
45
179
|
}
|
|
@@ -231,6 +365,10 @@ interface CauthySystem {
|
|
|
231
365
|
theme: {
|
|
232
366
|
get(clientId?: string): Promise<CauthyTheme>;
|
|
233
367
|
};
|
|
368
|
+
/** The catalog of roles of one of the application's systems, as Cauthy has it. */
|
|
369
|
+
policy: {
|
|
370
|
+
get(system: string): Promise<PolicyRole[]>;
|
|
371
|
+
};
|
|
234
372
|
/** The public half of `key`, to serve at the address Cauthy was given (`jwks_uri`). Empty with a secret. */
|
|
235
373
|
publicJwks(): Promise<{
|
|
236
374
|
keys: JWK[];
|
|
@@ -238,4 +376,4 @@ interface CauthySystem {
|
|
|
238
376
|
}
|
|
239
377
|
declare function createSystem(given?: SystemOptions): CauthySystem;
|
|
240
378
|
|
|
241
|
-
export { CauthyApiError as C, type JsonValue as J, type NewMember as N, type Organization as O, type
|
|
379
|
+
export { CauthyApiError as C, type JsonValue as J, type NewMember as N, type Organization as O, type PermissionOf as P, type RoleOf as R, type Session as S, CauthyConfigError as a, type CauthyOptions as b, type CauthySystem as c, type OrganizationMember as d, type Permitted as e, type Policy as f, type PolicyPermission as g, type PolicyRole as h, type PublicSession as i, type PushPolicyOptions as j, type SessionOrganization as k, type SessionStatus as l, type SessionUser as m, type SystemKey as n, type SystemOptions as o, can as p, createSystem as q, definePolicy as r, policySource as s, pullPolicy as t, pushPolicy as u };
|
package/dist/theme.d.mts
CHANGED
|
@@ -68,6 +68,12 @@ interface CauthyTheme {
|
|
|
68
68
|
panelIconUrl?: string;
|
|
69
69
|
/** The application's own words on the sign-in page, by language (`en`, `es`). */
|
|
70
70
|
texts?: Record<string, ThemeTexts>;
|
|
71
|
+
/**
|
|
72
|
+
* The application's Stackmyth tokens (`--sm-*`), from `tokensFromStackmyth`.
|
|
73
|
+
* Cauthy's pages are drawn with Stackmyth's components, so these make its
|
|
74
|
+
* buttons and fields the application's own. They are laid over the named values.
|
|
75
|
+
*/
|
|
76
|
+
tokens?: Record<string, string>;
|
|
71
77
|
}
|
|
72
78
|
interface StackmythThemeOptions {
|
|
73
79
|
/**
|
|
@@ -85,6 +91,22 @@ interface ImportedTheme {
|
|
|
85
91
|
/** Tokens that were there and could not be carried over, and why. */
|
|
86
92
|
warnings: string[];
|
|
87
93
|
}
|
|
94
|
+
interface StackmythTokens {
|
|
95
|
+
/** Every `--sm-*` token the stylesheets set for the page, ready for `theme.tokens`. */
|
|
96
|
+
tokens: Record<string, string>;
|
|
97
|
+
/** Tokens that were there and Cauthy would not take, and why. */
|
|
98
|
+
warnings: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Reads an application's Stackmyth tokens out of its stylesheets: every
|
|
102
|
+
* `--sm-*` custom property its theme sets, in the order the sheets are given
|
|
103
|
+
* (a later one wins). Its own names — a brand palette the tokens point at —
|
|
104
|
+
* are written in, so what comes out stands on Stackmyth's names alone.
|
|
105
|
+
*
|
|
106
|
+
* Cauthy's sign-in pages are drawn with Stackmyth's components: these tokens
|
|
107
|
+
* are what makes them look like the application.
|
|
108
|
+
*/
|
|
109
|
+
declare function tokensFromStackmyth(css: string | string[], options?: StackmythThemeOptions): StackmythTokens;
|
|
88
110
|
/** A colour as Cauthy takes it — `#rrggbb` or `rgba(…)` — or null when it is none it can read. */
|
|
89
111
|
declare function toColor(value: string): string | null;
|
|
90
112
|
/**
|
|
@@ -97,6 +119,39 @@ declare function toColor(value: string): string | null;
|
|
|
97
119
|
* application's dark mode is left out unless asked for.
|
|
98
120
|
*/
|
|
99
121
|
declare function themeFromStackmyth(css: string | string[], options?: StackmythThemeOptions): ImportedTheme;
|
|
122
|
+
/** The values of a theme a stylesheet can say. */
|
|
123
|
+
type ThemeField = 'background' | 'surface' | 'text' | 'textMuted' | 'border' | 'inputBackground' | 'inputBorder' | 'primary' | 'primaryText' | 'accent' | 'error' | 'errorBackground' | 'success' | 'successBackground' | 'radius' | 'buttonRadius' | 'fontFamily';
|
|
124
|
+
/** How a stylesheet names its look: Stackmyth's tokens, shadcn/ui's (and Tailwind's), or the application's own. */
|
|
125
|
+
type CssFormat = 'stackmyth' | 'shadcn' | 'custom';
|
|
126
|
+
interface CssThemeOptions {
|
|
127
|
+
/** Which names to read. Default: `auto`, told from the stylesheet itself. */
|
|
128
|
+
format?: CssFormat | 'auto';
|
|
129
|
+
/** Which of the application's two modes to take. Default: `light`. */
|
|
130
|
+
mode?: 'light' | 'dark';
|
|
131
|
+
/** The named theme to read, when the stylesheet keeps several under `[data-theme=…]`. */
|
|
132
|
+
theme?: string;
|
|
133
|
+
/** For `custom`: the variable each value is read from, `{ primary: '--brand' }`. */
|
|
134
|
+
map?: Partial<Record<ThemeField, string>>;
|
|
135
|
+
}
|
|
136
|
+
interface CssImportedTheme extends ImportedTheme {
|
|
137
|
+
/** The names that were read. */
|
|
138
|
+
format: CssFormat;
|
|
139
|
+
}
|
|
140
|
+
/** The custom properties a stylesheet sets for the page, by name: what a person picks from to map their own. */
|
|
141
|
+
declare function cssVariables(css: string | string[], options?: Pick<CssThemeOptions, 'mode' | 'theme'>): string[];
|
|
142
|
+
/**
|
|
143
|
+
* Reads an application's look out of its stylesheets, whatever names it uses:
|
|
144
|
+
* Stackmyth's tokens, shadcn/ui's (`--primary`, `--radius`, on Tailwind 3 or
|
|
145
|
+
* 4), or the application's own variables given in `map`. What comes out is a
|
|
146
|
+
* theme of named values, never CSS.
|
|
147
|
+
*/
|
|
148
|
+
declare function themeFromCss(css: string | string[], options?: CssThemeOptions): CssImportedTheme;
|
|
149
|
+
/**
|
|
150
|
+
* A theme as the CSS variables of `cauthy-auth/styles.css` (`--cauthy-*`), for
|
|
151
|
+
* the forms an application shows on its own pages. The page's own background,
|
|
152
|
+
* the layout and the words are Cauthy's pages' matter, and left out.
|
|
153
|
+
*/
|
|
154
|
+
declare function themeVariables(theme: CauthyTheme): Record<string, string>;
|
|
100
155
|
/** A theme as Cauthy's API names its values. */
|
|
101
156
|
declare function toWire(theme: CauthyTheme): Record<string, unknown>;
|
|
102
157
|
/** A theme as Cauthy answers it, in this package's names. */
|
|
@@ -123,4 +178,4 @@ interface PushThemeOptions {
|
|
|
123
178
|
*/
|
|
124
179
|
declare function pushTheme(o: PushThemeOptions): Promise<void>;
|
|
125
180
|
|
|
126
|
-
export { type CauthyTheme, type ImportedTheme, type PushThemeOptions, type StackmythThemeOptions, type ThemeFont, type ThemeTexts, fromWire, pushTheme, themeFromStackmyth, toColor, toWire };
|
|
181
|
+
export { type CauthyTheme, type CssFormat, type CssImportedTheme, type CssThemeOptions, type ImportedTheme, type PushThemeOptions, type StackmythThemeOptions, type StackmythTokens, type ThemeField, type ThemeFont, type ThemeTexts, cssVariables, fromWire, pushTheme, themeFromCss, themeFromStackmyth, themeVariables, toColor, toWire, tokensFromStackmyth };
|
package/dist/theme.d.ts
CHANGED
|
@@ -68,6 +68,12 @@ interface CauthyTheme {
|
|
|
68
68
|
panelIconUrl?: string;
|
|
69
69
|
/** The application's own words on the sign-in page, by language (`en`, `es`). */
|
|
70
70
|
texts?: Record<string, ThemeTexts>;
|
|
71
|
+
/**
|
|
72
|
+
* The application's Stackmyth tokens (`--sm-*`), from `tokensFromStackmyth`.
|
|
73
|
+
* Cauthy's pages are drawn with Stackmyth's components, so these make its
|
|
74
|
+
* buttons and fields the application's own. They are laid over the named values.
|
|
75
|
+
*/
|
|
76
|
+
tokens?: Record<string, string>;
|
|
71
77
|
}
|
|
72
78
|
interface StackmythThemeOptions {
|
|
73
79
|
/**
|
|
@@ -85,6 +91,22 @@ interface ImportedTheme {
|
|
|
85
91
|
/** Tokens that were there and could not be carried over, and why. */
|
|
86
92
|
warnings: string[];
|
|
87
93
|
}
|
|
94
|
+
interface StackmythTokens {
|
|
95
|
+
/** Every `--sm-*` token the stylesheets set for the page, ready for `theme.tokens`. */
|
|
96
|
+
tokens: Record<string, string>;
|
|
97
|
+
/** Tokens that were there and Cauthy would not take, and why. */
|
|
98
|
+
warnings: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Reads an application's Stackmyth tokens out of its stylesheets: every
|
|
102
|
+
* `--sm-*` custom property its theme sets, in the order the sheets are given
|
|
103
|
+
* (a later one wins). Its own names — a brand palette the tokens point at —
|
|
104
|
+
* are written in, so what comes out stands on Stackmyth's names alone.
|
|
105
|
+
*
|
|
106
|
+
* Cauthy's sign-in pages are drawn with Stackmyth's components: these tokens
|
|
107
|
+
* are what makes them look like the application.
|
|
108
|
+
*/
|
|
109
|
+
declare function tokensFromStackmyth(css: string | string[], options?: StackmythThemeOptions): StackmythTokens;
|
|
88
110
|
/** A colour as Cauthy takes it — `#rrggbb` or `rgba(…)` — or null when it is none it can read. */
|
|
89
111
|
declare function toColor(value: string): string | null;
|
|
90
112
|
/**
|
|
@@ -97,6 +119,39 @@ declare function toColor(value: string): string | null;
|
|
|
97
119
|
* application's dark mode is left out unless asked for.
|
|
98
120
|
*/
|
|
99
121
|
declare function themeFromStackmyth(css: string | string[], options?: StackmythThemeOptions): ImportedTheme;
|
|
122
|
+
/** The values of a theme a stylesheet can say. */
|
|
123
|
+
type ThemeField = 'background' | 'surface' | 'text' | 'textMuted' | 'border' | 'inputBackground' | 'inputBorder' | 'primary' | 'primaryText' | 'accent' | 'error' | 'errorBackground' | 'success' | 'successBackground' | 'radius' | 'buttonRadius' | 'fontFamily';
|
|
124
|
+
/** How a stylesheet names its look: Stackmyth's tokens, shadcn/ui's (and Tailwind's), or the application's own. */
|
|
125
|
+
type CssFormat = 'stackmyth' | 'shadcn' | 'custom';
|
|
126
|
+
interface CssThemeOptions {
|
|
127
|
+
/** Which names to read. Default: `auto`, told from the stylesheet itself. */
|
|
128
|
+
format?: CssFormat | 'auto';
|
|
129
|
+
/** Which of the application's two modes to take. Default: `light`. */
|
|
130
|
+
mode?: 'light' | 'dark';
|
|
131
|
+
/** The named theme to read, when the stylesheet keeps several under `[data-theme=…]`. */
|
|
132
|
+
theme?: string;
|
|
133
|
+
/** For `custom`: the variable each value is read from, `{ primary: '--brand' }`. */
|
|
134
|
+
map?: Partial<Record<ThemeField, string>>;
|
|
135
|
+
}
|
|
136
|
+
interface CssImportedTheme extends ImportedTheme {
|
|
137
|
+
/** The names that were read. */
|
|
138
|
+
format: CssFormat;
|
|
139
|
+
}
|
|
140
|
+
/** The custom properties a stylesheet sets for the page, by name: what a person picks from to map their own. */
|
|
141
|
+
declare function cssVariables(css: string | string[], options?: Pick<CssThemeOptions, 'mode' | 'theme'>): string[];
|
|
142
|
+
/**
|
|
143
|
+
* Reads an application's look out of its stylesheets, whatever names it uses:
|
|
144
|
+
* Stackmyth's tokens, shadcn/ui's (`--primary`, `--radius`, on Tailwind 3 or
|
|
145
|
+
* 4), or the application's own variables given in `map`. What comes out is a
|
|
146
|
+
* theme of named values, never CSS.
|
|
147
|
+
*/
|
|
148
|
+
declare function themeFromCss(css: string | string[], options?: CssThemeOptions): CssImportedTheme;
|
|
149
|
+
/**
|
|
150
|
+
* A theme as the CSS variables of `cauthy-auth/styles.css` (`--cauthy-*`), for
|
|
151
|
+
* the forms an application shows on its own pages. The page's own background,
|
|
152
|
+
* the layout and the words are Cauthy's pages' matter, and left out.
|
|
153
|
+
*/
|
|
154
|
+
declare function themeVariables(theme: CauthyTheme): Record<string, string>;
|
|
100
155
|
/** A theme as Cauthy's API names its values. */
|
|
101
156
|
declare function toWire(theme: CauthyTheme): Record<string, unknown>;
|
|
102
157
|
/** A theme as Cauthy answers it, in this package's names. */
|
|
@@ -123,4 +178,4 @@ interface PushThemeOptions {
|
|
|
123
178
|
*/
|
|
124
179
|
declare function pushTheme(o: PushThemeOptions): Promise<void>;
|
|
125
180
|
|
|
126
|
-
export { type CauthyTheme, type ImportedTheme, type PushThemeOptions, type StackmythThemeOptions, type ThemeFont, type ThemeTexts, fromWire, pushTheme, themeFromStackmyth, toColor, toWire };
|
|
181
|
+
export { type CauthyTheme, type CssFormat, type CssImportedTheme, type CssThemeOptions, type ImportedTheme, type PushThemeOptions, type StackmythThemeOptions, type StackmythTokens, type ThemeField, type ThemeFont, type ThemeTexts, cssVariables, fromWire, pushTheme, themeFromCss, themeFromStackmyth, themeVariables, toColor, toWire, tokensFromStackmyth };
|