cauthy-auth 0.30.0 → 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 +10 -3
- package/dist/{cauthy-BXgsZ-Um.d.mts → cauthy-2jtP2LVQ.d.mts} +1 -1
- package/dist/{cauthy-CHENs452.d.ts → cauthy-CKfvvv_i.d.ts} +1 -1
- package/dist/cli.js +8 -5
- package/dist/client.d.mts +47 -6
- package/dist/client.d.ts +47 -6
- package/dist/client.js +16 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +16 -2
- 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 +64 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -21
- 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 +61 -5
- package/dist/react.d.ts +61 -5
- package/dist/react.js +183 -46
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +182 -46
- 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 +16 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +16 -2
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-0mHrdAgO.d.mts → system-BrrJsrFW.d.mts} +14 -0
- package/dist/{system-BIYbS7h2.d.ts → system-BvvoNs2y.d.ts} +14 -0
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +16 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +16 -2
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -56,11 +56,17 @@ interface CauthyOptions {
|
|
|
56
56
|
* signIn where `<SignIn />` is: a sign-in link opens it
|
|
57
57
|
* resetPassword where `<ResetPassword />` is
|
|
58
58
|
* verifyEmail where `<VerifyEmail />` is
|
|
59
|
+
* acceptInvite where `<AcceptInvite />` is: an invitation opens it
|
|
60
|
+
*
|
|
61
|
+
* An invitation sent by `auth.system.members.add` or `auth.system.invite`
|
|
62
|
+
* opens `acceptInvite` only when the application knows its public origin
|
|
63
|
+
* (`baseURL`): that call has no request to read it from.
|
|
59
64
|
*/
|
|
60
65
|
pages?: {
|
|
61
66
|
signIn?: string;
|
|
62
67
|
resetPassword?: string;
|
|
63
68
|
verifyEmail?: string;
|
|
69
|
+
acceptInvite?: string;
|
|
64
70
|
};
|
|
65
71
|
/**
|
|
66
72
|
* The address of the person a request comes from, passed on to Cauthy so
|
|
@@ -448,6 +454,14 @@ interface SystemOptions {
|
|
|
448
454
|
key?: SystemKey;
|
|
449
455
|
/** The application's system, which `check` asks about. Default: `CAUTHY_SYSTEM`. */
|
|
450
456
|
system?: string;
|
|
457
|
+
/**
|
|
458
|
+
* The application's own page for accepting an invitation, as an absolute
|
|
459
|
+
* address (`https://app.example.com/accept-invite`, where `<AcceptInvite />`
|
|
460
|
+
* is). The invitations `members.add` and `invite` send open it; without it,
|
|
461
|
+
* they open Cauthy's own page. Cauthy follows it only on an origin the
|
|
462
|
+
* client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
|
|
463
|
+
*/
|
|
464
|
+
acceptInviteUrl?: string;
|
|
451
465
|
fetch?: typeof fetch;
|
|
452
466
|
}
|
|
453
467
|
/** Cauthy refused a request of the application's own. */
|
|
@@ -56,11 +56,17 @@ interface CauthyOptions {
|
|
|
56
56
|
* signIn where `<SignIn />` is: a sign-in link opens it
|
|
57
57
|
* resetPassword where `<ResetPassword />` is
|
|
58
58
|
* verifyEmail where `<VerifyEmail />` is
|
|
59
|
+
* acceptInvite where `<AcceptInvite />` is: an invitation opens it
|
|
60
|
+
*
|
|
61
|
+
* An invitation sent by `auth.system.members.add` or `auth.system.invite`
|
|
62
|
+
* opens `acceptInvite` only when the application knows its public origin
|
|
63
|
+
* (`baseURL`): that call has no request to read it from.
|
|
59
64
|
*/
|
|
60
65
|
pages?: {
|
|
61
66
|
signIn?: string;
|
|
62
67
|
resetPassword?: string;
|
|
63
68
|
verifyEmail?: string;
|
|
69
|
+
acceptInvite?: string;
|
|
64
70
|
};
|
|
65
71
|
/**
|
|
66
72
|
* The address of the person a request comes from, passed on to Cauthy so
|
|
@@ -448,6 +454,14 @@ interface SystemOptions {
|
|
|
448
454
|
key?: SystemKey;
|
|
449
455
|
/** The application's system, which `check` asks about. Default: `CAUTHY_SYSTEM`. */
|
|
450
456
|
system?: string;
|
|
457
|
+
/**
|
|
458
|
+
* The application's own page for accepting an invitation, as an absolute
|
|
459
|
+
* address (`https://app.example.com/accept-invite`, where `<AcceptInvite />`
|
|
460
|
+
* is). The invitations `members.add` and `invite` send open it; without it,
|
|
461
|
+
* they open Cauthy's own page. Cauthy follows it only on an origin the
|
|
462
|
+
* client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
|
|
463
|
+
*/
|
|
464
|
+
acceptInviteUrl?: string;
|
|
451
465
|
fetch?: typeof fetch;
|
|
452
466
|
}
|
|
453
467
|
/** Cauthy refused a request of the application's own. */
|
package/dist/vue.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ShallowRef, Plugin } from 'vue';
|
|
2
2
|
import { SessionStore, SessionState, SessionStoreOptions, AuthClient } from './client.mjs';
|
|
3
3
|
export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.mjs';
|
|
4
|
-
import { q as PublicSession } from './system-
|
|
5
|
-
export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-
|
|
4
|
+
import { q as PublicSession } from './system-BrrJsrFW.mjs';
|
|
5
|
+
export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-BrrJsrFW.mjs';
|
|
6
6
|
import './theme.mjs';
|
|
7
7
|
import './validate-sEXG82po.mjs';
|
|
8
8
|
import 'jose';
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ShallowRef, Plugin } from 'vue';
|
|
2
2
|
import { SessionStore, SessionState, SessionStoreOptions, AuthClient } from './client.js';
|
|
3
3
|
export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.js';
|
|
4
|
-
import { q as PublicSession } from './system-
|
|
5
|
-
export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-
|
|
4
|
+
import { q as PublicSession } from './system-BvvoNs2y.js';
|
|
5
|
+
export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-BvvoNs2y.js';
|
|
6
6
|
import './theme.js';
|
|
7
7
|
import './validate-sEXG82po.js';
|
|
8
8
|
import 'jose';
|
package/dist/vue.js
CHANGED
|
@@ -375,11 +375,11 @@ function createAuthClient(options = {}) {
|
|
|
375
375
|
if (res.ok) {
|
|
376
376
|
const m = await res.json();
|
|
377
377
|
if (m.password) policy = passwordPolicyOf(m.password);
|
|
378
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, ...policy ? { password: policy } : {}, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
|
|
378
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, ...policy ? { password: policy } : {}, passwordSignIn: m.passwordSignIn !== false, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
|
|
379
379
|
}
|
|
380
380
|
} catch {
|
|
381
381
|
}
|
|
382
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
382
|
+
return { providers: [], signUp: true, passwordSignIn: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
383
383
|
}
|
|
384
384
|
async function ceremony(begin, finish, form, run, more = {}) {
|
|
385
385
|
const begun = await post(begin, form, null);
|
|
@@ -526,6 +526,20 @@ function createAuthClient(options = {}) {
|
|
|
526
526
|
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
527
527
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password, policy)),
|
|
528
528
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
529
|
+
async invitation(token) {
|
|
530
|
+
const bad = { ok: false, error: { code: "invalid_token", message: "This invitation is not valid, or it has expired." } };
|
|
531
|
+
if (typeof token !== "string" || token.trim() === "") return bad;
|
|
532
|
+
try {
|
|
533
|
+
const res = await doFetch(`${base}/invitation?token=${encodeURIComponent(token.trim())}`, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
534
|
+
const body = await res.json().catch(() => null);
|
|
535
|
+
if (res.ok && body?.invitation) return { ok: true, status: "ok", invitation: body.invitation };
|
|
536
|
+
const e = body?.error;
|
|
537
|
+
return { ok: false, error: e && typeof e.code === "string" ? { code: e.code, message: String(e.message ?? "") } : UNAVAILABLE };
|
|
538
|
+
} catch {
|
|
539
|
+
return { ok: false, error: UNAVAILABLE };
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
acceptInvitation: (token, password) => post("/invitation/accept", { token, password }, checkNewPassword(password, policy)),
|
|
529
543
|
signOut: () => post("/sign-out", {}, null),
|
|
530
544
|
organizations: {
|
|
531
545
|
async list(system) {
|