cauthy-auth 0.24.2 → 0.25.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." };
@@ -397,7 +404,12 @@ function createAuthClient(options = {}) {
397
404
  }
398
405
  },
399
406
  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)
407
+ email: (f) => post(
408
+ "/sign-up/email",
409
+ { email: f.email, password: f.password, name: f.name, organization: f.organization },
410
+ firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
411
+ f.captchaToken
412
+ )
401
413
  },
402
414
  forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
403
415
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),