cauthy-auth 0.24.3 → 0.26.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/client.d.mts +36 -7
- package/dist/client.d.ts +36 -7
- package/dist/client.js +14 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +14 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -5
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +40 -6
- package/dist/react.d.ts +40 -6
- package/dist/react.js +39 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +39 -7
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +14 -1
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +14 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/{validate-B_iC-4y8.d.mts → validate-BTRit1O1.d.mts} +1 -1
- package/dist/{validate-B_iC-4y8.d.ts → validate-BTRit1O1.d.ts} +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +14 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +14 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.mjs';
|
|
2
2
|
import { i as PublicSession } from './system-BxMsSIu1.mjs';
|
|
3
|
-
import { A as AuthField } from './validate-
|
|
4
|
-
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-
|
|
3
|
+
import { A as AuthField } from './validate-BTRit1O1.mjs';
|
|
4
|
+
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-BTRit1O1.mjs';
|
|
5
5
|
import 'jose';
|
|
6
6
|
|
|
7
7
|
/** Whether this browser can use a passkey at all. */
|
|
@@ -78,6 +78,11 @@ interface AuthMethods {
|
|
|
78
78
|
}[];
|
|
79
79
|
/** Whether people may create an account themselves. */
|
|
80
80
|
signUp: boolean;
|
|
81
|
+
/** Set when the application's system makes an organization per sign-up: the form asks the company's name. */
|
|
82
|
+
organization?: {
|
|
83
|
+
ask: boolean;
|
|
84
|
+
required: boolean;
|
|
85
|
+
};
|
|
81
86
|
magicLink: boolean;
|
|
82
87
|
/** Whether to offer a passkey. */
|
|
83
88
|
passkey: boolean;
|
|
@@ -425,21 +430,34 @@ interface AuthClient {
|
|
|
425
430
|
}): Promise<AuthResult<'signed_in', {
|
|
426
431
|
session: PublicSession;
|
|
427
432
|
}>>;
|
|
428
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* With address and password. `mfa_required`: ask for the code and call
|
|
435
|
+
* `signIn.mfa`. `method: 'email'` says the code was just mailed to the
|
|
436
|
+
* account's address (it has no factor of its own and the workspace, or
|
|
437
|
+
* the sign-in's risk, asked a second step): say so, and offer
|
|
438
|
+
* `mfaSendEmail` for another.
|
|
439
|
+
*/
|
|
429
440
|
email(form: {
|
|
430
441
|
email: string;
|
|
431
442
|
password: string;
|
|
432
443
|
captchaToken?: string;
|
|
433
444
|
}): Promise<AuthResult<'signed_in', {
|
|
434
445
|
session: PublicSession;
|
|
435
|
-
}> | AuthResult<'mfa_required'
|
|
436
|
-
|
|
446
|
+
}> | AuthResult<'mfa_required', {
|
|
447
|
+
method?: 'email';
|
|
448
|
+
}>>;
|
|
449
|
+
/** The second step: the code of the authenticator app, the phone, the email, or a recovery code. */
|
|
437
450
|
mfa(form: {
|
|
438
451
|
code: string;
|
|
439
452
|
}): Promise<AuthResult<'signed_in', {
|
|
440
453
|
session: PublicSession;
|
|
441
454
|
}>>;
|
|
442
|
-
/**
|
|
455
|
+
/**
|
|
456
|
+
* While the second step is asked for: whether the account has an
|
|
457
|
+
* authenticator app, the phone (masked) a code can be sent to, phones
|
|
458
|
+
* that approve sign-ins, and the address (masked) a code went to when
|
|
459
|
+
* the step is by email.
|
|
460
|
+
*/
|
|
443
461
|
mfaMethods(): Promise<AuthResult<'ok', {
|
|
444
462
|
totp: boolean;
|
|
445
463
|
phone: {
|
|
@@ -449,6 +467,13 @@ interface AuthClient {
|
|
|
449
467
|
push: {
|
|
450
468
|
devices: number;
|
|
451
469
|
} | null;
|
|
470
|
+
email: {
|
|
471
|
+
to: string;
|
|
472
|
+
} | null;
|
|
473
|
+
}>>;
|
|
474
|
+
/** Mails the sign-in's code again, when its second step is by email; `mfa` takes it. A few per sign-in. */
|
|
475
|
+
mfaSendEmail(): Promise<AuthResult<'sent', {
|
|
476
|
+
sentTo: string;
|
|
452
477
|
}>>;
|
|
453
478
|
/**
|
|
454
479
|
* Sends a push to the account's phones (the application's app, with
|
|
@@ -597,6 +622,7 @@ interface AuthClient {
|
|
|
597
622
|
email: string;
|
|
598
623
|
password: string;
|
|
599
624
|
name?: string;
|
|
625
|
+
organization?: string;
|
|
600
626
|
captchaToken?: string;
|
|
601
627
|
}): Promise<AuthResult<'signed_in', {
|
|
602
628
|
session: PublicSession;
|
|
@@ -615,9 +641,12 @@ interface AuthClient {
|
|
|
615
641
|
password: string;
|
|
616
642
|
}): Promise<AuthResult<'changed'>>;
|
|
617
643
|
/** Confirms the address, with the token the mailed link opened the page with (`token`). */
|
|
644
|
+
/** Confirms the address a mailed link is for. The person is signed in from the link when their account asks no second step. */
|
|
618
645
|
verifyEmail(form: {
|
|
619
646
|
token: string;
|
|
620
|
-
}): Promise<AuthResult<'verified'
|
|
647
|
+
}): Promise<AuthResult<'verified'> | AuthResult<'signed_in', {
|
|
648
|
+
session: PublicSession;
|
|
649
|
+
}>>;
|
|
621
650
|
signOut(): Promise<AuthResult<'signed_out'>>;
|
|
622
651
|
/** The signed-in person's own account. */
|
|
623
652
|
account: AccountClient;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.js';
|
|
2
2
|
import { i as PublicSession } from './system-DTIeDXDP.js';
|
|
3
|
-
import { A as AuthField } from './validate-
|
|
4
|
-
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-
|
|
3
|
+
import { A as AuthField } from './validate-BTRit1O1.js';
|
|
4
|
+
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-BTRit1O1.js';
|
|
5
5
|
import 'jose';
|
|
6
6
|
|
|
7
7
|
/** Whether this browser can use a passkey at all. */
|
|
@@ -78,6 +78,11 @@ interface AuthMethods {
|
|
|
78
78
|
}[];
|
|
79
79
|
/** Whether people may create an account themselves. */
|
|
80
80
|
signUp: boolean;
|
|
81
|
+
/** Set when the application's system makes an organization per sign-up: the form asks the company's name. */
|
|
82
|
+
organization?: {
|
|
83
|
+
ask: boolean;
|
|
84
|
+
required: boolean;
|
|
85
|
+
};
|
|
81
86
|
magicLink: boolean;
|
|
82
87
|
/** Whether to offer a passkey. */
|
|
83
88
|
passkey: boolean;
|
|
@@ -425,21 +430,34 @@ interface AuthClient {
|
|
|
425
430
|
}): Promise<AuthResult<'signed_in', {
|
|
426
431
|
session: PublicSession;
|
|
427
432
|
}>>;
|
|
428
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* With address and password. `mfa_required`: ask for the code and call
|
|
435
|
+
* `signIn.mfa`. `method: 'email'` says the code was just mailed to the
|
|
436
|
+
* account's address (it has no factor of its own and the workspace, or
|
|
437
|
+
* the sign-in's risk, asked a second step): say so, and offer
|
|
438
|
+
* `mfaSendEmail` for another.
|
|
439
|
+
*/
|
|
429
440
|
email(form: {
|
|
430
441
|
email: string;
|
|
431
442
|
password: string;
|
|
432
443
|
captchaToken?: string;
|
|
433
444
|
}): Promise<AuthResult<'signed_in', {
|
|
434
445
|
session: PublicSession;
|
|
435
|
-
}> | AuthResult<'mfa_required'
|
|
436
|
-
|
|
446
|
+
}> | AuthResult<'mfa_required', {
|
|
447
|
+
method?: 'email';
|
|
448
|
+
}>>;
|
|
449
|
+
/** The second step: the code of the authenticator app, the phone, the email, or a recovery code. */
|
|
437
450
|
mfa(form: {
|
|
438
451
|
code: string;
|
|
439
452
|
}): Promise<AuthResult<'signed_in', {
|
|
440
453
|
session: PublicSession;
|
|
441
454
|
}>>;
|
|
442
|
-
/**
|
|
455
|
+
/**
|
|
456
|
+
* While the second step is asked for: whether the account has an
|
|
457
|
+
* authenticator app, the phone (masked) a code can be sent to, phones
|
|
458
|
+
* that approve sign-ins, and the address (masked) a code went to when
|
|
459
|
+
* the step is by email.
|
|
460
|
+
*/
|
|
443
461
|
mfaMethods(): Promise<AuthResult<'ok', {
|
|
444
462
|
totp: boolean;
|
|
445
463
|
phone: {
|
|
@@ -449,6 +467,13 @@ interface AuthClient {
|
|
|
449
467
|
push: {
|
|
450
468
|
devices: number;
|
|
451
469
|
} | null;
|
|
470
|
+
email: {
|
|
471
|
+
to: string;
|
|
472
|
+
} | null;
|
|
473
|
+
}>>;
|
|
474
|
+
/** Mails the sign-in's code again, when its second step is by email; `mfa` takes it. A few per sign-in. */
|
|
475
|
+
mfaSendEmail(): Promise<AuthResult<'sent', {
|
|
476
|
+
sentTo: string;
|
|
452
477
|
}>>;
|
|
453
478
|
/**
|
|
454
479
|
* Sends a push to the account's phones (the application's app, with
|
|
@@ -597,6 +622,7 @@ interface AuthClient {
|
|
|
597
622
|
email: string;
|
|
598
623
|
password: string;
|
|
599
624
|
name?: string;
|
|
625
|
+
organization?: string;
|
|
600
626
|
captchaToken?: string;
|
|
601
627
|
}): Promise<AuthResult<'signed_in', {
|
|
602
628
|
session: PublicSession;
|
|
@@ -615,9 +641,12 @@ interface AuthClient {
|
|
|
615
641
|
password: string;
|
|
616
642
|
}): Promise<AuthResult<'changed'>>;
|
|
617
643
|
/** Confirms the address, with the token the mailed link opened the page with (`token`). */
|
|
644
|
+
/** Confirms the address a mailed link is for. The person is signed in from the link when their account asks no second step. */
|
|
618
645
|
verifyEmail(form: {
|
|
619
646
|
token: string;
|
|
620
|
-
}): Promise<AuthResult<'verified'
|
|
647
|
+
}): Promise<AuthResult<'verified'> | AuthResult<'signed_in', {
|
|
648
|
+
session: PublicSession;
|
|
649
|
+
}>>;
|
|
621
650
|
signOut(): Promise<AuthResult<'signed_out'>>;
|
|
622
651
|
/** The signed-in person's own account. */
|
|
623
652
|
account: AccountClient;
|
package/dist/client.js
CHANGED
|
@@ -179,6 +179,13 @@ function checkName(value) {
|
|
|
179
179
|
if (typeof value !== "string" || value.trim().length > MAX_NAME) return { field: "name", code: "too_long", message: `Use at most ${MAX_NAME} characters.` };
|
|
180
180
|
return null;
|
|
181
181
|
}
|
|
182
|
+
var MAX_ORGANIZATION = 120;
|
|
183
|
+
function checkOrganization(value, required = false) {
|
|
184
|
+
const v = typeof value === "string" ? value.trim() : "";
|
|
185
|
+
if (v === "") return required ? { field: "organization", code: "required", message: "Enter your company's name." } : null;
|
|
186
|
+
if (v.length > MAX_ORGANIZATION) return { field: "organization", code: "too_long", message: `Use at most ${MAX_ORGANIZATION} characters.` };
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
182
189
|
function checkCode(value) {
|
|
183
190
|
const v = typeof value === "string" ? value.trim() : "";
|
|
184
191
|
if (v === "") return { field: "code", code: "required", message: "Enter the code." };
|
|
@@ -393,6 +400,7 @@ function createAuthClient(options = {}) {
|
|
|
393
400
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
394
401
|
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
395
402
|
mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
|
|
403
|
+
mfaSendEmail: () => post("/sign-in/mfa/email", {}, null),
|
|
396
404
|
mfaPush: () => post("/sign-in/mfa/push", {}, null),
|
|
397
405
|
async mfaPushWait(o = {}) {
|
|
398
406
|
const status = await new Promise((resolve) => {
|
|
@@ -509,7 +517,12 @@ function createAuthClient(options = {}) {
|
|
|
509
517
|
}
|
|
510
518
|
},
|
|
511
519
|
signUp: {
|
|
512
|
-
email: (f) => post(
|
|
520
|
+
email: (f) => post(
|
|
521
|
+
"/sign-up/email",
|
|
522
|
+
{ email: f.email, password: f.password, name: f.name, organization: f.organization },
|
|
523
|
+
firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
|
|
524
|
+
f.captchaToken
|
|
525
|
+
)
|
|
513
526
|
},
|
|
514
527
|
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
515
528
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|