@onderwijsin/nuxt-turnstile 0.2.10 → 0.3.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 CHANGED
@@ -135,6 +135,9 @@ Stable error codes are `TURNSTILE_TOKEN_MISSING`, `TURNSTILE_VALIDATION_FAILED`,
135
135
  `TURNSTILE_SERVER_MISCONFIGURED`. Apply authorization and business validation in the consuming route
136
136
  after Turnstile succeeds; the module does not replace the route's existing submit or business logic.
137
137
 
138
+ `verifyTokenWithTurnstile` is also auto-imported for server-only use when the raw Cloudflare
139
+ verification response is needed. Prefer `assertTurnstileToken` for protected application routes.
140
+
138
141
  ## Compatibility
139
142
 
140
143
  - Nuxt 4
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-turnstile",
3
3
  "configKey": "turnstile",
4
- "version": "0.2.10",
4
+ "version": "0.3.0",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { defu } from 'defu';
3
3
  import { enabled, resolveModuleName, resolveLoggerScope, moduleSetup, validateModuleOptions, transpileRuntime, moduleDependenciesWhenEnabled } from '@onderwijsin/nuxt-module-utils/build';
4
4
  import { z } from 'zod';
5
5
 
6
- const version = "0.2.10";
6
+ const version = "0.3.0";
7
7
 
8
8
  const turnstileOptionsSchema = z.object({
9
9
  enabled,
@@ -37,7 +37,7 @@ export type TurnstileValidationResponse = z.infer<typeof turnstileValidationResp
37
37
  * @param signal - Optional AbortSignal for request cancellation.
38
38
  * @returns The parsed Turnstile validation response.
39
39
  */
40
- export declare const verifyTurnstileToken: (token: string, event?: H3Event, signal?: AbortSignal) => Promise<TurnstileValidationResponse>;
40
+ export declare const verifyTokenWithTurnstile: (token: string, event?: H3Event, signal?: AbortSignal) => Promise<TurnstileValidationResponse>;
41
41
  /**
42
42
  * Validates the Turnstile token from a protected request.
43
43
  * @param event - H3 request event.
@@ -28,7 +28,7 @@ export const turnstileValidationResponseSchema = z.object({
28
28
  metadata: z.object({ result_with_testing_key: z.boolean().optional() }).optional()
29
29
  });
30
30
  const endpoint = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
31
- export const verifyTurnstileToken = async (token, event, signal) => {
31
+ export const verifyTokenWithTurnstile = async (token, event, signal) => {
32
32
  const secretKey = useRuntimeConfig(event).turnstile.secretKey;
33
33
  const response = await $fetch(endpoint, {
34
34
  method: "POST",
@@ -65,7 +65,7 @@ export async function assertTurnstileToken(event, expectedAction) {
65
65
  "TURNSTILE_TOKEN_MISSING",
66
66
  expectedAction
67
67
  );
68
- const result = await attempt(() => verifyTurnstileToken(token));
68
+ const result = await attempt(() => verifyTokenWithTurnstile(token));
69
69
  if (result.error !== null) {
70
70
  if (isErrorWithStatusCode(result.error)) throw result.error;
71
71
  throw createError({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-turnstile",
3
- "version": "0.2.10",
3
+ "version": "0.3.0",
4
4
  "description": "Nuxt Turnstile integration with client helpers and server-side validation.",
5
5
  "homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
6
6
  "bugs": {