kitcn 0.15.1 → 0.15.4
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/aggregate/index.d.ts +1 -1
- package/dist/auth/client/index.d.ts +8 -2
- package/dist/auth/client/index.js +4 -2
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +12 -12
- package/dist/auth/nextjs/index.d.ts +1 -1
- package/dist/auth-store-B_ARzzEX.d.ts +156 -0
- package/dist/{backend-core-B091CyHN.mjs → backend-core-BA0CgHrL.mjs} +163 -83
- package/dist/cli.mjs +1 -1
- package/dist/{generated-contract-disabled-C_-KWRfT.d.ts → generated-contract-disabled-xOmfTKh8.d.ts} +29 -29
- package/dist/orm/index.d.ts +1 -1
- package/dist/{procedure-caller-DplSC7Us.js → procedure-caller-9m6NBxQu.js} +27 -5
- package/dist/{procedure-name-BCRBr6Po.d.ts → procedure-name-Cy1AxayA.d.ts} +2 -1
- package/dist/react/index.d.ts +2 -152
- package/dist/react/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +1 -1
- package/dist/solid/index.js +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-DcEhkJ12.d.ts → where-clause-compiler-Dv-3mnJF.d.ts} +12 -12
- package/package.json +1 -1
- package/skills/kitcn/references/features/auth.md +1 -0
- package/skills/kitcn/references/features/react.md +11 -16
- package/skills/kitcn/references/setup/react.md +12 -21
|
@@ -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-
|
|
1
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-Dv-3mnJF.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";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { r as AuthStore } from "../../auth-store-B_ARzzEX.js";
|
|
2
3
|
import { ConvexReactClient } from "convex/react";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -314,10 +315,14 @@ type AuthClientWithPlugins<Plugins extends PluginsWithCrossDomain | PluginsWitho
|
|
|
314
315
|
type AuthClient = AuthClientWithPlugins<PluginsWithCrossDomain> | AuthClientWithPlugins<PluginsWithoutCrossDomain>;
|
|
315
316
|
//#endregion
|
|
316
317
|
//#region src/auth-client/convex-auth-provider.d.ts
|
|
318
|
+
type ConvexAuthProviderQueryClient = {
|
|
319
|
+
updateAuthStore: (authStore?: AuthStore) => void;
|
|
320
|
+
};
|
|
317
321
|
type ConvexAuthProviderProps = {
|
|
318
322
|
children: ReactNode; /** Convex client instance */
|
|
319
323
|
client: ConvexReactClient; /** Better Auth client instance */
|
|
320
|
-
authClient: AuthClient; /**
|
|
324
|
+
authClient: AuthClient; /** Shared Convex query client to sync with auth state */
|
|
325
|
+
convexQueryClient?: ConvexAuthProviderQueryClient; /** Initial session token (from SSR) */
|
|
321
326
|
initialToken?: string; /** Callback when mutation called while unauthorized */
|
|
322
327
|
onMutationUnauthorized?: () => void; /** Callback when query called while unauthorized */
|
|
323
328
|
onQueryUnauthorized?: (info: {
|
|
@@ -336,10 +341,11 @@ declare function ConvexAuthProvider({
|
|
|
336
341
|
children,
|
|
337
342
|
client,
|
|
338
343
|
authClient,
|
|
344
|
+
convexQueryClient,
|
|
339
345
|
initialToken,
|
|
340
346
|
onMutationUnauthorized,
|
|
341
347
|
onQueryUnauthorized,
|
|
342
348
|
isUnauthorized
|
|
343
349
|
}: ConvexAuthProviderProps): react_jsx_runtime0.JSX.Element;
|
|
344
350
|
//#endregion
|
|
345
|
-
export { type AuthClient, type AuthClientWithPlugins, ConvexAuthProvider, ConvexAuthProviderProps, type PluginsWithCrossDomain, type PluginsWithoutCrossDomain, convexClient };
|
|
351
|
+
export { type AuthClient, type AuthClientWithPlugins, ConvexAuthProvider, ConvexAuthProviderProps, ConvexAuthProviderQueryClient, type PluginsWithCrossDomain, type PluginsWithoutCrossDomain, convexClient };
|
|
@@ -77,7 +77,7 @@ const clearSessionAtom = (authClient) => {
|
|
|
77
77
|
* Structure: AuthProvider wraps ConvexAuthProviderInner so that
|
|
78
78
|
* useAuthStore() is available when creating fetchAccessToken.
|
|
79
79
|
*/
|
|
80
|
-
function ConvexAuthProvider({ children, client, authClient, initialToken, onMutationUnauthorized, onQueryUnauthorized, isUnauthorized }) {
|
|
80
|
+
function ConvexAuthProvider({ children, client, authClient, convexQueryClient, initialToken, onMutationUnauthorized, onQueryUnauthorized, isUnauthorized }) {
|
|
81
81
|
useOTTHandler(authClient);
|
|
82
82
|
return /* @__PURE__ */ jsx(AuthProvider, {
|
|
83
83
|
initialValues: useMemo(() => ({
|
|
@@ -90,6 +90,7 @@ function ConvexAuthProvider({ children, client, authClient, initialToken, onMuta
|
|
|
90
90
|
children: /* @__PURE__ */ jsx(ConvexAuthProviderInner, {
|
|
91
91
|
authClient,
|
|
92
92
|
client,
|
|
93
|
+
convexQueryClient,
|
|
93
94
|
children
|
|
94
95
|
})
|
|
95
96
|
});
|
|
@@ -98,8 +99,9 @@ function ConvexAuthProvider({ children, client, authClient, initialToken, onMuta
|
|
|
98
99
|
* Inner provider that has access to AuthStore via useAuthStore().
|
|
99
100
|
* Creates fetchAccessToken and passes it through context (no race condition).
|
|
100
101
|
*/
|
|
101
|
-
function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
102
|
+
function ConvexAuthProviderInner({ children, client, authClient, convexQueryClient }) {
|
|
102
103
|
const authStore = useAuthStore();
|
|
104
|
+
convexQueryClient?.updateAuthStore(authStore);
|
|
103
105
|
const { data: session, isPending } = authClient.useSession();
|
|
104
106
|
const sessionRef = useRef(session);
|
|
105
107
|
const isPendingRef = useRef(isPending);
|
|
@@ -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-
|
|
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-xOmfTKh8.js";
|
|
2
2
|
export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
2
2
|
import { t as GetAuth } from "../types-BCl8gfGy.js";
|
|
3
3
|
import { t as GenericCtx } from "../context-utils-OMkMGhBk.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-
|
|
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-xOmfTKh8.js";
|
|
5
5
|
import * as convex_values0 from "convex/values";
|
|
6
6
|
import { Infer } from "convex/values";
|
|
7
7
|
import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
|
|
@@ -107,27 +107,27 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
107
107
|
};
|
|
108
108
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
109
109
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
110
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
110
111
|
connector?: "AND" | "OR" | undefined;
|
|
111
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
112
112
|
value: string | number | boolean | string[] | number[] | null;
|
|
113
113
|
field: string;
|
|
114
114
|
}, {
|
|
115
115
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
116
116
|
field: convex_values0.VString<string, "required">;
|
|
117
117
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
118
|
-
operator: convex_values0.VUnion<"
|
|
118
|
+
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>;
|
|
119
119
|
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>;
|
|
120
|
-
}, "required", "mode" | "
|
|
120
|
+
}, "required", "mode" | "operator" | "value" | "field" | "connector">;
|
|
121
121
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
122
|
-
|
|
122
|
+
limit?: number | undefined;
|
|
123
123
|
where?: {
|
|
124
124
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
125
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
125
126
|
connector?: "AND" | "OR" | undefined;
|
|
126
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
127
127
|
value: string | number | boolean | string[] | number[] | null;
|
|
128
128
|
field: string;
|
|
129
129
|
}[] | undefined;
|
|
130
|
-
|
|
130
|
+
select?: string[] | undefined;
|
|
131
131
|
offset?: number | undefined;
|
|
132
132
|
sortBy?: {
|
|
133
133
|
field: string;
|
|
@@ -148,24 +148,24 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
148
148
|
}, "optional", "field" | "direction">;
|
|
149
149
|
where: convex_values0.VArray<{
|
|
150
150
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
151
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
151
152
|
connector?: "AND" | "OR" | undefined;
|
|
152
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
153
153
|
value: string | number | boolean | string[] | number[] | null;
|
|
154
154
|
field: string;
|
|
155
155
|
}[] | undefined, convex_values0.VObject<{
|
|
156
156
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
157
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
157
158
|
connector?: "AND" | "OR" | undefined;
|
|
158
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
159
159
|
value: string | number | boolean | string[] | number[] | null;
|
|
160
160
|
field: string;
|
|
161
161
|
}, {
|
|
162
162
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
163
163
|
field: convex_values0.VString<string, "required">;
|
|
164
164
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
165
|
-
operator: convex_values0.VUnion<"
|
|
165
|
+
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>;
|
|
166
166
|
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>;
|
|
167
|
-
}, "required", "mode" | "
|
|
168
|
-
}, "required", "
|
|
167
|
+
}, "required", "mode" | "operator" | "value" | "field" | "connector">, "optional">;
|
|
168
|
+
}, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
|
|
169
169
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
170
170
|
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>;
|
|
171
171
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as ConvexContext, W as LazyCaller } from "../../procedure-name-Cy1AxayA.js";
|
|
2
2
|
import { t as GetTokenOptions } from "../../token-B9Bjcqug.js";
|
|
3
3
|
|
|
4
4
|
//#region src/auth-nextjs/index.d.ts
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ConvexProviderWithAuth } from "convex/react";
|
|
3
|
+
import * as react from "react";
|
|
4
|
+
import * as jotai_x0 from "jotai-x";
|
|
5
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import * as jotai_vanilla0 from "jotai/vanilla";
|
|
7
|
+
|
|
8
|
+
//#region src/react/auth-store.d.ts
|
|
9
|
+
type FetchAccessTokenFn = (args: {
|
|
10
|
+
forceRefreshToken: boolean;
|
|
11
|
+
}) => Promise<string | null>;
|
|
12
|
+
declare const FetchAccessTokenContext: react.Context<FetchAccessTokenFn | null>;
|
|
13
|
+
/** Get fetchAccessToken from context (available immediately, no race condition) */
|
|
14
|
+
declare const useFetchAccessToken: () => FetchAccessTokenFn | null;
|
|
15
|
+
type ConvexAuthResult = {
|
|
16
|
+
isAuthenticated: boolean;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Get auth from bridge context (null if no bridge configured) */
|
|
20
|
+
declare const useConvexAuthBridge: () => ConvexAuthResult | null;
|
|
21
|
+
type AuthStoreState = {
|
|
22
|
+
/** Callback when mutation/action called while unauthorized. Throws by default. */onMutationUnauthorized: () => void; /** Callback when query called while unauthorized. Noop by default. */
|
|
23
|
+
onQueryUnauthorized: (info: {
|
|
24
|
+
queryName: string;
|
|
25
|
+
}) => void; /** Custom function to detect UNAUTHORIZED errors. Default checks code or "auth" in message. */
|
|
26
|
+
isUnauthorized: (error: unknown) => boolean; /** Cached Convex JWT for HTTP requests */
|
|
27
|
+
token: string | null; /** JWT expiration timestamp (ms) */
|
|
28
|
+
expiresAt: number | null; /** Auth loading state (synced from useConvexAuth for class methods) */
|
|
29
|
+
isLoading: boolean; /** Auth state (synced from useConvexAuth for class methods) */
|
|
30
|
+
isAuthenticated: boolean; /** Grace window for freshly seeded auth tokens while session sync catches up */
|
|
31
|
+
sessionSyncGraceUntil: number | null;
|
|
32
|
+
};
|
|
33
|
+
declare const AUTH_SESSION_SYNC_GRACE_MS = 10000;
|
|
34
|
+
declare const isSessionSyncGraceActive: (sessionSyncGraceUntil: number | null) => boolean;
|
|
35
|
+
/** Decode JWT expiration (ms timestamp) from token */
|
|
36
|
+
declare function decodeJwtExp(token: string): number | null;
|
|
37
|
+
declare const AuthProvider: react.FC<jotai_x0.ProviderProps<{
|
|
38
|
+
onMutationUnauthorized: () => void;
|
|
39
|
+
onQueryUnauthorized: (info: {
|
|
40
|
+
queryName: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
isUnauthorized: (error: unknown) => boolean;
|
|
43
|
+
token: string | null;
|
|
44
|
+
expiresAt: number | null;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
isAuthenticated: boolean;
|
|
47
|
+
sessionSyncGraceUntil: number | null;
|
|
48
|
+
}>>, useAuthStore: jotai_x0.UseStoreApi<AuthStoreState, object>, useAuthState: <K extends keyof AuthStoreState>(key: K, options?: string | jotai_x0.UseAtomOptions) => ({
|
|
49
|
+
onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
|
|
50
|
+
onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
|
|
51
|
+
queryName: string;
|
|
52
|
+
}) => void>;
|
|
53
|
+
isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
|
|
54
|
+
token: jotai_x0.SimpleWritableAtom<string | null>;
|
|
55
|
+
expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
|
|
56
|
+
isLoading: jotai_x0.SimpleWritableAtom<boolean>;
|
|
57
|
+
isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
|
|
58
|
+
sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
|
|
59
|
+
} & object)[K] extends jotai_vanilla0.WritableAtom<infer V, infer A extends unknown[], infer R> ? [V, (...args: A) => R] : never, useAuthValue: <K extends keyof AuthStoreState, S = (({
|
|
60
|
+
onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
|
|
61
|
+
onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
|
|
62
|
+
queryName: string;
|
|
63
|
+
}) => void>;
|
|
64
|
+
isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
|
|
65
|
+
token: jotai_x0.SimpleWritableAtom<string | null>;
|
|
66
|
+
expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
|
|
67
|
+
isLoading: jotai_x0.SimpleWritableAtom<boolean>;
|
|
68
|
+
isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
|
|
69
|
+
sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
|
|
70
|
+
} & object)[K] extends jotai_vanilla0.Atom<infer V> ? V : never)>(key: K, options?: ({
|
|
71
|
+
selector?: ((v: ({
|
|
72
|
+
onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
|
|
73
|
+
onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
|
|
74
|
+
queryName: string;
|
|
75
|
+
}) => void>;
|
|
76
|
+
isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
|
|
77
|
+
token: jotai_x0.SimpleWritableAtom<string | null>;
|
|
78
|
+
expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
|
|
79
|
+
isLoading: jotai_x0.SimpleWritableAtom<boolean>;
|
|
80
|
+
isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
|
|
81
|
+
sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
|
|
82
|
+
} & object)[K] extends jotai_vanilla0.Atom<infer V_1> ? V_1 : never, prevSelectorOutput?: S | undefined) => S) | undefined;
|
|
83
|
+
equalityFn?: ((prev: S, next: S) => boolean) | undefined;
|
|
84
|
+
} & jotai_x0.UseAtomOptions) | undefined, deps?: unknown[]) => S;
|
|
85
|
+
type AuthStore = ReturnType<typeof useAuthStore>;
|
|
86
|
+
/**
|
|
87
|
+
* Safe wrapper around useConvexAuth that doesn't throw when used outside auth provider.
|
|
88
|
+
* Returns { isAuthenticated: false, isLoading: false } when no auth provider.
|
|
89
|
+
*
|
|
90
|
+
* Supports both:
|
|
91
|
+
* - better-auth users (via AuthProvider)
|
|
92
|
+
* - @convex-dev/auth users (via ConvexAuthBridge)
|
|
93
|
+
*/
|
|
94
|
+
declare function useSafeConvexAuth(): ConvexAuthResult;
|
|
95
|
+
/**
|
|
96
|
+
* Internal bridge component. Use `ConvexProviderWithAuth` instead.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
declare function ConvexAuthBridge({
|
|
100
|
+
children
|
|
101
|
+
}: {
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* Convex provider with auth bridge for @convex-dev/auth users.
|
|
106
|
+
* Automatically wraps children with ConvexAuthBridge.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* import { ConvexProviderWithAuth } from 'kitcn/react';
|
|
111
|
+
*
|
|
112
|
+
* <ConvexProviderWithAuth client={convex} useAuth={useAuthFromConvexDev}>
|
|
113
|
+
* <App />
|
|
114
|
+
* </ConvexProviderWithAuth>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function ConvexProviderWithAuth$1({
|
|
118
|
+
children,
|
|
119
|
+
...props
|
|
120
|
+
}: React.ComponentProps<typeof ConvexProviderWithAuth>): react_jsx_runtime0.JSX.Element;
|
|
121
|
+
declare const useAuth: () => {
|
|
122
|
+
hasSession: boolean;
|
|
123
|
+
isAuthenticated: boolean;
|
|
124
|
+
isLoading: boolean;
|
|
125
|
+
};
|
|
126
|
+
/** Check if user maybe has auth (optimistic, has token) */
|
|
127
|
+
declare const useMaybeAuth: () => boolean;
|
|
128
|
+
/** Check if user is authenticated (server-verified) */
|
|
129
|
+
declare const useIsAuth: () => boolean;
|
|
130
|
+
declare const useAuthGuard: () => (callback?: () => Promise<void> | void) => boolean | undefined;
|
|
131
|
+
/** Render children only when maybe has auth (optimistic) */
|
|
132
|
+
declare function MaybeAuthenticated({
|
|
133
|
+
children
|
|
134
|
+
}: {
|
|
135
|
+
children: React.ReactNode;
|
|
136
|
+
}): react.ReactNode;
|
|
137
|
+
/** Render children only when authenticated (server-verified) */
|
|
138
|
+
declare function Authenticated({
|
|
139
|
+
children
|
|
140
|
+
}: {
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
}): react.ReactNode;
|
|
143
|
+
/** Render children only when maybe not auth (optimistic) */
|
|
144
|
+
declare function MaybeUnauthenticated({
|
|
145
|
+
children
|
|
146
|
+
}: {
|
|
147
|
+
children: React.ReactNode;
|
|
148
|
+
}): react.ReactNode;
|
|
149
|
+
/** Render children only when not authenticated (server-verified) */
|
|
150
|
+
declare function Unauthenticated({
|
|
151
|
+
children
|
|
152
|
+
}: {
|
|
153
|
+
children: React.ReactNode;
|
|
154
|
+
}): react.ReactNode;
|
|
155
|
+
//#endregion
|
|
156
|
+
export { useMaybeAuth as C, useIsAuth as S, useAuthState as _, Authenticated as a, useConvexAuthBridge as b, FetchAccessTokenContext as c, MaybeUnauthenticated as d, Unauthenticated as f, useAuthGuard as g, useAuth as h, AuthStoreState as i, FetchAccessTokenFn as l, isSessionSyncGraceActive as m, AuthProvider as n, ConvexAuthBridge as o, decodeJwtExp as p, AuthStore as r, ConvexProviderWithAuth$1 as s, AUTH_SESSION_SYNC_GRACE_MS as t, MaybeAuthenticated as u, useAuthStore as v, useSafeConvexAuth as w, useFetchAccessToken as x, useAuthValue as y };
|