@clerk/nuxt 1.13.27 → 1.13.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js
CHANGED
package/dist/runtime/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ var plugin_default = defineNuxtPlugin((nuxtApp) => {
|
|
|
14
14
|
...runtimeConfig.public.clerk ?? {},
|
|
15
15
|
sdkMetadata: {
|
|
16
16
|
name: "@clerk/nuxt",
|
|
17
|
-
version: "1.13.
|
|
17
|
+
version: "1.13.28",
|
|
18
18
|
environment: process.env.NODE_ENV
|
|
19
19
|
},
|
|
20
20
|
routerPush: (to) => navigateTo(to),
|
|
@@ -17,10 +17,10 @@ function clerkClient(event) {
|
|
|
17
17
|
disabled: isTruthy(runtimeConfig.public.clerk.telemetry?.disabled),
|
|
18
18
|
debug: isTruthy(runtimeConfig.public.clerk.telemetry?.debug)
|
|
19
19
|
},
|
|
20
|
-
userAgent: `${"@clerk/nuxt"}@${"1.13.
|
|
20
|
+
userAgent: `${"@clerk/nuxt"}@${"1.13.28"}`,
|
|
21
21
|
sdkMetadata: {
|
|
22
22
|
name: "@clerk/nuxt",
|
|
23
|
-
version: "1.13.
|
|
23
|
+
version: "1.13.28",
|
|
24
24
|
environment: process.env.NODE_ENV
|
|
25
25
|
}
|
|
26
26
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthStatus, constants, getAuthObjectForAcceptedToken } from "@clerk/backend/internal";
|
|
2
2
|
import { deprecated } from "@clerk/shared/deprecated";
|
|
3
3
|
import { handleNetlifyCacheInDevInstance } from "@clerk/shared/netlifyCacheHandler";
|
|
4
|
+
import { isMalformedURLError } from "@clerk/shared/pathMatcher";
|
|
4
5
|
import { createError, eventHandler, setResponseHeader } from "h3";
|
|
5
6
|
import { clerkClient } from "./clerkClient";
|
|
6
7
|
import { createInitialState, toWebRequest } from "./utils";
|
|
@@ -50,7 +51,14 @@ const clerkMiddleware = (...args) => {
|
|
|
50
51
|
});
|
|
51
52
|
event.context.auth = auth;
|
|
52
53
|
event.context.__clerk_initial_state = createInitialState(authObjectFn());
|
|
53
|
-
|
|
54
|
+
try {
|
|
55
|
+
await handler?.(event);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (isMalformedURLError(e)) {
|
|
58
|
+
throw createError({ statusCode: 400, statusMessage: "Bad Request" });
|
|
59
|
+
}
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
54
62
|
});
|
|
55
63
|
};
|
|
56
64
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/server/clerkMiddleware.ts"],"sourcesContent":["import type { AuthenticateRequestOptions } from '@clerk/backend/internal';\nimport { AuthStatus, constants, getAuthObjectForAcceptedToken } from '@clerk/backend/internal';\nimport { deprecated } from '@clerk/shared/deprecated';\nimport { handleNetlifyCacheInDevInstance } from '@clerk/shared/netlifyCacheHandler';\nimport type { PendingSessionOptions } from '@clerk/types';\nimport type { EventHandler } from 'h3';\nimport { createError, eventHandler, setResponseHeader } from 'h3';\n\nimport { clerkClient } from './clerkClient';\nimport type { AuthFn, AuthOptions } from './types';\nimport { createInitialState, toWebRequest } from './utils';\n\nfunction parseHandlerAndOptions(args: unknown[]) {\n return [\n typeof args[0] === 'function' ? args[0] : undefined,\n (args.length === 2 ? args[1] : typeof args[0] === 'function' ? {} : args[0]) || {},\n ] as [EventHandler | undefined, AuthenticateRequestOptions];\n}\n\ninterface ClerkMiddleware {\n /**\n * @example\n * export default clerkMiddleware((event) => { ... }, options);\n */\n (handler: EventHandler, options?: AuthenticateRequestOptions): ReturnType<typeof eventHandler>;\n\n /**\n * @example\n * export default clerkMiddleware(options);\n */\n (options?: AuthenticateRequestOptions): ReturnType<typeof eventHandler>;\n}\n\n/**\n * Middleware for Nuxt that handles authentication and authorization with Clerk.\n *\n * @example\n * Basic usage with options:\n * ```ts\n * export default clerkMiddleware({\n * authorizedParties: ['https://example.com']\n * })\n * ```\n *\n * @example\n * With custom handler:\n * ```ts\n * export default clerkMiddleware((event) => {\n * // Access auth data from the event context\n * const { auth } = event.context\n *\n * // Example: Require authentication for all API routes\n * if (!auth.userId && event.path.startsWith('/api')) {\n * throw createError({\n * statusCode: 401,\n * message: 'Unauthorized'\n * })\n * }\n * })\n * ```\n *\n * @example\n * With custom handler and options:\n * ```ts\n * export default clerkMiddleware((event) => {\n * // Access auth data from the event context\n * const { auth } = event.context\n *\n * // Example: Require authentication for all API routes\n * if (!auth.userId && event.path.startsWith('/api')) {\n * throw createError({\n * statusCode: 401,\n * message: 'Unauthorized'\n * })\n * }\n * }, {\n * authorizedParties: ['https://example.com']\n * })\n * ```\n */\nexport const clerkMiddleware: ClerkMiddleware = (...args: unknown[]) => {\n const [handler, options] = parseHandlerAndOptions(args);\n return eventHandler(async event => {\n const clerkRequest = toWebRequest(event);\n\n const requestState = await clerkClient(event).authenticateRequest(clerkRequest, {\n ...options,\n acceptsToken: 'any',\n });\n\n const locationHeader = requestState.headers.get(constants.Headers.Location);\n if (locationHeader) {\n handleNetlifyCacheInDevInstance({\n locationHeader,\n requestStateHeaders: requestState.headers,\n publishableKey: requestState.publishableKey,\n });\n // Trigger a handshake redirect\n return new Response(null, { status: 307, headers: requestState.headers });\n }\n\n if (requestState.status === AuthStatus.Handshake) {\n throw createError('Clerk: handshake status without redirect');\n }\n\n if (requestState.headers) {\n requestState.headers.forEach((value, key) => {\n setResponseHeader(event, key, value);\n });\n }\n\n const authObjectFn = (opts?: PendingSessionOptions) => requestState.toAuth(opts);\n const authHandler: AuthFn = ((options?: AuthOptions) => {\n return getAuthObjectForAcceptedToken({ authObject: authObjectFn(options), acceptsToken: options?.acceptsToken });\n }) as AuthFn;\n\n const auth = new Proxy(authHandler, {\n get(target, prop, receiver) {\n deprecated('event.context.auth', 'Use `event.context.auth()` as a function instead.');\n // If the property exists on the function, return it\n if (prop in target) {\n return Reflect.get(target, prop, receiver);\n }\n // Otherwise, get it from the authObject\n return authObjectFn()?.[prop as keyof typeof authObjectFn];\n },\n });\n\n event.context.auth = auth;\n // Internal serializable state that will be passed to the client\n event.context.__clerk_initial_state = createInitialState(authObjectFn());\n\n await handler?.(event);\n });\n};\n"],"mappings":"AACA,SAAS,YAAY,WAAW,qCAAqC;AACrE,SAAS,kBAAkB;AAC3B,SAAS,uCAAuC;
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/server/clerkMiddleware.ts"],"sourcesContent":["import type { AuthenticateRequestOptions } from '@clerk/backend/internal';\nimport { AuthStatus, constants, getAuthObjectForAcceptedToken } from '@clerk/backend/internal';\nimport { deprecated } from '@clerk/shared/deprecated';\nimport { handleNetlifyCacheInDevInstance } from '@clerk/shared/netlifyCacheHandler';\nimport { isMalformedURLError } from '@clerk/shared/pathMatcher';\nimport type { PendingSessionOptions } from '@clerk/types';\nimport type { EventHandler } from 'h3';\nimport { createError, eventHandler, setResponseHeader } from 'h3';\n\nimport { clerkClient } from './clerkClient';\nimport type { AuthFn, AuthOptions } from './types';\nimport { createInitialState, toWebRequest } from './utils';\n\nfunction parseHandlerAndOptions(args: unknown[]) {\n return [\n typeof args[0] === 'function' ? args[0] : undefined,\n (args.length === 2 ? args[1] : typeof args[0] === 'function' ? {} : args[0]) || {},\n ] as [EventHandler | undefined, AuthenticateRequestOptions];\n}\n\ninterface ClerkMiddleware {\n /**\n * @example\n * export default clerkMiddleware((event) => { ... }, options);\n */\n (handler: EventHandler, options?: AuthenticateRequestOptions): ReturnType<typeof eventHandler>;\n\n /**\n * @example\n * export default clerkMiddleware(options);\n */\n (options?: AuthenticateRequestOptions): ReturnType<typeof eventHandler>;\n}\n\n/**\n * Middleware for Nuxt that handles authentication and authorization with Clerk.\n *\n * @example\n * Basic usage with options:\n * ```ts\n * export default clerkMiddleware({\n * authorizedParties: ['https://example.com']\n * })\n * ```\n *\n * @example\n * With custom handler:\n * ```ts\n * export default clerkMiddleware((event) => {\n * // Access auth data from the event context\n * const { auth } = event.context\n *\n * // Example: Require authentication for all API routes\n * if (!auth.userId && event.path.startsWith('/api')) {\n * throw createError({\n * statusCode: 401,\n * message: 'Unauthorized'\n * })\n * }\n * })\n * ```\n *\n * @example\n * With custom handler and options:\n * ```ts\n * export default clerkMiddleware((event) => {\n * // Access auth data from the event context\n * const { auth } = event.context\n *\n * // Example: Require authentication for all API routes\n * if (!auth.userId && event.path.startsWith('/api')) {\n * throw createError({\n * statusCode: 401,\n * message: 'Unauthorized'\n * })\n * }\n * }, {\n * authorizedParties: ['https://example.com']\n * })\n * ```\n */\nexport const clerkMiddleware: ClerkMiddleware = (...args: unknown[]) => {\n const [handler, options] = parseHandlerAndOptions(args);\n return eventHandler(async event => {\n const clerkRequest = toWebRequest(event);\n\n const requestState = await clerkClient(event).authenticateRequest(clerkRequest, {\n ...options,\n acceptsToken: 'any',\n });\n\n const locationHeader = requestState.headers.get(constants.Headers.Location);\n if (locationHeader) {\n handleNetlifyCacheInDevInstance({\n locationHeader,\n requestStateHeaders: requestState.headers,\n publishableKey: requestState.publishableKey,\n });\n // Trigger a handshake redirect\n return new Response(null, { status: 307, headers: requestState.headers });\n }\n\n if (requestState.status === AuthStatus.Handshake) {\n throw createError('Clerk: handshake status without redirect');\n }\n\n if (requestState.headers) {\n requestState.headers.forEach((value, key) => {\n setResponseHeader(event, key, value);\n });\n }\n\n const authObjectFn = (opts?: PendingSessionOptions) => requestState.toAuth(opts);\n const authHandler: AuthFn = ((options?: AuthOptions) => {\n return getAuthObjectForAcceptedToken({ authObject: authObjectFn(options), acceptsToken: options?.acceptsToken });\n }) as AuthFn;\n\n const auth = new Proxy(authHandler, {\n get(target, prop, receiver) {\n deprecated('event.context.auth', 'Use `event.context.auth()` as a function instead.');\n // If the property exists on the function, return it\n if (prop in target) {\n return Reflect.get(target, prop, receiver);\n }\n // Otherwise, get it from the authObject\n return authObjectFn()?.[prop as keyof typeof authObjectFn];\n },\n });\n\n event.context.auth = auth;\n // Internal serializable state that will be passed to the client\n event.context.__clerk_initial_state = createInitialState(authObjectFn());\n\n try {\n await handler?.(event);\n } catch (e) {\n if (isMalformedURLError(e)) {\n throw createError({ statusCode: 400, statusMessage: 'Bad Request' });\n }\n throw e;\n }\n });\n};\n"],"mappings":"AACA,SAAS,YAAY,WAAW,qCAAqC;AACrE,SAAS,kBAAkB;AAC3B,SAAS,uCAAuC;AAChD,SAAS,2BAA2B;AAGpC,SAAS,aAAa,cAAc,yBAAyB;AAE7D,SAAS,mBAAmB;AAE5B,SAAS,oBAAoB,oBAAoB;AAEjD,SAAS,uBAAuB,MAAiB;AAC/C,SAAO;AAAA,IACL,OAAO,KAAK,CAAC,MAAM,aAAa,KAAK,CAAC,IAAI;AAAA,KACzC,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC;AAAA,EACnF;AACF;AA+DO,MAAM,kBAAmC,IAAI,SAAoB;AACtE,QAAM,CAAC,SAAS,OAAO,IAAI,uBAAuB,IAAI;AACtD,SAAO,aAAa,OAAM,UAAS;AACjC,UAAM,eAAe,aAAa,KAAK;AAEvC,UAAM,eAAe,MAAM,YAAY,KAAK,EAAE,oBAAoB,cAAc;AAAA,MAC9E,GAAG;AAAA,MACH,cAAc;AAAA,IAChB,CAAC;AAED,UAAM,iBAAiB,aAAa,QAAQ,IAAI,UAAU,QAAQ,QAAQ;AAC1E,QAAI,gBAAgB;AAClB,sCAAgC;AAAA,QAC9B;AAAA,QACA,qBAAqB,aAAa;AAAA,QAClC,gBAAgB,aAAa;AAAA,MAC/B,CAAC;AAED,aAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,SAAS,aAAa,QAAQ,CAAC;AAAA,IAC1E;AAEA,QAAI,aAAa,WAAW,WAAW,WAAW;AAChD,YAAM,YAAY,0CAA0C;AAAA,IAC9D;AAEA,QAAI,aAAa,SAAS;AACxB,mBAAa,QAAQ,QAAQ,CAAC,OAAO,QAAQ;AAC3C,0BAAkB,OAAO,KAAK,KAAK;AAAA,MACrC,CAAC;AAAA,IACH;AAEA,UAAM,eAAe,CAAC,SAAiC,aAAa,OAAO,IAAI;AAC/E,UAAM,eAAuB,CAACA,aAA0B;AACtD,aAAO,8BAA8B,EAAE,YAAY,aAAaA,QAAO,GAAG,cAAcA,UAAS,aAAa,CAAC;AAAA,IACjH;AAEA,UAAM,OAAO,IAAI,MAAM,aAAa;AAAA,MAClC,IAAI,QAAQ,MAAM,UAAU;AAC1B,mBAAW,sBAAsB,mDAAmD;AAEpF,YAAI,QAAQ,QAAQ;AAClB,iBAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,QAC3C;AAEA,eAAO,aAAa,IAAI,IAAiC;AAAA,MAC3D;AAAA,IACF,CAAC;AAED,UAAM,QAAQ,OAAO;AAErB,UAAM,QAAQ,wBAAwB,mBAAmB,aAAa,CAAC;AAEvE,QAAI;AACF,YAAM,UAAU,KAAK;AAAA,IACvB,SAAS,GAAG;AACV,UAAI,oBAAoB,CAAC,GAAG;AAC1B,cAAM,YAAY,EAAE,YAAY,KAAK,eAAe,cAAc,CAAC;AAAA,MACrE;AACA,YAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;","names":["options"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerk/nuxt",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.28",
|
|
4
4
|
"description": "Clerk SDK for Nuxt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clerk",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@nuxt/kit": "^4.1.3",
|
|
61
61
|
"@nuxt/schema": "^4.1.3",
|
|
62
62
|
"h3": "^1.15.4",
|
|
63
|
-
"@clerk/backend": "^2.33.
|
|
64
|
-
"@clerk/shared": "^3.47.
|
|
65
|
-
"@clerk/types": "^4.101.
|
|
66
|
-
"@clerk/vue": "^1.17.
|
|
63
|
+
"@clerk/backend": "^2.33.2",
|
|
64
|
+
"@clerk/shared": "^3.47.4",
|
|
65
|
+
"@clerk/types": "^4.101.22",
|
|
66
|
+
"@clerk/vue": "^1.17.20"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"nuxt": "^4.1.2",
|