Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
moldypenguins committed Jul 6, 2024
1 parent 5b13007 commit 7407867
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 94 deletions.
2 changes: 1 addition & 1 deletion playground/.output/nitro.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2024-07-05T23:33:48.723Z",
"date": "2024-07-06T18:13:24.549Z",
"preset": "node-server",
"framework": {
"name": "nuxt",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion playground/.output/public/_nuxt/builds/latest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"64d2b9bd-b625-4a69-8c63-52de8d6690a9","timestamp":1720222417338}
{"id":"292d48f5-a1a3-449e-9846-880116a142d2","timestamp":1720289589196}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"292d48f5-a1a3-449e-9846-880116a142d2","timestamp":1720289589196,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions playground/.output/server/chunks/build/client.manifest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "mJS2XvxE.js",
"file": "tr5hBR7C.js",
"name": "error-404",
"src": "../node_modules/.pnpm/nuxt@3.12.3_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.14.9_eslint@9.6.0_i_f25eyvu7tzx3ixeamhjp2papoy/node_modules/nuxt/dist/app/components/error-404.vue",
"isDynamicEntry": true,
Expand All @@ -24,7 +24,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "N-EqdTw2.js",
"file": "DTJR8xyR.js",
"name": "error-500",
"src": "../node_modules/.pnpm/nuxt@3.12.3_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.14.9_eslint@9.6.0_i_f25eyvu7tzx3ixeamhjp2papoy/node_modules/nuxt/dist/app/components/error-500.vue",
"isDynamicEntry": true,
Expand All @@ -44,7 +44,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "D_X2kP3v.js",
"file": "q-QPnIUX.js",
"name": "entry",
"src": "../node_modules/.pnpm/nuxt@3.12.3_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.14.9_eslint@9.6.0_i_f25eyvu7tzx3ixeamhjp2papoy/node_modules/nuxt/dist/app/entry.js",
"isEntry": true,
Expand Down
7 changes: 5 additions & 2 deletions playground/.output/server/chunks/build/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,11 @@ watch(hidden, (value) => {
});
const toggleBadge = (value) => hidden.value = value;
function useRecaptcha() {
const { gsuite } = (/* @__PURE__ */ useRuntimeConfig()).public;
const execute = async (action) => await grecaptcha.execute(gsuite.recaptcha.siteKey, { action });
const gsuite = (/* @__PURE__ */ useRuntimeConfig()).public.gsuite;
const execute = async (action) => {
var _a;
return await grecaptcha.execute((_a = gsuite.recaptcha) == null ? void 0 : _a.siteKey, { action });
};
const verify = async (token) => await $fetch(`/recaptcha/${token}`);
return {
hidden,
Expand Down
48 changes: 24 additions & 24 deletions playground/.output/server/chunks/runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ const appConfig = defuFn(inlineAppConfig);
const _inlineRuntimeConfig = {
"app": {
"baseURL": "/",
"buildId": "64d2b9bd-b625-4a69-8c63-52de8d6690a9",
"buildId": "292d48f5-a1a3-449e-9846-880116a142d2",
"buildAssetsDir": "/_nuxt/",
"cdnURL": ""
},
Expand Down Expand Up @@ -5222,54 +5222,54 @@ const errorHandler = (async function errorhandler(error, event) {
});

const assets = {
"/_nuxt/D_X2kP3v.js": {
"/_nuxt/DTJR8xyR.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"1cb2a-eRCJOYkbpFkiEfoffmQTXzrQpcY\"",
"mtime": "2024-07-05T23:33:41.839Z",
"size": 117546,
"path": "../public/_nuxt/D_X2kP3v.js"
"etag": "\"ab3-Hw66/AuMN7HMNh9DcWfIMGZKWNs\"",
"mtime": "2024-07-06T18:13:15.167Z",
"size": 2739,
"path": "../public/_nuxt/DTJR8xyR.js"
},
"/_nuxt/error-404.CPoJt-Mw.css": {
"type": "text/css; charset=utf-8",
"etag": "\"de4-HoYY+VULRLxo9INpsMyVuP/BSaU\"",
"mtime": "2024-07-05T23:33:41.842Z",
"mtime": "2024-07-06T18:13:15.167Z",
"size": 3556,
"path": "../public/_nuxt/error-404.CPoJt-Mw.css"
},
"/_nuxt/error-500.CRm5MgNe.css": {
"type": "text/css; charset=utf-8",
"etag": "\"75c-aZv8f9SzIABfsNN4kJWna4Zm66U\"",
"mtime": "2024-07-05T23:33:41.840Z",
"mtime": "2024-07-06T18:13:15.163Z",
"size": 1884,
"path": "../public/_nuxt/error-500.CRm5MgNe.css"
},
"/_nuxt/mJS2XvxE.js": {
"/_nuxt/q-QPnIUX.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"200e-KJhGBfa3yJ9jT625vww0DixXBEY\"",
"mtime": "2024-07-05T23:33:41.842Z",
"size": 8206,
"path": "../public/_nuxt/mJS2XvxE.js"
"etag": "\"1cb4b-LfjiVsggRq6ZnMvHUjnTaQO27mw\"",
"mtime": "2024-07-06T18:13:15.167Z",
"size": 117579,
"path": "../public/_nuxt/q-QPnIUX.js"
},
"/_nuxt/N-EqdTw2.js": {
"/_nuxt/tr5hBR7C.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"ab3-3Seg6G2rgSTyoPT3MI8LX4CwfB4\"",
"mtime": "2024-07-05T23:33:41.842Z",
"size": 2739,
"path": "../public/_nuxt/N-EqdTw2.js"
"etag": "\"200e-BFrr+q4DJEzbhPzMloMYcz7GmTk\"",
"mtime": "2024-07-06T18:13:15.167Z",
"size": 8206,
"path": "../public/_nuxt/tr5hBR7C.js"
},
"/_nuxt/builds/latest.json": {
"type": "application/json",
"etag": "\"47-8d8GCNMAY/JeL1fWdanTNVQJl/4\"",
"mtime": "2024-07-05T23:33:42.609Z",
"etag": "\"47-ua3aHiLcf4MppjA4T6nIMNs8Adk\"",
"mtime": "2024-07-06T18:13:16.186Z",
"size": 71,
"path": "../public/_nuxt/builds/latest.json"
},
"/_nuxt/builds/meta/64d2b9bd-b625-4a69-8c63-52de8d6690a9.json": {
"/_nuxt/builds/meta/292d48f5-a1a3-449e-9846-880116a142d2.json": {
"type": "application/json",
"etag": "\"8b-IPtv/Jj9YwYywBQx1xuaxoarLYc\"",
"mtime": "2024-07-05T23:33:42.609Z",
"etag": "\"8b-poaS9IuwCsVzAuJSsAA8rOcdxSA\"",
"mtime": "2024-07-06T18:13:16.187Z",
"size": 139,
"path": "../public/_nuxt/builds/meta/64d2b9bd-b625-4a69-8c63-52de8d6690a9.json"
"path": "../public/_nuxt/builds/meta/292d48f5-a1a3-449e-9846-880116a142d2.json"
}
};

Expand Down
2 changes: 1 addition & 1 deletion playground/.output/server/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"nuxt-gsuite-prod","version":"1.0.0","type":"module","private":true,"dependencies":{"@babel/parser":"7.24.7","@unhead/dom":"1.9.15","@unhead/shared":"1.9.15","@unhead/ssr":"1.9.15","@vue/compiler-core":"3.4.31","@vue/compiler-dom":"3.4.31","@vue/compiler-ssr":"3.4.31","@vue/reactivity":"3.4.31","@vue/runtime-core":"3.4.31","@vue/runtime-dom":"3.4.31","@vue/server-renderer":"3.4.31","@vue/shared":"3.4.31","devalue":"5.0.0","entities":"4.5.0","estree-walker":"2.0.2","hookable":"5.5.3","source-map-js":"1.2.0","ufo":"1.5.3","unhead":"1.9.15","vue":"3.4.31","vue-bundle-renderer":"2.1.0"}}
{"name":"nuxt-gsuite-prod","version":"0.1.1","type":"module","private":true,"dependencies":{"@babel/parser":"7.24.7","@unhead/dom":"1.9.15","@unhead/shared":"1.9.15","@unhead/ssr":"1.9.15","@vue/compiler-core":"3.4.31","@vue/compiler-dom":"3.4.31","@vue/compiler-ssr":"3.4.31","@vue/reactivity":"3.4.31","@vue/runtime-core":"3.4.31","@vue/runtime-dom":"3.4.31","@vue/server-renderer":"3.4.31","@vue/shared":"3.4.31","devalue":"5.0.0","entities":"4.5.0","estree-walker":"2.0.2","hookable":"5.5.3","source-map-js":"1.2.0","ufo":"1.5.3","unhead":"1.9.15","vue":"3.4.31","vue-bundle-renderer":"2.1.0"}}
46 changes: 3 additions & 43 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,9 @@
import process from 'node:process'
import { addImports, addPlugin, addServerHandler, createResolver, defineNuxtModule, logger } from '@nuxt/kit'
import defu from 'defu'
import type { NuxtGSuiteOptions } from './types'

// Module options TypeScript interface definition
export interface ModuleOptions {
recaptcha?: {
/**
* Site key for Recaptcha.
*
* @default process.env.GSUITE_RECAPTCHA_SITEKEY
*
*/
siteKey: string
/**
* Secret key for Recaptcha.
*
* @default process.env.GSUITE_RECAPTCHA_SECRETKEY
*
*/
secretKey?: string
/**
* Minimum score to use for Recaptcha verification.
*
* @default 0.5
*
*/
minScore?: number
/**
* Version of Recaptcha to use.
*
* @default 'v3'
*
*/
version?: string
}
analytics?: {
/**
* Measurement Id for Analytics.
*
* @default process.env.GSUITE_ANALYTICS_MEASUREMENTID
*
*/
measurementId: string
}
}
export * from './types'

declare module '#app' {
const grecaptcha: any
Expand All @@ -53,7 +13,7 @@ declare module '#app' {
}
}

export default defineNuxtModule<ModuleOptions>({
export default defineNuxtModule<NuxtGSuiteOptions>({
meta: {
name: 'nuxt-gsuite',
configKey: 'gsuite',
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/compostables/useRecaptcha.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ref, watch } from 'vue'
import type { NuxtGSuiteOptions, RecaptchaResponse } from '../../types'
import { useHead, useRuntimeConfig } from '#imports'

const hidden = ref(false)
Expand All @@ -17,9 +18,9 @@ watch(hidden, (value) => {
const toggleBadge = (value: boolean) => hidden.value = value

export function useRecaptcha() {
const { gsuite } = useRuntimeConfig().public
const gsuite = useRuntimeConfig().public.gsuite as NuxtGSuiteOptions

const execute = async (action: string) => await grecaptcha.execute(gsuite.recaptcha.siteKey, { action })
const execute = async (action: string) => await grecaptcha.execute(gsuite.recaptcha?.siteKey, { action })

const verify = async (token: string) => await $fetch<RecaptchaResponse>(`/recaptcha/${token}`)

Expand Down
11 changes: 0 additions & 11 deletions src/runtime/types/index.d.ts

This file was deleted.

50 changes: 50 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export declare interface RecaptchaResponse {
'success': boolean
'challenge_ts'?: string
'hostname'?: string
'score'?: number
'action'?: string
'error-codes'?: string[]
}

export interface NuxtGSuiteOptions {
recaptcha?: {
/**
* Site key for Recaptcha.
*
* @default process.env.GSUITE_RECAPTCHA_SITEKEY
*
*/
siteKey: string
/**
* Secret key for Recaptcha.
*
* @default process.env.GSUITE_RECAPTCHA_SECRETKEY
*
*/
secretKey?: string
/**
* Minimum score to use for Recaptcha verification.
*
* @default 0.5
*
*/
minScore?: number
/**
* Version of Recaptcha to use.
*
* @default 'v3'
*
*/
version?: string
}
analytics?: {
/**
* Measurement Id for Analytics.
*
* @default process.env.GSUITE_ANALYTICS_MEASUREMENTID
*
*/
measurementId: string
}
}

0 comments on commit 7407867

Please sign in to comment.