nuxt-og-image 6.7.2 → 6.7.4
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/chunks/tw4.cjs +7 -7
- package/dist/chunks/tw4.mjs +7 -7
- package/dist/chunks/uno.cjs +6 -6
- package/dist/chunks/uno.mjs +6 -6
- package/dist/cli.cjs +5 -12
- package/dist/cli.mjs +3 -10
- package/dist/devtools/lib/og-image/shared/urlEncoding.ts +5 -4
- package/dist/module.cjs +5 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -5
- package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.js +4 -6
- package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.js +4 -6
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.d.ts +1 -2
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +1 -7
- package/dist/runtime/app/plugins/route-rule-og-image.server.d.ts +1 -2
- package/dist/runtime/app/plugins/route-rule-og-image.server.js +1 -7
- package/dist/runtime/app/utils/plugins.d.ts +2 -3
- package/dist/runtime/app/utils/plugins.js +5 -5
- package/dist/runtime/server/og-image/context.js +6 -5
- package/dist/runtime/server/routes/resolve.js +3 -2
- package/dist/runtime/server/util/cache.js +5 -4
- package/dist/runtime/server/util/kit.js +2 -2
- package/dist/runtime/server/util/query.d.ts +7 -0
- package/dist/runtime/server/util/query.js +4 -0
- package/dist/runtime/shared/hash.d.ts +10 -0
- package/dist/runtime/shared/hash.js +5 -0
- package/dist/runtime/shared/urlEncoding.d.ts +3 -2
- package/dist/runtime/shared/urlEncoding.js +9 -9
- package/dist/shared/{nuxt-og-image.BCK8Adm4.cjs → nuxt-og-image.BRBtdkUp.cjs} +570 -81
- package/dist/shared/{nuxt-og-image.Pfj5JkJd.mjs → nuxt-og-image.Bv8VSGTj.mjs} +499 -10
- package/dist/shared/nuxt-og-image.CJa2KCie.mjs +189 -0
- package/dist/shared/nuxt-og-image.CMYbz66P.cjs +193 -0
- package/package.json +46 -44
- package/types/virtual.d.ts +9 -0
- package/dist/shared/nuxt-og-image.DQkJQHaN.cjs +0 -689
- package/dist/shared/nuxt-og-image.LgUGeaz-.mjs +0 -660
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { digest } from "ohash/crypto";
|
|
2
2
|
const MAX_PATH_LENGTH = 200;
|
|
3
3
|
const RE_BASE64_PADDING = /=/g;
|
|
4
4
|
const RE_BASE64_PLUS = /\+/g;
|
|
@@ -85,13 +85,13 @@ function b64Decode(str) {
|
|
|
85
85
|
return Buffer.from(padded, "base64").toString("utf8");
|
|
86
86
|
}
|
|
87
87
|
function simpleHash(str) {
|
|
88
|
-
let
|
|
88
|
+
let hash = 0;
|
|
89
89
|
for (let i = 0; i < str.length; i++) {
|
|
90
90
|
const char = str.charCodeAt(i);
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
hash = (hash << 5) - hash + char;
|
|
92
|
+
hash = hash & hash;
|
|
93
93
|
}
|
|
94
|
-
return Math.abs(
|
|
94
|
+
return Math.abs(hash).toString(36);
|
|
95
95
|
}
|
|
96
96
|
export function hashOgImageOptions(options, componentHash, version) {
|
|
97
97
|
const { _path, _hash, ...hashableOptions } = options;
|
|
@@ -233,10 +233,10 @@ export function buildOgImageUrl(options, extension = "png", isStatic = false, de
|
|
|
233
233
|
const encoded = encodeOgImageParams(options, defaults);
|
|
234
234
|
const prefix = isStatic ? "/_og/s" : "/_og/d";
|
|
235
235
|
if (isStatic && (encoded.length > MAX_PATH_LENGTH || encoded.includes("%"))) {
|
|
236
|
-
const
|
|
236
|
+
const hash = hashOgImageOptions(options);
|
|
237
237
|
return {
|
|
238
|
-
url: `${prefix}/o_${
|
|
239
|
-
hash
|
|
238
|
+
url: `${prefix}/o_${hash}.${extension}`,
|
|
239
|
+
hash
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
const segment = encoded || "default";
|
|
@@ -246,7 +246,7 @@ export function buildOgImageUrl(options, extension = "png", isStatic = false, de
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
export function signEncodedParams(encoded, secret) {
|
|
249
|
-
return
|
|
249
|
+
return digest(`${secret}:${encoded}`).slice(0, 16);
|
|
250
250
|
}
|
|
251
251
|
export function verifyOgImageSignature(encoded, signature, secret) {
|
|
252
252
|
const expected = signEncodedParams(encoded, secret);
|