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.
@@ -1,4 +1,4 @@
1
- type AuthField = 'email' | 'password' | 'newPassword' | 'name' | 'code';
1
+ type AuthField = 'email' | 'password' | 'newPassword' | 'name' | 'code' | 'organization';
2
2
  /** A value of a form that cannot be sent as it is. */
3
3
  interface FieldProblem {
4
4
  field: AuthField;
@@ -1,4 +1,4 @@
1
- type AuthField = 'email' | 'password' | 'newPassword' | 'name' | 'code';
1
+ type AuthField = 'email' | 'password' | 'newPassword' | 'name' | 'code' | 'organization';
2
2
  /** A value of a form that cannot be sent as it is. */
3
3
  interface FieldProblem {
4
4
  field: AuthField;
package/dist/vue.d.mts CHANGED
@@ -4,7 +4,7 @@ export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, P
4
4
  import { i as PublicSession } from './system-BxMsSIu1.mjs';
5
5
  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';
6
6
  import './theme.mjs';
7
- import './validate-B_iC-4y8.mjs';
7
+ import './validate-BTRit1O1.mjs';
8
8
  import 'jose';
9
9
 
10
10
  interface CauthyVueSession extends Pick<SessionStore, 'refresh' | 'signIn' | 'signOut' | 'accountUrl' | 'basePath'> {
package/dist/vue.d.ts CHANGED
@@ -4,7 +4,7 @@ export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, P
4
4
  import { i as PublicSession } from './system-DTIeDXDP.js';
5
5
  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';
6
6
  import './theme.js';
7
- import './validate-B_iC-4y8.js';
7
+ import './validate-BTRit1O1.js';
8
8
  import 'jose';
9
9
 
10
10
  interface CauthyVueSession extends Pick<SessionStore, 'refresh' | 'signIn' | 'signOut' | 'accountUrl' | 'basePath'> {
package/dist/vue.js CHANGED
@@ -175,6 +175,13 @@ function checkName(value) {
175
175
  if (typeof value !== "string" || value.trim().length > MAX_NAME) return { field: "name", code: "too_long", message: `Use at most ${MAX_NAME} characters.` };
176
176
  return null;
177
177
  }
178
+ var MAX_ORGANIZATION = 120;
179
+ function checkOrganization(value, required = false) {
180
+ const v = typeof value === "string" ? value.trim() : "";
181
+ if (v === "") return required ? { field: "organization", code: "required", message: "Enter your company's name." } : null;
182
+ if (v.length > MAX_ORGANIZATION) return { field: "organization", code: "too_long", message: `Use at most ${MAX_ORGANIZATION} characters.` };
183
+ return null;
184
+ }
178
185
  function checkCode(value) {
179
186
  const v = typeof value === "string" ? value.trim() : "";
180
187
  if (v === "") return { field: "code", code: "required", message: "Enter the code." };
@@ -281,6 +288,7 @@ function createAuthClient(options = {}) {
281
288
  mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
282
289
  mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
283
290
  mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
291
+ mfaSendEmail: () => post("/sign-in/mfa/email", {}, null),
284
292
  mfaPush: () => post("/sign-in/mfa/push", {}, null),
285
293
  async mfaPushWait(o = {}) {
286
294
  const status = await new Promise((resolve) => {
@@ -397,7 +405,12 @@ function createAuthClient(options = {}) {
397
405
  }
398
406
  },
399
407
  signUp: {
400
- email: (f) => post("/sign-up/email", { email: f.email, password: f.password, name: f.name }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password)), f.captchaToken)
408
+ email: (f) => post(
409
+ "/sign-up/email",
410
+ { email: f.email, password: f.password, name: f.name, organization: f.organization },
411
+ firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
412
+ f.captchaToken
413
+ )
401
414
  },
402
415
  forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
403
416
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),