@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.
Files changed (268) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/Apache-2.0.txt +201 -0
  3. package/README.md +151 -0
  4. package/THIRD_PARTY_NOTICES.md +38 -0
  5. package/dist/module.d.mts +55 -0
  6. package/dist/module.json +12 -0
  7. package/dist/module.mjs +309 -0
  8. package/dist/runtime/auth/auth-identity.d.ts +31 -0
  9. package/dist/runtime/auth/auth-identity.js +21 -0
  10. package/dist/runtime/auth/better-auth-browser-adapter.d.ts +33 -0
  11. package/dist/runtime/auth/better-auth-browser-adapter.js +215 -0
  12. package/dist/runtime/auth/client-engine-types.d.ts +4 -0
  13. package/dist/runtime/auth/client-engine-types.js +0 -0
  14. package/dist/runtime/auth/integrated-client.d.ts +25 -0
  15. package/dist/runtime/auth/integrated-client.js +132 -0
  16. package/dist/runtime/auth/operation-tracker.d.ts +7 -0
  17. package/dist/runtime/auth/operation-tracker.js +14 -0
  18. package/dist/runtime/auth/session-synchronization.d.ts +23 -0
  19. package/dist/runtime/auth/session-synchronization.js +156 -0
  20. package/dist/runtime/auth/token-fetcher.d.ts +66 -0
  21. package/dist/runtime/auth/token-fetcher.js +131 -0
  22. package/dist/runtime/auth/validate-auth-client-definition.d.ts +12 -0
  23. package/dist/runtime/auth/validate-auth-client-definition.js +47 -0
  24. package/dist/runtime/auth-client/convex-client-plugin.d.ts +31 -0
  25. package/dist/runtime/auth-client/convex-client-plugin.js +14 -0
  26. package/dist/runtime/auth-client/definition-types.d.ts +6 -0
  27. package/dist/runtime/auth-client/definition-types.js +0 -0
  28. package/dist/runtime/auth-client/empty-definition.d.ts +2 -0
  29. package/dist/runtime/auth-client/empty-definition.js +2 -0
  30. package/dist/runtime/auth-client/index.d.ts +71 -0
  31. package/dist/runtime/auth-client/index.js +3 -0
  32. package/dist/runtime/cli/auth-schema.d.ts +2 -0
  33. package/dist/runtime/cli/auth-schema.js +169 -0
  34. package/dist/runtime/cli/convex.d.ts +11 -0
  35. package/dist/runtime/cli/convex.js +274 -0
  36. package/dist/runtime/composables/useConvex.d.ts +4 -0
  37. package/dist/runtime/composables/useConvex.js +9 -0
  38. package/dist/runtime/composables/useConvexAction.d.ts +4 -0
  39. package/dist/runtime/composables/useConvexAction.js +18 -0
  40. package/dist/runtime/composables/useConvexAttachment.d.ts +9 -0
  41. package/dist/runtime/composables/useConvexAttachment.js +14 -0
  42. package/dist/runtime/composables/useConvexAuth.d.ts +10 -0
  43. package/dist/runtime/composables/useConvexAuth.js +37 -0
  44. package/dist/runtime/composables/useConvexConfig.d.ts +12 -0
  45. package/dist/runtime/composables/useConvexConfig.js +7 -0
  46. package/dist/runtime/composables/useConvexConnectionState.d.ts +33 -0
  47. package/dist/runtime/composables/useConvexConnectionState.js +24 -0
  48. package/dist/runtime/composables/useConvexFileUpload.d.ts +169 -0
  49. package/dist/runtime/composables/useConvexFileUpload.js +198 -0
  50. package/dist/runtime/composables/useConvexMutation.d.ts +13 -0
  51. package/dist/runtime/composables/useConvexMutation.js +24 -0
  52. package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +13 -0
  53. package/dist/runtime/composables/useConvexPaginatedQuery.js +256 -0
  54. package/dist/runtime/composables/useConvexQuery.d.ts +19 -0
  55. package/dist/runtime/composables/useConvexQuery.js +308 -0
  56. package/dist/runtime/convex-auth/adapter/create-adapter.d.ts +33 -0
  57. package/dist/runtime/convex-auth/adapter/create-adapter.js +308 -0
  58. package/dist/runtime/convex-auth/adapter/define-functions.d.ts +160 -0
  59. package/dist/runtime/convex-auth/adapter/define-functions.js +497 -0
  60. package/dist/runtime/convex-auth/adapter/generate-schema.d.ts +16 -0
  61. package/dist/runtime/convex-auth/adapter/generate-schema.js +332 -0
  62. package/dist/runtime/convex-auth/adapter/metadata.d.ts +44 -0
  63. package/dist/runtime/convex-auth/adapter/metadata.js +91 -0
  64. package/dist/runtime/convex-auth/adapter/query.d.ts +32 -0
  65. package/dist/runtime/convex-auth/adapter/query.js +275 -0
  66. package/dist/runtime/convex-auth/adapter/relationships.d.ts +20 -0
  67. package/dist/runtime/convex-auth/adapter/relationships.js +128 -0
  68. package/dist/runtime/convex-auth/component/_generated/api.js +5 -0
  69. package/dist/runtime/convex-auth/component/_generated/component.d.ts +116 -0
  70. package/dist/runtime/convex-auth/component/_generated/component.js +0 -0
  71. package/dist/runtime/convex-auth/component/_generated/dataModel.js +0 -0
  72. package/dist/runtime/convex-auth/component/_generated/server.js +16 -0
  73. package/dist/runtime/convex-auth/component/adapter.d.ts +142 -0
  74. package/dist/runtime/convex-auth/component/adapter.js +16 -0
  75. package/dist/runtime/convex-auth/component/convex.config.d.ts +2 -0
  76. package/dist/runtime/convex-auth/component/convex.config.js +3 -0
  77. package/dist/runtime/convex-auth/component/schema.d.ts +799 -0
  78. package/dist/runtime/convex-auth/component/schema.js +180 -0
  79. package/dist/runtime/convex-auth/component/schemaMetadata.d.ts +2094 -0
  80. package/dist/runtime/convex-auth/component/schemaMetadata.js +2161 -0
  81. package/dist/runtime/convex-auth/context.d.ts +5 -0
  82. package/dist/runtime/convex-auth/context.js +8 -0
  83. package/dist/runtime/convex-auth/create-auth-component.d.ts +41 -0
  84. package/dist/runtime/convex-auth/create-auth-component.js +157 -0
  85. package/dist/runtime/convex-auth/index.d.ts +11 -0
  86. package/dist/runtime/convex-auth/index.js +7 -0
  87. package/dist/runtime/convex-auth/internal-session.d.ts +2 -0
  88. package/dist/runtime/convex-auth/internal-session.js +1 -0
  89. package/dist/runtime/convex-auth/jwks-rotation.d.ts +58 -0
  90. package/dist/runtime/convex-auth/jwks-rotation.js +163 -0
  91. package/dist/runtime/convex-auth/oauth-live-access.d.ts +17 -0
  92. package/dist/runtime/convex-auth/oauth-live-access.js +78 -0
  93. package/dist/runtime/convex-auth/oauth-provider-compat.d.ts +10 -0
  94. package/dist/runtime/convex-auth/oauth-provider-compat.js +170 -0
  95. package/dist/runtime/convex-auth/oauth-resource.d.ts +39 -0
  96. package/dist/runtime/convex-auth/oauth-resource.js +118 -0
  97. package/dist/runtime/convex-auth/oauth-security.d.ts +82 -0
  98. package/dist/runtime/convex-auth/oauth-security.js +454 -0
  99. package/dist/runtime/convex-auth/origin.d.ts +4 -0
  100. package/dist/runtime/convex-auth/origin.js +9 -0
  101. package/dist/runtime/convex-auth/plugin.d.ts +18 -0
  102. package/dist/runtime/convex-auth/plugin.js +605 -0
  103. package/dist/runtime/convex-auth/provider.d.ts +2 -0
  104. package/dist/runtime/convex-auth/provider.js +11 -0
  105. package/dist/runtime/convex-auth/test.d.ts +410 -0
  106. package/dist/runtime/convex-auth/test.js +9 -0
  107. package/dist/runtime/convex-auth/types.d.ts +18 -0
  108. package/dist/runtime/convex-auth/types.js +0 -0
  109. package/dist/runtime/convex-auth/user-projection.d.ts +106 -0
  110. package/dist/runtime/convex-auth/user-projection.js +128 -0
  111. package/dist/runtime/devtools/auth-proxy-registry.d.ts +4 -0
  112. package/dist/runtime/devtools/auth-proxy-registry.js +47 -0
  113. package/dist/runtime/devtools/bridge-setup.d.ts +21 -0
  114. package/dist/runtime/devtools/bridge-setup.js +165 -0
  115. package/dist/runtime/devtools/path-utils.d.ts +2 -0
  116. package/dist/runtime/devtools/path-utils.js +12 -0
  117. package/dist/runtime/devtools/server.d.ts +2 -0
  118. package/dist/runtime/devtools/server.js +108 -0
  119. package/dist/runtime/devtools/setup-client.d.ts +16 -0
  120. package/dist/runtime/devtools/setup-client.js +43 -0
  121. package/dist/runtime/devtools/sink.d.ts +18 -0
  122. package/dist/runtime/devtools/sink.js +110 -0
  123. package/dist/runtime/devtools/transport.d.ts +16 -0
  124. package/dist/runtime/devtools/transport.js +149 -0
  125. package/dist/runtime/devtools/types.d.ts +167 -0
  126. package/dist/runtime/devtools/types.js +1 -0
  127. package/dist/runtime/devtools/ui/dist/200.html +1 -0
  128. package/dist/runtime/devtools/ui/dist/404.html +1 -0
  129. package/dist/runtime/devtools/ui/dist/_nuxt/C4MASuCh.js +1 -0
  130. package/dist/runtime/devtools/ui/dist/_nuxt/DJHkqtZq.js +3 -0
  131. package/dist/runtime/devtools/ui/dist/_nuxt/DWwrCltl.js +2 -0
  132. package/dist/runtime/devtools/ui/dist/_nuxt/DZ_UiYoH.js +1 -0
  133. package/dist/runtime/devtools/ui/dist/_nuxt/_m9ujb-i.js +1 -0
  134. package/dist/runtime/devtools/ui/dist/_nuxt/builds/latest.json +1 -0
  135. package/dist/runtime/devtools/ui/dist/_nuxt/builds/meta/better-convex-nuxt-devtools.json +1 -0
  136. package/dist/runtime/devtools/ui/dist/_nuxt/entry.DpFDKYZ5.css +1 -0
  137. package/dist/runtime/devtools/ui/dist/_nuxt/error-404.DYUJo5xt.css +1 -0
  138. package/dist/runtime/devtools/ui/dist/_nuxt/error-500.DQdoJJXg.css +1 -0
  139. package/dist/runtime/devtools/ui/dist/convex-logo.svg +5 -0
  140. package/dist/runtime/devtools/ui/dist/index.html +1 -0
  141. package/dist/runtime/errors/index.d.ts +7 -0
  142. package/dist/runtime/errors/index.js +5 -0
  143. package/dist/runtime/middleware/convex-auth.global.d.ts +2 -0
  144. package/dist/runtime/middleware/convex-auth.global.js +31 -0
  145. package/dist/runtime/plugin.auth.client.d.ts +3 -0
  146. package/dist/runtime/plugin.auth.client.js +217 -0
  147. package/dist/runtime/plugin.client.d.ts +3 -0
  148. package/dist/runtime/plugin.client.js +43 -0
  149. package/dist/runtime/plugin.server.d.ts +12 -0
  150. package/dist/runtime/plugin.server.js +98 -0
  151. package/dist/runtime/plugins/convex-call-error-payload.d.ts +14 -0
  152. package/dist/runtime/plugins/convex-call-error-payload.js +12 -0
  153. package/dist/runtime/runtime-context.d.ts +26 -0
  154. package/dist/runtime/runtime-context.js +48 -0
  155. package/dist/runtime/server/api/auth/[...].d.ts +10 -0
  156. package/dist/runtime/server/api/auth/[...].js +509 -0
  157. package/dist/runtime/server/api/auth/authorization-server-metadata.d.ts +2 -0
  158. package/dist/runtime/server/api/auth/authorization-server-metadata.js +6 -0
  159. package/dist/runtime/server/api/auth/body-size.d.ts +15 -0
  160. package/dist/runtime/server/api/auth/body-size.js +179 -0
  161. package/dist/runtime/server/api/auth/headers.d.ts +6 -0
  162. package/dist/runtime/server/api/auth/headers.js +98 -0
  163. package/dist/runtime/server/api/auth/jwks.d.ts +2 -0
  164. package/dist/runtime/server/api/auth/jwks.js +6 -0
  165. package/dist/runtime/server/api/auth/security.d.ts +14 -0
  166. package/dist/runtime/server/api/auth/security.js +85 -0
  167. package/dist/runtime/server/api/release-fingerprint.d.ts +2 -0
  168. package/dist/runtime/server/api/release-fingerprint.js +36 -0
  169. package/dist/runtime/server/index.d.ts +1 -0
  170. package/dist/runtime/server/index.js +3 -0
  171. package/dist/runtime/server/plugins/runtime-config.d.ts +7 -0
  172. package/dist/runtime/server/plugins/runtime-config.js +7 -0
  173. package/dist/runtime/server/utils/auth-snapshot.d.ts +26 -0
  174. package/dist/runtime/server/utils/auth-snapshot.js +165 -0
  175. package/dist/runtime/server/utils/http.d.ts +16 -0
  176. package/dist/runtime/server/utils/http.js +133 -0
  177. package/dist/runtime/server/utils/server-convex-caller.d.ts +31 -0
  178. package/dist/runtime/server/utils/server-convex-caller.js +151 -0
  179. package/dist/runtime/server/utils/server-convex-options.d.ts +83 -0
  180. package/dist/runtime/server/utils/server-convex-options.js +69 -0
  181. package/dist/runtime/server/utils/signed-client-ip.d.ts +6 -0
  182. package/dist/runtime/server/utils/signed-client-ip.js +29 -0
  183. package/dist/runtime/server/utils/ssr-auth-headers.d.ts +26 -0
  184. package/dist/runtime/server/utils/ssr-auth-headers.js +49 -0
  185. package/dist/runtime/server/utils/token-exchange.d.ts +27 -0
  186. package/dist/runtime/server/utils/token-exchange.js +96 -0
  187. package/dist/runtime/shared/auth-cookie.d.ts +4 -0
  188. package/dist/runtime/shared/auth-cookie.js +25 -0
  189. package/dist/runtime/shared/auth-origin.d.ts +15 -0
  190. package/dist/runtime/shared/auth-origin.js +42 -0
  191. package/dist/runtime/shared/bounded-stream.d.ts +2 -0
  192. package/dist/runtime/shared/bounded-stream.js +50 -0
  193. package/dist/runtime/shared/client-ip.d.ts +21 -0
  194. package/dist/runtime/shared/client-ip.js +123 -0
  195. package/dist/runtime/shared/release-fingerprint.d.ts +5 -0
  196. package/dist/runtime/shared/release-fingerprint.js +17 -0
  197. package/dist/runtime/types.d.ts +19 -0
  198. package/dist/runtime/utils/auth-config.d.ts +24 -0
  199. package/dist/runtime/utils/auth-config.js +45 -0
  200. package/dist/runtime/utils/auth-contract.d.ts +22 -0
  201. package/dist/runtime/utils/auth-contract.js +0 -0
  202. package/dist/runtime/utils/auth-errors.d.ts +5 -0
  203. package/dist/runtime/utils/auth-errors.js +22 -0
  204. package/dist/runtime/utils/auth-identity-state.d.ts +4 -0
  205. package/dist/runtime/utils/auth-identity-state.js +8 -0
  206. package/dist/runtime/utils/auth-pending-state.d.ts +13 -0
  207. package/dist/runtime/utils/auth-pending-state.js +4 -0
  208. package/dist/runtime/utils/auth-pending.d.ts +10 -0
  209. package/dist/runtime/utils/auth-pending.js +30 -0
  210. package/dist/runtime/utils/auth-route-protection.d.ts +16 -0
  211. package/dist/runtime/utils/auth-route-protection.js +58 -0
  212. package/dist/runtime/utils/auth-status.d.ts +47 -0
  213. package/dist/runtime/utils/auth-status.js +8 -0
  214. package/dist/runtime/utils/bounded-convex-fetch.d.ts +18 -0
  215. package/dist/runtime/utils/bounded-convex-fetch.js +152 -0
  216. package/dist/runtime/utils/callable-devtools.d.ts +17 -0
  217. package/dist/runtime/utils/callable-devtools.js +49 -0
  218. package/dist/runtime/utils/callable-observer.d.ts +2 -0
  219. package/dist/runtime/utils/callable-observer.js +1 -0
  220. package/dist/runtime/utils/composable-scope.d.ts +2 -0
  221. package/dist/runtime/utils/composable-scope.js +8 -0
  222. package/dist/runtime/utils/config-defaults.d.ts +8 -0
  223. package/dist/runtime/utils/config-defaults.js +8 -0
  224. package/dist/runtime/utils/convex-cache.d.ts +68 -0
  225. package/dist/runtime/utils/convex-cache.js +47 -0
  226. package/dist/runtime/utils/convex-config.d.ts +16 -0
  227. package/dist/runtime/utils/convex-config.js +50 -0
  228. package/dist/runtime/utils/convex-shared.d.ts +67 -0
  229. package/dist/runtime/utils/convex-shared.js +134 -0
  230. package/dist/runtime/utils/identity-changed-error.d.ts +4 -0
  231. package/dist/runtime/utils/identity-changed-error.js +12 -0
  232. package/dist/runtime/utils/identity-key.d.ts +19 -0
  233. package/dist/runtime/utils/identity-key.js +10 -0
  234. package/dist/runtime/utils/integrated-auth-client.d.ts +5 -0
  235. package/dist/runtime/utils/integrated-auth-client.js +0 -0
  236. package/dist/runtime/utils/logger.d.ts +42 -0
  237. package/dist/runtime/utils/logger.js +190 -0
  238. package/dist/runtime/utils/mime-type.d.ts +33 -0
  239. package/dist/runtime/utils/mime-type.js +10 -0
  240. package/dist/runtime/utils/query-execution-gate.d.ts +47 -0
  241. package/dist/runtime/utils/query-execution-gate.js +63 -0
  242. package/dist/runtime/utils/query-execution.d.ts +8 -0
  243. package/dist/runtime/utils/query-execution.js +19 -0
  244. package/dist/runtime/utils/query-foundation.d.ts +20 -0
  245. package/dist/runtime/utils/query-foundation.js +39 -0
  246. package/dist/runtime/utils/query-state.d.ts +12 -0
  247. package/dist/runtime/utils/query-state.js +12 -0
  248. package/dist/runtime/utils/reactive-args.d.ts +5 -0
  249. package/dist/runtime/utils/reactive-args.js +42 -0
  250. package/dist/runtime/utils/runtime-config-normalize.d.ts +22 -0
  251. package/dist/runtime/utils/runtime-config-normalize.js +28 -0
  252. package/dist/runtime/utils/runtime-config.d.ts +4 -0
  253. package/dist/runtime/utils/runtime-config.js +8 -0
  254. package/dist/runtime/utils/sanitize-diagnostic.d.ts +6 -0
  255. package/dist/runtime/utils/sanitize-diagnostic.js +81 -0
  256. package/dist/runtime/utils/shared-helpers.d.ts +46 -0
  257. package/dist/runtime/utils/shared-helpers.js +139 -0
  258. package/dist/runtime/utils/site-url.d.ts +4 -0
  259. package/dist/runtime/utils/site-url.js +15 -0
  260. package/dist/runtime/utils/ssr-pagination-state.d.ts +3 -0
  261. package/dist/runtime/utils/ssr-pagination-state.js +3 -0
  262. package/dist/runtime/utils/types.d.ts +29 -0
  263. package/dist/runtime/utils/types.js +0 -0
  264. package/dist/runtime/utils/upload-core.d.ts +16 -0
  265. package/dist/runtime/utils/upload-core.js +116 -0
  266. package/dist/types.d.mts +21 -0
  267. package/package.json +253 -0
  268. 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;