cauthy-auth 0.19.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cauthy-Bn3iv50y.d.ts → cauthy-DGAy45G2.d.ts} +1 -1
- package/dist/{cauthy-C29HCvag.d.mts → cauthy-XkIbG5gE.d.mts} +1 -1
- package/dist/client.d.mts +157 -2
- package/dist/client.d.ts +157 -2
- package/dist/client.js +37 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +37 -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 +181 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -6
- 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 +192 -1
- package/dist/react.d.ts +192 -1
- package/dist/react.js +279 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +278 -23
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +3 -3
- package/dist/svelte.d.ts +3 -3
- package/dist/svelte.js +37 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +37 -2
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-ZD_Wa8Bm.d.mts → system-BxMsSIu1.d.mts} +2 -0
- package/dist/{system-DhRr_WxR.d.ts → system-DTIeDXDP.d.ts} +2 -0
- package/dist/vue.d.mts +3 -3
- package/dist/vue.d.ts +3 -3
- package/dist/vue.js +37 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +37 -2
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/svelte.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionStore, SessionState, SessionStoreOptions } from './client.mjs';
|
|
2
|
-
export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind } from './client.mjs';
|
|
3
|
-
import { i as PublicSession } from './system-
|
|
4
|
-
export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-
|
|
2
|
+
export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.mjs';
|
|
3
|
+
import { i as PublicSession } from './system-BxMsSIu1.mjs';
|
|
4
|
+
export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-BxMsSIu1.mjs';
|
|
5
5
|
import './theme.mjs';
|
|
6
6
|
import './validate-B_iC-4y8.mjs';
|
|
7
7
|
import 'jose';
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionStore, SessionState, SessionStoreOptions } from './client.js';
|
|
2
|
-
export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind } from './client.js';
|
|
3
|
-
import { i as PublicSession } from './system-
|
|
4
|
-
export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-
|
|
2
|
+
export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.js';
|
|
3
|
+
import { i as PublicSession } from './system-DTIeDXDP.js';
|
|
4
|
+
export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-DTIeDXDP.js';
|
|
5
5
|
import './theme.js';
|
|
6
6
|
import './validate-B_iC-4y8.js';
|
|
7
7
|
import 'jose';
|
package/dist/svelte.js
CHANGED
|
@@ -228,8 +228,14 @@ function createAuthClient(options = {}) {
|
|
|
228
228
|
return null;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
+
const upgradeUrl = (provider, o = {}) => `${base}/me/upgrade/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
231
232
|
const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
232
233
|
const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
234
|
+
const ssoUrl = (target, o = {}) => {
|
|
235
|
+
const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
|
|
236
|
+
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
237
|
+
return `${base}/sign-in/sso?${q}`;
|
|
238
|
+
};
|
|
233
239
|
const passkeyUrl = (o = {}) => {
|
|
234
240
|
const q = new URLSearchParams({ method: "passkey" });
|
|
235
241
|
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
@@ -241,11 +247,11 @@ function createAuthClient(options = {}) {
|
|
|
241
247
|
const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
242
248
|
if (res.ok) {
|
|
243
249
|
const m = await res.json();
|
|
244
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true };
|
|
250
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
|
|
245
251
|
}
|
|
246
252
|
} catch {
|
|
247
253
|
}
|
|
248
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
|
|
254
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
249
255
|
}
|
|
250
256
|
async function ceremony(begin, finish, form, run, more = {}) {
|
|
251
257
|
const begun = await post(begin, form, null);
|
|
@@ -260,6 +266,7 @@ function createAuthClient(options = {}) {
|
|
|
260
266
|
}
|
|
261
267
|
return {
|
|
262
268
|
signIn: {
|
|
269
|
+
anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
|
|
263
270
|
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
|
|
264
271
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
265
272
|
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
@@ -343,6 +350,11 @@ function createAuthClient(options = {}) {
|
|
|
343
350
|
socialUrl,
|
|
344
351
|
social(provider, o) {
|
|
345
352
|
window.location.assign(socialUrl(provider, o));
|
|
353
|
+
},
|
|
354
|
+
ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
|
|
355
|
+
ssoUrl,
|
|
356
|
+
sso(target, o) {
|
|
357
|
+
window.location.assign(ssoUrl(target, o));
|
|
346
358
|
}
|
|
347
359
|
},
|
|
348
360
|
signUp: {
|
|
@@ -352,6 +364,24 @@ function createAuthClient(options = {}) {
|
|
|
352
364
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|
|
353
365
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
354
366
|
signOut: () => post("/sign-out", {}, null),
|
|
367
|
+
organizations: {
|
|
368
|
+
async list(system) {
|
|
369
|
+
const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
|
|
370
|
+
return body && Array.isArray(body.organizations) ? body.organizations : [];
|
|
371
|
+
},
|
|
372
|
+
async members(id) {
|
|
373
|
+
const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
|
|
374
|
+
return body && Array.isArray(body.members) ? body.members : null;
|
|
375
|
+
},
|
|
376
|
+
async roles(id) {
|
|
377
|
+
const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
|
|
378
|
+
return body && Array.isArray(body.roles) ? body.roles : null;
|
|
379
|
+
},
|
|
380
|
+
add: (id, f) => post("/me/organizations/members/add", { organizationId: id, email: f.email, role: f.role, name: f.name ?? "", locale: f.locale ?? "" }, checkEmail(f.email)),
|
|
381
|
+
setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
|
|
382
|
+
remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
|
|
383
|
+
inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
|
|
384
|
+
},
|
|
355
385
|
account: {
|
|
356
386
|
async get() {
|
|
357
387
|
const body = await read("/me");
|
|
@@ -390,6 +420,11 @@ function createAuthClient(options = {}) {
|
|
|
390
420
|
return body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
391
421
|
},
|
|
392
422
|
signOutEverywhere: () => post("/me/sessions/end", {}, null),
|
|
423
|
+
upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
|
|
424
|
+
upgradeUrl,
|
|
425
|
+
upgradeWith(provider, o) {
|
|
426
|
+
window.location.assign(upgradeUrl(provider, o));
|
|
427
|
+
},
|
|
393
428
|
async agents() {
|
|
394
429
|
const body = await read("/me/agents");
|
|
395
430
|
return body && Array.isArray(body.agents) ? body.agents : [];
|