@rpcbase/auth 0.70.0 → 0.72.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 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/sign-in/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBAwDlC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/sign-in/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBAgElC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/sign-up/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBA8ElC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/sign-up/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBAiFlC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/verify-otp/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAGnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBA0DlC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/api/verify-otp/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,cAAc,CAAA;AAGnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;yBAkElC,KAAK,GAAG,CAAC,eAAe,CAAC;AAAzC,wBAEC"}
@@ -1,4 +1,4 @@
1
- import { o as object, b as boolean } from "./schemas-KL7REOdt.js";
1
+ import { o as object, b as boolean } from "./schemas-BfVe_QYZ.js";
2
2
  const Route = "/api/rb/auth/sign-out";
3
3
  object({});
4
4
  object({
@@ -1,6 +1,6 @@
1
1
  import { loadRbModel } from "@rpcbase/db";
2
2
  import { verifyPasswordFromStorage } from "@rpcbase/server";
3
- import { R as Route, r as requestSchema } from "./index-D-Zfc6Rv.js";
3
+ import { R as Route, r as requestSchema } from "./index-V5AZ3kmZ.js";
4
4
  const signIn = async (payload, ctx) => {
5
5
  const User = await loadRbModel("RBUser", ctx);
6
6
  const parsed = requestSchema.safeParse(payload);
@@ -9,7 +9,7 @@ const signIn = async (payload, ctx) => {
9
9
  return { success: false, error: "invalid_payload" };
10
10
  }
11
11
  const { email, password } = parsed.data;
12
- const user = await User.findOne({ email }, { password: 1, tenants: 1 });
12
+ const user = await User.findOne({ email }, { password: 1, tenants: 1, tenantRoles: 1 });
13
13
  if (!user?.password) {
14
14
  ctx.res.status(401);
15
15
  return { success: false, error: "invalid_credentials" };
@@ -25,6 +25,8 @@ const signIn = async (payload, ctx) => {
25
25
  }
26
26
  const tenantId = user.tenants?.[0]?.toString?.() || "00000000";
27
27
  const signedInTenants = (user.tenants || []).map((t) => t.toString?.() || String(t)) || [tenantId];
28
+ const tenantRolesRaw = user.tenantRoles;
29
+ const tenantRoles = tenantRolesRaw instanceof Map ? Object.fromEntries(tenantRolesRaw.entries()) : tenantRolesRaw && typeof tenantRolesRaw === "object" ? tenantRolesRaw : void 0;
28
30
  if (!ctx.req.session) {
29
31
  ctx.res.status(500);
30
32
  return { success: false, error: "session_unavailable" };
@@ -33,7 +35,8 @@ const signIn = async (payload, ctx) => {
33
35
  id: user._id.toString(),
34
36
  currentTenantId: tenantId,
35
37
  signedInTenants: signedInTenants.length ? signedInTenants : [tenantId],
36
- isEntryGateAuthorized: true
38
+ isEntryGateAuthorized: true,
39
+ tenantRoles
37
40
  };
38
41
  return { success: true, userId: user._id.toString(), tenantId };
39
42
  };
@@ -1,7 +1,7 @@
1
1
  import crypto from "crypto";
2
2
  import { loadRbModel } from "@rpcbase/db";
3
3
  import { sendEmail } from "@rpcbase/server";
4
- import { o as object, s as string, b as boolean } from "./schemas-KL7REOdt.js";
4
+ import { o as object, s as string, b as boolean } from "./schemas-BfVe_QYZ.js";
5
5
  const Route = "/api/rb/auth/resend-otp";
6
6
  const requestSchema = object({
7
7
  email: string().email()
@@ -1,7 +1,7 @@
1
1
  import crypto from "crypto";
2
2
  import { loadRbModel } from "@rpcbase/db";
3
3
  import { hashPasswordForStorage, sendEmail } from "@rpcbase/server";
4
- import { R as Route, r as requestSchema } from "./index-DusvXcjg.js";
4
+ import { R as Route, r as requestSchema } from "./index-FbCE80yc.js";
5
5
  const signUp = async (payload, ctx) => {
6
6
  const User = await loadRbModel("RBUser", ctx);
7
7
  const Tenant = await loadRbModel("RBTenant", ctx);
@@ -25,6 +25,9 @@ const signUp = async (payload, ctx) => {
25
25
  email,
26
26
  password: hashedPassword,
27
27
  tenants: [tenantId],
28
+ tenantRoles: {
29
+ [tenantId]: ["owner"]
30
+ },
28
31
  emailVerificationCode,
29
32
  emailVerificationExpiresAt
30
33
  });
@@ -1,6 +1,6 @@
1
1
  import { loadRbModel } from "@rpcbase/db";
2
2
  import { r as restrictSessionMiddleware } from "./middleware-BiMXO6Dq.js";
3
- import { o as object, s as string, a as array } from "./schemas-KL7REOdt.js";
3
+ import { o as object, s as string, a as array } from "./schemas-BfVe_QYZ.js";
4
4
  const Route = "/api/rb/auth/me";
5
5
  object({});
6
6
  object({
@@ -1,5 +1,5 @@
1
1
  import { loadRbModel } from "@rpcbase/db";
2
- import { o as object, b as boolean, s as string } from "./schemas-KL7REOdt.js";
2
+ import { o as object, b as boolean, s as string } from "./schemas-BfVe_QYZ.js";
3
3
  const Route = "/api/rb/auth/verify-otp";
4
4
  const requestSchema = object({
5
5
  email: string().email(),
@@ -20,7 +20,7 @@ const verifyOtp = async (payload, ctx) => {
20
20
  return { success: false, error: "invalid_payload" };
21
21
  }
22
22
  const { email, code } = parsed.data;
23
- const user = await User.findOne({ email }, { emailVerificationCode: 1, emailVerificationExpiresAt: 1, tenants: 1 });
23
+ const user = await User.findOne({ email }, { emailVerificationCode: 1, emailVerificationExpiresAt: 1, tenants: 1, tenantRoles: 1 });
24
24
  if (!user) {
25
25
  ctx.res.status(404);
26
26
  return { success: false, error: "user_not_found" };
@@ -37,6 +37,8 @@ const verifyOtp = async (payload, ctx) => {
37
37
  await user.save();
38
38
  const tenantId = user.tenants?.[0]?.toString?.() || "00000000";
39
39
  const signedInTenants = (user.tenants || []).map((t) => t.toString?.() || String(t)) || [tenantId];
40
+ const tenantRolesRaw = user.tenantRoles;
41
+ const tenantRoles = tenantRolesRaw instanceof Map ? Object.fromEntries(tenantRolesRaw.entries()) : tenantRolesRaw && typeof tenantRolesRaw === "object" ? tenantRolesRaw : void 0;
40
42
  if (!ctx.req.session) {
41
43
  ctx.res.status(500);
42
44
  return { success: false, error: "session_unavailable" };
@@ -45,7 +47,8 @@ const verifyOtp = async (payload, ctx) => {
45
47
  id: user._id.toString(),
46
48
  currentTenantId: tenantId,
47
49
  signedInTenants: signedInTenants.length ? signedInTenants : [tenantId],
48
- isEntryGateAuthorized: true
50
+ isEntryGateAuthorized: true,
51
+ tenantRoles
49
52
  };
50
53
  return { success: true, userId: user._id.toString(), tenantId };
51
54
  };
@@ -1,4 +1,4 @@
1
- import { o as object, b as boolean, s as string } from "./schemas-KL7REOdt.js";
1
+ import { o as object, b as boolean, s as string } from "./schemas-BfVe_QYZ.js";
2
2
  const Route = "/api/rb/auth/sign-up";
3
3
  const requestSchema = object({
4
4
  email: string().nonempty("Email is required").email("Please enter a valid email address"),
@@ -1,4 +1,4 @@
1
- import { o as object, b as boolean, s as string } from "./schemas-KL7REOdt.js";
1
+ import { o as object, b as boolean, s as string } from "./schemas-BfVe_QYZ.js";
2
2
  const Route = "/api/rb/auth/sign-in";
3
3
  const requestSchema = object({
4
4
  email: string().nonempty("Email is required").email("Please enter a valid email address"),
package/dist/index.js CHANGED
@@ -2,10 +2,9 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
3
3
  import clsx from "clsx";
4
4
  import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
5
- import { r as requestSchema } from "./index-D-Zfc6Rv.js";
6
- import { useState, useEffect, useCallback, useMemo } from "react";
7
- import { r as requestSchema$1 } from "./index-DusvXcjg.js";
8
- import { EyeOff, Eye } from "lucide-react";
5
+ import { r as requestSchema } from "./index-V5AZ3kmZ.js";
6
+ import { useState, forwardRef, createElement, useEffect, useCallback, useMemo } from "react";
7
+ import { r as requestSchema$1 } from "./index-FbCE80yc.js";
9
8
  import { b, a, r } from "./middleware-BiMXO6Dq.js";
10
9
  const LINKS_REDIRECTION_MAP = {
11
10
  "/auth/sign-in": {
@@ -256,6 +255,111 @@ const RememberMeCheckbox = ({
256
255
  )
257
256
  ] });
258
257
  };
258
+ const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
259
+ const toCamelCase = (string) => string.replace(
260
+ /^([A-Z])|[\s-_]+(\w)/g,
261
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
262
+ );
263
+ const toPascalCase = (string) => {
264
+ const camelCase = toCamelCase(string);
265
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
266
+ };
267
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
268
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
269
+ }).join(" ").trim();
270
+ const hasA11yProp = (props) => {
271
+ for (const prop in props) {
272
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
273
+ return true;
274
+ }
275
+ }
276
+ };
277
+ var defaultAttributes = {
278
+ xmlns: "http://www.w3.org/2000/svg",
279
+ width: 24,
280
+ height: 24,
281
+ viewBox: "0 0 24 24",
282
+ fill: "none",
283
+ stroke: "currentColor",
284
+ strokeWidth: 2,
285
+ strokeLinecap: "round",
286
+ strokeLinejoin: "round"
287
+ };
288
+ const Icon = forwardRef(
289
+ ({
290
+ color = "currentColor",
291
+ size = 24,
292
+ strokeWidth = 2,
293
+ absoluteStrokeWidth,
294
+ className = "",
295
+ children,
296
+ iconNode,
297
+ ...rest
298
+ }, ref) => createElement(
299
+ "svg",
300
+ {
301
+ ref,
302
+ ...defaultAttributes,
303
+ width: size,
304
+ height: size,
305
+ stroke: color,
306
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
307
+ className: mergeClasses("lucide", className),
308
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
309
+ ...rest
310
+ },
311
+ [
312
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
313
+ ...Array.isArray(children) ? children : [children]
314
+ ]
315
+ )
316
+ );
317
+ const createLucideIcon = (iconName, iconNode) => {
318
+ const Component = forwardRef(
319
+ ({ className, ...props }, ref) => createElement(Icon, {
320
+ ref,
321
+ iconNode,
322
+ className: mergeClasses(
323
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
324
+ `lucide-${iconName}`,
325
+ className
326
+ ),
327
+ ...props
328
+ })
329
+ );
330
+ Component.displayName = toPascalCase(iconName);
331
+ return Component;
332
+ };
333
+ const __iconNode$1 = [
334
+ [
335
+ "path",
336
+ {
337
+ d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
338
+ key: "ct8e1f"
339
+ }
340
+ ],
341
+ ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
342
+ [
343
+ "path",
344
+ {
345
+ d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
346
+ key: "13bj9a"
347
+ }
348
+ ],
349
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }]
350
+ ];
351
+ const EyeOff = createLucideIcon("eye-off", __iconNode$1);
352
+ const __iconNode = [
353
+ [
354
+ "path",
355
+ {
356
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
357
+ key: "1nclc0"
358
+ }
359
+ ],
360
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
361
+ ];
362
+ const Eye = createLucideIcon("eye", __iconNode);
259
363
  const PasswordInput = ({
260
364
  id,
261
365
  name = "password",
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const routes = Object.entries({
2
- .../* @__PURE__ */ Object.assign({ "./api/me/handler.ts": () => import("./handler-D5EPEBYU.js"), "./api/resend-otp/handler.ts": () => import("./handler-c6CkOrui.js"), "./api/sign-in/handler.ts": () => import("./handler-BB84i8oG.js"), "./api/sign-out/handler.ts": () => import("./handler-CNHucHrj.js"), "./api/sign-up/handler.ts": () => import("./handler-DGKxKbQ0.js"), "./api/verify-otp/handler.ts": () => import("./handler-CJC8FYyM.js") })
2
+ .../* @__PURE__ */ Object.assign({ "./api/me/handler.ts": () => import("./handler-SQkbSqqd.js"), "./api/resend-otp/handler.ts": () => import("./handler-DDGoeMLQ.js"), "./api/sign-in/handler.ts": () => import("./handler-Bq9NwTuS.js"), "./api/sign-out/handler.ts": () => import("./handler-BEAVSu5T.js"), "./api/sign-up/handler.ts": () => import("./handler-DT8jbCdX.js"), "./api/verify-otp/handler.ts": () => import("./handler-ekuyY0v_.js") })
3
3
  }).reduce((acc, [path, mod]) => {
4
4
  acc[path.replace("./api/", "@rpcbase/auth/api/")] = mod;
5
5
  return acc;
@@ -93,7 +93,7 @@ function cleanRegex(source) {
93
93
  const end = source.endsWith("$") ? source.length - 1 : source.length;
94
94
  return source.slice(start, end);
95
95
  }
96
- const EVALUATING = Symbol("evaluating");
96
+ const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
97
97
  function defineLazy(object2, key, getter) {
98
98
  let value = void 0;
99
99
  Object.defineProperty(object2, key, {
@@ -869,8 +869,8 @@ class Doc {
869
869
  }
870
870
  const version = {
871
871
  major: 4,
872
- minor: 1,
873
- patch: 13
872
+ minor: 2,
873
+ patch: 1
874
874
  };
875
875
  const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
876
876
  var _a2;
@@ -2407,6 +2407,513 @@ function _check(fn, params) {
2407
2407
  ch._zod.check = fn;
2408
2408
  return ch;
2409
2409
  }
2410
+ function initializeContext(params) {
2411
+ let target = params?.target ?? "draft-2020-12";
2412
+ if (target === "draft-4")
2413
+ target = "draft-04";
2414
+ if (target === "draft-7")
2415
+ target = "draft-07";
2416
+ return {
2417
+ processors: params.processors ?? {},
2418
+ metadataRegistry: params?.metadata ?? globalRegistry,
2419
+ target,
2420
+ unrepresentable: params?.unrepresentable ?? "throw",
2421
+ override: params?.override ?? (() => {
2422
+ }),
2423
+ io: params?.io ?? "output",
2424
+ counter: 0,
2425
+ seen: /* @__PURE__ */ new Map(),
2426
+ cycles: params?.cycles ?? "ref",
2427
+ reused: params?.reused ?? "inline",
2428
+ external: params?.external ?? void 0
2429
+ };
2430
+ }
2431
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
2432
+ var _a2;
2433
+ const def = schema._zod.def;
2434
+ const seen = ctx.seen.get(schema);
2435
+ if (seen) {
2436
+ seen.count++;
2437
+ const isCycle = _params.schemaPath.includes(schema);
2438
+ if (isCycle) {
2439
+ seen.cycle = _params.path;
2440
+ }
2441
+ return seen.schema;
2442
+ }
2443
+ const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
2444
+ ctx.seen.set(schema, result);
2445
+ const overrideSchema = schema._zod.toJSONSchema?.();
2446
+ if (overrideSchema) {
2447
+ result.schema = overrideSchema;
2448
+ } else {
2449
+ const params = {
2450
+ ..._params,
2451
+ schemaPath: [..._params.schemaPath, schema],
2452
+ path: _params.path
2453
+ };
2454
+ const parent = schema._zod.parent;
2455
+ if (parent) {
2456
+ result.ref = parent;
2457
+ process(parent, ctx, params);
2458
+ ctx.seen.get(parent).isParent = true;
2459
+ } else if (schema._zod.processJSONSchema) {
2460
+ schema._zod.processJSONSchema(ctx, result.schema, params);
2461
+ } else {
2462
+ const _json = result.schema;
2463
+ const processor = ctx.processors[def.type];
2464
+ if (!processor) {
2465
+ throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2466
+ }
2467
+ processor(schema, ctx, _json, params);
2468
+ }
2469
+ }
2470
+ const meta = ctx.metadataRegistry.get(schema);
2471
+ if (meta)
2472
+ Object.assign(result.schema, meta);
2473
+ if (ctx.io === "input" && isTransforming(schema)) {
2474
+ delete result.schema.examples;
2475
+ delete result.schema.default;
2476
+ }
2477
+ if (ctx.io === "input" && result.schema._prefault)
2478
+ (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
2479
+ delete result.schema._prefault;
2480
+ const _result = ctx.seen.get(schema);
2481
+ return _result.schema;
2482
+ }
2483
+ function extractDefs(ctx, schema) {
2484
+ const root = ctx.seen.get(schema);
2485
+ if (!root)
2486
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
2487
+ const makeURI = (entry) => {
2488
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2489
+ if (ctx.external) {
2490
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2491
+ const uriGenerator = ctx.external.uri ?? ((id2) => id2);
2492
+ if (externalId) {
2493
+ return { ref: uriGenerator(externalId) };
2494
+ }
2495
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2496
+ entry[1].defId = id;
2497
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
2498
+ }
2499
+ if (entry[1] === root) {
2500
+ return { ref: "#" };
2501
+ }
2502
+ const uriPrefix = `#`;
2503
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
2504
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2505
+ return { defId, ref: defUriPrefix + defId };
2506
+ };
2507
+ const extractToDef = (entry) => {
2508
+ if (entry[1].schema.$ref) {
2509
+ return;
2510
+ }
2511
+ const seen = entry[1];
2512
+ const { ref, defId } = makeURI(entry);
2513
+ seen.def = { ...seen.schema };
2514
+ if (defId)
2515
+ seen.defId = defId;
2516
+ const schema2 = seen.schema;
2517
+ for (const key in schema2) {
2518
+ delete schema2[key];
2519
+ }
2520
+ schema2.$ref = ref;
2521
+ };
2522
+ if (ctx.cycles === "throw") {
2523
+ for (const entry of ctx.seen.entries()) {
2524
+ const seen = entry[1];
2525
+ if (seen.cycle) {
2526
+ throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2527
+
2528
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2529
+ }
2530
+ }
2531
+ }
2532
+ for (const entry of ctx.seen.entries()) {
2533
+ const seen = entry[1];
2534
+ if (schema === entry[0]) {
2535
+ extractToDef(entry);
2536
+ continue;
2537
+ }
2538
+ if (ctx.external) {
2539
+ const ext = ctx.external.registry.get(entry[0])?.id;
2540
+ if (schema !== entry[0] && ext) {
2541
+ extractToDef(entry);
2542
+ continue;
2543
+ }
2544
+ }
2545
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2546
+ if (id) {
2547
+ extractToDef(entry);
2548
+ continue;
2549
+ }
2550
+ if (seen.cycle) {
2551
+ extractToDef(entry);
2552
+ continue;
2553
+ }
2554
+ if (seen.count > 1) {
2555
+ if (ctx.reused === "ref") {
2556
+ extractToDef(entry);
2557
+ continue;
2558
+ }
2559
+ }
2560
+ }
2561
+ }
2562
+ function finalize(ctx, schema) {
2563
+ const root = ctx.seen.get(schema);
2564
+ if (!root)
2565
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
2566
+ const flattenRef = (zodSchema) => {
2567
+ const seen = ctx.seen.get(zodSchema);
2568
+ const schema2 = seen.def ?? seen.schema;
2569
+ const _cached = { ...schema2 };
2570
+ if (seen.ref === null) {
2571
+ return;
2572
+ }
2573
+ const ref = seen.ref;
2574
+ seen.ref = null;
2575
+ if (ref) {
2576
+ flattenRef(ref);
2577
+ const refSchema = ctx.seen.get(ref).schema;
2578
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2579
+ schema2.allOf = schema2.allOf ?? [];
2580
+ schema2.allOf.push(refSchema);
2581
+ } else {
2582
+ Object.assign(schema2, refSchema);
2583
+ Object.assign(schema2, _cached);
2584
+ }
2585
+ }
2586
+ if (!seen.isParent)
2587
+ ctx.override({
2588
+ zodSchema,
2589
+ jsonSchema: schema2,
2590
+ path: seen.path ?? []
2591
+ });
2592
+ };
2593
+ for (const entry of [...ctx.seen.entries()].reverse()) {
2594
+ flattenRef(entry[0]);
2595
+ }
2596
+ const result = {};
2597
+ if (ctx.target === "draft-2020-12") {
2598
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
2599
+ } else if (ctx.target === "draft-07") {
2600
+ result.$schema = "http://json-schema.org/draft-07/schema#";
2601
+ } else if (ctx.target === "draft-04") {
2602
+ result.$schema = "http://json-schema.org/draft-04/schema#";
2603
+ } else if (ctx.target === "openapi-3.0") ;
2604
+ else ;
2605
+ if (ctx.external?.uri) {
2606
+ const id = ctx.external.registry.get(schema)?.id;
2607
+ if (!id)
2608
+ throw new Error("Schema is missing an `id` property");
2609
+ result.$id = ctx.external.uri(id);
2610
+ }
2611
+ Object.assign(result, root.def ?? root.schema);
2612
+ const defs = ctx.external?.defs ?? {};
2613
+ for (const entry of ctx.seen.entries()) {
2614
+ const seen = entry[1];
2615
+ if (seen.def && seen.defId) {
2616
+ defs[seen.defId] = seen.def;
2617
+ }
2618
+ }
2619
+ if (ctx.external) ;
2620
+ else {
2621
+ if (Object.keys(defs).length > 0) {
2622
+ if (ctx.target === "draft-2020-12") {
2623
+ result.$defs = defs;
2624
+ } else {
2625
+ result.definitions = defs;
2626
+ }
2627
+ }
2628
+ }
2629
+ try {
2630
+ const finalized = JSON.parse(JSON.stringify(result));
2631
+ Object.defineProperty(finalized, "~standard", {
2632
+ value: {
2633
+ ...schema["~standard"],
2634
+ jsonSchema: {
2635
+ input: createStandardJSONSchemaMethod(schema, "input"),
2636
+ output: createStandardJSONSchemaMethod(schema, "output")
2637
+ }
2638
+ },
2639
+ enumerable: false,
2640
+ writable: false
2641
+ });
2642
+ return finalized;
2643
+ } catch (_err) {
2644
+ throw new Error("Error converting schema to JSON.");
2645
+ }
2646
+ }
2647
+ function isTransforming(_schema, _ctx) {
2648
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
2649
+ if (ctx.seen.has(_schema))
2650
+ return false;
2651
+ ctx.seen.add(_schema);
2652
+ const def = _schema._zod.def;
2653
+ if (def.type === "transform")
2654
+ return true;
2655
+ if (def.type === "array")
2656
+ return isTransforming(def.element, ctx);
2657
+ if (def.type === "set")
2658
+ return isTransforming(def.valueType, ctx);
2659
+ if (def.type === "lazy")
2660
+ return isTransforming(def.getter(), ctx);
2661
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
2662
+ return isTransforming(def.innerType, ctx);
2663
+ }
2664
+ if (def.type === "intersection") {
2665
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2666
+ }
2667
+ if (def.type === "record" || def.type === "map") {
2668
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2669
+ }
2670
+ if (def.type === "pipe") {
2671
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2672
+ }
2673
+ if (def.type === "object") {
2674
+ for (const key in def.shape) {
2675
+ if (isTransforming(def.shape[key], ctx))
2676
+ return true;
2677
+ }
2678
+ return false;
2679
+ }
2680
+ if (def.type === "union") {
2681
+ for (const option of def.options) {
2682
+ if (isTransforming(option, ctx))
2683
+ return true;
2684
+ }
2685
+ return false;
2686
+ }
2687
+ if (def.type === "tuple") {
2688
+ for (const item of def.items) {
2689
+ if (isTransforming(item, ctx))
2690
+ return true;
2691
+ }
2692
+ if (def.rest && isTransforming(def.rest, ctx))
2693
+ return true;
2694
+ return false;
2695
+ }
2696
+ return false;
2697
+ }
2698
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2699
+ const ctx = initializeContext({ ...params, processors });
2700
+ process(schema, ctx);
2701
+ extractDefs(ctx, schema);
2702
+ return finalize(ctx, schema);
2703
+ };
2704
+ const createStandardJSONSchemaMethod = (schema, io) => (params) => {
2705
+ const { libraryOptions, target } = params ?? {};
2706
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors: {} });
2707
+ process(schema, ctx);
2708
+ extractDefs(ctx, schema);
2709
+ return finalize(ctx, schema);
2710
+ };
2711
+ const formatMap = {
2712
+ guid: "uuid",
2713
+ url: "uri",
2714
+ datetime: "date-time",
2715
+ json_string: "json-string",
2716
+ regex: ""
2717
+ // do not set
2718
+ };
2719
+ const stringProcessor = (schema, ctx, _json, _params) => {
2720
+ const json = _json;
2721
+ json.type = "string";
2722
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
2723
+ if (typeof minimum === "number")
2724
+ json.minLength = minimum;
2725
+ if (typeof maximum === "number")
2726
+ json.maxLength = maximum;
2727
+ if (format) {
2728
+ json.format = formatMap[format] ?? format;
2729
+ if (json.format === "")
2730
+ delete json.format;
2731
+ }
2732
+ if (contentEncoding)
2733
+ json.contentEncoding = contentEncoding;
2734
+ if (patterns && patterns.size > 0) {
2735
+ const regexes = [...patterns];
2736
+ if (regexes.length === 1)
2737
+ json.pattern = regexes[0].source;
2738
+ else if (regexes.length > 1) {
2739
+ json.allOf = [
2740
+ ...regexes.map((regex) => ({
2741
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
2742
+ pattern: regex.source
2743
+ }))
2744
+ ];
2745
+ }
2746
+ }
2747
+ };
2748
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
2749
+ json.type = "boolean";
2750
+ };
2751
+ const neverProcessor = (_schema, _ctx, json, _params) => {
2752
+ json.not = {};
2753
+ };
2754
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {
2755
+ };
2756
+ const enumProcessor = (schema, _ctx, json, _params) => {
2757
+ const def = schema._zod.def;
2758
+ const values = getEnumValues(def.entries);
2759
+ if (values.every((v) => typeof v === "number"))
2760
+ json.type = "number";
2761
+ if (values.every((v) => typeof v === "string"))
2762
+ json.type = "string";
2763
+ json.enum = values;
2764
+ };
2765
+ const customProcessor = (_schema, ctx, _json, _params) => {
2766
+ if (ctx.unrepresentable === "throw") {
2767
+ throw new Error("Custom types cannot be represented in JSON Schema");
2768
+ }
2769
+ };
2770
+ const transformProcessor = (_schema, ctx, _json, _params) => {
2771
+ if (ctx.unrepresentable === "throw") {
2772
+ throw new Error("Transforms cannot be represented in JSON Schema");
2773
+ }
2774
+ };
2775
+ const arrayProcessor = (schema, ctx, _json, params) => {
2776
+ const json = _json;
2777
+ const def = schema._zod.def;
2778
+ const { minimum, maximum } = schema._zod.bag;
2779
+ if (typeof minimum === "number")
2780
+ json.minItems = minimum;
2781
+ if (typeof maximum === "number")
2782
+ json.maxItems = maximum;
2783
+ json.type = "array";
2784
+ json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
2785
+ };
2786
+ const objectProcessor = (schema, ctx, _json, params) => {
2787
+ const json = _json;
2788
+ const def = schema._zod.def;
2789
+ json.type = "object";
2790
+ json.properties = {};
2791
+ const shape = def.shape;
2792
+ for (const key in shape) {
2793
+ json.properties[key] = process(shape[key], ctx, {
2794
+ ...params,
2795
+ path: [...params.path, "properties", key]
2796
+ });
2797
+ }
2798
+ const allKeys = new Set(Object.keys(shape));
2799
+ const requiredKeys = new Set([...allKeys].filter((key) => {
2800
+ const v = def.shape[key]._zod;
2801
+ if (ctx.io === "input") {
2802
+ return v.optin === void 0;
2803
+ } else {
2804
+ return v.optout === void 0;
2805
+ }
2806
+ }));
2807
+ if (requiredKeys.size > 0) {
2808
+ json.required = Array.from(requiredKeys);
2809
+ }
2810
+ if (def.catchall?._zod.def.type === "never") {
2811
+ json.additionalProperties = false;
2812
+ } else if (!def.catchall) {
2813
+ if (ctx.io === "output")
2814
+ json.additionalProperties = false;
2815
+ } else if (def.catchall) {
2816
+ json.additionalProperties = process(def.catchall, ctx, {
2817
+ ...params,
2818
+ path: [...params.path, "additionalProperties"]
2819
+ });
2820
+ }
2821
+ };
2822
+ const unionProcessor = (schema, ctx, json, params) => {
2823
+ const def = schema._zod.def;
2824
+ const isExclusive = def.inclusive === false;
2825
+ const options = def.options.map((x, i) => process(x, ctx, {
2826
+ ...params,
2827
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
2828
+ }));
2829
+ if (isExclusive) {
2830
+ json.oneOf = options;
2831
+ } else {
2832
+ json.anyOf = options;
2833
+ }
2834
+ };
2835
+ const intersectionProcessor = (schema, ctx, json, params) => {
2836
+ const def = schema._zod.def;
2837
+ const a = process(def.left, ctx, {
2838
+ ...params,
2839
+ path: [...params.path, "allOf", 0]
2840
+ });
2841
+ const b = process(def.right, ctx, {
2842
+ ...params,
2843
+ path: [...params.path, "allOf", 1]
2844
+ });
2845
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
2846
+ const allOf = [
2847
+ ...isSimpleIntersection(a) ? a.allOf : [a],
2848
+ ...isSimpleIntersection(b) ? b.allOf : [b]
2849
+ ];
2850
+ json.allOf = allOf;
2851
+ };
2852
+ const nullableProcessor = (schema, ctx, json, params) => {
2853
+ const def = schema._zod.def;
2854
+ const inner = process(def.innerType, ctx, params);
2855
+ const seen = ctx.seen.get(schema);
2856
+ if (ctx.target === "openapi-3.0") {
2857
+ seen.ref = def.innerType;
2858
+ json.nullable = true;
2859
+ } else {
2860
+ json.anyOf = [inner, { type: "null" }];
2861
+ }
2862
+ };
2863
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
2864
+ const def = schema._zod.def;
2865
+ process(def.innerType, ctx, params);
2866
+ const seen = ctx.seen.get(schema);
2867
+ seen.ref = def.innerType;
2868
+ };
2869
+ const defaultProcessor = (schema, ctx, json, params) => {
2870
+ const def = schema._zod.def;
2871
+ process(def.innerType, ctx, params);
2872
+ const seen = ctx.seen.get(schema);
2873
+ seen.ref = def.innerType;
2874
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
2875
+ };
2876
+ const prefaultProcessor = (schema, ctx, json, params) => {
2877
+ const def = schema._zod.def;
2878
+ process(def.innerType, ctx, params);
2879
+ const seen = ctx.seen.get(schema);
2880
+ seen.ref = def.innerType;
2881
+ if (ctx.io === "input")
2882
+ json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
2883
+ };
2884
+ const catchProcessor = (schema, ctx, json, params) => {
2885
+ const def = schema._zod.def;
2886
+ process(def.innerType, ctx, params);
2887
+ const seen = ctx.seen.get(schema);
2888
+ seen.ref = def.innerType;
2889
+ let catchValue;
2890
+ try {
2891
+ catchValue = def.catchValue(void 0);
2892
+ } catch {
2893
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
2894
+ }
2895
+ json.default = catchValue;
2896
+ };
2897
+ const pipeProcessor = (schema, ctx, _json, params) => {
2898
+ const def = schema._zod.def;
2899
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
2900
+ process(innerType, ctx, params);
2901
+ const seen = ctx.seen.get(schema);
2902
+ seen.ref = innerType;
2903
+ };
2904
+ const readonlyProcessor = (schema, ctx, json, params) => {
2905
+ const def = schema._zod.def;
2906
+ process(def.innerType, ctx, params);
2907
+ const seen = ctx.seen.get(schema);
2908
+ seen.ref = def.innerType;
2909
+ json.readOnly = true;
2910
+ };
2911
+ const optionalProcessor = (schema, ctx, _json, params) => {
2912
+ const def = schema._zod.def;
2913
+ process(def.innerType, ctx, params);
2914
+ const seen = ctx.seen.get(schema);
2915
+ seen.ref = def.innerType;
2916
+ };
2410
2917
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
2411
2918
  $ZodISODateTime.init(inst, def);
2412
2919
  ZodStringFormat.init(inst, def);
@@ -2486,6 +2993,13 @@ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2486
2993
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2487
2994
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2488
2995
  $ZodType.init(inst, def);
2996
+ Object.assign(inst["~standard"], {
2997
+ jsonSchema: {
2998
+ input: createStandardJSONSchemaMethod(inst, "input"),
2999
+ output: createStandardJSONSchemaMethod(inst, "output")
3000
+ }
3001
+ });
3002
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
2489
3003
  inst.def = def;
2490
3004
  inst.type = def.type;
2491
3005
  Object.defineProperty(inst, "_def", { value: def });
@@ -2558,6 +3072,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2558
3072
  const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2559
3073
  $ZodString.init(inst, def);
2560
3074
  ZodType.init(inst, def);
3075
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
2561
3076
  const bag = inst._zod.bag;
2562
3077
  inst.format = bag.format ?? null;
2563
3078
  inst.minLength = bag.minimum ?? null;
@@ -2695,6 +3210,7 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
2695
3210
  const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
2696
3211
  $ZodBoolean.init(inst, def);
2697
3212
  ZodType.init(inst, def);
3213
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
2698
3214
  });
2699
3215
  function boolean(params) {
2700
3216
  return _boolean(ZodBoolean, params);
@@ -2702,6 +3218,7 @@ function boolean(params) {
2702
3218
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2703
3219
  $ZodUnknown.init(inst, def);
2704
3220
  ZodType.init(inst, def);
3221
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
2705
3222
  });
2706
3223
  function unknown() {
2707
3224
  return _unknown(ZodUnknown);
@@ -2709,6 +3226,7 @@ function unknown() {
2709
3226
  const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2710
3227
  $ZodNever.init(inst, def);
2711
3228
  ZodType.init(inst, def);
3229
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
2712
3230
  });
2713
3231
  function never(params) {
2714
3232
  return _never(ZodNever, params);
@@ -2716,6 +3234,7 @@ function never(params) {
2716
3234
  const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2717
3235
  $ZodArray.init(inst, def);
2718
3236
  ZodType.init(inst, def);
3237
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
2719
3238
  inst.element = def.element;
2720
3239
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
2721
3240
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -2729,6 +3248,7 @@ function array(element, params) {
2729
3248
  const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2730
3249
  $ZodObjectJIT.init(inst, def);
2731
3250
  ZodType.init(inst, def);
3251
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
2732
3252
  defineLazy(inst, "shape", () => {
2733
3253
  return def.shape;
2734
3254
  });
@@ -2761,6 +3281,7 @@ function object(shape, params) {
2761
3281
  const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2762
3282
  $ZodUnion.init(inst, def);
2763
3283
  ZodType.init(inst, def);
3284
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
2764
3285
  inst.options = def.options;
2765
3286
  });
2766
3287
  function union(options, params) {
@@ -2773,6 +3294,7 @@ function union(options, params) {
2773
3294
  const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2774
3295
  $ZodIntersection.init(inst, def);
2775
3296
  ZodType.init(inst, def);
3297
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
2776
3298
  });
2777
3299
  function intersection(left, right) {
2778
3300
  return new ZodIntersection({
@@ -2784,6 +3306,7 @@ function intersection(left, right) {
2784
3306
  const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2785
3307
  $ZodEnum.init(inst, def);
2786
3308
  ZodType.init(inst, def);
3309
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
2787
3310
  inst.enum = def.entries;
2788
3311
  inst.options = Object.values(def.entries);
2789
3312
  const keys = new Set(Object.keys(def.entries));
@@ -2829,6 +3352,7 @@ function _enum(values, params) {
2829
3352
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2830
3353
  $ZodTransform.init(inst, def);
2831
3354
  ZodType.init(inst, def);
3355
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
2832
3356
  inst._zod.parse = (payload, _ctx) => {
2833
3357
  if (_ctx.direction === "backward") {
2834
3358
  throw new $ZodEncodeError(inst.constructor.name);
@@ -2866,6 +3390,7 @@ function transform(fn) {
2866
3390
  const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2867
3391
  $ZodOptional.init(inst, def);
2868
3392
  ZodType.init(inst, def);
3393
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
2869
3394
  inst.unwrap = () => inst._zod.def.innerType;
2870
3395
  });
2871
3396
  function optional(innerType) {
@@ -2877,6 +3402,7 @@ function optional(innerType) {
2877
3402
  const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2878
3403
  $ZodNullable.init(inst, def);
2879
3404
  ZodType.init(inst, def);
3405
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
2880
3406
  inst.unwrap = () => inst._zod.def.innerType;
2881
3407
  });
2882
3408
  function nullable(innerType) {
@@ -2888,6 +3414,7 @@ function nullable(innerType) {
2888
3414
  const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
2889
3415
  $ZodDefault.init(inst, def);
2890
3416
  ZodType.init(inst, def);
3417
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
2891
3418
  inst.unwrap = () => inst._zod.def.innerType;
2892
3419
  inst.removeDefault = inst.unwrap;
2893
3420
  });
@@ -2903,6 +3430,7 @@ function _default(innerType, defaultValue) {
2903
3430
  const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
2904
3431
  $ZodPrefault.init(inst, def);
2905
3432
  ZodType.init(inst, def);
3433
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
2906
3434
  inst.unwrap = () => inst._zod.def.innerType;
2907
3435
  });
2908
3436
  function prefault(innerType, defaultValue) {
@@ -2917,6 +3445,7 @@ function prefault(innerType, defaultValue) {
2917
3445
  const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
2918
3446
  $ZodNonOptional.init(inst, def);
2919
3447
  ZodType.init(inst, def);
3448
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
2920
3449
  inst.unwrap = () => inst._zod.def.innerType;
2921
3450
  });
2922
3451
  function nonoptional(innerType, params) {
@@ -2929,6 +3458,7 @@ function nonoptional(innerType, params) {
2929
3458
  const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
2930
3459
  $ZodCatch.init(inst, def);
2931
3460
  ZodType.init(inst, def);
3461
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
2932
3462
  inst.unwrap = () => inst._zod.def.innerType;
2933
3463
  inst.removeCatch = inst.unwrap;
2934
3464
  });
@@ -2942,6 +3472,7 @@ function _catch(innerType, catchValue) {
2942
3472
  const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
2943
3473
  $ZodPipe.init(inst, def);
2944
3474
  ZodType.init(inst, def);
3475
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
2945
3476
  inst.in = def.in;
2946
3477
  inst.out = def.out;
2947
3478
  });
@@ -2956,6 +3487,7 @@ function pipe(in_, out) {
2956
3487
  const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
2957
3488
  $ZodReadonly.init(inst, def);
2958
3489
  ZodType.init(inst, def);
3490
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
2959
3491
  inst.unwrap = () => inst._zod.def.innerType;
2960
3492
  });
2961
3493
  function readonly(innerType) {
@@ -2967,6 +3499,7 @@ function readonly(innerType) {
2967
3499
  const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
2968
3500
  $ZodCustom.init(inst, def);
2969
3501
  ZodType.init(inst, def);
3502
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
2970
3503
  });
2971
3504
  function refine(fn, _params = {}) {
2972
3505
  return _refine(ZodCustom, fn, _params);
package/dist/types.d.ts CHANGED
@@ -3,5 +3,6 @@ export type AuthSessionUser = {
3
3
  currentTenantId: string;
4
4
  signedInTenants: string[];
5
5
  isEntryGateAuthorized: boolean;
6
+ tenantRoles?: Record<string, string[]>;
6
7
  };
7
8
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACvC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/auth",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -67,8 +67,5 @@
67
67
  "peerDependencies": {
68
68
  "clsx": "*"
69
69
  },
70
- "dependencies": {
71
- "lucide-react": "0.560.0"
72
- },
73
70
  "devDependencies": {}
74
71
  }