nuxt-convex-module 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -4
- package/dist/chunks/index.mjs +37 -15
- package/dist/devtools-client/_nuxt/BbiHJLbN.js +4 -0
- package/dist/devtools-client/_nuxt/entry.CfoJPZu4.css +1 -0
- package/dist/devtools-client/index.html +1 -1
- package/dist/module.d.mts +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +38 -10
- package/dist/runtime/auth0/vue/index.js +1 -1
- package/dist/runtime/better-auth/nuxt/middleware.js +2 -13
- package/dist/runtime/better-auth/nuxt/server-guard.d.ts +12 -0
- package/dist/runtime/better-auth/nuxt/server-guard.js +13 -0
- package/dist/runtime/better-auth/vue/auth-boundary.js +2 -2
- package/dist/runtime/better-auth/vue/client.d.ts +5 -357
- package/dist/runtime/better-auth/vue/use-better-auth.d.ts +4 -65
- package/dist/runtime/clerk/vue/index.js +1 -1
- package/dist/runtime/nuxt/composables/use-async-paginated-query.js +12 -12
- package/dist/runtime/nuxt/composables/use-async-query.d.ts +2 -2
- package/dist/runtime/nuxt/index.d.ts +6 -6
- package/dist/runtime/polar/vue/components.js +2 -2
- package/dist/runtime/vue/auth/helpers.js +4 -4
- package/dist/runtime/vue/client.d.ts +6 -6
- package/dist/runtime/vue/components/convex-image.js +1 -1
- package/dist/runtime/vue/composables/use-action.d.ts +3 -3
- package/dist/runtime/vue/composables/use-mutation.d.ts +4 -4
- package/dist/runtime/vue/composables/use-queries.d.ts +14 -7
- package/dist/runtime/vue/composables/use-query.d.ts +5 -5
- package/dist/runtime/vue/hydration.d.ts +3 -3
- package/dist/runtime/vue/index.d.ts +1 -1
- package/dist/runtime/vue/queries-observer.d.ts +9 -9
- package/package.json +26 -25
- package/dist/devtools-client/200.html +0 -1
- package/dist/devtools-client/404.html +0 -1
- package/dist/devtools-client/_nuxt/71bSMC-_.js +0 -2
- package/dist/devtools-client/_nuxt/BAaUCl_m.js +0 -1
- package/dist/devtools-client/_nuxt/BhmjAr2Q.js +0 -1
- package/dist/devtools-client/_nuxt/BmBQNDID.js +0 -1
- package/dist/devtools-client/_nuxt/C6YdTgGl.js +0 -2
- package/dist/devtools-client/_nuxt/CKakiU_h.js +0 -1
- package/dist/devtools-client/_nuxt/Cm7YqZQ-.js +0 -1
- package/dist/devtools-client/_nuxt/DQmVr-EY.js +0 -1
- package/dist/devtools-client/_nuxt/D_Rij7MD.js +0 -1
- package/dist/devtools-client/_nuxt/EZ4-8Xzm.js +0 -3
- package/dist/devtools-client/_nuxt/Kba0XpjH.js +0 -1
- package/dist/devtools-client/_nuxt/OVE7s6ty.js +0 -1
- package/dist/devtools-client/_nuxt/_Lf3mfPR.js +0 -1
- package/dist/devtools-client/_nuxt/builds/latest.json +0 -1
- package/dist/devtools-client/_nuxt/builds/meta/1734dcfa-caf6-447b-a68b-4dd3cf138875.json +0 -1
- package/dist/devtools-client/_nuxt/entry.HF8C6P11.css +0 -1
- package/dist/devtools-client/_nuxt/error-404.CLlwiMp-.css +0 -1
- package/dist/devtools-client/_nuxt/error-500.Bxr6fpDU.css +0 -1
- package/dist/devtools-client/_nuxt/queries.DNBUjWk2.css +0 -1
- package/dist/devtools-client/_nuxt/vZZlEX5A.js +0 -1
- package/dist/devtools-client/auth/index.html +0 -1
- package/dist/devtools-client/logs/index.html +0 -1
- package/dist/devtools-client/queries/index.html +0 -1
package/dist/module.d.mts
CHANGED
|
@@ -112,12 +112,12 @@ interface ModuleOptions {
|
|
|
112
112
|
/**
|
|
113
113
|
* Run Convex beside Nuxt with one command. On the first `nuxt dev` (or
|
|
114
114
|
* `nuxt prepare`) in an app whose `dev` script is still the plain
|
|
115
|
-
* `nuxt dev`, the module rewrites it to `convex dev --start
|
|
116
|
-
* the Convex CLI starts the dev deployment,
|
|
117
|
-
*
|
|
118
|
-
* needed for local development. A `dev` script you
|
|
119
|
-
* or one that runs `convex dev` somewhere, is left
|
|
120
|
-
* never touch `package.json`.
|
|
115
|
+
* `nuxt dev`, the module rewrites it to `convex dev --start "nuxt dev"`:
|
|
116
|
+
* the Convex CLI starts the dev deployment, writes its URL to `.env.local`
|
|
117
|
+
* and starts Nuxt next to it, and the module reads that file in
|
|
118
|
+
* development — no `.env` needed for local development. A `dev` script you
|
|
119
|
+
* have already changed, or one that runs `convex dev` somewhere, is left
|
|
120
|
+
* alone. Set `false` to never touch `package.json`.
|
|
121
121
|
*/
|
|
122
122
|
devScript?: boolean;
|
|
123
123
|
}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useLogger, updateTemplates, defineNuxtModule, createResolver, addPlugin, hasNuxtModule, addServerPlugin, addPluginTemplate, addTypeTemplate, addImports, addServerImports, addComponent, addServerHandler, extendRouteRules, addRouteMiddleware } from '@nuxt/kit';
|
|
2
|
-
import { join, isAbsolute } from 'node:path';
|
|
2
|
+
import { dirname, join, isAbsolute, basename } from 'node:path';
|
|
3
|
+
import { detectAgent } from 'std-env';
|
|
3
4
|
import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import {
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { parseEnv } from 'node:util';
|
|
5
7
|
|
|
6
8
|
function resolveIntegrationState(explicit, installed, declared = installed) {
|
|
7
9
|
if (explicit === false) return { enabled: false, missingPackage: false };
|
|
@@ -110,11 +112,16 @@ function formatStartupSummary(url, functionsDir, integrations) {
|
|
|
110
112
|
return `Convex ${url || "(no URL)"} \xB7 functions: ${functionsDir}/ \xB7 integrations: ${enabled.join(", ") || "none"}`;
|
|
111
113
|
}
|
|
112
114
|
function isPackageInstalled(id, rootDir) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
return [rootDir, dirname(fileURLToPath(import.meta.url))].some(
|
|
116
|
+
(base) => nodeModulesPaths(base).some((dir) => existsSync(join(dir, id, "package.json")))
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function nodeModulesPaths(dir) {
|
|
120
|
+
const paths = [];
|
|
121
|
+
for (let current = dir; ; current = dirname(current)) {
|
|
122
|
+
if (basename(current) !== "node_modules") paths.push(join(current, "node_modules"));
|
|
123
|
+
if (dirname(current) === current) return paths;
|
|
116
124
|
}
|
|
117
|
-
return false;
|
|
118
125
|
}
|
|
119
126
|
function resolveDeploymentUrls(options, env) {
|
|
120
127
|
return {
|
|
@@ -122,6 +129,16 @@ function resolveDeploymentUrls(options, env) {
|
|
|
122
129
|
siteUrl: stripTrailingSlashes(options.siteUrl || env.NUXT_PUBLIC_CONVEX_SITE_URL || env.CONVEX_SITE_URL || "")
|
|
123
130
|
};
|
|
124
131
|
}
|
|
132
|
+
function deploymentEnv(rootDir, env, dev) {
|
|
133
|
+
if (!dev) return env;
|
|
134
|
+
let local;
|
|
135
|
+
try {
|
|
136
|
+
local = parseEnv(readFileSync(join(rootDir, ".env.local"), "utf8"));
|
|
137
|
+
} catch {
|
|
138
|
+
return env;
|
|
139
|
+
}
|
|
140
|
+
return { ...local, ...env };
|
|
141
|
+
}
|
|
125
142
|
|
|
126
143
|
const logger$1 = useLogger("nuxt-convex-module");
|
|
127
144
|
const DEFAULT_FUNCTIONS_DIR = "convex";
|
|
@@ -175,9 +192,9 @@ function watchConvexCodegen(nuxt) {
|
|
|
175
192
|
});
|
|
176
193
|
}
|
|
177
194
|
|
|
178
|
-
const PLAIN_NUXT_DEV = /^(?:npx )?(?:nuxt|nuxi) dev(?: [^&|;]*)?$/;
|
|
195
|
+
const PLAIN_NUXT_DEV = /^(?:npx )?(?:nuxt|nuxi) dev(?: [^&|;"']*)?$/;
|
|
179
196
|
function combinedDevScript(nuxtCommand) {
|
|
180
|
-
return `convex dev --start
|
|
197
|
+
return `convex dev --start "${nuxtCommand}"`;
|
|
181
198
|
}
|
|
182
199
|
function setupDevScript(rootDir) {
|
|
183
200
|
const path = join(rootDir, "package.json");
|
|
@@ -349,6 +366,8 @@ const module$1 = defineNuxtModule({
|
|
|
349
366
|
async setup(options, nuxt) {
|
|
350
367
|
const resolver = createResolver(import.meta.url);
|
|
351
368
|
nuxt.options.build.transpile.push(resolver.resolve("./runtime"));
|
|
369
|
+
nuxt.options.vite.resolve ??= {};
|
|
370
|
+
nuxt.options.vite.resolve.dedupe = [...nuxt.options.vite.resolve.dedupe ?? [], "convex"];
|
|
352
371
|
const { url, siteUrl } = applyRuntimeConfig(nuxt, options);
|
|
353
372
|
const diagnostics = validateModuleOptions({
|
|
354
373
|
url,
|
|
@@ -389,10 +408,17 @@ const module$1 = defineNuxtModule({
|
|
|
389
408
|
const result = setupDevScript(nuxt.options.rootDir);
|
|
390
409
|
if (result.changed) {
|
|
391
410
|
logger.info(`Set \`scripts.dev\` to \`${result.to}\` \u2014 one command now runs Convex beside Nuxt, no .env needed locally. Set \`convex.devScript: false\` to keep your own script.`);
|
|
411
|
+
hintAgent();
|
|
392
412
|
}
|
|
393
413
|
}
|
|
394
414
|
}
|
|
395
415
|
});
|
|
416
|
+
let agentHinted = false;
|
|
417
|
+
function hintAgent() {
|
|
418
|
+
if (agentHinted || !detectAgent().name) return;
|
|
419
|
+
agentHinted = true;
|
|
420
|
+
logger.info("An AI agent is running Nuxt. `CONVEX_AGENT_MODE=anonymous npx convex dev --once` sets up a local Convex deployment with no prompts and no account, writes .env.local and the codegen, then exits. For the setup steps and this module's API: `npx skills add https://nuxt-convex-module.dev --skill nuxt-convex-module -y`.");
|
|
421
|
+
}
|
|
396
422
|
function isDevtoolsUiEnabled(nuxt) {
|
|
397
423
|
const devtools = nuxt.options.devtools;
|
|
398
424
|
return typeof devtools === "boolean" ? devtools : devtools?.enabled !== false;
|
|
@@ -448,12 +474,13 @@ function registerSecurity(resolver) {
|
|
|
448
474
|
addServerPlugin(resolver.resolve("./runtime/nuxt/security"));
|
|
449
475
|
}
|
|
450
476
|
function applyRuntimeConfig(nuxt, options) {
|
|
451
|
-
const resolved = resolveDeploymentUrls(options, process.env);
|
|
477
|
+
const resolved = resolveDeploymentUrls(options, deploymentEnv(nuxt.options.rootDir, process.env, nuxt.options.dev));
|
|
452
478
|
const url = nuxt.options._prepare ? "" : resolved.url;
|
|
453
479
|
if (!url && !nuxt.options._prepare) {
|
|
454
480
|
logger.warn(
|
|
455
|
-
"No Convex deployment URL configured. Set NUXT_PUBLIC_CONVEX_URL or `convex.url` in nuxt.config
|
|
481
|
+
"No Convex deployment URL configured. Set NUXT_PUBLIC_CONVEX_URL or `convex.url` in nuxt.config, or run `npx convex dev`: it writes CONVEX_URL to .env.local, which the module reads in development."
|
|
456
482
|
);
|
|
483
|
+
hintAgent();
|
|
457
484
|
}
|
|
458
485
|
const siteUrl = resolved.siteUrl;
|
|
459
486
|
const crossDomainCallbackRoute = typeof options.betterAuth === "object" && options.betterAuth.crossDomainCallbackRoute || "";
|
|
@@ -497,6 +524,7 @@ function registerConvexApiPlugin(resolver, nuxt) {
|
|
|
497
524
|
if (nuxt.options.dev && !nuxt.options._prepare && !notifiedMissing) {
|
|
498
525
|
notifiedMissing = true;
|
|
499
526
|
logger.info(`Convex codegen not found in \`${functionsDir}/_generated\` \u2014 run \`npx convex dev\`. Convex features no-op until it exists.`);
|
|
527
|
+
hintAgent();
|
|
500
528
|
}
|
|
501
529
|
return "import { defineNuxtPlugin } from '#app'\nexport default defineNuxtPlugin(() => {})\n";
|
|
502
530
|
}
|
|
@@ -6,7 +6,7 @@ export function provideConvexAuthFromAuth0(options = {}) {
|
|
|
6
6
|
const client = options.client ?? useConvexOrThrow("provideConvexAuthFromAuth0");
|
|
7
7
|
return provideConvexAuth({ client, useAuth: useAuthFromAuth0 });
|
|
8
8
|
}
|
|
9
|
-
export const ConvexProviderWithAuth0 = defineComponent({
|
|
9
|
+
export const ConvexProviderWithAuth0 = /* @__PURE__ */ defineComponent({
|
|
10
10
|
name: "ConvexProviderWithAuth0",
|
|
11
11
|
props: {
|
|
12
12
|
client: { type: Object, default: void 0 }
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { defineNuxtRouteMiddleware, navigateTo,
|
|
1
|
+
import { defineNuxtRouteMiddleware, navigateTo, useRuntimeConfig } from "#app";
|
|
2
2
|
import { watch } from "vue";
|
|
3
3
|
import { useBetterAuth } from "../vue/use-better-auth.js";
|
|
4
|
-
import {
|
|
5
|
-
function loginTarget(to, loginPath) {
|
|
6
|
-
return { path: loginPath, query: { redirect: to.fullPath } };
|
|
7
|
-
}
|
|
8
|
-
export async function serverGuard(to, loginPath) {
|
|
9
|
-
const nuxtApp = useNuxtApp();
|
|
10
|
-
const event = useRequestEvent();
|
|
11
|
-
const authed = event ? await convexAuth(event).isAuthenticated() : false;
|
|
12
|
-
if (!authed && to.path !== loginPath) {
|
|
13
|
-
return nuxtApp.runWithContext(() => navigateTo(loginTarget(to, loginPath)));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
4
|
+
import { loginTarget, serverGuard } from "./server-guard.js";
|
|
16
5
|
function waitForSession(isPending) {
|
|
17
6
|
return new Promise((resolve) => {
|
|
18
7
|
const stop = watch(
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface GuardedRoute {
|
|
2
|
+
path: string;
|
|
3
|
+
fullPath: string;
|
|
4
|
+
}
|
|
5
|
+
/** Where a visitor who isn't signed in goes: the login page, with the page they asked for in `?redirect=`. */
|
|
6
|
+
export declare function loginTarget(to: GuardedRoute, loginPath: string): {
|
|
7
|
+
path: string;
|
|
8
|
+
query: {
|
|
9
|
+
redirect: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { navigateTo, useNuxtApp, useRequestEvent } from "#app";
|
|
2
|
+
import { convexAuth } from "./server.js";
|
|
3
|
+
export function loginTarget(to, loginPath) {
|
|
4
|
+
return { path: loginPath, query: { redirect: to.fullPath } };
|
|
5
|
+
}
|
|
6
|
+
export async function serverGuard(to, loginPath) {
|
|
7
|
+
const nuxtApp = useNuxtApp();
|
|
8
|
+
const event = useRequestEvent();
|
|
9
|
+
const authed = event ? await convexAuth(event).isAuthenticated() : false;
|
|
10
|
+
if (!authed && to.path !== loginPath) {
|
|
11
|
+
return nuxtApp.runWithContext(() => navigateTo(loginTarget(to, loginPath)));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -2,7 +2,7 @@ import { defineComponent, h, onErrorCaptured, ref, watch } from "vue";
|
|
|
2
2
|
import { useConvexAuth } from "../../vue/auth/index.js";
|
|
3
3
|
import { Authenticated } from "../../vue/auth/helpers.js";
|
|
4
4
|
import { useQuery } from "../../vue/composables/use-query.js";
|
|
5
|
-
const UserSubscription = defineComponent({
|
|
5
|
+
const UserSubscription = /* @__PURE__ */ defineComponent({
|
|
6
6
|
name: "UserSubscription",
|
|
7
7
|
props: {
|
|
8
8
|
getAuthUserFn: { type: Object, required: true }
|
|
@@ -15,7 +15,7 @@ const UserSubscription = defineComponent({
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
export const AuthBoundary = defineComponent({
|
|
18
|
+
export const AuthBoundary = /* @__PURE__ */ defineComponent({
|
|
19
19
|
name: "AuthBoundary",
|
|
20
20
|
props: {
|
|
21
21
|
/**
|
|
@@ -1,358 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
authConfig: import("convex/server").AuthConfig;
|
|
7
|
-
jwt?: {
|
|
8
|
-
expirationSeconds?: number;
|
|
9
|
-
definePayload?: (session: {
|
|
10
|
-
user: import("better-auth").User & Record<string, any>;
|
|
11
|
-
session: import("better-auth").Session & Record<string, any>;
|
|
12
|
-
}) => Promise<Record<string, any>> | Record<string, any> | undefined;
|
|
13
|
-
};
|
|
14
|
-
jwtExpirationSeconds?: number;
|
|
15
|
-
jwks?: string;
|
|
16
|
-
jwksRotateOnTokenGenerationError?: boolean;
|
|
17
|
-
options?: import("better-auth").BetterAuthOptions;
|
|
18
|
-
}) => {
|
|
19
|
-
id: "convex";
|
|
20
|
-
version: string;
|
|
21
|
-
init: (ctx: import("better-auth").AuthContext) => void;
|
|
22
|
-
hooks: {
|
|
23
|
-
before: ({
|
|
24
|
-
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
25
|
-
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
26
|
-
context: {
|
|
27
|
-
headers: Headers;
|
|
28
|
-
};
|
|
29
|
-
} | undefined>;
|
|
30
|
-
} | {
|
|
31
|
-
matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
|
|
32
|
-
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
33
|
-
context: import("better-auth").MiddlewareContext<import("better-auth").MiddlewareOptions, {
|
|
34
|
-
returned?: unknown | undefined;
|
|
35
|
-
responseHeaders?: Headers | undefined;
|
|
36
|
-
} & import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
|
|
37
|
-
options: import("better-auth").BetterAuthOptions;
|
|
38
|
-
trustedOrigins: string[];
|
|
39
|
-
trustedProviders: string[];
|
|
40
|
-
isTrustedOrigin: (url: string, settings?: {
|
|
41
|
-
allowRelativePaths: boolean;
|
|
42
|
-
}) => boolean;
|
|
43
|
-
oauthConfig: {
|
|
44
|
-
skipStateCookieCheck?: boolean | undefined;
|
|
45
|
-
storeStateStrategy: "database" | "cookie";
|
|
46
|
-
};
|
|
47
|
-
newSession: {
|
|
48
|
-
session: {
|
|
49
|
-
id: string;
|
|
50
|
-
createdAt: Date;
|
|
51
|
-
updatedAt: Date;
|
|
52
|
-
userId: string;
|
|
53
|
-
expiresAt: Date;
|
|
54
|
-
token: string;
|
|
55
|
-
ipAddress?: string | null | undefined;
|
|
56
|
-
userAgent?: string | null | undefined;
|
|
57
|
-
} & Record<string, any>;
|
|
58
|
-
user: {
|
|
59
|
-
id: string;
|
|
60
|
-
createdAt: Date;
|
|
61
|
-
updatedAt: Date;
|
|
62
|
-
email: string;
|
|
63
|
-
emailVerified: boolean;
|
|
64
|
-
name: string;
|
|
65
|
-
image?: string | null | undefined;
|
|
66
|
-
} & Record<string, any>;
|
|
67
|
-
} | null;
|
|
68
|
-
session: {
|
|
69
|
-
session: {
|
|
70
|
-
id: string;
|
|
71
|
-
createdAt: Date;
|
|
72
|
-
updatedAt: Date;
|
|
73
|
-
userId: string;
|
|
74
|
-
expiresAt: Date;
|
|
75
|
-
token: string;
|
|
76
|
-
ipAddress?: string | null | undefined;
|
|
77
|
-
userAgent?: string | null | undefined;
|
|
78
|
-
} & Record<string, any>;
|
|
79
|
-
user: {
|
|
80
|
-
id: string;
|
|
81
|
-
createdAt: Date;
|
|
82
|
-
updatedAt: Date;
|
|
83
|
-
email: string;
|
|
84
|
-
emailVerified: boolean;
|
|
85
|
-
name: string;
|
|
86
|
-
image?: string | null | undefined;
|
|
87
|
-
} & Record<string, any>;
|
|
88
|
-
} | null;
|
|
89
|
-
setNewSession: (session: {
|
|
90
|
-
session: {
|
|
91
|
-
id: string;
|
|
92
|
-
createdAt: Date;
|
|
93
|
-
updatedAt: Date;
|
|
94
|
-
userId: string;
|
|
95
|
-
expiresAt: Date;
|
|
96
|
-
token: string;
|
|
97
|
-
ipAddress?: string | null | undefined;
|
|
98
|
-
userAgent?: string | null | undefined;
|
|
99
|
-
} & Record<string, any>;
|
|
100
|
-
user: {
|
|
101
|
-
id: string;
|
|
102
|
-
createdAt: Date;
|
|
103
|
-
updatedAt: Date;
|
|
104
|
-
email: string;
|
|
105
|
-
emailVerified: boolean;
|
|
106
|
-
name: string;
|
|
107
|
-
image?: string | null | undefined;
|
|
108
|
-
} & Record<string, any>;
|
|
109
|
-
} | null) => void;
|
|
110
|
-
socialProviders: import("better-auth").OAuthProvider[];
|
|
111
|
-
authCookies: import("better-auth").BetterAuthCookies;
|
|
112
|
-
logger: ReturnType<(options?: import("better-auth").Logger | undefined) => import("better-auth").InternalLogger>;
|
|
113
|
-
rateLimit: {
|
|
114
|
-
enabled: boolean;
|
|
115
|
-
window: number;
|
|
116
|
-
max: number;
|
|
117
|
-
storage: "memory" | "database" | "secondary-storage";
|
|
118
|
-
} & Omit<import("better-auth").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
119
|
-
adapter: import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
|
|
120
|
-
internalAdapter: import("better-auth").InternalAdapter<import("better-auth").BetterAuthOptions>;
|
|
121
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-auth").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
|
|
122
|
-
secret: string;
|
|
123
|
-
secretConfig: string | import("better-auth").SecretConfig;
|
|
124
|
-
sessionConfig: {
|
|
125
|
-
updateAge: number;
|
|
126
|
-
expiresIn: number;
|
|
127
|
-
freshAge: number;
|
|
128
|
-
cookieRefreshCache: false | {
|
|
129
|
-
enabled: true;
|
|
130
|
-
updateAge: number;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
generateId: (options: {
|
|
134
|
-
model: import("better-auth").ModelNames;
|
|
135
|
-
size?: number | undefined;
|
|
136
|
-
}) => string | false;
|
|
137
|
-
secondaryStorage: import("better-auth").SecondaryStorage | undefined;
|
|
138
|
-
password: {
|
|
139
|
-
hash: (password: string) => Promise<string>;
|
|
140
|
-
verify: (data: {
|
|
141
|
-
password: string;
|
|
142
|
-
hash: string;
|
|
143
|
-
}) => Promise<boolean>;
|
|
144
|
-
config: {
|
|
145
|
-
minPasswordLength: number;
|
|
146
|
-
maxPasswordLength: number;
|
|
147
|
-
};
|
|
148
|
-
checkPassword: (userId: string, ctx: import("better-auth").GenericEndpointContext<import("better-auth").BetterAuthOptions>) => Promise<boolean>;
|
|
149
|
-
};
|
|
150
|
-
tables: import("better-auth").BetterAuthDBSchema;
|
|
151
|
-
runMigrations: () => Promise<void>;
|
|
152
|
-
publishTelemetry: (event: {
|
|
153
|
-
type: string;
|
|
154
|
-
anonymousId?: string | undefined;
|
|
155
|
-
payload: Record<string, any>;
|
|
156
|
-
}) => Promise<void>;
|
|
157
|
-
skipOriginCheck: boolean | string[];
|
|
158
|
-
skipCSRFCheck: boolean;
|
|
159
|
-
runInBackground: (promise: Promise<unknown>) => void;
|
|
160
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
|
|
161
|
-
}>;
|
|
162
|
-
}>;
|
|
163
|
-
})[];
|
|
164
|
-
after: {
|
|
165
|
-
matcher: (context: import("better-auth").HookEndpointContext) => boolean;
|
|
166
|
-
handler: import("better-auth/api").AuthMiddleware;
|
|
167
|
-
}[];
|
|
168
|
-
};
|
|
169
|
-
endpoints: {
|
|
170
|
-
getOpenIdConfig: import("better-auth").StrictEndpoint<"/convex/.well-known/openid-configuration", {
|
|
171
|
-
method: "GET";
|
|
172
|
-
metadata: {
|
|
173
|
-
isAction: false;
|
|
174
|
-
};
|
|
175
|
-
}, import("better-auth/plugins/oidc-provider").OIDCMetadata>;
|
|
176
|
-
getJwks: import("better-auth").StrictEndpoint<"/convex/jwks", {
|
|
177
|
-
method: "GET";
|
|
178
|
-
metadata: {
|
|
179
|
-
openapi: {
|
|
180
|
-
description: string;
|
|
181
|
-
responses: {
|
|
182
|
-
"200": {
|
|
183
|
-
description: string;
|
|
184
|
-
content: {
|
|
185
|
-
"application/json": {
|
|
186
|
-
schema: {
|
|
187
|
-
type: "object";
|
|
188
|
-
properties: {
|
|
189
|
-
keys: {
|
|
190
|
-
type: string;
|
|
191
|
-
description: string;
|
|
192
|
-
items: {
|
|
193
|
-
type: string;
|
|
194
|
-
properties: {
|
|
195
|
-
kid: {
|
|
196
|
-
type: string;
|
|
197
|
-
description: string;
|
|
198
|
-
};
|
|
199
|
-
kty: {
|
|
200
|
-
type: string;
|
|
201
|
-
description: string;
|
|
202
|
-
};
|
|
203
|
-
alg: {
|
|
204
|
-
type: string;
|
|
205
|
-
description: string;
|
|
206
|
-
};
|
|
207
|
-
use: {
|
|
208
|
-
type: string;
|
|
209
|
-
description: string;
|
|
210
|
-
enum: string[];
|
|
211
|
-
nullable: boolean;
|
|
212
|
-
};
|
|
213
|
-
n: {
|
|
214
|
-
type: string;
|
|
215
|
-
description: string;
|
|
216
|
-
nullable: boolean;
|
|
217
|
-
};
|
|
218
|
-
e: {
|
|
219
|
-
type: string;
|
|
220
|
-
description: string;
|
|
221
|
-
nullable: boolean;
|
|
222
|
-
};
|
|
223
|
-
crv: {
|
|
224
|
-
type: string;
|
|
225
|
-
description: string;
|
|
226
|
-
nullable: boolean;
|
|
227
|
-
};
|
|
228
|
-
x: {
|
|
229
|
-
type: string;
|
|
230
|
-
description: string;
|
|
231
|
-
nullable: boolean;
|
|
232
|
-
};
|
|
233
|
-
y: {
|
|
234
|
-
type: string;
|
|
235
|
-
description: string;
|
|
236
|
-
nullable: boolean;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
required: string[];
|
|
240
|
-
};
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
required: string[];
|
|
244
|
-
};
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
}, import("better-auth").JSONWebKeySet>;
|
|
252
|
-
getLatestJwks: import("better-auth").StrictEndpoint<"/convex/latest-jwks", {
|
|
253
|
-
isAction: boolean;
|
|
254
|
-
method: "POST";
|
|
255
|
-
metadata: {
|
|
256
|
-
SERVER_ONLY: true;
|
|
257
|
-
openapi: {
|
|
258
|
-
description: string;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
}, any[]>;
|
|
262
|
-
rotateKeys: import("better-auth").StrictEndpoint<"/convex/rotate-keys", {
|
|
263
|
-
isAction: boolean;
|
|
264
|
-
method: "POST";
|
|
265
|
-
metadata: {
|
|
266
|
-
SERVER_ONLY: true;
|
|
267
|
-
openapi: {
|
|
268
|
-
description: string;
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
}, any[]>;
|
|
272
|
-
getToken: import("better-auth").StrictEndpoint<"/convex/token", {
|
|
273
|
-
method: "GET";
|
|
274
|
-
requireHeaders: true;
|
|
275
|
-
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
276
|
-
session: {
|
|
277
|
-
session: Record<string, any> & {
|
|
278
|
-
id: string;
|
|
279
|
-
createdAt: Date;
|
|
280
|
-
updatedAt: Date;
|
|
281
|
-
userId: string;
|
|
282
|
-
expiresAt: Date;
|
|
283
|
-
token: string;
|
|
284
|
-
ipAddress?: string | null | undefined;
|
|
285
|
-
userAgent?: string | null | undefined;
|
|
286
|
-
};
|
|
287
|
-
user: Record<string, any> & {
|
|
288
|
-
id: string;
|
|
289
|
-
createdAt: Date;
|
|
290
|
-
updatedAt: Date;
|
|
291
|
-
email: string;
|
|
292
|
-
emailVerified: boolean;
|
|
293
|
-
name: string;
|
|
294
|
-
image?: string | null | undefined;
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
}>)[];
|
|
298
|
-
metadata: {
|
|
299
|
-
openapi: {
|
|
300
|
-
description: string;
|
|
301
|
-
responses: {
|
|
302
|
-
200: {
|
|
303
|
-
description: string;
|
|
304
|
-
content: {
|
|
305
|
-
"application/json": {
|
|
306
|
-
schema: {
|
|
307
|
-
type: "object";
|
|
308
|
-
properties: {
|
|
309
|
-
token: {
|
|
310
|
-
type: string;
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
}, {
|
|
321
|
-
token: string;
|
|
322
|
-
}>;
|
|
323
|
-
};
|
|
324
|
-
schema: {
|
|
325
|
-
jwks: {
|
|
326
|
-
fields: {
|
|
327
|
-
publicKey: {
|
|
328
|
-
type: "string";
|
|
329
|
-
required: true;
|
|
330
|
-
};
|
|
331
|
-
privateKey: {
|
|
332
|
-
type: "string";
|
|
333
|
-
required: true;
|
|
334
|
-
};
|
|
335
|
-
createdAt: {
|
|
336
|
-
type: "date";
|
|
337
|
-
required: true;
|
|
338
|
-
};
|
|
339
|
-
expiresAt: {
|
|
340
|
-
type: "date";
|
|
341
|
-
required: false;
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
user: {
|
|
346
|
-
readonly fields: {
|
|
347
|
-
readonly userId: {
|
|
348
|
-
readonly type: "string";
|
|
349
|
-
readonly required: false;
|
|
350
|
-
readonly input: false;
|
|
351
|
-
};
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
};
|
|
355
|
-
}>;
|
|
356
|
-
}[];
|
|
357
|
-
}>;
|
|
1
|
+
import { convexClient } from '@convex-dev/better-auth/client/plugins';
|
|
2
|
+
import { createAuthClient } from 'better-auth/vue';
|
|
3
|
+
export declare const authClient: ReturnType<typeof createAuthClient<{
|
|
4
|
+
plugins: ReturnType<typeof convexClient>[];
|
|
5
|
+
}>>;
|
|
358
6
|
export type AuthClient = typeof authClient;
|
|
@@ -1,70 +1,10 @@
|
|
|
1
1
|
import type { AuthTokenFetcher } from 'convex/browser';
|
|
2
2
|
import { type ComputedRef } from 'vue';
|
|
3
3
|
import { type AuthClient } from '#convex/auth-client';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly createdAt: Date;
|
|
9
|
-
readonly updatedAt: Date;
|
|
10
|
-
readonly email: string;
|
|
11
|
-
readonly emailVerified: boolean;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly image?: string | null | undefined;
|
|
14
|
-
readonly userId?: string | null | undefined;
|
|
15
|
-
};
|
|
16
|
-
readonly session: {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly createdAt: Date;
|
|
19
|
-
readonly updatedAt: Date;
|
|
20
|
-
readonly userId: string;
|
|
21
|
-
readonly expiresAt: Date;
|
|
22
|
-
readonly token: string;
|
|
23
|
-
readonly ipAddress?: string | null | undefined;
|
|
24
|
-
readonly userAgent?: string | null | undefined;
|
|
25
|
-
};
|
|
26
|
-
} | null;
|
|
27
|
-
readonly isPending: boolean;
|
|
28
|
-
readonly isRefetching: boolean;
|
|
29
|
-
readonly error: import("better-auth/client").BetterFetchError | null;
|
|
30
|
-
readonly refetch: (queryParams
|
|
31
|
-
/** The Better Auth client from `#convex/auth-client` — sign-in, sign-out and every plugin flow live here. */
|
|
32
|
-
?: {
|
|
33
|
-
query?: import("better-auth").SessionQueryParams;
|
|
34
|
-
} | undefined) => Promise<void>;
|
|
35
|
-
}, {
|
|
36
|
-
readonly data: {
|
|
37
|
-
readonly user: {
|
|
38
|
-
readonly id: string;
|
|
39
|
-
readonly createdAt: Date;
|
|
40
|
-
readonly updatedAt: Date;
|
|
41
|
-
readonly email: string;
|
|
42
|
-
readonly emailVerified: boolean;
|
|
43
|
-
readonly name: string;
|
|
44
|
-
readonly image?: string | null | undefined;
|
|
45
|
-
readonly userId?: string | null | undefined;
|
|
46
|
-
};
|
|
47
|
-
readonly session: {
|
|
48
|
-
readonly id: string;
|
|
49
|
-
readonly createdAt: Date;
|
|
50
|
-
readonly updatedAt: Date;
|
|
51
|
-
readonly userId: string;
|
|
52
|
-
readonly expiresAt: Date;
|
|
53
|
-
readonly token: string;
|
|
54
|
-
readonly ipAddress?: string | null | undefined;
|
|
55
|
-
readonly userAgent?: string | null | undefined;
|
|
56
|
-
};
|
|
57
|
-
} | null;
|
|
58
|
-
readonly isPending: boolean;
|
|
59
|
-
readonly isRefetching: boolean;
|
|
60
|
-
readonly error: import("better-auth/client").BetterFetchError | null;
|
|
61
|
-
readonly refetch: (queryParams
|
|
62
|
-
/** The Better Auth client from `#convex/auth-client` — sign-in, sign-out and every plugin flow live here. */
|
|
63
|
-
?: {
|
|
64
|
-
query?: import("better-auth").SessionQueryParams;
|
|
65
|
-
} | undefined) => Promise<void>;
|
|
66
|
-
}>>;
|
|
67
|
-
export type BetterAuthSession = ReturnType<typeof useClientSession>;
|
|
4
|
+
export type BetterAuthSession = AuthClient['useSession'] extends {
|
|
5
|
+
(): infer R;
|
|
6
|
+
(useFetch: any): any;
|
|
7
|
+
} ? R : never;
|
|
68
8
|
/** The signed-in user (loose — exact fields depend on your auth schema). */
|
|
69
9
|
export type BetterAuthUser = {
|
|
70
10
|
id: string;
|
|
@@ -109,4 +49,3 @@ export interface UseBetterAuthReturn {
|
|
|
109
49
|
* @public
|
|
110
50
|
*/
|
|
111
51
|
export declare function useBetterAuth(initialToken?: string | null): UseBetterAuthReturn;
|
|
112
|
-
export {};
|