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
package/README.md
CHANGED
|
@@ -47,16 +47,21 @@ const { signIn } = useAuth()
|
|
|
47
47
|
const r = await signIn.email({ email, password }) // r.ok, r.status, r.error.field
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
What Cauthy mails opens your pages too: a new password, a confirmed address, a sign-in link.
|
|
50
|
+
What Cauthy mails opens your pages too: a new password, a confirmed address, a sign-in link, an invitation.
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
export const auth = createCauthy({ pages: { signIn: '/sign-in', resetPassword: '/new-password', verifyEmail: '/confirm' } })
|
|
53
|
+
export const auth = createCauthy({ pages: { signIn: '/sign-in', resetPassword: '/new-password', verifyEmail: '/confirm', acceptInvite: '/accept-invite' } })
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
```tsx
|
|
57
|
-
import { ResetPassword, VerifyEmail } from 'cauthy-auth/react'
|
|
57
|
+
import { AcceptInvite, ResetPassword, VerifyEmail } from 'cauthy-auth/react'
|
|
58
|
+
<AcceptInvite links={{ signIn: '/sign-in' }} returnTo="/" /> // "You've been invited to Acme", a password, signed in
|
|
59
|
+
|
|
60
|
+
const { invitation, acceptInvitation } = useAuth() // or with your own form
|
|
58
61
|
```
|
|
59
62
|
|
|
63
|
+
The forms follow what the workspace turned on in Cauthy's dashboard: each provider's button carries its logo (`classNames.providerIcon` styles it), and a workspace that turned off the password or passkeys does not see them offered. `methods()` says so: `passwordSignIn`, `passkey`, `providers[].iconUrl`.
|
|
64
|
+
|
|
60
65
|
And the person's account, in your application: name, password, second step, sessions.
|
|
61
66
|
|
|
62
67
|
```tsx
|
|
@@ -166,6 +171,8 @@ const org = await auth.system.organizations.create({ name: 'Acme' })
|
|
|
166
171
|
await auth.system.members.add(org.id, { role: 'owner', email: 'ana@acme.com' })
|
|
167
172
|
```
|
|
168
173
|
|
|
174
|
+
Its invitations open your `pages.acceptInvite` when the application knows its public origin (`baseURL`, `CAUTHY_BASE_URL`); otherwise Cauthy's own page.
|
|
175
|
+
|
|
169
176
|
A backend that is handed a Cauthy access token checks it with Cauthy's published keys: no secret, no call per request.
|
|
170
177
|
|
|
171
178
|
```ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-BrrJsrFW.mjs';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-BvvoNs2y.js';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
package/dist/cli.js
CHANGED
|
@@ -989,6 +989,8 @@ function createSystem(given = {}) {
|
|
|
989
989
|
const envKey = env("CAUTHY_SYSTEM_KEY");
|
|
990
990
|
const key = given.key ?? (envKey ? { privateKey: envKey, keyId: env("CAUTHY_SYSTEM_KEY_ID") ?? "" } : void 0);
|
|
991
991
|
const ownSystem = given.system ?? env("CAUTHY_SYSTEM") ?? "";
|
|
992
|
+
const acceptInviteUrl = given.acceptInviteUrl ?? env("CAUTHY_ACCEPT_INVITE_URL") ?? "";
|
|
993
|
+
const inviteHeaders = /^https?:\/\//.test(acceptInviteUrl) ? { "x-cauthy-client-id": clientId, "x-cauthy-link-to": acceptInviteUrl } : {};
|
|
992
994
|
const doFetch = (...args) => (given.fetch ?? fetch)(...args);
|
|
993
995
|
const tokenEndpoint = `${issuer}/v1/oauth/token`;
|
|
994
996
|
function configured() {
|
|
@@ -1031,10 +1033,10 @@ function createSystem(given = {}) {
|
|
|
1031
1033
|
asking = void 0;
|
|
1032
1034
|
});
|
|
1033
1035
|
}
|
|
1034
|
-
async function call(method, path, body) {
|
|
1036
|
+
async function call(method, path, body, extra = {}) {
|
|
1035
1037
|
const send = async () => doFetch(`${issuer}${path}`, {
|
|
1036
1038
|
method,
|
|
1037
|
-
headers: { authorization: `Bearer ${await token()}`, ...body === void 0 ? {} : { "content-type": "application/json" } },
|
|
1039
|
+
headers: { authorization: `Bearer ${await token()}`, ...extra, ...body === void 0 ? {} : { "content-type": "application/json" } },
|
|
1038
1040
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
1039
1041
|
});
|
|
1040
1042
|
let res = await send();
|
|
@@ -1045,7 +1047,7 @@ function createSystem(given = {}) {
|
|
|
1045
1047
|
if (!res.ok) await fail2(res, `${method} ${path}`);
|
|
1046
1048
|
return res.status === 204 ? void 0 : res.json();
|
|
1047
1049
|
}
|
|
1048
|
-
const data = async (method, path, body) => (await call(method, path, body))?.data;
|
|
1050
|
+
const data = async (method, path, body, extra) => (await call(method, path, body, extra))?.data;
|
|
1049
1051
|
const id = encodeURIComponent;
|
|
1050
1052
|
return {
|
|
1051
1053
|
token,
|
|
@@ -1082,7 +1084,8 @@ function createSystem(given = {}) {
|
|
|
1082
1084
|
return toMember(await data(
|
|
1083
1085
|
"POST",
|
|
1084
1086
|
`/v1/organizations/${id(orgId)}/members`,
|
|
1085
|
-
{ role: m.role, user_id: m.userId, email: m.email, name: m.name, locale: m.locale, client_id: clientId }
|
|
1087
|
+
{ role: m.role, user_id: m.userId, email: m.email, name: m.name, locale: m.locale, client_id: clientId },
|
|
1088
|
+
inviteHeaders
|
|
1086
1089
|
));
|
|
1087
1090
|
},
|
|
1088
1091
|
async setRole(orgId, userId, role) {
|
|
@@ -1093,7 +1096,7 @@ function createSystem(given = {}) {
|
|
|
1093
1096
|
}
|
|
1094
1097
|
},
|
|
1095
1098
|
async invite(person) {
|
|
1096
|
-
const u = await data("POST", "/v1/users", { ...person, client_id: clientId });
|
|
1099
|
+
const u = await data("POST", "/v1/users", { ...person, client_id: clientId }, inviteHeaders);
|
|
1097
1100
|
return { id: u.id, email: u.email };
|
|
1098
1101
|
},
|
|
1099
1102
|
theme: {
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.mjs';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-BrrJsrFW.mjs';
|
|
3
|
+
export { h as CheckRule } from './system-BrrJsrFW.mjs';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.mjs';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.mjs';
|
|
6
6
|
import 'jose';
|
|
@@ -74,11 +74,25 @@ type AuthResult<S extends string, More = unknown> = ({
|
|
|
74
74
|
};
|
|
75
75
|
/** What the screen may offer. */
|
|
76
76
|
interface AuthMethods {
|
|
77
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The providers the workspace signs people in with and has turned on:
|
|
79
|
+
* `{ id: 'google', name: 'Google', iconUrl: 'https://…/v1/social/icons/google.svg' }`.
|
|
80
|
+
* `iconUrl` is the provider's logo, served by Cauthy; absent from a Cauthy
|
|
81
|
+
* that does not serve logos.
|
|
82
|
+
*/
|
|
78
83
|
providers: {
|
|
79
84
|
id: string;
|
|
80
85
|
name: string;
|
|
86
|
+
iconUrl?: string;
|
|
81
87
|
}[];
|
|
88
|
+
/**
|
|
89
|
+
* Whether the workspace signs people in with a password. False: the
|
|
90
|
+
* password field, "forgot your password" and a sign-up with a password are
|
|
91
|
+
* not offered, and Cauthy refuses them (`password_disabled`). True from a
|
|
92
|
+
* server that does not say. (`password` is something else: the policy a new
|
|
93
|
+
* password must meet.)
|
|
94
|
+
*/
|
|
95
|
+
passwordSignIn: boolean;
|
|
82
96
|
/** Whether people may create an account themselves. */
|
|
83
97
|
signUp: boolean;
|
|
84
98
|
/** Set when the application's system makes an organization per sign-up: the form asks the company's name. */
|
|
@@ -87,7 +101,7 @@ interface AuthMethods {
|
|
|
87
101
|
required: boolean;
|
|
88
102
|
};
|
|
89
103
|
magicLink: boolean;
|
|
90
|
-
/** Whether to offer a passkey. */
|
|
104
|
+
/** Whether to offer a passkey. False when the workspace turned passkeys off. */
|
|
91
105
|
passkey: boolean;
|
|
92
106
|
/**
|
|
93
107
|
* Whether the passkey is used on this page itself. False: `signIn.passkey`
|
|
@@ -139,6 +153,15 @@ interface AuthMethods {
|
|
|
139
153
|
*/
|
|
140
154
|
password?: PasswordPolicy;
|
|
141
155
|
}
|
|
156
|
+
/** An invitation, as its page shows it before the person chooses a password. */
|
|
157
|
+
interface Invitation {
|
|
158
|
+
/** The address invited: the account the person signs in as. */
|
|
159
|
+
email: string;
|
|
160
|
+
/** The workspace's name. */
|
|
161
|
+
workspace: string;
|
|
162
|
+
/** The organization the person was invited to, when there is one. */
|
|
163
|
+
organization?: string;
|
|
164
|
+
}
|
|
142
165
|
/** A legal document the person owes: not yet accepted in its current version. */
|
|
143
166
|
interface PendingLegal {
|
|
144
167
|
kind: string;
|
|
@@ -730,7 +753,25 @@ interface AuthClient {
|
|
|
730
753
|
token: string;
|
|
731
754
|
password: string;
|
|
732
755
|
}): Promise<AuthResult<'changed'>>;
|
|
733
|
-
/**
|
|
756
|
+
/**
|
|
757
|
+
* Who an invitation is for and to what, with the token the mailed link
|
|
758
|
+
* opened the page with (`token`). Reading it does not spend it.
|
|
759
|
+
* `invalid_token`: unknown, spent or expired.
|
|
760
|
+
*/
|
|
761
|
+
invitation(token: string): Promise<AuthResult<'ok', {
|
|
762
|
+
invitation: Invitation;
|
|
763
|
+
}>>;
|
|
764
|
+
/**
|
|
765
|
+
* Accepts an invitation with the password the person chose (the workspace's
|
|
766
|
+
* policy, as for a sign-up) and signs them in. `mfa_required`: the account
|
|
767
|
+
* owes a second step; ask for the code and call `signIn.mfa`, as after
|
|
768
|
+
* `signIn.email`. A password refused leaves the invitation good.
|
|
769
|
+
*/
|
|
770
|
+
acceptInvitation(token: string, password: string): Promise<AuthResult<'signed_in', {
|
|
771
|
+
session: PublicSession;
|
|
772
|
+
}> | AuthResult<'mfa_required', {
|
|
773
|
+
method?: 'email';
|
|
774
|
+
}>>;
|
|
734
775
|
/** Confirms the address a mailed link is for. The person is signed in from the link when their account asks no second step. */
|
|
735
776
|
verifyEmail(form: {
|
|
736
777
|
token: string;
|
|
@@ -765,4 +806,4 @@ interface AuthClientOptions {
|
|
|
765
806
|
}
|
|
766
807
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
767
808
|
|
|
768
|
-
export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, CheckQuestion, CheckResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, OrganizationRef, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, PasswordPolicy, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
|
809
|
+
export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, CheckQuestion, CheckResult, type ConnectedAgent, type Invitation, type LinkedIdentity, type OrganizationPerson, OrganizationRef, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, PasswordPolicy, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.js';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-BvvoNs2y.js';
|
|
3
|
+
export { h as CheckRule } from './system-BvvoNs2y.js';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.js';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.js';
|
|
6
6
|
import 'jose';
|
|
@@ -74,11 +74,25 @@ type AuthResult<S extends string, More = unknown> = ({
|
|
|
74
74
|
};
|
|
75
75
|
/** What the screen may offer. */
|
|
76
76
|
interface AuthMethods {
|
|
77
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The providers the workspace signs people in with and has turned on:
|
|
79
|
+
* `{ id: 'google', name: 'Google', iconUrl: 'https://…/v1/social/icons/google.svg' }`.
|
|
80
|
+
* `iconUrl` is the provider's logo, served by Cauthy; absent from a Cauthy
|
|
81
|
+
* that does not serve logos.
|
|
82
|
+
*/
|
|
78
83
|
providers: {
|
|
79
84
|
id: string;
|
|
80
85
|
name: string;
|
|
86
|
+
iconUrl?: string;
|
|
81
87
|
}[];
|
|
88
|
+
/**
|
|
89
|
+
* Whether the workspace signs people in with a password. False: the
|
|
90
|
+
* password field, "forgot your password" and a sign-up with a password are
|
|
91
|
+
* not offered, and Cauthy refuses them (`password_disabled`). True from a
|
|
92
|
+
* server that does not say. (`password` is something else: the policy a new
|
|
93
|
+
* password must meet.)
|
|
94
|
+
*/
|
|
95
|
+
passwordSignIn: boolean;
|
|
82
96
|
/** Whether people may create an account themselves. */
|
|
83
97
|
signUp: boolean;
|
|
84
98
|
/** Set when the application's system makes an organization per sign-up: the form asks the company's name. */
|
|
@@ -87,7 +101,7 @@ interface AuthMethods {
|
|
|
87
101
|
required: boolean;
|
|
88
102
|
};
|
|
89
103
|
magicLink: boolean;
|
|
90
|
-
/** Whether to offer a passkey. */
|
|
104
|
+
/** Whether to offer a passkey. False when the workspace turned passkeys off. */
|
|
91
105
|
passkey: boolean;
|
|
92
106
|
/**
|
|
93
107
|
* Whether the passkey is used on this page itself. False: `signIn.passkey`
|
|
@@ -139,6 +153,15 @@ interface AuthMethods {
|
|
|
139
153
|
*/
|
|
140
154
|
password?: PasswordPolicy;
|
|
141
155
|
}
|
|
156
|
+
/** An invitation, as its page shows it before the person chooses a password. */
|
|
157
|
+
interface Invitation {
|
|
158
|
+
/** The address invited: the account the person signs in as. */
|
|
159
|
+
email: string;
|
|
160
|
+
/** The workspace's name. */
|
|
161
|
+
workspace: string;
|
|
162
|
+
/** The organization the person was invited to, when there is one. */
|
|
163
|
+
organization?: string;
|
|
164
|
+
}
|
|
142
165
|
/** A legal document the person owes: not yet accepted in its current version. */
|
|
143
166
|
interface PendingLegal {
|
|
144
167
|
kind: string;
|
|
@@ -730,7 +753,25 @@ interface AuthClient {
|
|
|
730
753
|
token: string;
|
|
731
754
|
password: string;
|
|
732
755
|
}): Promise<AuthResult<'changed'>>;
|
|
733
|
-
/**
|
|
756
|
+
/**
|
|
757
|
+
* Who an invitation is for and to what, with the token the mailed link
|
|
758
|
+
* opened the page with (`token`). Reading it does not spend it.
|
|
759
|
+
* `invalid_token`: unknown, spent or expired.
|
|
760
|
+
*/
|
|
761
|
+
invitation(token: string): Promise<AuthResult<'ok', {
|
|
762
|
+
invitation: Invitation;
|
|
763
|
+
}>>;
|
|
764
|
+
/**
|
|
765
|
+
* Accepts an invitation with the password the person chose (the workspace's
|
|
766
|
+
* policy, as for a sign-up) and signs them in. `mfa_required`: the account
|
|
767
|
+
* owes a second step; ask for the code and call `signIn.mfa`, as after
|
|
768
|
+
* `signIn.email`. A password refused leaves the invitation good.
|
|
769
|
+
*/
|
|
770
|
+
acceptInvitation(token: string, password: string): Promise<AuthResult<'signed_in', {
|
|
771
|
+
session: PublicSession;
|
|
772
|
+
}> | AuthResult<'mfa_required', {
|
|
773
|
+
method?: 'email';
|
|
774
|
+
}>>;
|
|
734
775
|
/** Confirms the address a mailed link is for. The person is signed in from the link when their account asks no second step. */
|
|
735
776
|
verifyEmail(form: {
|
|
736
777
|
token: string;
|
|
@@ -765,4 +806,4 @@ interface AuthClientOptions {
|
|
|
765
806
|
}
|
|
766
807
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
767
808
|
|
|
768
|
-
export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, CheckQuestion, CheckResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, OrganizationRef, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, PasswordPolicy, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
|
809
|
+
export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, CheckQuestion, CheckResult, type ConnectedAgent, type Invitation, type LinkedIdentity, type OrganizationPerson, OrganizationRef, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, PasswordPolicy, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
package/dist/client.js
CHANGED
|
@@ -492,11 +492,11 @@ function createAuthClient(options = {}) {
|
|
|
492
492
|
if (res.ok) {
|
|
493
493
|
const m = await res.json();
|
|
494
494
|
if (m.password) policy = passwordPolicyOf(m.password);
|
|
495
|
-
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 };
|
|
495
|
+
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 };
|
|
496
496
|
}
|
|
497
497
|
} catch {
|
|
498
498
|
}
|
|
499
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
499
|
+
return { providers: [], signUp: true, passwordSignIn: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
500
500
|
}
|
|
501
501
|
async function ceremony(begin, finish, form, run, more = {}) {
|
|
502
502
|
const begun = await post(begin, form, null);
|
|
@@ -643,6 +643,20 @@ function createAuthClient(options = {}) {
|
|
|
643
643
|
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
644
644
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password, policy)),
|
|
645
645
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
646
|
+
async invitation(token) {
|
|
647
|
+
const bad = { ok: false, error: { code: "invalid_token", message: "This invitation is not valid, or it has expired." } };
|
|
648
|
+
if (typeof token !== "string" || token.trim() === "") return bad;
|
|
649
|
+
try {
|
|
650
|
+
const res = await doFetch(`${base}/invitation?token=${encodeURIComponent(token.trim())}`, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
651
|
+
const body = await res.json().catch(() => null);
|
|
652
|
+
if (res.ok && body?.invitation) return { ok: true, status: "ok", invitation: body.invitation };
|
|
653
|
+
const e = body?.error;
|
|
654
|
+
return { ok: false, error: e && typeof e.code === "string" ? { code: e.code, message: String(e.message ?? "") } : UNAVAILABLE };
|
|
655
|
+
} catch {
|
|
656
|
+
return { ok: false, error: UNAVAILABLE };
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
acceptInvitation: (token, password) => post("/invitation/accept", { token, password }, checkNewPassword(password, policy)),
|
|
646
660
|
signOut: () => post("/sign-out", {}, null),
|
|
647
661
|
organizations: {
|
|
648
662
|
async list(system) {
|