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/svelte.mjs CHANGED
@@ -144,6 +144,13 @@ function checkName(value) {
144
144
  if (typeof value !== "string" || value.trim().length > MAX_NAME) return { field: "name", code: "too_long", message: `Use at most ${MAX_NAME} characters.` };
145
145
  return null;
146
146
  }
147
+ var MAX_ORGANIZATION = 120;
148
+ function checkOrganization(value, required = false) {
149
+ const v = typeof value === "string" ? value.trim() : "";
150
+ if (v === "") return required ? { field: "organization", code: "required", message: "Enter your company's name." } : null;
151
+ if (v.length > MAX_ORGANIZATION) return { field: "organization", code: "too_long", message: `Use at most ${MAX_ORGANIZATION} characters.` };
152
+ return null;
153
+ }
147
154
  function checkCode(value) {
148
155
  const v = typeof value === "string" ? value.trim() : "";
149
156
  if (v === "") return { field: "code", code: "required", message: "Enter the code." };
@@ -250,6 +257,7 @@ function createAuthClient(options = {}) {
250
257
  mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
251
258
  mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
252
259
  mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
260
+ mfaSendEmail: () => post("/sign-in/mfa/email", {}, null),
253
261
  mfaPush: () => post("/sign-in/mfa/push", {}, null),
254
262
  async mfaPushWait(o = {}) {
255
263
  const status = await new Promise((resolve) => {
@@ -366,7 +374,12 @@ function createAuthClient(options = {}) {
366
374
  }
367
375
  },
368
376
  signUp: {
369
- 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)
377
+ email: (f) => post(
378
+ "/sign-up/email",
379
+ { email: f.email, password: f.password, name: f.name, organization: f.organization },
380
+ firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
381
+ f.captchaToken
382
+ )
370
383
  },
371
384
  forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
372
385
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),