@rpcbase/auth 0.42.0 → 0.44.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
- import { o as object, b as boolean } from "./schemas-DKK0lkQz.js";
1
+ import { o as object, b as boolean } from "./schemas-7XFc7XYG.js";
2
2
  const Route = "/api/rb/auth/sign-out";
3
3
  object({});
4
4
  object({
@@ -1,5 +1,5 @@
1
1
  import { i as isEmail } from "./isEmail-IG0hXiQk.js";
2
- import { R as Route, r as requestSchema } from "./index-BphnyggH.js";
2
+ import { R as Route, r as requestSchema } from "./index-oIC-DH2m.js";
3
3
  const signIn = async (payload, ctx) => {
4
4
  const { email_or_phone } = requestSchema.parse(payload);
5
5
  if (isEmail(email_or_phone)) {
@@ -2,7 +2,7 @@ import crypto from "crypto";
2
2
  import { i as isEmail } from "./isEmail-IG0hXiQk.js";
3
3
  import { loadModel } from "@rpcbase/api";
4
4
  import { hashPassword } from "@rpcbase/server";
5
- import { R as Route, r as requestSchema } from "./index-BYEYCL3Q.js";
5
+ import { R as Route, r as requestSchema } from "./index-Nc4R1TKZ.js";
6
6
  const signUp = async (payload, ctx) => {
7
7
  const User = await loadModel("User", ctx);
8
8
  const { email_or_phone, password } = requestSchema.parse(payload);
@@ -1,5 +1,5 @@
1
1
  import { i as isValidNumber } from "./isValidNumber-6pMDGLRn.js";
2
- import { o as object, s as string, b as boolean } from "./schemas-DKK0lkQz.js";
2
+ import { o as object, s as string, b as boolean } from "./schemas-7XFc7XYG.js";
3
3
  const Route = "/api/rb/auth/sign-up";
4
4
  const requestSchema = object({
5
5
  email_or_phone: string().nonempty("Email or phone number is required").refine(
@@ -1,5 +1,5 @@
1
1
  import { i as isValidNumber } from "./isValidNumber-6pMDGLRn.js";
2
- import { o as object, b as boolean, s as string } from "./schemas-DKK0lkQz.js";
2
+ import { o as object, b as boolean, s as string } from "./schemas-7XFc7XYG.js";
3
3
  const Route = "/api/rb/auth/sign-in";
4
4
  const requestSchema = object({
5
5
  email_or_phone: string().nonempty("Email or phone number is required").default("").refine(
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ import { useLocation, Link } from "@rpcbase/router";
3
3
  import clsx from "clsx";
4
4
  import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
5
5
  import { useEffect } from "react";
6
- import { r as requestSchema } from "./index-BphnyggH.js";
7
- import { r as requestSchema$1 } from "./index-BYEYCL3Q.js";
6
+ import { r as requestSchema } from "./index-oIC-DH2m.js";
7
+ import { r as requestSchema$1 } from "./index-Nc4R1TKZ.js";
8
8
  const LINKS_REDIRECTION_MAP = {
9
9
  "/auth/sign-in": {
10
10
  "title": "Sign Up",
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const routes = Object.entries({
2
- .../* @__PURE__ */ Object.assign({ "./api/sign-in/handler.ts": () => import("./handler-CSmOkoqC.js"), "./api/sign-out/handler.ts": () => import("./handler-rzI-pkuD.js"), "./api/sign-up/handler.ts": () => import("./handler-Bl5DlLdb.js") })
2
+ .../* @__PURE__ */ Object.assign({ "./api/sign-in/handler.ts": () => import("./handler-BD2C82Z3.js"), "./api/sign-out/handler.ts": () => import("./handler-42q87FS8.js"), "./api/sign-up/handler.ts": () => import("./handler-C7htSfmB.js") })
3
3
  }).reduce((acc, [path, mod]) => {
4
4
  acc[path.replace("./api/", "@rpcbase/auth/api/")] = mod;
5
5
  return acc;
@@ -1,29 +1,38 @@
1
1
  function $constructor(name, initializer2, params) {
2
2
  function init(inst, def) {
3
- var _a;
4
- Object.defineProperty(inst, "_zod", {
5
- value: inst._zod ?? {},
6
- enumerable: false
7
- });
8
- (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
3
+ if (!inst._zod) {
4
+ Object.defineProperty(inst, "_zod", {
5
+ value: {
6
+ def,
7
+ constr: _,
8
+ traits: /* @__PURE__ */ new Set()
9
+ },
10
+ enumerable: false
11
+ });
12
+ }
13
+ if (inst._zod.traits.has(name)) {
14
+ return;
15
+ }
9
16
  inst._zod.traits.add(name);
10
17
  initializer2(inst, def);
11
- for (const k in _.prototype) {
12
- if (!(k in inst))
13
- Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
18
+ const proto = _.prototype;
19
+ const keys = Object.keys(proto);
20
+ for (let i = 0; i < keys.length; i++) {
21
+ const k = keys[i];
22
+ if (!(k in inst)) {
23
+ inst[k] = proto[k].bind(inst);
24
+ }
14
25
  }
15
- inst._zod.constr = _;
16
- inst._zod.def = def;
17
26
  }
18
27
  const Parent = params?.Parent ?? Object;
19
28
  class Definition extends Parent {
20
29
  }
21
30
  Object.defineProperty(Definition, "name", { value: name });
22
31
  function _(def) {
23
- var _a;
32
+ var _a2;
24
33
  const inst = params?.Parent ? new Definition() : this;
25
34
  init(inst, def);
26
- (_a = inst._zod).deferred ?? (_a.deferred = []);
35
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
27
36
  for (const fn of inst._zod.deferred) {
28
37
  fn();
29
38
  }
@@ -126,6 +135,9 @@ function mergeDefs(...defs) {
126
135
  function esc(str) {
127
136
  return JSON.stringify(str);
128
137
  }
138
+ function slugify(input) {
139
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
140
+ }
129
141
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
130
142
  };
131
143
  function isObject(data) {
@@ -149,6 +161,8 @@ function isPlainObject(o) {
149
161
  const ctor = o.constructor;
150
162
  if (ctor === void 0)
151
163
  return true;
164
+ if (typeof ctor !== "function")
165
+ return true;
152
166
  const prot = ctor.prototype;
153
167
  if (isObject(prot) === false)
154
168
  return false;
@@ -360,8 +374,8 @@ function aborted(x, startIndex = 0) {
360
374
  }
361
375
  function prefixIssues(path, issues) {
362
376
  return issues.map((iss) => {
363
- var _a;
364
- (_a = iss).path ?? (_a.path = []);
377
+ var _a2;
378
+ (_a2 = iss).path ?? (_a2.path = []);
365
379
  iss.path.unshift(path);
366
380
  return iss;
367
381
  });
@@ -565,7 +579,6 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
565
579
  const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
566
580
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
567
581
  const base64url = /^[A-Za-z0-9_-]*$/;
568
- const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
569
582
  const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
570
583
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
571
584
  const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
@@ -595,15 +608,15 @@ const boolean$1 = /^(?:true|false)$/i;
595
608
  const lowercase = /^[^A-Z]*$/;
596
609
  const uppercase = /^[^a-z]*$/;
597
610
  const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
598
- var _a;
611
+ var _a2;
599
612
  inst._zod ?? (inst._zod = {});
600
613
  inst._zod.def = def;
601
- (_a = inst._zod).onattach ?? (_a.onattach = []);
614
+ (_a2 = inst._zod).onattach ?? (_a2.onattach = []);
602
615
  });
603
616
  const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
604
- var _a;
617
+ var _a2;
605
618
  $ZodCheck.init(inst, def);
606
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
619
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
607
620
  const val = payload.value;
608
621
  return !nullish(val) && val.length !== void 0;
609
622
  });
@@ -630,9 +643,9 @@ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (i
630
643
  };
631
644
  });
632
645
  const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
633
- var _a;
646
+ var _a2;
634
647
  $ZodCheck.init(inst, def);
635
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
648
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
636
649
  const val = payload.value;
637
650
  return !nullish(val) && val.length !== void 0;
638
651
  });
@@ -659,9 +672,9 @@ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (i
659
672
  };
660
673
  });
661
674
  const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
662
- var _a;
675
+ var _a2;
663
676
  $ZodCheck.init(inst, def);
664
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
677
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
665
678
  const val = payload.value;
666
679
  return !nullish(val) && val.length !== void 0;
667
680
  });
@@ -690,7 +703,7 @@ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEqual
690
703
  };
691
704
  });
692
705
  const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
693
- var _a, _b;
706
+ var _a2, _b;
694
707
  $ZodCheck.init(inst, def);
695
708
  inst._zod.onattach.push((inst2) => {
696
709
  const bag = inst2._zod.bag;
@@ -701,7 +714,7 @@ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringForma
701
714
  }
702
715
  });
703
716
  if (def.pattern)
704
- (_a = inst._zod).check ?? (_a.check = (payload) => {
717
+ (_a2 = inst._zod).check ?? (_a2.check = (payload) => {
705
718
  def.pattern.lastIndex = 0;
706
719
  if (def.pattern.test(payload.value))
707
720
  return;
@@ -857,10 +870,10 @@ class Doc {
857
870
  const version = {
858
871
  major: 4,
859
872
  minor: 1,
860
- patch: 12
873
+ patch: 13
861
874
  };
862
875
  const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
863
- var _a;
876
+ var _a2;
864
877
  inst ?? (inst = {});
865
878
  inst._zod.def = def;
866
879
  inst._zod.bag = inst._zod.bag || {};
@@ -875,7 +888,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
875
888
  }
876
889
  }
877
890
  if (checks.length === 0) {
878
- (_a = inst._zod).deferred ?? (_a.deferred = []);
891
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
879
892
  inst._zod.deferred?.push(() => {
880
893
  inst._zod.run = inst._zod.parse;
881
894
  });
@@ -1033,7 +1046,7 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1033
1046
  code: "invalid_format",
1034
1047
  format: "url",
1035
1048
  note: "Invalid hostname",
1036
- pattern: hostname.source,
1049
+ pattern: def.hostname.source,
1037
1050
  input: payload.value,
1038
1051
  inst,
1039
1052
  continue: !def.abort
@@ -1118,18 +1131,12 @@ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, d
1118
1131
  const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1119
1132
  def.pattern ?? (def.pattern = ipv4);
1120
1133
  $ZodStringFormat.init(inst, def);
1121
- inst._zod.onattach.push((inst2) => {
1122
- const bag = inst2._zod.bag;
1123
- bag.format = `ipv4`;
1124
- });
1134
+ inst._zod.bag.format = `ipv4`;
1125
1135
  });
1126
1136
  const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1127
1137
  def.pattern ?? (def.pattern = ipv6);
1128
1138
  $ZodStringFormat.init(inst, def);
1129
- inst._zod.onattach.push((inst2) => {
1130
- const bag = inst2._zod.bag;
1131
- bag.format = `ipv6`;
1132
- });
1139
+ inst._zod.bag.format = `ipv6`;
1133
1140
  inst._zod.check = (payload) => {
1134
1141
  try {
1135
1142
  new URL(`http://[${payload.value}]`);
@@ -1191,9 +1198,7 @@ function isValidBase64(data) {
1191
1198
  const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1192
1199
  def.pattern ?? (def.pattern = base64);
1193
1200
  $ZodStringFormat.init(inst, def);
1194
- inst._zod.onattach.push((inst2) => {
1195
- inst2._zod.bag.contentEncoding = "base64";
1196
- });
1201
+ inst._zod.bag.contentEncoding = "base64";
1197
1202
  inst._zod.check = (payload) => {
1198
1203
  if (isValidBase64(payload.value))
1199
1204
  return;
@@ -1216,9 +1221,7 @@ function isValidBase64URL(data) {
1216
1221
  const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1217
1222
  def.pattern ?? (def.pattern = base64url);
1218
1223
  $ZodStringFormat.init(inst, def);
1219
- inst._zod.onattach.push((inst2) => {
1220
- inst2._zod.bag.contentEncoding = "base64url";
1221
- });
1224
+ inst._zod.bag.contentEncoding = "base64url";
1222
1225
  inst._zod.check = (payload) => {
1223
1226
  if (isValidBase64URL(payload.value))
1224
1227
  return;
@@ -1378,7 +1381,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1378
1381
  const keySet = def.keySet;
1379
1382
  const _catchall = def.catchall._zod;
1380
1383
  const t = _catchall.def.type;
1381
- for (const key of Object.keys(input)) {
1384
+ for (const key in input) {
1382
1385
  if (keySet.has(key))
1383
1386
  continue;
1384
1387
  if (t === "never") {
@@ -1909,8 +1912,8 @@ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) =>
1909
1912
  $ZodType.init(inst, def);
1910
1913
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1911
1914
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1912
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1913
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1915
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1916
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
1914
1917
  inst._zod.parse = (payload, ctx) => {
1915
1918
  if (ctx.direction === "backward") {
1916
1919
  return def.innerType._zod.run(payload, ctx);
@@ -1959,6 +1962,7 @@ function handleRefineResult(result, payload, input, inst) {
1959
1962
  payload.issues.push(issue(_iss));
1960
1963
  }
1961
1964
  }
1965
+ var _a;
1962
1966
  class $ZodRegistry {
1963
1967
  constructor() {
1964
1968
  this._map = /* @__PURE__ */ new WeakMap();
@@ -2005,7 +2009,8 @@ class $ZodRegistry {
2005
2009
  function registry() {
2006
2010
  return new $ZodRegistry();
2007
2011
  }
2008
- const globalRegistry = /* @__PURE__ */ registry();
2012
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2013
+ const globalRegistry = globalThis.__zod_globalRegistry;
2009
2014
  function _string(Class, params) {
2010
2015
  return new Class({
2011
2016
  type: "string",
@@ -2352,6 +2357,9 @@ function _toLowerCase() {
2352
2357
  function _toUpperCase() {
2353
2358
  return _overwrite((input) => input.toUpperCase());
2354
2359
  }
2360
+ function _slugify() {
2361
+ return _overwrite((input) => slugify(input));
2362
+ }
2355
2363
  function _array(Class, element, params) {
2356
2364
  return new Class({
2357
2365
  type: "array",
@@ -2568,6 +2576,7 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2568
2576
  inst.normalize = (...args) => inst.check(_normalize(...args));
2569
2577
  inst.toLowerCase = () => inst.check(_toLowerCase());
2570
2578
  inst.toUpperCase = () => inst.check(_toUpperCase());
2579
+ inst.slugify = () => inst.check(_slugify());
2571
2580
  });
2572
2581
  const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
2573
2582
  $ZodString.init(inst, def);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/auth",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"