nuxt-skew-protection 0.3.6 → 0.3.8
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.json +1 -1
- package/dist/module.mjs +59 -4
- package/package.json +8 -6
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { writeFileSync, unlinkSync, existsSync, readFileSync, promises } from 'node:fs';
|
|
2
|
-
import { useNuxt, tryUseNuxt,
|
|
2
|
+
import { useLogger, useNuxt, tryUseNuxt, defineNuxtModule, createResolver, hasNuxtModule, addTypeTemplate, addComponent, addImports, addPlugin, addServerHandler } from '@nuxt/kit';
|
|
3
3
|
import { colors } from 'consola/utils';
|
|
4
|
+
import { useSiteConfig, installNuxtSiteConfig } from 'nuxt-site-config/kit';
|
|
4
5
|
import { readPackageJSON } from 'pkg-types';
|
|
5
|
-
import
|
|
6
|
+
import * as p from '@clack/prompts';
|
|
7
|
+
import { $fetch } from 'ofetch';
|
|
8
|
+
import { isTest, isCI, provider, env } from 'std-env';
|
|
6
9
|
import { join } from 'node:path';
|
|
7
10
|
import { tmpdir } from 'node:os';
|
|
8
11
|
import { x } from 'tinyexec';
|
|
9
12
|
import { defineDriver, createStorage } from 'unstorage';
|
|
10
13
|
import { join as join$1, dirname } from 'pathe';
|
|
11
14
|
|
|
15
|
+
const logger = useLogger("nuxt-skew-protection");
|
|
16
|
+
|
|
12
17
|
function isStaticPreset(nuxt = useNuxt()) {
|
|
13
18
|
return nuxt.options.nitro?.static || nuxt.options._generate || [
|
|
14
19
|
"static",
|
|
@@ -42,8 +47,56 @@ function resolveNitroPreset(nitroConfig) {
|
|
|
42
47
|
preset = env.NITRO_PRESET || env.SERVER_PRESET || detectTarget() || "node-server";
|
|
43
48
|
return preset.replace("_", "-");
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
const
|
|
50
|
+
function hookNuxtSeoProLicense() {
|
|
51
|
+
const nuxt = useNuxt();
|
|
52
|
+
const isBuild = !nuxt.options.dev && !nuxt.options._prepare;
|
|
53
|
+
if (isBuild && !nuxt._isNuxtSeoProVerifying) {
|
|
54
|
+
const license = nuxt.options.runtimeConfig.seoProKey || process.env.NUXT_SEO_PRO_KEY;
|
|
55
|
+
if (isTest) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!isCI && !license) {
|
|
59
|
+
p.log.warn("\u26A0\uFE0F Building without license in non-CI environment. A license is required for production builds.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!license) {
|
|
63
|
+
p.log.error("\u{1F510} Nuxt SEO Pro license required");
|
|
64
|
+
p.note("Set NUXT_SEO_PRO_KEY or configure via module options.\n\nhttps://nuxtseo.com/pro/dashboard", "Get your license");
|
|
65
|
+
throw new Error("Missing Nuxt SEO Pro license key.");
|
|
66
|
+
}
|
|
67
|
+
nuxt._isNuxtSeoProVerifying = true;
|
|
68
|
+
nuxt.hooks.hook("build:before", async () => {
|
|
69
|
+
p.intro("Nuxt SEO Pro: License Verification");
|
|
70
|
+
const siteConfig = useSiteConfig();
|
|
71
|
+
const spinner = p.spinner();
|
|
72
|
+
spinner.start("\u{1F511} Verifying Nuxt SEO Pro license...");
|
|
73
|
+
const siteUrl = siteConfig.url?.startsWith("http") ? siteConfig.url : void 0;
|
|
74
|
+
const siteName = siteConfig.name || void 0;
|
|
75
|
+
const res = await $fetch("https://nuxtseo.com/api/pro/verify", {
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: { apiKey: license, siteUrl, siteName }
|
|
78
|
+
}).catch((err) => {
|
|
79
|
+
if (err?.response?.status === 401) {
|
|
80
|
+
spinner.stop("\u274C Invalid API key");
|
|
81
|
+
p.note("Your API key is invalid.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
|
|
82
|
+
throw new Error("Invalid Nuxt SEO Pro API key.");
|
|
83
|
+
}
|
|
84
|
+
if (err?.response?.status === 403) {
|
|
85
|
+
spinner.stop("\u274C No active subscription");
|
|
86
|
+
p.note("Your subscription has expired or is inactive.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
|
|
87
|
+
throw new Error("No active Nuxt SEO Pro subscription.");
|
|
88
|
+
}
|
|
89
|
+
logger.error(err);
|
|
90
|
+
return null;
|
|
91
|
+
});
|
|
92
|
+
if (!res) {
|
|
93
|
+
spinner.stop("\u26A0\uFE0F License verification skipped (network issue)");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
spinner.stop("License verified \u2713");
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
47
100
|
|
|
48
101
|
const cloudflareKVWranglerDriver = defineDriver((opts) => {
|
|
49
102
|
const { namespaceId, local = false, base = "" } = opts;
|
|
@@ -589,6 +642,8 @@ const module$1 = defineNuxtModule({
|
|
|
589
642
|
logger.debug("The module is disabled, skipping setup.");
|
|
590
643
|
return;
|
|
591
644
|
}
|
|
645
|
+
await installNuxtSiteConfig();
|
|
646
|
+
hookNuxtSeoProLicense();
|
|
592
647
|
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
593
648
|
nuxt.options.runtimeConfig.public.skewProtection = {
|
|
594
649
|
cookie: options.cookie,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-skew-protection",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.8",
|
|
5
5
|
"description": "Solve Nuxt version skews with persistent assets and instant updates.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -29,13 +29,15 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
32
|
+
"@clack/prompts": "^0.11.0",
|
|
33
|
+
"@nuxt/kit": "^4.2.2",
|
|
34
|
+
"@nuxtjs/robots": "^5.6.3",
|
|
34
35
|
"@vueuse/core": "^14.1.0",
|
|
35
36
|
"consola": "^3.4.2",
|
|
36
37
|
"cookie-es": "^2.0.0",
|
|
37
38
|
"defu": "^6.1.4",
|
|
38
39
|
"nuxt-site-config": "^3.2.11",
|
|
40
|
+
"ofetch": "^1.5.1",
|
|
39
41
|
"pathe": "^2.0.3",
|
|
40
42
|
"pkg-types": "^2.3.0",
|
|
41
43
|
"std-env": "^3.10.0",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"ufo": "^1.6.1"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@antfu/eslint-config": "^6.
|
|
48
|
+
"@antfu/eslint-config": "^6.5.1",
|
|
47
49
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
48
50
|
"@nuxt/content": "^3.9.0",
|
|
49
51
|
"@nuxt/devtools-ui-kit": "^3.1.1",
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
"firebase-functions": "^7.0.1",
|
|
69
71
|
"happy-dom": "^20.0.11",
|
|
70
72
|
"ioredis": "^5.8.2",
|
|
71
|
-
"nuxt": "^4.2.
|
|
73
|
+
"nuxt": "^4.2.2",
|
|
72
74
|
"playwright-core": "^1.57.0",
|
|
73
75
|
"tsx": "^4.21.0",
|
|
74
76
|
"typescript": "^5.9.3",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"vitest": "^4.0.15",
|
|
78
80
|
"vue": "^3.5.25",
|
|
79
81
|
"vue-router": "^4.6.3",
|
|
80
|
-
"vue-tsc": "^3.1.
|
|
82
|
+
"vue-tsc": "^3.1.8",
|
|
81
83
|
"wrangler": "^4.53.0",
|
|
82
84
|
"ws": "^8.18.3"
|
|
83
85
|
},
|