@lupinum/better-convex-nuxt 0.8.0-beta.40
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/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +201 -0
- package/README.md +151 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/dist/module.d.mts +55 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +309 -0
- package/dist/runtime/auth/auth-identity.d.ts +31 -0
- package/dist/runtime/auth/auth-identity.js +21 -0
- package/dist/runtime/auth/better-auth-browser-adapter.d.ts +33 -0
- package/dist/runtime/auth/better-auth-browser-adapter.js +215 -0
- package/dist/runtime/auth/client-engine-types.d.ts +4 -0
- package/dist/runtime/auth/client-engine-types.js +0 -0
- package/dist/runtime/auth/integrated-client.d.ts +25 -0
- package/dist/runtime/auth/integrated-client.js +132 -0
- package/dist/runtime/auth/operation-tracker.d.ts +7 -0
- package/dist/runtime/auth/operation-tracker.js +14 -0
- package/dist/runtime/auth/session-synchronization.d.ts +23 -0
- package/dist/runtime/auth/session-synchronization.js +156 -0
- package/dist/runtime/auth/token-fetcher.d.ts +66 -0
- package/dist/runtime/auth/token-fetcher.js +131 -0
- package/dist/runtime/auth/validate-auth-client-definition.d.ts +12 -0
- package/dist/runtime/auth/validate-auth-client-definition.js +47 -0
- package/dist/runtime/auth-client/convex-client-plugin.d.ts +31 -0
- package/dist/runtime/auth-client/convex-client-plugin.js +14 -0
- package/dist/runtime/auth-client/definition-types.d.ts +6 -0
- package/dist/runtime/auth-client/definition-types.js +0 -0
- package/dist/runtime/auth-client/empty-definition.d.ts +2 -0
- package/dist/runtime/auth-client/empty-definition.js +2 -0
- package/dist/runtime/auth-client/index.d.ts +71 -0
- package/dist/runtime/auth-client/index.js +3 -0
- package/dist/runtime/cli/auth-schema.d.ts +2 -0
- package/dist/runtime/cli/auth-schema.js +169 -0
- package/dist/runtime/cli/convex.d.ts +11 -0
- package/dist/runtime/cli/convex.js +274 -0
- package/dist/runtime/composables/useConvex.d.ts +4 -0
- package/dist/runtime/composables/useConvex.js +9 -0
- package/dist/runtime/composables/useConvexAction.d.ts +4 -0
- package/dist/runtime/composables/useConvexAction.js +18 -0
- package/dist/runtime/composables/useConvexAttachment.d.ts +9 -0
- package/dist/runtime/composables/useConvexAttachment.js +14 -0
- package/dist/runtime/composables/useConvexAuth.d.ts +10 -0
- package/dist/runtime/composables/useConvexAuth.js +37 -0
- package/dist/runtime/composables/useConvexConfig.d.ts +12 -0
- package/dist/runtime/composables/useConvexConfig.js +7 -0
- package/dist/runtime/composables/useConvexConnectionState.d.ts +33 -0
- package/dist/runtime/composables/useConvexConnectionState.js +24 -0
- package/dist/runtime/composables/useConvexFileUpload.d.ts +169 -0
- package/dist/runtime/composables/useConvexFileUpload.js +198 -0
- package/dist/runtime/composables/useConvexMutation.d.ts +13 -0
- package/dist/runtime/composables/useConvexMutation.js +24 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +13 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.js +256 -0
- package/dist/runtime/composables/useConvexQuery.d.ts +19 -0
- package/dist/runtime/composables/useConvexQuery.js +308 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.d.ts +33 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.js +308 -0
- package/dist/runtime/convex-auth/adapter/define-functions.d.ts +160 -0
- package/dist/runtime/convex-auth/adapter/define-functions.js +497 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.d.ts +16 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.js +332 -0
- package/dist/runtime/convex-auth/adapter/metadata.d.ts +44 -0
- package/dist/runtime/convex-auth/adapter/metadata.js +91 -0
- package/dist/runtime/convex-auth/adapter/query.d.ts +32 -0
- package/dist/runtime/convex-auth/adapter/query.js +275 -0
- package/dist/runtime/convex-auth/adapter/relationships.d.ts +20 -0
- package/dist/runtime/convex-auth/adapter/relationships.js +128 -0
- package/dist/runtime/convex-auth/component/_generated/api.js +5 -0
- package/dist/runtime/convex-auth/component/_generated/component.d.ts +116 -0
- package/dist/runtime/convex-auth/component/_generated/component.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/dataModel.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/server.js +16 -0
- package/dist/runtime/convex-auth/component/adapter.d.ts +142 -0
- package/dist/runtime/convex-auth/component/adapter.js +16 -0
- package/dist/runtime/convex-auth/component/convex.config.d.ts +2 -0
- package/dist/runtime/convex-auth/component/convex.config.js +3 -0
- package/dist/runtime/convex-auth/component/schema.d.ts +799 -0
- package/dist/runtime/convex-auth/component/schema.js +180 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.d.ts +2094 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.js +2161 -0
- package/dist/runtime/convex-auth/context.d.ts +5 -0
- package/dist/runtime/convex-auth/context.js +8 -0
- package/dist/runtime/convex-auth/create-auth-component.d.ts +41 -0
- package/dist/runtime/convex-auth/create-auth-component.js +157 -0
- package/dist/runtime/convex-auth/index.d.ts +11 -0
- package/dist/runtime/convex-auth/index.js +7 -0
- package/dist/runtime/convex-auth/internal-session.d.ts +2 -0
- package/dist/runtime/convex-auth/internal-session.js +1 -0
- package/dist/runtime/convex-auth/jwks-rotation.d.ts +58 -0
- package/dist/runtime/convex-auth/jwks-rotation.js +163 -0
- package/dist/runtime/convex-auth/oauth-live-access.d.ts +17 -0
- package/dist/runtime/convex-auth/oauth-live-access.js +78 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.d.ts +10 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.js +170 -0
- package/dist/runtime/convex-auth/oauth-resource.d.ts +39 -0
- package/dist/runtime/convex-auth/oauth-resource.js +118 -0
- package/dist/runtime/convex-auth/oauth-security.d.ts +82 -0
- package/dist/runtime/convex-auth/oauth-security.js +454 -0
- package/dist/runtime/convex-auth/origin.d.ts +4 -0
- package/dist/runtime/convex-auth/origin.js +9 -0
- package/dist/runtime/convex-auth/plugin.d.ts +18 -0
- package/dist/runtime/convex-auth/plugin.js +605 -0
- package/dist/runtime/convex-auth/provider.d.ts +2 -0
- package/dist/runtime/convex-auth/provider.js +11 -0
- package/dist/runtime/convex-auth/test.d.ts +410 -0
- package/dist/runtime/convex-auth/test.js +9 -0
- package/dist/runtime/convex-auth/types.d.ts +18 -0
- package/dist/runtime/convex-auth/types.js +0 -0
- package/dist/runtime/convex-auth/user-projection.d.ts +106 -0
- package/dist/runtime/convex-auth/user-projection.js +128 -0
- package/dist/runtime/devtools/auth-proxy-registry.d.ts +4 -0
- package/dist/runtime/devtools/auth-proxy-registry.js +47 -0
- package/dist/runtime/devtools/bridge-setup.d.ts +21 -0
- package/dist/runtime/devtools/bridge-setup.js +165 -0
- package/dist/runtime/devtools/path-utils.d.ts +2 -0
- package/dist/runtime/devtools/path-utils.js +12 -0
- package/dist/runtime/devtools/server.d.ts +2 -0
- package/dist/runtime/devtools/server.js +108 -0
- package/dist/runtime/devtools/setup-client.d.ts +16 -0
- package/dist/runtime/devtools/setup-client.js +43 -0
- package/dist/runtime/devtools/sink.d.ts +18 -0
- package/dist/runtime/devtools/sink.js +110 -0
- package/dist/runtime/devtools/transport.d.ts +16 -0
- package/dist/runtime/devtools/transport.js +149 -0
- package/dist/runtime/devtools/types.d.ts +167 -0
- package/dist/runtime/devtools/types.js +1 -0
- package/dist/runtime/devtools/ui/dist/200.html +1 -0
- package/dist/runtime/devtools/ui/dist/404.html +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/C4MASuCh.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DJHkqtZq.js +3 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DWwrCltl.js +2 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DZ_UiYoH.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/_m9ujb-i.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/latest.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/meta/better-convex-nuxt-devtools.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/entry.DpFDKYZ5.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-404.DYUJo5xt.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-500.DQdoJJXg.css +1 -0
- package/dist/runtime/devtools/ui/dist/convex-logo.svg +5 -0
- package/dist/runtime/devtools/ui/dist/index.html +1 -0
- package/dist/runtime/errors/index.d.ts +7 -0
- package/dist/runtime/errors/index.js +5 -0
- package/dist/runtime/middleware/convex-auth.global.d.ts +2 -0
- package/dist/runtime/middleware/convex-auth.global.js +31 -0
- package/dist/runtime/plugin.auth.client.d.ts +3 -0
- package/dist/runtime/plugin.auth.client.js +217 -0
- package/dist/runtime/plugin.client.d.ts +3 -0
- package/dist/runtime/plugin.client.js +43 -0
- package/dist/runtime/plugin.server.d.ts +12 -0
- package/dist/runtime/plugin.server.js +98 -0
- package/dist/runtime/plugins/convex-call-error-payload.d.ts +14 -0
- package/dist/runtime/plugins/convex-call-error-payload.js +12 -0
- package/dist/runtime/runtime-context.d.ts +26 -0
- package/dist/runtime/runtime-context.js +48 -0
- package/dist/runtime/server/api/auth/[...].d.ts +10 -0
- package/dist/runtime/server/api/auth/[...].js +509 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.d.ts +2 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.js +6 -0
- package/dist/runtime/server/api/auth/body-size.d.ts +15 -0
- package/dist/runtime/server/api/auth/body-size.js +179 -0
- package/dist/runtime/server/api/auth/headers.d.ts +6 -0
- package/dist/runtime/server/api/auth/headers.js +98 -0
- package/dist/runtime/server/api/auth/jwks.d.ts +2 -0
- package/dist/runtime/server/api/auth/jwks.js +6 -0
- package/dist/runtime/server/api/auth/security.d.ts +14 -0
- package/dist/runtime/server/api/auth/security.js +85 -0
- package/dist/runtime/server/api/release-fingerprint.d.ts +2 -0
- package/dist/runtime/server/api/release-fingerprint.js +36 -0
- package/dist/runtime/server/index.d.ts +1 -0
- package/dist/runtime/server/index.js +3 -0
- package/dist/runtime/server/plugins/runtime-config.d.ts +7 -0
- package/dist/runtime/server/plugins/runtime-config.js +7 -0
- package/dist/runtime/server/utils/auth-snapshot.d.ts +26 -0
- package/dist/runtime/server/utils/auth-snapshot.js +165 -0
- package/dist/runtime/server/utils/http.d.ts +16 -0
- package/dist/runtime/server/utils/http.js +133 -0
- package/dist/runtime/server/utils/server-convex-caller.d.ts +31 -0
- package/dist/runtime/server/utils/server-convex-caller.js +151 -0
- package/dist/runtime/server/utils/server-convex-options.d.ts +83 -0
- package/dist/runtime/server/utils/server-convex-options.js +69 -0
- package/dist/runtime/server/utils/signed-client-ip.d.ts +6 -0
- package/dist/runtime/server/utils/signed-client-ip.js +29 -0
- package/dist/runtime/server/utils/ssr-auth-headers.d.ts +26 -0
- package/dist/runtime/server/utils/ssr-auth-headers.js +49 -0
- package/dist/runtime/server/utils/token-exchange.d.ts +27 -0
- package/dist/runtime/server/utils/token-exchange.js +96 -0
- package/dist/runtime/shared/auth-cookie.d.ts +4 -0
- package/dist/runtime/shared/auth-cookie.js +25 -0
- package/dist/runtime/shared/auth-origin.d.ts +15 -0
- package/dist/runtime/shared/auth-origin.js +42 -0
- package/dist/runtime/shared/bounded-stream.d.ts +2 -0
- package/dist/runtime/shared/bounded-stream.js +50 -0
- package/dist/runtime/shared/client-ip.d.ts +21 -0
- package/dist/runtime/shared/client-ip.js +123 -0
- package/dist/runtime/shared/release-fingerprint.d.ts +5 -0
- package/dist/runtime/shared/release-fingerprint.js +17 -0
- package/dist/runtime/types.d.ts +19 -0
- package/dist/runtime/utils/auth-config.d.ts +24 -0
- package/dist/runtime/utils/auth-config.js +45 -0
- package/dist/runtime/utils/auth-contract.d.ts +22 -0
- package/dist/runtime/utils/auth-contract.js +0 -0
- package/dist/runtime/utils/auth-errors.d.ts +5 -0
- package/dist/runtime/utils/auth-errors.js +22 -0
- package/dist/runtime/utils/auth-identity-state.d.ts +4 -0
- package/dist/runtime/utils/auth-identity-state.js +8 -0
- package/dist/runtime/utils/auth-pending-state.d.ts +13 -0
- package/dist/runtime/utils/auth-pending-state.js +4 -0
- package/dist/runtime/utils/auth-pending.d.ts +10 -0
- package/dist/runtime/utils/auth-pending.js +30 -0
- package/dist/runtime/utils/auth-route-protection.d.ts +16 -0
- package/dist/runtime/utils/auth-route-protection.js +58 -0
- package/dist/runtime/utils/auth-status.d.ts +47 -0
- package/dist/runtime/utils/auth-status.js +8 -0
- package/dist/runtime/utils/bounded-convex-fetch.d.ts +18 -0
- package/dist/runtime/utils/bounded-convex-fetch.js +152 -0
- package/dist/runtime/utils/callable-devtools.d.ts +17 -0
- package/dist/runtime/utils/callable-devtools.js +49 -0
- package/dist/runtime/utils/callable-observer.d.ts +2 -0
- package/dist/runtime/utils/callable-observer.js +1 -0
- package/dist/runtime/utils/composable-scope.d.ts +2 -0
- package/dist/runtime/utils/composable-scope.js +8 -0
- package/dist/runtime/utils/config-defaults.d.ts +8 -0
- package/dist/runtime/utils/config-defaults.js +8 -0
- package/dist/runtime/utils/convex-cache.d.ts +68 -0
- package/dist/runtime/utils/convex-cache.js +47 -0
- package/dist/runtime/utils/convex-config.d.ts +16 -0
- package/dist/runtime/utils/convex-config.js +50 -0
- package/dist/runtime/utils/convex-shared.d.ts +67 -0
- package/dist/runtime/utils/convex-shared.js +134 -0
- package/dist/runtime/utils/identity-changed-error.d.ts +4 -0
- package/dist/runtime/utils/identity-changed-error.js +12 -0
- package/dist/runtime/utils/identity-key.d.ts +19 -0
- package/dist/runtime/utils/identity-key.js +10 -0
- package/dist/runtime/utils/integrated-auth-client.d.ts +5 -0
- package/dist/runtime/utils/integrated-auth-client.js +0 -0
- package/dist/runtime/utils/logger.d.ts +42 -0
- package/dist/runtime/utils/logger.js +190 -0
- package/dist/runtime/utils/mime-type.d.ts +33 -0
- package/dist/runtime/utils/mime-type.js +10 -0
- package/dist/runtime/utils/query-execution-gate.d.ts +47 -0
- package/dist/runtime/utils/query-execution-gate.js +63 -0
- package/dist/runtime/utils/query-execution.d.ts +8 -0
- package/dist/runtime/utils/query-execution.js +19 -0
- package/dist/runtime/utils/query-foundation.d.ts +20 -0
- package/dist/runtime/utils/query-foundation.js +39 -0
- package/dist/runtime/utils/query-state.d.ts +12 -0
- package/dist/runtime/utils/query-state.js +12 -0
- package/dist/runtime/utils/reactive-args.d.ts +5 -0
- package/dist/runtime/utils/reactive-args.js +42 -0
- package/dist/runtime/utils/runtime-config-normalize.d.ts +22 -0
- package/dist/runtime/utils/runtime-config-normalize.js +28 -0
- package/dist/runtime/utils/runtime-config.d.ts +4 -0
- package/dist/runtime/utils/runtime-config.js +8 -0
- package/dist/runtime/utils/sanitize-diagnostic.d.ts +6 -0
- package/dist/runtime/utils/sanitize-diagnostic.js +81 -0
- package/dist/runtime/utils/shared-helpers.d.ts +46 -0
- package/dist/runtime/utils/shared-helpers.js +139 -0
- package/dist/runtime/utils/site-url.d.ts +4 -0
- package/dist/runtime/utils/site-url.js +15 -0
- package/dist/runtime/utils/ssr-pagination-state.d.ts +3 -0
- package/dist/runtime/utils/ssr-pagination-state.js +3 -0
- package/dist/runtime/utils/types.d.ts +29 -0
- package/dist/runtime/utils/types.js +0 -0
- package/dist/runtime/utils/upload-core.d.ts +16 -0
- package/dist/runtime/utils/upload-core.js +116 -0
- package/dist/types.d.mts +21 -0
- package/package.json +253 -0
- package/security/upstream-convex-better-auth.json +477 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useState, useRuntimeConfig, useRequestEvent } from "#app";
|
|
2
|
+
import { ANONYMOUS_IDENTITY, toAuthenticatedIdentity } from "./auth/auth-identity.js";
|
|
3
|
+
import { resolveServerAuthSnapshot } from "./server/utils/auth-snapshot.js";
|
|
4
|
+
import { applyConvexAuthSsrHeaders } from "./server/utils/ssr-auth-headers.js";
|
|
5
|
+
import { buildMissingSiteUrlMessage } from "./utils/auth-errors.js";
|
|
6
|
+
import { useConvexIdentityState } from "./utils/auth-identity-state.js";
|
|
7
|
+
import { createLogger, getLogLevel } from "./utils/logger.js";
|
|
8
|
+
import { getConvexRuntimeConfig } from "./utils/runtime-config.js";
|
|
9
|
+
import { filterBetterAuthCookies } from "./utils/shared-helpers.js";
|
|
10
|
+
export default defineNuxtPlugin(async () => {
|
|
11
|
+
const config = useRuntimeConfig();
|
|
12
|
+
const convexConfig = getConvexRuntimeConfig();
|
|
13
|
+
const authConfig = convexConfig.auth;
|
|
14
|
+
const publicConvex = config.public.convex;
|
|
15
|
+
const logLevel = getLogLevel(publicConvex);
|
|
16
|
+
const logger = createLogger(logLevel);
|
|
17
|
+
const endInit = logger.time("plugin:init (server)");
|
|
18
|
+
if (authConfig === false) {
|
|
19
|
+
throw new Error("[better-convex-nuxt] auth server plugin loaded in a no-auth build");
|
|
20
|
+
}
|
|
21
|
+
const event = useRequestEvent();
|
|
22
|
+
if (!event) {
|
|
23
|
+
logger.auth({
|
|
24
|
+
phase: "init",
|
|
25
|
+
outcome: "error",
|
|
26
|
+
details: { code: "AUTH_REQUEST_EVENT_MISSING" }
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const requestMethod = event.method || "GET";
|
|
31
|
+
const requestId = crypto.randomUUID();
|
|
32
|
+
const traceEnabled = logLevel === "debug";
|
|
33
|
+
const convexIdentity = useConvexIdentityState();
|
|
34
|
+
const cookieHeader = event.headers.get("cookie");
|
|
35
|
+
const hasSupportedBetterAuthCookie = filterBetterAuthCookies(cookieHeader) !== null;
|
|
36
|
+
const siteUrl = convexConfig.siteUrl;
|
|
37
|
+
if (!siteUrl) {
|
|
38
|
+
applyConvexAuthSsrHeaders(event, {
|
|
39
|
+
hasBetterAuthCookie: hasSupportedBetterAuthCookie,
|
|
40
|
+
serializesToken: false
|
|
41
|
+
});
|
|
42
|
+
const message = buildMissingSiteUrlMessage();
|
|
43
|
+
const convexAuthError2 = useState("convex:authError", () => null);
|
|
44
|
+
convexAuthError2.value = message;
|
|
45
|
+
endInit();
|
|
46
|
+
logger.auth({
|
|
47
|
+
phase: "init",
|
|
48
|
+
outcome: "error",
|
|
49
|
+
details: { code: "AUTH_SITE_URL_MISSING" }
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const logAuth = (phase, outcome, details) => {
|
|
54
|
+
logger.auth({
|
|
55
|
+
phase,
|
|
56
|
+
outcome,
|
|
57
|
+
details: traceEnabled ? { requestId, method: requestMethod, ...details } : details
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
if (traceEnabled) {
|
|
61
|
+
logAuth("ssr.auth.started", "success", {
|
|
62
|
+
hasSupportedAuthCookie: hasSupportedBetterAuthCookie
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const convexAuthError = useState("convex:authError", () => null);
|
|
66
|
+
const convexAuthWaterfall = useState("convex:authWaterfall", () => null);
|
|
67
|
+
const snapshotStartedAt = Date.now();
|
|
68
|
+
const snapshot = await resolveServerAuthSnapshot({
|
|
69
|
+
event,
|
|
70
|
+
siteUrl,
|
|
71
|
+
cookieHeader,
|
|
72
|
+
requestId,
|
|
73
|
+
trackWaterfall: import.meta.dev,
|
|
74
|
+
trustedClientIpHeader: authConfig.trustedClientIpHeader
|
|
75
|
+
});
|
|
76
|
+
convexIdentity.value = snapshot.token && snapshot.user ? toAuthenticatedIdentity(snapshot.token, snapshot.user) : ANONYMOUS_IDENTITY;
|
|
77
|
+
convexAuthError.value = snapshot.authError;
|
|
78
|
+
convexAuthWaterfall.value = snapshot.waterfall;
|
|
79
|
+
applyConvexAuthSsrHeaders(event, {
|
|
80
|
+
hasBetterAuthCookie: hasSupportedBetterAuthCookie,
|
|
81
|
+
serializesToken: snapshot.token !== null
|
|
82
|
+
});
|
|
83
|
+
endInit();
|
|
84
|
+
for (const logEvent of snapshot.logEvents) {
|
|
85
|
+
logAuth(logEvent.phase, logEvent.outcome, logEvent.details);
|
|
86
|
+
}
|
|
87
|
+
if (traceEnabled) {
|
|
88
|
+
logAuth(
|
|
89
|
+
"ssr.auth.completed",
|
|
90
|
+
snapshot.token ? "success" : snapshot.authError ? "error" : "miss",
|
|
91
|
+
{
|
|
92
|
+
durationMs: Date.now() - snapshotStartedAt,
|
|
93
|
+
identityHydrated: snapshot.user !== null,
|
|
94
|
+
tokenSerialized: snapshot.token !== null
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Nuxt payload plugin for {@link ConvexCallError} (internal
|
|
3
|
+
*). Registered with `mode: 'all'` and an explicit negative `order` (-50) by
|
|
4
|
+
* `src/module.ts`, so the reviver exists before Nuxt parses the SSR payload.
|
|
5
|
+
*
|
|
6
|
+
* The framework-free `/errors` entry stays unaware of Nuxt; this Nuxt-aware
|
|
7
|
+
* plugin is the only place the two meet. The reducer emits the public
|
|
8
|
+
* `toJSON()` shape (never `cause`); the reviver reconstructs a real
|
|
9
|
+
* `ConvexCallError` — instance identity survives hydration — WITHOUT a `cause`,
|
|
10
|
+
* and only after strict structural validation, so an arbitrary object carrying
|
|
11
|
+
* `name: 'ConvexCallError'` is never revived.
|
|
12
|
+
*/
|
|
13
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePayloadPlugin, definePayloadReducer, definePayloadReviver } from "#app";
|
|
2
|
+
import { ConvexCallError, isSerializedConvexCallError } from "../errors/index.js";
|
|
3
|
+
export default definePayloadPlugin(() => {
|
|
4
|
+
definePayloadReducer("ConvexCallError", (value) => {
|
|
5
|
+
if (!(value instanceof ConvexCallError)) return;
|
|
6
|
+
return value.toJSON();
|
|
7
|
+
});
|
|
8
|
+
definePayloadReviver("ConvexCallError", (value) => {
|
|
9
|
+
if (!isSerializedConvexCallError(value)) return;
|
|
10
|
+
return new ConvexCallError(value);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BetterConvexAttachment } from '@lupinum/better-convex-vue/embedded';
|
|
2
|
+
import type { ComputedRef } from 'vue';
|
|
3
|
+
import type { DevtoolsSink } from './devtools/sink.js';
|
|
4
|
+
import type { ConvexAuthStatus } from './utils/auth-status.js';
|
|
5
|
+
import type { Logger } from './utils/logger.js';
|
|
6
|
+
/** Nuxt-owned Better Auth presentation; it never controls a Convex client. */
|
|
7
|
+
export interface NuxtConvexAuthController {
|
|
8
|
+
readonly isPending: ComputedRef<boolean>;
|
|
9
|
+
readonly client: object;
|
|
10
|
+
ready(options?: {
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}): Promise<ConvexAuthStatus>;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
}
|
|
15
|
+
/** Nuxt adapters around the one Vue-owned browser runtime. */
|
|
16
|
+
export interface ConvexRuntimeContext {
|
|
17
|
+
readonly attachment: BetterConvexAttachment;
|
|
18
|
+
readonly logger: Logger;
|
|
19
|
+
getAuthController(): NuxtConvexAuthController | null;
|
|
20
|
+
attachAuthController(controller: NuxtConvexAuthController): void;
|
|
21
|
+
getDevtoolsSink(): DevtoolsSink | null;
|
|
22
|
+
attachDevtoolsSink(sink: DevtoolsSink): (() => void) | null;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function readConvexRuntimeContext(nuxtApp: unknown): ConvexRuntimeContext | undefined;
|
|
26
|
+
export declare function createConvexRuntimeContext(attachment: BetterConvexAttachment, logger: Logger): ConvexRuntimeContext;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function readConvexRuntimeContext(nuxtApp) {
|
|
2
|
+
if (typeof nuxtApp !== "object" && typeof nuxtApp !== "function" || nuxtApp === null) {
|
|
3
|
+
return void 0;
|
|
4
|
+
}
|
|
5
|
+
return nuxtApp.$convexRuntime;
|
|
6
|
+
}
|
|
7
|
+
export function createConvexRuntimeContext(attachment, logger) {
|
|
8
|
+
let authController = null;
|
|
9
|
+
let devtoolsSink = null;
|
|
10
|
+
let disposed = false;
|
|
11
|
+
const stopIdentityObservation = attachment.identity.subscribe(() => {
|
|
12
|
+
devtoolsSink?.clearIdentityOwned();
|
|
13
|
+
});
|
|
14
|
+
const context = {
|
|
15
|
+
attachment,
|
|
16
|
+
logger,
|
|
17
|
+
getAuthController: () => authController,
|
|
18
|
+
attachAuthController(controller) {
|
|
19
|
+
if (authController && authController !== controller) {
|
|
20
|
+
throw new Error("[convex-runtime] auth controller is already attached");
|
|
21
|
+
}
|
|
22
|
+
authController = controller;
|
|
23
|
+
},
|
|
24
|
+
getDevtoolsSink: () => devtoolsSink,
|
|
25
|
+
attachDevtoolsSink(sink) {
|
|
26
|
+
if (disposed) {
|
|
27
|
+
sink.dispose();
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
devtoolsSink?.dispose();
|
|
31
|
+
devtoolsSink = sink;
|
|
32
|
+
return () => {
|
|
33
|
+
if (devtoolsSink !== sink) return;
|
|
34
|
+
devtoolsSink = null;
|
|
35
|
+
sink.dispose();
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
dispose() {
|
|
39
|
+
if (disposed) return;
|
|
40
|
+
disposed = true;
|
|
41
|
+
stopIdentityObservation();
|
|
42
|
+
authController?.dispose();
|
|
43
|
+
devtoolsSink?.dispose();
|
|
44
|
+
devtoolsSink = null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return Object.freeze(context);
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AuthProxyHandlerOptions {
|
|
2
|
+
allowedMethods?: readonly string[];
|
|
3
|
+
/** Fixed issuer-relative path for a standards-defined public alias. */
|
|
4
|
+
fixedAuthPath?: string;
|
|
5
|
+
/** Expose a standards-defined, credential-free metadata document to browsers. */
|
|
6
|
+
publicMetadataCors?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createAuthProxyHandler(options?: AuthProxyHandlerOptions): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
|
|
9
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
|
|
10
|
+
export default _default;
|