cauthy-auth 0.28.1 → 0.31.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 +61 -3
- package/dist/{cauthy-CTVg4kvo.d.mts → cauthy-2jtP2LVQ.d.mts} +19 -1
- package/dist/{cauthy-BAwAJChs.d.ts → cauthy-CKfvvv_i.d.ts} +19 -1
- package/dist/cli.js +163 -59
- package/dist/client.d.mts +91 -10
- package/dist/client.d.ts +91 -10
- package/dist/client.js +39 -3
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +39 -3
- package/dist/client.mjs.map +1 -1
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +387 -148
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +385 -148
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/react.d.mts +275 -23
- package/dist/react.d.ts +275 -23
- package/dist/react.js +312 -78
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +311 -78
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +8 -0
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +53 -4
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +53 -4
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-CVBW_AV8.d.mts → system-BrrJsrFW.d.mts} +321 -109
- package/dist/{system-Bn8uckvQ.d.ts → system-BvvoNs2y.d.ts} +321 -109
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +53 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +53 -4
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -85,6 +85,8 @@ interface Permitted {
|
|
|
85
85
|
permissions?: string[];
|
|
86
86
|
/** Entries the person is denied whatever else allows them. */
|
|
87
87
|
denied?: string[];
|
|
88
|
+
/** Permissions with a condition: in neither list, so `can` never counts them. Ask with `auth.check`. */
|
|
89
|
+
conditional?: ConditionalPermission[];
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
92
|
* Whether the person may do an action on a resource in an organization:
|
|
@@ -93,6 +95,11 @@ interface Permitted {
|
|
|
93
95
|
* An organization of a system that keeps no catalog in Cauthy carries no
|
|
94
96
|
* permissions, and the answer is `false`: decide by its `role` instead.
|
|
95
97
|
*
|
|
98
|
+
* A permission with a condition (`organization.conditional`) is not in the
|
|
99
|
+
* lists, so `can` answers `false` for what only it allows: the condition reads
|
|
100
|
+
* the record at hand, which only Cauthy can weigh. Ask with `auth.check`
|
|
101
|
+
* (`organizations.check` in the browser).
|
|
102
|
+
*
|
|
96
103
|
* if (!can(organization, 'invoicing', 'write')) return forbidden()
|
|
97
104
|
*/
|
|
98
105
|
declare function can(organization: Permitted | null | undefined, resource: string, action: string): boolean;
|
|
@@ -101,6 +108,21 @@ interface PolicyPermission {
|
|
|
101
108
|
kind?: string;
|
|
102
109
|
resource: string;
|
|
103
110
|
action: string;
|
|
111
|
+
/**
|
|
112
|
+
* When it holds, in CEL: `resource.attrs.amount <= 1000000`. A permission
|
|
113
|
+
* with one is decided by Cauthy per question (`auth.check`), never by `can`.
|
|
114
|
+
*/
|
|
115
|
+
condition?: string;
|
|
116
|
+
}
|
|
117
|
+
/** The type of an attribute a condition may read: `list` is any JSON array. */
|
|
118
|
+
type AttributeType = 'string' | 'number' | 'bool' | 'list';
|
|
119
|
+
/** A resource of a system's catalog: the actions done on it and the attributes its conditions read. */
|
|
120
|
+
interface CatalogResource {
|
|
121
|
+
resource: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
actions: string[];
|
|
124
|
+
/** Name → type, as `resource.attrs.<name>` in a condition. */
|
|
125
|
+
attributes?: Record<string, AttributeType>;
|
|
104
126
|
}
|
|
105
127
|
interface PolicyRole {
|
|
106
128
|
role: string;
|
|
@@ -110,17 +132,28 @@ interface PolicyRole {
|
|
|
110
132
|
inherits?: string[];
|
|
111
133
|
permissions?: PolicyPermission[];
|
|
112
134
|
}
|
|
135
|
+
type PermissionShape = {
|
|
136
|
+
readonly kind?: string;
|
|
137
|
+
readonly resource: string;
|
|
138
|
+
readonly action: string;
|
|
139
|
+
readonly condition?: string;
|
|
140
|
+
};
|
|
113
141
|
/** A role as `definePolicy` reads it: any `PolicyRole`, kept as written. */
|
|
114
142
|
type RoleShape = {
|
|
115
143
|
readonly role: string;
|
|
116
144
|
readonly name?: string;
|
|
117
145
|
readonly description?: string;
|
|
118
146
|
readonly inherits?: readonly string[];
|
|
119
|
-
readonly permissions?: readonly
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
readonly permissions?: readonly PermissionShape[];
|
|
148
|
+
};
|
|
149
|
+
/** A resource as `definePolicy` reads it: any `CatalogResource`, kept as written. */
|
|
150
|
+
type ResourceShape = {
|
|
151
|
+
readonly resource: string;
|
|
152
|
+
readonly description?: string;
|
|
153
|
+
readonly actions: readonly string[];
|
|
154
|
+
readonly attributes?: {
|
|
155
|
+
readonly [name: string]: AttributeType;
|
|
156
|
+
};
|
|
124
157
|
};
|
|
125
158
|
type Named<S extends string> = S extends '*' ? string : S;
|
|
126
159
|
type PermissionsIn<R> = R extends {
|
|
@@ -129,13 +162,56 @@ type PermissionsIn<R> = R extends {
|
|
|
129
162
|
readonly resource: infer Res extends string;
|
|
130
163
|
readonly action: infer Act extends string;
|
|
131
164
|
} ? `${Named<Res>}:${Named<Act>}` : never : never;
|
|
165
|
+
type ValueOf<T> = T extends 'string' ? string : T extends 'number' ? number : T extends 'bool' ? boolean : T extends 'list' ? unknown[] : never;
|
|
166
|
+
/** What a check may say about one declared resource. */
|
|
167
|
+
type QuestionAbout<E> = E extends {
|
|
168
|
+
readonly resource: infer R extends string;
|
|
169
|
+
readonly actions: readonly (infer A extends string)[];
|
|
170
|
+
} ? {
|
|
171
|
+
resource: R;
|
|
172
|
+
action: A;
|
|
173
|
+
attributes?: E extends {
|
|
174
|
+
readonly attributes: infer T;
|
|
175
|
+
} ? {
|
|
176
|
+
[K in keyof T]?: ValueOf<T[K]>;
|
|
177
|
+
} : Record<string, never>;
|
|
178
|
+
resourceId?: string;
|
|
179
|
+
ownerId?: string;
|
|
180
|
+
} : never;
|
|
181
|
+
/**
|
|
182
|
+
* What a role of a catalog that declares its resources may name: a declared
|
|
183
|
+
* resource with one of its actions, or "*", or one of Cauthy's own powers.
|
|
184
|
+
*/
|
|
185
|
+
type PermissionFor<C extends readonly ResourceShape[]> = {
|
|
186
|
+
readonly kind?: string;
|
|
187
|
+
readonly condition?: string;
|
|
188
|
+
} & ((C[number] extends infer E ? E extends {
|
|
189
|
+
readonly resource: infer R extends string;
|
|
190
|
+
readonly actions: readonly (infer A extends string)[];
|
|
191
|
+
} ? {
|
|
192
|
+
readonly resource: R;
|
|
193
|
+
readonly action: A | '*';
|
|
194
|
+
} : never : never) | {
|
|
195
|
+
readonly resource: '*';
|
|
196
|
+
readonly action: string;
|
|
197
|
+
} | {
|
|
198
|
+
readonly resource: `cauthy:${string}`;
|
|
199
|
+
readonly action: string;
|
|
200
|
+
});
|
|
201
|
+
type RoleFor<C extends readonly ResourceShape[]> = Omit<RoleShape, 'permissions'> & {
|
|
202
|
+
readonly permissions?: readonly PermissionFor<C>[];
|
|
203
|
+
};
|
|
132
204
|
/** The roles a catalog names: `RoleOf<typeof policy>`. */
|
|
133
|
-
type RoleOf<P> = P extends Policy<infer R,
|
|
205
|
+
type RoleOf<P> = P extends Policy<infer R, any, any> ? R : never;
|
|
134
206
|
/** The "resource:action" permissions a catalog names: `PermissionOf<typeof policy>`. */
|
|
135
|
-
type PermissionOf<P> = P extends Policy<
|
|
136
|
-
|
|
207
|
+
type PermissionOf<P> = P extends Policy<any, infer X, any> ? X : never;
|
|
208
|
+
/** The fields of a question: whatever else the asker takes (the organization, the person) passes through. */
|
|
209
|
+
type QuestionKeys = keyof CheckQuestion;
|
|
210
|
+
interface Policy<Role extends string = string, Permission extends string = string, Question extends CheckQuestion = CheckQuestion> {
|
|
137
211
|
/** The catalog as Cauthy takes it: `pushPolicy({ roles: policy.roles })`. */
|
|
138
212
|
roles: PolicyRole[];
|
|
213
|
+
/** The resources the system declares, as Cauthy takes them; empty when it declares none. */
|
|
214
|
+
catalog: CatalogResource[];
|
|
139
215
|
/** Every role's name. */
|
|
140
216
|
roleNames: Role[];
|
|
141
217
|
/** Every permission some role has, as "resource:action". */
|
|
@@ -143,7 +219,8 @@ interface Policy<Role extends string = string, Permission extends string = strin
|
|
|
143
219
|
/**
|
|
144
220
|
* Whether the person may do this in the organization: `can(org, 'ledger:write')`.
|
|
145
221
|
* It reads what Cauthy sent with the session, so a catalog edited in Cauthy
|
|
146
|
-
* since this file was written is still what decides.
|
|
222
|
+
* since this file was written is still what decides. A permission with a
|
|
223
|
+
* condition is not there: ask with `check`.
|
|
147
224
|
*/
|
|
148
225
|
can(organization: Permitted | null | undefined, permission: Permission): boolean;
|
|
149
226
|
/** Whether the person's role in the organization is one of these. */
|
|
@@ -155,9 +232,30 @@ interface Policy<Role extends string = string, Permission extends string = strin
|
|
|
155
232
|
* role, never for deciding about a person (their exceptions are not here).
|
|
156
233
|
*/
|
|
157
234
|
permissionsOf(role: Role): Permission[];
|
|
235
|
+
/**
|
|
236
|
+
* Asks Cauthy, with the resource, action and attributes typed by the
|
|
237
|
+
* catalog. Give it whoever asks: the server's `auth` with the request,
|
|
238
|
+
* the browser's `organizations`, or the application's `system`.
|
|
239
|
+
*
|
|
240
|
+
* await policy.check(auth, request, { organization, resource: 'invoices', action: 'approve', attributes: { amount: 500 } })
|
|
241
|
+
* await policy.check(auth.system, { organizationId, userId, resource: 'invoices', action: 'read' })
|
|
242
|
+
*/
|
|
243
|
+
check<I extends CheckQuestion>(asker: {
|
|
244
|
+
check(input: I): Promise<CheckResult>;
|
|
245
|
+
}, input: Omit<I, QuestionKeys> & Question): Promise<CheckResult>;
|
|
246
|
+
check<R, I extends CheckQuestion>(asker: {
|
|
247
|
+
check(request: R, input: I): Promise<CheckResult>;
|
|
248
|
+
}, request: R, input: Omit<I, QuestionKeys> & Question): Promise<CheckResult>;
|
|
249
|
+
}
|
|
250
|
+
/** A catalog with its resources declared, for `definePolicy`. */
|
|
251
|
+
interface PolicyDefinition<C extends readonly ResourceShape[], T extends readonly RoleShape[]> {
|
|
252
|
+
catalog: C;
|
|
253
|
+
roles: T;
|
|
158
254
|
}
|
|
159
255
|
/** Gives a catalog of roles its types. See the top of this section. */
|
|
160
256
|
declare function definePolicy<const T extends readonly RoleShape[]>(roles: T): Policy<T[number]['role'], PermissionsIn<T[number]>>;
|
|
257
|
+
/** Gives a catalog of resources and roles its types: a role names only what the catalog declares. */
|
|
258
|
+
declare function definePolicy<const C extends readonly ResourceShape[], const T extends readonly RoleFor<C>[]>(definition: PolicyDefinition<C, T>): Policy<T[number]['role'], PermissionsIn<T[number]>, QuestionAbout<C[number]>>;
|
|
161
259
|
|
|
162
260
|
/** The person signed in. Every moment is UTC. */
|
|
163
261
|
interface SessionUser {
|
|
@@ -200,6 +298,54 @@ interface SessionOrganization {
|
|
|
200
298
|
permissions?: string[];
|
|
201
299
|
/** What the person is denied here, whatever else allows it. */
|
|
202
300
|
denied?: string[];
|
|
301
|
+
/**
|
|
302
|
+
* Permissions that hold only when their condition does (an amount under a
|
|
303
|
+
* limit, the person's own records…). They are in neither list above: `can`
|
|
304
|
+
* answers no for them, and `auth.check` asks Cauthy. Present, maybe empty,
|
|
305
|
+
* whenever `permissions` is.
|
|
306
|
+
*/
|
|
307
|
+
conditional?: ConditionalPermission[];
|
|
308
|
+
}
|
|
309
|
+
/** A permission with a condition: Cauthy decides it per question (`auth.check`). */
|
|
310
|
+
interface ConditionalPermission {
|
|
311
|
+
resource: string;
|
|
312
|
+
action: string;
|
|
313
|
+
effect: 'allow' | 'deny';
|
|
314
|
+
}
|
|
315
|
+
/** What to ask Cauthy about: an action on a resource, with what the conditions read of it. */
|
|
316
|
+
interface CheckQuestion {
|
|
317
|
+
resource: string;
|
|
318
|
+
action: string;
|
|
319
|
+
/** What a condition reads as `resource.attrs`: `{ amount: 500 }`. */
|
|
320
|
+
attributes?: Record<string, unknown>;
|
|
321
|
+
/** The record's id, as a condition reads it (`resource.id`). */
|
|
322
|
+
resourceId?: string;
|
|
323
|
+
/** Whose the record is (`resource.owner_id`): `resource.owner_id == subject.id`. */
|
|
324
|
+
ownerId?: string;
|
|
325
|
+
}
|
|
326
|
+
/** An organization, by its id or as the session has it. */
|
|
327
|
+
type OrganizationRef = string | {
|
|
328
|
+
id: string;
|
|
329
|
+
};
|
|
330
|
+
/** The rule that decided a check. */
|
|
331
|
+
interface CheckRule {
|
|
332
|
+
/** A permission of the person's role, or an exception given to the person. */
|
|
333
|
+
source: 'role' | 'exception';
|
|
334
|
+
/** The role, when `source` is `role`. */
|
|
335
|
+
role?: string;
|
|
336
|
+
kind: string;
|
|
337
|
+
resource: string;
|
|
338
|
+
action: string;
|
|
339
|
+
effect: 'allow' | 'deny';
|
|
340
|
+
condition?: string;
|
|
341
|
+
}
|
|
342
|
+
/** Cauthy's answer to a check. */
|
|
343
|
+
interface CheckResult {
|
|
344
|
+
allowed: boolean;
|
|
345
|
+
/** Why, in words: "allowed by role accountant: invoices:approve". */
|
|
346
|
+
reason: string;
|
|
347
|
+
/** The rule that decided; absent when none did (nothing allows it). */
|
|
348
|
+
rule?: CheckRule;
|
|
203
349
|
}
|
|
204
350
|
/** What the browser is told of a session: who, and their organizations — never a token. */
|
|
205
351
|
interface PublicSession {
|
|
@@ -257,11 +403,25 @@ type AuthResult<S extends string, More = unknown> = ({
|
|
|
257
403
|
};
|
|
258
404
|
/** What the screen may offer. */
|
|
259
405
|
interface AuthMethods {
|
|
260
|
-
/**
|
|
406
|
+
/**
|
|
407
|
+
* The providers the workspace signs people in with and has turned on:
|
|
408
|
+
* `{ id: 'google', name: 'Google', iconUrl: 'https://…/v1/social/icons/google.svg' }`.
|
|
409
|
+
* `iconUrl` is the provider's logo, served by Cauthy; absent from a Cauthy
|
|
410
|
+
* that does not serve logos.
|
|
411
|
+
*/
|
|
261
412
|
providers: {
|
|
262
413
|
id: string;
|
|
263
414
|
name: string;
|
|
415
|
+
iconUrl?: string;
|
|
264
416
|
}[];
|
|
417
|
+
/**
|
|
418
|
+
* Whether the workspace signs people in with a password. False: the
|
|
419
|
+
* password field, "forgot your password" and a sign-up with a password are
|
|
420
|
+
* not offered, and Cauthy refuses them (`password_disabled`). True from a
|
|
421
|
+
* server that does not say. (`password` is something else: the policy a new
|
|
422
|
+
* password must meet.)
|
|
423
|
+
*/
|
|
424
|
+
passwordSignIn: boolean;
|
|
265
425
|
/** Whether people may create an account themselves. */
|
|
266
426
|
signUp: boolean;
|
|
267
427
|
/** Set when the application's system makes an organization per sign-up: the form asks the company's name. */
|
|
@@ -270,7 +430,7 @@ interface AuthMethods {
|
|
|
270
430
|
required: boolean;
|
|
271
431
|
};
|
|
272
432
|
magicLink: boolean;
|
|
273
|
-
/** Whether to offer a passkey. */
|
|
433
|
+
/** Whether to offer a passkey. False when the workspace turned passkeys off. */
|
|
274
434
|
passkey: boolean;
|
|
275
435
|
/**
|
|
276
436
|
* Whether the passkey is used on this page itself. False: `signIn.passkey`
|
|
@@ -322,6 +482,15 @@ interface AuthMethods {
|
|
|
322
482
|
*/
|
|
323
483
|
password?: PasswordPolicy;
|
|
324
484
|
}
|
|
485
|
+
/** An invitation, as its page shows it before the person chooses a password. */
|
|
486
|
+
interface Invitation {
|
|
487
|
+
/** The address invited: the account the person signs in as. */
|
|
488
|
+
email: string;
|
|
489
|
+
/** The workspace's name. */
|
|
490
|
+
workspace: string;
|
|
491
|
+
/** The organization the person was invited to, when there is one. */
|
|
492
|
+
organization?: string;
|
|
493
|
+
}
|
|
325
494
|
/** A legal document the person owes: not yet accepted in its current version. */
|
|
326
495
|
interface PendingLegal {
|
|
327
496
|
kind: string;
|
|
@@ -385,19 +554,29 @@ interface ConnectedAgent {
|
|
|
385
554
|
connectedAt: string;
|
|
386
555
|
lastUsedAt: string;
|
|
387
556
|
}
|
|
388
|
-
/** An organization the person belongs to, with what their role lets them do with its people. */
|
|
557
|
+
/** An organization the person belongs to, with what their role lets them do with it and its people. */
|
|
389
558
|
interface OrganizationSeat {
|
|
390
559
|
id: string;
|
|
391
|
-
/** The client system it is of (`
|
|
560
|
+
/** The client system it is of (`acme-crm`). */
|
|
392
561
|
system: string;
|
|
393
562
|
name: string;
|
|
394
563
|
kind: string;
|
|
395
564
|
/** The person's role in it. */
|
|
396
565
|
role: string;
|
|
397
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Cauthy's reserved powers, from the system's catalog. `manageMembers`
|
|
568
|
+
* (cauthy:members:manage) adds, invites and changes roles; removing another
|
|
569
|
+
* member is `removeMembers` (cauthy:members:remove), and anybody may leave.
|
|
570
|
+
* `update`, `archive` and `delete` are cauthy:organization's: rename it,
|
|
571
|
+
* archive it, delete it for good.
|
|
572
|
+
*/
|
|
398
573
|
can: {
|
|
399
574
|
readMembers: boolean;
|
|
400
575
|
manageMembers: boolean;
|
|
576
|
+
removeMembers: boolean;
|
|
577
|
+
update: boolean;
|
|
578
|
+
archive: boolean;
|
|
579
|
+
delete: boolean;
|
|
401
580
|
};
|
|
402
581
|
}
|
|
403
582
|
/** A person of an organization, as a member who may see them reads it. */
|
|
@@ -427,8 +606,12 @@ interface OrganizationRoleChoice {
|
|
|
427
606
|
}
|
|
428
607
|
/**
|
|
429
608
|
* The signed-in person's organizations, and their people. Seeing them needs
|
|
430
|
-
* cauthy:members read in the person's role; changing them needs manage
|
|
431
|
-
*
|
|
609
|
+
* cauthy:members read in the person's role; changing them needs manage, and
|
|
610
|
+
* removing someone needs remove. The organization itself is renamed, archived
|
|
611
|
+
* or deleted with cauthy:organization update, archive or delete. Only an
|
|
612
|
+
* `owner` gives the owner role or changes an owner, and the last owner stays
|
|
613
|
+
* (`last_owner`). Cauthy decides, with the person's own session: the
|
|
614
|
+
* application authorizes nothing.
|
|
432
615
|
*/
|
|
433
616
|
interface OrganizationsClient {
|
|
434
617
|
/** The organizations the person belongs to; one system's only with `system`. */
|
|
@@ -460,6 +643,31 @@ interface OrganizationsClient {
|
|
|
460
643
|
}): Promise<AuthResult<'sent', {
|
|
461
644
|
userId: string;
|
|
462
645
|
}>>;
|
|
646
|
+
/** Gives the organization a new name (cauthy:organization update). */
|
|
647
|
+
rename(organizationId: string, name: string): Promise<AuthResult<'renamed', {
|
|
648
|
+
organization: OrganizationSeat;
|
|
649
|
+
}>>;
|
|
650
|
+
/** Archives the organization: its members no longer reach it, and only the workspace restores it. */
|
|
651
|
+
archive(organizationId: string): Promise<AuthResult<'archived', {
|
|
652
|
+
organizationId: string;
|
|
653
|
+
}>>;
|
|
654
|
+
/** Deletes the organization for good. */
|
|
655
|
+
delete(organizationId: string): Promise<AuthResult<'deleted', {
|
|
656
|
+
organizationId: string;
|
|
657
|
+
}>>;
|
|
658
|
+
/**
|
|
659
|
+
* Asks Cauthy, through the application's server, whether the person may do
|
|
660
|
+
* an action on a resource in the organization, with what its conditions
|
|
661
|
+
* read. A question that could not be asked is a no, with `error` saying why.
|
|
662
|
+
*
|
|
663
|
+
* const r = await organizations.check({ organization, resource: 'invoices', action: 'approve', attributes: { amount: 500 } })
|
|
664
|
+
* if (r.allowed) showApprove()
|
|
665
|
+
*/
|
|
666
|
+
check(question: CheckQuestion & {
|
|
667
|
+
organization: OrganizationRef;
|
|
668
|
+
}): Promise<CheckResult & {
|
|
669
|
+
error?: AuthError;
|
|
670
|
+
}>;
|
|
463
671
|
}
|
|
464
672
|
interface AccountSession {
|
|
465
673
|
/** "Mac · Chrome", or "" when the browser did not say. */
|
|
@@ -874,7 +1082,25 @@ interface AuthClient {
|
|
|
874
1082
|
token: string;
|
|
875
1083
|
password: string;
|
|
876
1084
|
}): Promise<AuthResult<'changed'>>;
|
|
877
|
-
/**
|
|
1085
|
+
/**
|
|
1086
|
+
* Who an invitation is for and to what, with the token the mailed link
|
|
1087
|
+
* opened the page with (`token`). Reading it does not spend it.
|
|
1088
|
+
* `invalid_token`: unknown, spent or expired.
|
|
1089
|
+
*/
|
|
1090
|
+
invitation(token: string): Promise<AuthResult<'ok', {
|
|
1091
|
+
invitation: Invitation;
|
|
1092
|
+
}>>;
|
|
1093
|
+
/**
|
|
1094
|
+
* Accepts an invitation with the password the person chose (the workspace's
|
|
1095
|
+
* policy, as for a sign-up) and signs them in. `mfa_required`: the account
|
|
1096
|
+
* owes a second step; ask for the code and call `signIn.mfa`, as after
|
|
1097
|
+
* `signIn.email`. A password refused leaves the invitation good.
|
|
1098
|
+
*/
|
|
1099
|
+
acceptInvitation(token: string, password: string): Promise<AuthResult<'signed_in', {
|
|
1100
|
+
session: PublicSession;
|
|
1101
|
+
}> | AuthResult<'mfa_required', {
|
|
1102
|
+
method?: 'email';
|
|
1103
|
+
}>>;
|
|
878
1104
|
/** Confirms the address a mailed link is for. The person is signed in from the link when their account asks no second step. */
|
|
879
1105
|
verifyEmail(form: {
|
|
880
1106
|
token: string;
|
|
@@ -966,6 +1192,13 @@ interface AuthTexts {
|
|
|
966
1192
|
passwordChanged: string;
|
|
967
1193
|
confirming: string;
|
|
968
1194
|
emailConfirmed: string;
|
|
1195
|
+
invitedTo: string;
|
|
1196
|
+
invitedToOrganization: string;
|
|
1197
|
+
invitedAs: string;
|
|
1198
|
+
choosePassword: string;
|
|
1199
|
+
acceptInvite: string;
|
|
1200
|
+
openingInvitation: string;
|
|
1201
|
+
invitationInvalid: string;
|
|
969
1202
|
profile: string;
|
|
970
1203
|
save: string;
|
|
971
1204
|
saved: string;
|
|
@@ -1027,12 +1260,21 @@ interface AuthTexts {
|
|
|
1027
1260
|
memberLeaveConfirm: string;
|
|
1028
1261
|
memberInviteAgain: string;
|
|
1029
1262
|
memberInvitationSent: string;
|
|
1263
|
+
organization: string;
|
|
1264
|
+
organizationRename: string;
|
|
1265
|
+
organizationRenamed: string;
|
|
1266
|
+
organizationArchive: string;
|
|
1267
|
+
organizationArchiveConfirm: string;
|
|
1268
|
+
organizationArchived: string;
|
|
1269
|
+
organizationDelete: string;
|
|
1270
|
+
organizationDeleteConfirm: string;
|
|
1271
|
+
organizationDeleted: string;
|
|
1030
1272
|
yes: string;
|
|
1031
1273
|
cancel: string;
|
|
1032
1274
|
/** By error code; one missing shows what the server said. */
|
|
1033
1275
|
errors: Record<string, string>;
|
|
1034
1276
|
}
|
|
1035
|
-
type Slot = 'form' | 'field' | 'label' | 'input' | 'button' | 'providerButton' | 'link' | 'error' | 'fieldError' | 'hint' | 'notice' | 'separator' | 'footer' | 'check' | 'account' | 'section' | 'heading' | 'secret' | 'codes' | 'sessions' | 'session';
|
|
1277
|
+
type Slot = 'form' | 'field' | 'label' | 'input' | 'button' | 'providerButton' | 'providerIcon' | 'link' | 'error' | 'fieldError' | 'hint' | 'notice' | 'separator' | 'footer' | 'check' | 'account' | 'section' | 'heading' | 'secret' | 'codes' | 'sessions' | 'session';
|
|
1036
1278
|
interface AuthFormProps {
|
|
1037
1279
|
/** The language of the built-in sentences. Default: `en`. */
|
|
1038
1280
|
locale?: 'en' | 'es';
|
|
@@ -1122,6 +1364,14 @@ declare function ForgotPassword(props: AuthFormProps): react.JSX.Element;
|
|
|
1122
1364
|
declare function ResetPassword(props: AuthFormProps): react.JSX.Element;
|
|
1123
1365
|
/** The page a "confirm your address" link opens: `pages.verifyEmail`. It confirms as it opens. */
|
|
1124
1366
|
declare function VerifyEmail(props: AuthFormProps): react.JSX.Element;
|
|
1367
|
+
/**
|
|
1368
|
+
* The page an invitation opens: `pages.acceptInvite`. It says who is invited
|
|
1369
|
+
* to what, asks for a password under the workspace's policy, signs the person
|
|
1370
|
+
* in (with the second step, when their account owes one) and goes on to
|
|
1371
|
+
* `returnTo`. The invitation is good until it is accepted: reading it, or a
|
|
1372
|
+
* password refused, does not spend it.
|
|
1373
|
+
*/
|
|
1374
|
+
declare function AcceptInvite(props: AuthFormProps): react.JSX.Element;
|
|
1125
1375
|
interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess'> {
|
|
1126
1376
|
/** Called after "sign out everywhere". Default: go to `/`. */
|
|
1127
1377
|
onSignedOut?: () => void;
|
|
@@ -1144,10 +1394,12 @@ interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'return
|
|
|
1144
1394
|
* The people of one of the signed-in person's organizations, administered
|
|
1145
1395
|
* from the application. What it offers follows the person's role in the
|
|
1146
1396
|
* system's catalog: cauthy:members read lists the people; manage adds them by
|
|
1147
|
-
* address (one with no account is invited), changes their role
|
|
1148
|
-
* invitation again
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1397
|
+
* address (one with no account is invited), changes their role and sends an
|
|
1398
|
+
* invitation again; remove removes them. Anybody may leave. Only an owner
|
|
1399
|
+
* gives the owner role or changes an owner. cauthy:organization update,
|
|
1400
|
+
* archive and delete rename the organization, archive it, delete it. Cauthy
|
|
1401
|
+
* checks each change with the person's own session; the application
|
|
1402
|
+
* authorizes nothing. Like the other forms, it carries no styles.
|
|
1151
1403
|
*/
|
|
1152
1404
|
declare function OrganizationMembers(props: OrganizationMembersProps): react.JSX.Element;
|
|
1153
1405
|
|
|
@@ -1194,4 +1446,4 @@ declare function useSession(): SessionContext;
|
|
|
1194
1446
|
*/
|
|
1195
1447
|
declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
|
|
1196
1448
|
|
|
1197
|
-
export { Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|
|
1449
|
+
export { AcceptInvite, Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|