nuxt-convex-module 0.9.1 → 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 +20 -7
- package/dist/module.json +1 -1
- package/dist/module.mjs +75 -39
- package/dist/runtime/auth0/vue/index.js +1 -1
- package/dist/runtime/better-auth/nuxt/middleware.d.ts +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/f9d540d6-1746-4214-8384-31e7759da89f.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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
+
/** The `convex.autoImports` option: every name, only the `Convex`-marked ones, or none. */
|
|
4
|
+
type AutoImports = boolean | 'prefixed';
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Configuration for the opt-in Better Auth integration.
|
|
5
8
|
*
|
|
@@ -31,7 +34,7 @@ interface BetterAuthModuleOptions {
|
|
|
31
34
|
*/
|
|
32
35
|
crossDomainCallbackRoute?: string;
|
|
33
36
|
/**
|
|
34
|
-
* Route the `auth` middleware sends unauthenticated visitors to (and never
|
|
37
|
+
* Route the `convex-auth` middleware sends unauthenticated visitors to (and never
|
|
35
38
|
* redirects away from, to avoid a self-redirect loop). The original
|
|
36
39
|
* destination is appended as a `?redirect=` query so the login page can
|
|
37
40
|
* return the visitor after sign-in. Defaults to `/login`.
|
|
@@ -88,6 +91,16 @@ interface ModuleOptions {
|
|
|
88
91
|
* `nuxt.config`) turns this off too.
|
|
89
92
|
*/
|
|
90
93
|
security?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Which names are auto-imported. `true` registers every composable, component
|
|
96
|
+
* and Nitro helper under its upstream name (`useQuery`, `<Authenticated>`,
|
|
97
|
+
* `fetchQuery`) and, where one exists, its prefixed twin (`useConvexQuery`).
|
|
98
|
+
* `'prefixed'` registers only names carrying `Convex` (`useConvexQuery`,
|
|
99
|
+
* `<ConvexImage>`, `provideConvexAuth`, `convexAuth`, …) so a bare name never
|
|
100
|
+
* collides with another module's; the rest stay importable from the subpath
|
|
101
|
+
* exports. `false` auto-imports nothing.
|
|
102
|
+
*/
|
|
103
|
+
autoImports?: AutoImports;
|
|
91
104
|
/** Route the Better Auth same-origin proxy is mounted at. Defaults to `/api/auth`. */
|
|
92
105
|
authRoute?: string;
|
|
93
106
|
/**
|
|
@@ -99,12 +112,12 @@ interface ModuleOptions {
|
|
|
99
112
|
/**
|
|
100
113
|
* Run Convex beside Nuxt with one command. On the first `nuxt dev` (or
|
|
101
114
|
* `nuxt prepare`) in an app whose `dev` script is still the plain
|
|
102
|
-
* `nuxt dev`, the module rewrites it to `convex dev --start
|
|
103
|
-
* the Convex CLI starts the dev deployment,
|
|
104
|
-
*
|
|
105
|
-
* needed for local development. A `dev` script you
|
|
106
|
-
* or one that runs `convex dev` somewhere, is left
|
|
107
|
-
* 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`.
|
|
108
121
|
*/
|
|
109
122
|
devScript?: boolean;
|
|
110
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");
|
|
@@ -207,6 +224,9 @@ function setupDevScript(rootDir) {
|
|
|
207
224
|
return { changed: true, from: dev, to };
|
|
208
225
|
}
|
|
209
226
|
|
|
227
|
+
function isAutoImported(name, mode) {
|
|
228
|
+
return mode === true || mode === "prefixed" && /convex/i.test(name);
|
|
229
|
+
}
|
|
210
230
|
const vue = (file) => `runtime/vue/${file}`;
|
|
211
231
|
const composable = (file) => vue(`composables/${file}`);
|
|
212
232
|
const asyncQuery = "runtime/nuxt/composables/use-async-query";
|
|
@@ -331,6 +351,7 @@ const module$1 = defineNuxtModule({
|
|
|
331
351
|
}
|
|
332
352
|
},
|
|
333
353
|
defaults: {
|
|
354
|
+
autoImports: true,
|
|
334
355
|
authRoute: "/api/auth",
|
|
335
356
|
devtools: true,
|
|
336
357
|
devScript: true
|
|
@@ -345,6 +366,8 @@ const module$1 = defineNuxtModule({
|
|
|
345
366
|
async setup(options, nuxt) {
|
|
346
367
|
const resolver = createResolver(import.meta.url);
|
|
347
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"];
|
|
348
371
|
const { url, siteUrl } = applyRuntimeConfig(nuxt, options);
|
|
349
372
|
const diagnostics = validateModuleOptions({
|
|
350
373
|
url,
|
|
@@ -362,9 +385,10 @@ const module$1 = defineNuxtModule({
|
|
|
362
385
|
registerConvexAliases(nuxt);
|
|
363
386
|
registerConvexApiPlugin(resolver, nuxt);
|
|
364
387
|
registerConvexTypeFallback(nuxt);
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
388
|
+
const autoImports = options.autoImports ?? true;
|
|
389
|
+
registerVueComposables(resolver, autoImports);
|
|
390
|
+
registerAuthComponents(resolver, autoImports);
|
|
391
|
+
const integrations = registerIntegrations(resolver, nuxt, options, autoImports);
|
|
368
392
|
watchConvexCodegen(nuxt);
|
|
369
393
|
if (nuxt.options.dev && options.devtools !== false && isDevtoolsUiEnabled(nuxt)) {
|
|
370
394
|
const { setupDevtools } = await import('./chunks/index.mjs');
|
|
@@ -384,15 +408,22 @@ const module$1 = defineNuxtModule({
|
|
|
384
408
|
const result = setupDevScript(nuxt.options.rootDir);
|
|
385
409
|
if (result.changed) {
|
|
386
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();
|
|
387
412
|
}
|
|
388
413
|
}
|
|
389
414
|
}
|
|
390
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
|
+
}
|
|
391
422
|
function isDevtoolsUiEnabled(nuxt) {
|
|
392
423
|
const devtools = nuxt.options.devtools;
|
|
393
424
|
return typeof devtools === "boolean" ? devtools : devtools?.enabled !== false;
|
|
394
425
|
}
|
|
395
|
-
function registerIntegrations(resolver, nuxt, options) {
|
|
426
|
+
function registerIntegrations(resolver, nuxt, options, autoImports) {
|
|
396
427
|
const report = (key, pkg, state) => {
|
|
397
428
|
if (state.missingPackage) {
|
|
398
429
|
logger.error(`\`convex.${key}\` is enabled but \`${pkg}\` is not installed. Run \`npm install ${pkg}\` or remove the option.`);
|
|
@@ -403,21 +434,21 @@ function registerIntegrations(resolver, nuxt, options) {
|
|
|
403
434
|
const resolve = (key, pkg) => report(key, pkg, resolveIntegrationState(options[key], isPackageInstalled(pkg, rootDir), isDeclaredDependency(pkg, rootDir)));
|
|
404
435
|
const betterAuth = resolve("betterAuth", "@convex-dev/better-auth");
|
|
405
436
|
if (betterAuth) {
|
|
406
|
-
registerBetterAuth(resolver, options.authRoute || "/api/auth");
|
|
437
|
+
registerBetterAuth(resolver, options.authRoute || "/api/auth", autoImports);
|
|
407
438
|
} else {
|
|
408
439
|
registerBaseConvexClient(resolver);
|
|
409
440
|
}
|
|
410
441
|
const clerk = resolve("clerk", "@clerk/vue");
|
|
411
442
|
if (clerk) {
|
|
412
|
-
registerClerk(resolver);
|
|
443
|
+
registerClerk(resolver, autoImports);
|
|
413
444
|
}
|
|
414
445
|
const auth0 = resolve("auth0", "@auth0/auth0-vue");
|
|
415
446
|
if (auth0) {
|
|
416
|
-
registerAuth0(resolver);
|
|
447
|
+
registerAuth0(resolver, autoImports);
|
|
417
448
|
}
|
|
418
449
|
const polar = resolve("polar", "@convex-dev/polar");
|
|
419
450
|
if (polar) {
|
|
420
|
-
registerPolarComponents(resolver);
|
|
451
|
+
registerPolarComponents(resolver, autoImports);
|
|
421
452
|
}
|
|
422
453
|
const security = report("security", "nuxt-security", resolveSecurityState(nuxt, options.security));
|
|
423
454
|
if (security) {
|
|
@@ -443,12 +474,13 @@ function registerSecurity(resolver) {
|
|
|
443
474
|
addServerPlugin(resolver.resolve("./runtime/nuxt/security"));
|
|
444
475
|
}
|
|
445
476
|
function applyRuntimeConfig(nuxt, options) {
|
|
446
|
-
const resolved = resolveDeploymentUrls(options, process.env);
|
|
477
|
+
const resolved = resolveDeploymentUrls(options, deploymentEnv(nuxt.options.rootDir, process.env, nuxt.options.dev));
|
|
447
478
|
const url = nuxt.options._prepare ? "" : resolved.url;
|
|
448
479
|
if (!url && !nuxt.options._prepare) {
|
|
449
480
|
logger.warn(
|
|
450
|
-
"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."
|
|
451
482
|
);
|
|
483
|
+
hintAgent();
|
|
452
484
|
}
|
|
453
485
|
const siteUrl = resolved.siteUrl;
|
|
454
486
|
const crossDomainCallbackRoute = typeof options.betterAuth === "object" && options.betterAuth.crossDomainCallbackRoute || "";
|
|
@@ -492,6 +524,7 @@ function registerConvexApiPlugin(resolver, nuxt) {
|
|
|
492
524
|
if (nuxt.options.dev && !nuxt.options._prepare && !notifiedMissing) {
|
|
493
525
|
notifiedMissing = true;
|
|
494
526
|
logger.info(`Convex codegen not found in \`${functionsDir}/_generated\` \u2014 run \`npx convex dev\`. Convex features no-op until it exists.`);
|
|
527
|
+
hintAgent();
|
|
495
528
|
}
|
|
496
529
|
return "import { defineNuxtPlugin } from '#app'\nexport default defineNuxtPlugin(() => {})\n";
|
|
497
530
|
}
|
|
@@ -518,19 +551,22 @@ function registerConvexTypeFallback(nuxt) {
|
|
|
518
551
|
getContents: () => convexTypeFallbackContents(hasGeneratedApi(nuxt.options.rootDir, functionsDir), functionsDir)
|
|
519
552
|
}, { nuxt: true, nitro: true });
|
|
520
553
|
}
|
|
521
|
-
function registerVueComposables(resolver) {
|
|
522
|
-
registerIntegrationImports(resolver, "core");
|
|
554
|
+
function registerVueComposables(resolver, autoImports) {
|
|
555
|
+
registerIntegrationImports(resolver, "core", autoImports);
|
|
523
556
|
}
|
|
524
|
-
function registerAuthComponents(resolver) {
|
|
525
|
-
registerComponents(resolver, "core");
|
|
557
|
+
function registerAuthComponents(resolver, autoImports) {
|
|
558
|
+
registerComponents(resolver, "core", autoImports);
|
|
526
559
|
}
|
|
527
|
-
function registerIntegrationImports(resolver, integration) {
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
560
|
+
function registerIntegrationImports(resolver, integration, autoImports) {
|
|
561
|
+
const kept = (entries) => entries.filter((entry) => isAutoImported(entry.name, autoImports)).map((entry) => ({ ...entry, from: resolver.resolve(`./${entry.from}`) }));
|
|
562
|
+
const app = kept(APP_IMPORTS[integration]);
|
|
563
|
+
const server = kept(SERVER_IMPORTS[integration]);
|
|
564
|
+
if (app.length > 0) addImports(app);
|
|
565
|
+
if (server.length > 0) addServerImports(server);
|
|
531
566
|
}
|
|
532
|
-
function registerComponents(resolver, integration) {
|
|
567
|
+
function registerComponents(resolver, integration, autoImports) {
|
|
533
568
|
for (const { name, from } of APP_COMPONENTS[integration]) {
|
|
569
|
+
if (!isAutoImported(name, autoImports)) continue;
|
|
534
570
|
addComponent({ name, filePath: resolver.resolve(`./${from}`), export: name });
|
|
535
571
|
}
|
|
536
572
|
}
|
|
@@ -538,11 +574,11 @@ const AUTH_PROXY_SECURITY_RULES = {
|
|
|
538
574
|
xssValidator: false,
|
|
539
575
|
allowedMethodsRestricter: { methods: ["GET", "HEAD", "POST", "OPTIONS"] }
|
|
540
576
|
};
|
|
541
|
-
function registerBetterAuth(resolver, authRoute) {
|
|
577
|
+
function registerBetterAuth(resolver, authRoute, autoImports) {
|
|
542
578
|
addPlugin(resolver.resolve("./runtime/better-auth/vue/plugin.client"));
|
|
543
579
|
addPlugin(resolver.resolve("./runtime/better-auth/vue/plugin.server"));
|
|
544
|
-
registerIntegrationImports(resolver, "betterAuth");
|
|
545
|
-
registerComponents(resolver, "betterAuth");
|
|
580
|
+
registerIntegrationImports(resolver, "betterAuth", autoImports);
|
|
581
|
+
registerComponents(resolver, "betterAuth", autoImports);
|
|
546
582
|
addServerHandler({
|
|
547
583
|
route: `${authRoute}/**`,
|
|
548
584
|
handler: resolver.resolve("./runtime/better-auth/nuxt/proxy")
|
|
@@ -553,7 +589,7 @@ function registerBetterAuth(resolver, authRoute) {
|
|
|
553
589
|
security: AUTH_PROXY_SECURITY_RULES
|
|
554
590
|
});
|
|
555
591
|
addRouteMiddleware({
|
|
556
|
-
name: "auth",
|
|
592
|
+
name: "convex-auth",
|
|
557
593
|
path: resolver.resolve("./runtime/better-auth/nuxt/middleware"),
|
|
558
594
|
global: false
|
|
559
595
|
});
|
|
@@ -561,16 +597,16 @@ function registerBetterAuth(resolver, authRoute) {
|
|
|
561
597
|
function registerBaseConvexClient(resolver) {
|
|
562
598
|
addPlugin(resolver.resolve("./runtime/vue/plugin"));
|
|
563
599
|
}
|
|
564
|
-
function registerClerk(resolver) {
|
|
565
|
-
registerIntegrationImports(resolver, "clerk");
|
|
566
|
-
registerComponents(resolver, "clerk");
|
|
600
|
+
function registerClerk(resolver, autoImports) {
|
|
601
|
+
registerIntegrationImports(resolver, "clerk", autoImports);
|
|
602
|
+
registerComponents(resolver, "clerk", autoImports);
|
|
567
603
|
}
|
|
568
|
-
function registerAuth0(resolver) {
|
|
569
|
-
registerIntegrationImports(resolver, "auth0");
|
|
570
|
-
registerComponents(resolver, "auth0");
|
|
604
|
+
function registerAuth0(resolver, autoImports) {
|
|
605
|
+
registerIntegrationImports(resolver, "auth0", autoImports);
|
|
606
|
+
registerComponents(resolver, "auth0", autoImports);
|
|
571
607
|
}
|
|
572
|
-
function registerPolarComponents(resolver) {
|
|
573
|
-
registerComponents(resolver, "polar");
|
|
608
|
+
function registerPolarComponents(resolver, autoImports) {
|
|
609
|
+
registerComponents(resolver, "polar", autoImports);
|
|
574
610
|
}
|
|
575
611
|
|
|
576
612
|
export { module$1 as default };
|
|
@@ -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
|
/**
|