kitcn 0.12.17 → 0.12.19

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.
Files changed (38) hide show
  1. package/dist/aggregate/index.d.ts +1 -1
  2. package/dist/{api-entry-BckXqaLb.js → api-entry-BMCQSsCw.js} +6 -1
  3. package/dist/auth/client/index.js +82 -1
  4. package/dist/auth/generated/index.d.ts +1 -1
  5. package/dist/auth/index.d.ts +13 -13
  6. package/dist/auth/index.js +1 -1
  7. package/dist/auth/nextjs/index.d.ts +1 -1
  8. package/dist/auth/start/index.d.ts +7 -1
  9. package/dist/auth/start/index.js +37 -0
  10. package/dist/{auth-store-Cljlmdmi.js → auth-store-C0iMu34r.js} +53 -1
  11. package/dist/{backend-core-Rv9NorIW.mjs → backend-core-C0uwGXLx.mjs} +202 -167
  12. package/dist/{builder-CBdG5W6A.js → builder-Cb6gloDB.js} +161 -6
  13. package/dist/cli.mjs +1 -1
  14. package/dist/{context-utils-HPC5nXzx.d.ts → context-utils-BvWW0Ilq.d.ts} +8 -1
  15. package/dist/crpc/index.d.ts +2 -2
  16. package/dist/{generated-contract-disabled-Dzx2IRId.d.ts → generated-contract-disabled-UsFjh8jz.d.ts} +30 -30
  17. package/dist/{http-types-BS63Nsug.d.ts → http-types-BLFA9zS7.d.ts} +2 -1
  18. package/dist/{middleware-C2qTZ3V7.js → middleware-DkIhQXwg.js} +1 -1
  19. package/dist/{middleware-CU0mDiRs.d.ts → middleware-nS_qXecO.d.ts} +1 -1
  20. package/dist/orm/index.d.ts +1 -1
  21. package/dist/plugins/index.d.ts +1 -1
  22. package/dist/plugins/index.js +1 -1
  23. package/dist/{procedure-caller-MWcxhQDv.js → procedure-caller-AjLfkHyF.js} +1 -1
  24. package/dist/{procedure-caller-C15h5Iel.d.ts → procedure-name-D-fDCBlo.d.ts} +33 -131
  25. package/dist/ratelimit/index.d.ts +2 -2
  26. package/dist/ratelimit/index.js +3 -3
  27. package/dist/react/index.js +7 -2
  28. package/dist/rsc/index.d.ts +3 -3
  29. package/dist/server/index.d.ts +5 -5
  30. package/dist/server/index.js +4 -4
  31. package/dist/{types-DrB2VeNb.d.ts → types-C6pQrnzD.d.ts} +1 -1
  32. package/dist/{types-BqUIoMfT.d.ts → types-a-RHmrDZ.d.ts} +9 -1
  33. package/dist/watcher.mjs +12 -9
  34. package/dist/{where-clause-compiler-DdjN63Io.d.ts → where-clause-compiler-CuH2JNxb.d.ts} +12 -12
  35. package/package.json +1 -1
  36. package/skills/convex/SKILL.md +8 -4
  37. package/skills/convex/references/features/auth-organizations.md +7 -2
  38. package/skills/convex/references/features/react.md +18 -3
@@ -1,4 +1,4 @@
1
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DdjN63Io.js";
1
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-CuH2JNxb.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Infer, Value } from "convex/values";
4
4
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -5,6 +5,7 @@ const isQueryCtx = (ctx) => "db" in ctx;
5
5
  const isMutationCtx = (ctx) => "db" in ctx && "scheduler" in ctx;
6
6
  const isActionCtx = (ctx) => "runAction" in ctx;
7
7
  const isRunMutationCtx = (ctx) => "runMutation" in ctx;
8
+ const isSchedulerCtx = (ctx) => "scheduler" in ctx && typeof ctx.scheduler === "object" && ctx.scheduler !== null;
8
9
  const requireQueryCtx = (ctx) => {
9
10
  if (!isQueryCtx(ctx)) throw new Error("Query context required");
10
11
  return ctx;
@@ -21,6 +22,10 @@ const requireRunMutationCtx = (ctx) => {
21
22
  if (!isRunMutationCtx(ctx)) throw new Error("Mutation or action context required");
22
23
  return ctx;
23
24
  };
25
+ const requireSchedulerCtx = (ctx) => {
26
+ if (!isSchedulerCtx(ctx)) throw new Error("Mutation or action context with scheduler required");
27
+ return ctx;
28
+ };
24
29
 
25
30
  //#endregion
26
31
  //#region src/server/api-entry.ts
@@ -63,4 +68,4 @@ function createGeneratedFunctionReference(name) {
63
68
  }
64
69
 
65
70
  //#endregion
66
- export { isMutationCtx as a, requireActionCtx as c, requireRunMutationCtx as d, isActionCtx as i, requireMutationCtx as l, createGeneratedFunctionReference as n, isQueryCtx as o, getGeneratedValue as r, isRunMutationCtx as s, createApiLeaf as t, requireQueryCtx as u };
71
+ export { isMutationCtx as a, isSchedulerCtx as c, requireQueryCtx as d, requireRunMutationCtx as f, isActionCtx as i, requireActionCtx as l, createGeneratedFunctionReference as n, isQueryCtx as o, requireSchedulerCtx as p, getGeneratedValue as r, isRunMutationCtx as s, createApiLeaf as t, requireMutationCtx as u };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { C as defaultIsUnauthorized, S as CRPCClientError, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, n as AuthProvider, o as FetchAccessTokenContext, u as decodeJwtExp } from "../../auth-store-Cljlmdmi.js";
2
+ import { C as readAuthSessionFallbackData, D as CRPCClientError, O as defaultIsUnauthorized, S as clearAuthSessionFallback, T as writeAuthSessionFallbackData, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, n as AuthProvider, o as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as decodeJwtExp, w as readAuthSessionFallbackToken } from "../../auth-store-C0iMu34r.js";
3
3
  import { convexClient } from "@convex-dev/better-auth/client/plugins";
4
4
  import { ConvexProviderWithAuth, useConvexAuth } from "convex/react";
5
5
  import { useCallback, useEffect, useMemo, useRef } from "react";
@@ -16,6 +16,48 @@ const hasActiveSessionData = (session) => {
16
16
  if (!session || typeof session !== "object") return false;
17
17
  return Boolean(session.session);
18
18
  };
19
+ const wait = (ms) => new Promise((resolve) => {
20
+ setTimeout(resolve, ms);
21
+ });
22
+ const getSessionFromPersistedToken = async (authClient, token) => {
23
+ await wait(250);
24
+ for (let attempt = 0; attempt < 10; attempt += 1) {
25
+ const result = authClient.$fetch ? await authClient.$fetch("/get-session", {
26
+ credentials: "omit",
27
+ headers: { Authorization: `Bearer ${token}` }
28
+ }) : await authClient.getSession?.({ fetchOptions: {
29
+ credentials: "omit",
30
+ headers: { Authorization: `Bearer ${token}` }
31
+ } });
32
+ if (result?.data) return result.data;
33
+ if (attempt < 9) await wait(100);
34
+ }
35
+ return null;
36
+ };
37
+ const syncSessionAtom = (authClient, sessionData) => {
38
+ const sessionAtom = authClient.$store?.atoms?.session;
39
+ if (typeof sessionAtom?.get !== "function" || typeof sessionAtom.set !== "function") return;
40
+ const current = sessionAtom.get();
41
+ sessionAtom.set({
42
+ data: sessionData,
43
+ error: null,
44
+ isPending: false,
45
+ isRefetching: false,
46
+ refetch: current?.refetch ?? (async () => {})
47
+ });
48
+ };
49
+ const clearSessionAtom = (authClient) => {
50
+ const sessionAtom = authClient.$store?.atoms?.session;
51
+ if (typeof sessionAtom?.get !== "function" || typeof sessionAtom.set !== "function") return;
52
+ const current = sessionAtom.get();
53
+ sessionAtom.set({
54
+ data: null,
55
+ error: null,
56
+ isPending: false,
57
+ isRefetching: false,
58
+ refetch: current?.refetch ?? (async () => {})
59
+ });
60
+ };
19
61
  /**
20
62
  * Unified auth provider for Convex + Better Auth.
21
63
  * Handles token sync, HMR persistence, and auth callbacks.
@@ -75,6 +117,45 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
75
117
  isPending,
76
118
  authStore
77
119
  ]);
120
+ useEffect(() => {
121
+ if (hasActiveSessionData(session) || isPending || authStore.get("token")) return;
122
+ const persistedToken = readAuthSessionFallbackToken();
123
+ const persistedSessionData = readAuthSessionFallbackData();
124
+ if (!persistedToken || typeof authClient.getSession !== "function" && typeof authClient.$fetch !== "function") return;
125
+ let cancelled = false;
126
+ authStore.set("token", persistedToken);
127
+ authStore.set("expiresAt", decodeJwtExp(persistedToken));
128
+ authStore.set("sessionSyncGraceUntil", Date.now() + AUTH_SESSION_SYNC_GRACE_MS);
129
+ if (persistedSessionData) syncSessionAtom(authClient, persistedSessionData);
130
+ getSessionFromPersistedToken(authClient, persistedToken).then((result) => {
131
+ if (cancelled) return;
132
+ if (result) {
133
+ syncSessionAtom(authClient, result);
134
+ writeAuthSessionFallbackData(result);
135
+ return;
136
+ }
137
+ clearAuthSessionFallback();
138
+ clearSessionAtom(authClient);
139
+ authStore.set("token", null);
140
+ authStore.set("expiresAt", null);
141
+ authStore.set("sessionSyncGraceUntil", null);
142
+ }).catch(() => {
143
+ if (cancelled) return;
144
+ clearAuthSessionFallback();
145
+ clearSessionAtom(authClient);
146
+ authStore.set("token", null);
147
+ authStore.set("expiresAt", null);
148
+ authStore.set("sessionSyncGraceUntil", null);
149
+ });
150
+ return () => {
151
+ cancelled = true;
152
+ };
153
+ }, [
154
+ session,
155
+ isPending,
156
+ authStore,
157
+ authClient
158
+ ]);
78
159
  const fetchAccessToken = useCallback(async ({ forceRefreshToken = false } = {}) => {
79
160
  const fetchFreshToken = () => {
80
161
  if (pendingTokenRef.current) return pendingTokenRef.current;
@@ -1,2 +1,2 @@
1
- import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-Dzx2IRId.js";
1
+ import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-UsFjh8jz.js";
2
2
  export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
@@ -1,7 +1,7 @@
1
1
  import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-CFZqIvD7.js";
2
2
  import { t as GetAuth } from "../types-BiJE7qxR.js";
3
- import { t as GenericCtx } from "../context-utils-HPC5nXzx.js";
4
- import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-Dzx2IRId.js";
3
+ import { t as GenericCtx } from "../context-utils-BvWW0Ilq.js";
4
+ import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-UsFjh8jz.js";
5
5
  import * as convex_values0 from "convex/values";
6
6
  import { Infer } from "convex/values";
7
7
  import { DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
@@ -103,25 +103,25 @@ type AdapterPaginationOptions = PaginationOptions & {
103
103
  maximumRowsRead?: number;
104
104
  };
105
105
  declare const adapterWhereValidator: convex_values0.VObject<{
106
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
106
107
  connector?: "AND" | "OR" | undefined;
107
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
108
108
  value: string | number | boolean | string[] | number[] | null;
109
109
  field: string;
110
110
  }, {
111
111
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
112
112
  field: convex_values0.VString<string, "required">;
113
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
113
+ operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
114
114
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
115
- }, "required", "value" | "connector" | "field" | "operator">;
115
+ }, "required", "operator" | "value" | "field" | "connector">;
116
116
  declare const adapterArgsValidator: convex_values0.VObject<{
117
- select?: string[] | undefined;
117
+ limit?: number | undefined;
118
118
  where?: {
119
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
119
120
  connector?: "AND" | "OR" | undefined;
120
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
121
121
  value: string | number | boolean | string[] | number[] | null;
122
122
  field: string;
123
123
  }[] | undefined;
124
- limit?: number | undefined;
124
+ select?: string[] | undefined;
125
125
  offset?: number | undefined;
126
126
  sortBy?: {
127
127
  field: string;
@@ -141,22 +141,22 @@ declare const adapterArgsValidator: convex_values0.VObject<{
141
141
  field: convex_values0.VString<string, "required">;
142
142
  }, "optional", "field" | "direction">;
143
143
  where: convex_values0.VArray<{
144
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
144
145
  connector?: "AND" | "OR" | undefined;
145
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
146
146
  value: string | number | boolean | string[] | number[] | null;
147
147
  field: string;
148
148
  }[] | undefined, convex_values0.VObject<{
149
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
149
150
  connector?: "AND" | "OR" | undefined;
150
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
151
151
  value: string | number | boolean | string[] | number[] | null;
152
152
  field: string;
153
153
  }, {
154
154
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
155
155
  field: convex_values0.VString<string, "required">;
156
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
156
+ operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
157
157
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
158
- }, "required", "value" | "connector" | "field" | "operator">, "optional">;
159
- }, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
158
+ }, "required", "operator" | "value" | "field" | "connector">, "optional">;
159
+ }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
160
160
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
161
161
  declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
162
162
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -1,6 +1,6 @@
1
1
  import { r as partial, s as asyncMap } from "../validators-B7oIJCAp.js";
2
2
  import { i as defineAuth, n as createDisabledAuthRuntime, r as getGeneratedAuthDisabledReason, t as DEFAULT_AUTH_DEFINITION_PATH } from "../generated-contract-disabled-Cih4eITO.js";
3
- import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutationCtx } from "../api-entry-BckXqaLb.js";
3
+ import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutationCtx } from "../api-entry-BMCQSsCw.js";
4
4
  import { n as customCtx, r as customMutation } from "../customFunctions-C0voKmtx.js";
5
5
  import { a as mergedStream, l as unsetToken, o as stream, t as getByIdWithOrmQueryFallback, v as eq } from "../query-context-B8o6-8kC.js";
6
6
  import { v } from "convex/values";
@@ -1,4 +1,4 @@
1
- import { I as ConvexContext, R as LazyCaller } from "../../procedure-caller-C15h5Iel.js";
1
+ import { U as LazyCaller, V as ConvexContext } from "../../procedure-name-D-fDCBlo.js";
2
2
  import { GetTokenOptions } from "@convex-dev/better-auth/utils";
3
3
 
4
4
  //#region src/auth-nextjs/index.d.ts
@@ -1 +1,7 @@
1
- export * from "@convex-dev/better-auth/react-start";
1
+ import { convexBetterAuthReactStart as convexBetterAuthReactStart$1 } from "@convex-dev/better-auth/react-start";
2
+ export * from "@convex-dev/better-auth/react-start";
3
+
4
+ //#region src/auth-start/index.d.ts
5
+ declare const convexBetterAuthReactStart: typeof convexBetterAuthReactStart$1;
6
+ //#endregion
7
+ export { convexBetterAuthReactStart };
@@ -1 +1,38 @@
1
+ import { convexBetterAuthReactStart as convexBetterAuthReactStart$1 } from "@convex-dev/better-auth/react-start";
2
+
1
3
  export * from "@convex-dev/better-auth/react-start"
4
+
5
+ //#region src/auth-start/index.ts
6
+ const appendSetCookieHeaders = (target, source) => {
7
+ const getSetCookie = source.getSetCookie;
8
+ if (typeof getSetCookie === "function") {
9
+ const values = getSetCookie.call(source);
10
+ for (const value of values) target.append("set-cookie", value);
11
+ return;
12
+ }
13
+ const value = source.get("set-cookie");
14
+ if (value) target.append("set-cookie", value);
15
+ };
16
+ const cloneAuthHandlerResponse = (response) => {
17
+ const headers = new Headers();
18
+ for (const [key, value] of response.headers.entries()) {
19
+ if (key.toLowerCase() === "set-cookie") continue;
20
+ headers.append(key, value);
21
+ }
22
+ appendSetCookieHeaders(headers, response.headers);
23
+ return new Response(response.body, {
24
+ headers,
25
+ status: response.status,
26
+ statusText: response.statusText
27
+ });
28
+ };
29
+ const convexBetterAuthReactStart = ((...args) => {
30
+ const auth = convexBetterAuthReactStart$1(...args);
31
+ return {
32
+ ...auth,
33
+ handler: async (request) => cloneAuthHandlerResponse(await auth.handler(request))
34
+ };
35
+ });
36
+
37
+ //#endregion
38
+ export { convexBetterAuthReactStart };
@@ -32,6 +32,58 @@ const defaultIsUnauthorized = (error) => {
32
32
  return false;
33
33
  };
34
34
 
35
+ //#endregion
36
+ //#region src/react/auth-session-fallback.ts
37
+ const SESSION_TOKEN_FALLBACK_KEY = "kitcn.auth.session-token";
38
+ const SESSION_DATA_FALLBACK_KEY = "kitcn.auth.session-data";
39
+ const getSessionStorage = () => {
40
+ if (typeof window === "undefined") return null;
41
+ try {
42
+ return window.sessionStorage;
43
+ } catch {
44
+ return null;
45
+ }
46
+ };
47
+ const readAuthSessionFallbackToken = () => {
48
+ const storage = getSessionStorage();
49
+ if (!storage) return null;
50
+ const token = storage.getItem(SESSION_TOKEN_FALLBACK_KEY);
51
+ return token && token.length > 0 ? token : null;
52
+ };
53
+ const writeAuthSessionFallbackToken = (token) => {
54
+ const storage = getSessionStorage();
55
+ if (!storage) return;
56
+ if (token && token.length > 0) {
57
+ storage.setItem(SESSION_TOKEN_FALLBACK_KEY, token);
58
+ return;
59
+ }
60
+ storage.removeItem(SESSION_TOKEN_FALLBACK_KEY);
61
+ };
62
+ const readAuthSessionFallbackData = () => {
63
+ const storage = getSessionStorage();
64
+ if (!storage) return null;
65
+ const value = storage.getItem(SESSION_DATA_FALLBACK_KEY);
66
+ if (!value) return null;
67
+ try {
68
+ return JSON.parse(value);
69
+ } catch {
70
+ return null;
71
+ }
72
+ };
73
+ const writeAuthSessionFallbackData = (data) => {
74
+ const storage = getSessionStorage();
75
+ if (!storage) return;
76
+ if (data === null || data === void 0) {
77
+ storage.removeItem(SESSION_DATA_FALLBACK_KEY);
78
+ return;
79
+ }
80
+ storage.setItem(SESSION_DATA_FALLBACK_KEY, JSON.stringify(data));
81
+ };
82
+ const clearAuthSessionFallback = () => {
83
+ writeAuthSessionFallbackToken(null);
84
+ writeAuthSessionFallbackData(null);
85
+ };
86
+
35
87
  //#endregion
36
88
  //#region src/react/auth-store.tsx
37
89
  /**
@@ -194,4 +246,4 @@ function Unauthenticated({ children }) {
194
246
  }
195
247
 
196
248
  //#endregion
197
- export { defaultIsUnauthorized as C, CRPCClientError as S, useConvexAuthBridge as _, ConvexProviderWithAuth$1 as a, useMaybeAuth as b, MaybeUnauthenticated as c, isSessionSyncGraceActive as d, useAuth as f, useAuthValue as g, useAuthStore as h, ConvexAuthBridge as i, Unauthenticated as l, useAuthState as m, AuthProvider as n, FetchAccessTokenContext as o, useAuthGuard as p, Authenticated as r, MaybeAuthenticated as s, AUTH_SESSION_SYNC_GRACE_MS as t, decodeJwtExp as u, useFetchAccessToken as v, isCRPCClientError as w, useSafeConvexAuth as x, useIsAuth as y };
249
+ export { readAuthSessionFallbackData as C, CRPCClientError as D, writeAuthSessionFallbackToken as E, defaultIsUnauthorized as O, clearAuthSessionFallback as S, writeAuthSessionFallbackData as T, useConvexAuthBridge as _, ConvexProviderWithAuth$1 as a, useMaybeAuth as b, MaybeUnauthenticated as c, isSessionSyncGraceActive as d, useAuth as f, useAuthValue as g, useAuthStore as h, ConvexAuthBridge as i, isCRPCClientError as k, Unauthenticated as l, useAuthState as m, AuthProvider as n, FetchAccessTokenContext as o, useAuthGuard as p, Authenticated as r, MaybeAuthenticated as s, AUTH_SESSION_SYNC_GRACE_MS as t, decodeJwtExp as u, useFetchAccessToken as v, readAuthSessionFallbackToken as w, useSafeConvexAuth as x, useIsAuth as y };