@cimplify/sdk 0.53.0 → 0.54.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/dist/server.d.mts +19 -35
- package/dist/server.d.ts +19 -35
- package/dist/server.js +0 -86
- package/dist/server.mjs +1 -86
- package/package.json +1 -1
package/dist/server.d.mts
CHANGED
|
@@ -145,26 +145,26 @@ type CacheLifeDefault = typeof CACHE_LIFE_DEFAULT;
|
|
|
145
145
|
type CacheLifeProbe = typeof CACHE_LIFE_PROBE;
|
|
146
146
|
|
|
147
147
|
/** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
|
|
148
|
-
type RevalidateProfile
|
|
148
|
+
type RevalidateProfile = string | {
|
|
149
149
|
expire: number;
|
|
150
150
|
};
|
|
151
|
-
declare function revalidateProducts(profile?: RevalidateProfile
|
|
152
|
-
declare function revalidateProduct(id: string, profile?: RevalidateProfile
|
|
153
|
-
declare function revalidateCategories(profile?: RevalidateProfile
|
|
154
|
-
declare function revalidateCategory(id: string, profile?: RevalidateProfile
|
|
155
|
-
declare function revalidateCollections(profile?: RevalidateProfile
|
|
156
|
-
declare function revalidateCollection(id: string, profile?: RevalidateProfile
|
|
157
|
-
declare function revalidateBusiness(profile?: RevalidateProfile
|
|
158
|
-
declare function revalidateBrand(profile?: RevalidateProfile
|
|
159
|
-
declare function revalidateLocations(profile?: RevalidateProfile
|
|
160
|
-
declare function revalidateLocation(id: string, profile?: RevalidateProfile
|
|
161
|
-
declare function revalidatePricing(profile?: RevalidateProfile
|
|
162
|
-
declare function revalidateAddOns(profile?: RevalidateProfile
|
|
163
|
-
declare function revalidateAddOn(id: string, profile?: RevalidateProfile
|
|
164
|
-
declare function revalidateSubscriptions(profile?: RevalidateProfile
|
|
165
|
-
declare function revalidateSubscription(id: string, profile?: RevalidateProfile
|
|
166
|
-
declare function revalidateStock(productId?: string, profile?: RevalidateProfile
|
|
167
|
-
declare function revalidateByTag(tag: string, profile?: RevalidateProfile
|
|
151
|
+
declare function revalidateProducts(profile?: RevalidateProfile): Promise<void>;
|
|
152
|
+
declare function revalidateProduct(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
153
|
+
declare function revalidateCategories(profile?: RevalidateProfile): Promise<void>;
|
|
154
|
+
declare function revalidateCategory(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
155
|
+
declare function revalidateCollections(profile?: RevalidateProfile): Promise<void>;
|
|
156
|
+
declare function revalidateCollection(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
157
|
+
declare function revalidateBusiness(profile?: RevalidateProfile): Promise<void>;
|
|
158
|
+
declare function revalidateBrand(profile?: RevalidateProfile): Promise<void>;
|
|
159
|
+
declare function revalidateLocations(profile?: RevalidateProfile): Promise<void>;
|
|
160
|
+
declare function revalidateLocation(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
161
|
+
declare function revalidatePricing(profile?: RevalidateProfile): Promise<void>;
|
|
162
|
+
declare function revalidateAddOns(profile?: RevalidateProfile): Promise<void>;
|
|
163
|
+
declare function revalidateAddOn(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
164
|
+
declare function revalidateSubscriptions(profile?: RevalidateProfile): Promise<void>;
|
|
165
|
+
declare function revalidateSubscription(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
166
|
+
declare function revalidateStock(productId?: string, profile?: RevalidateProfile): Promise<void>;
|
|
167
|
+
declare function revalidateByTag(tag: string, profile?: RevalidateProfile): Promise<void>;
|
|
168
168
|
|
|
169
169
|
declare function updateProducts(): Promise<void>;
|
|
170
170
|
declare function updateProduct(id: string): Promise<void>;
|
|
@@ -185,20 +185,4 @@ declare function updateStock(productId?: string): Promise<void>;
|
|
|
185
185
|
declare function updateByTag(tag: string): Promise<void>;
|
|
186
186
|
declare function refreshPage(): Promise<void>;
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
type RevalidateProfile = string | {
|
|
190
|
-
expire: number;
|
|
191
|
-
};
|
|
192
|
-
interface RevalidateRouteOptions {
|
|
193
|
-
/** Defaults to `process.env.CIMPLIFY_REVALIDATE_SECRET`. */
|
|
194
|
-
secret?: string;
|
|
195
|
-
/** Defaults to a lazy import of `next/cache.revalidateTag`. Override for tests. */
|
|
196
|
-
revalidateTag?: (tag: string, profile: RevalidateProfile) => void;
|
|
197
|
-
/** Defaults to `Date.now`. Override for tests. */
|
|
198
|
-
now?: () => number;
|
|
199
|
-
/** Profile used when the request body doesn't include one. Defaults to `'max'`. */
|
|
200
|
-
defaultProfile?: RevalidateProfile;
|
|
201
|
-
}
|
|
202
|
-
declare function revalidateRouteHandler(req: Request, options?: RevalidateRouteOptions): Promise<Response>;
|
|
203
|
-
|
|
204
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|
|
188
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|
package/dist/server.d.ts
CHANGED
|
@@ -145,26 +145,26 @@ type CacheLifeDefault = typeof CACHE_LIFE_DEFAULT;
|
|
|
145
145
|
type CacheLifeProbe = typeof CACHE_LIFE_PROBE;
|
|
146
146
|
|
|
147
147
|
/** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
|
|
148
|
-
type RevalidateProfile
|
|
148
|
+
type RevalidateProfile = string | {
|
|
149
149
|
expire: number;
|
|
150
150
|
};
|
|
151
|
-
declare function revalidateProducts(profile?: RevalidateProfile
|
|
152
|
-
declare function revalidateProduct(id: string, profile?: RevalidateProfile
|
|
153
|
-
declare function revalidateCategories(profile?: RevalidateProfile
|
|
154
|
-
declare function revalidateCategory(id: string, profile?: RevalidateProfile
|
|
155
|
-
declare function revalidateCollections(profile?: RevalidateProfile
|
|
156
|
-
declare function revalidateCollection(id: string, profile?: RevalidateProfile
|
|
157
|
-
declare function revalidateBusiness(profile?: RevalidateProfile
|
|
158
|
-
declare function revalidateBrand(profile?: RevalidateProfile
|
|
159
|
-
declare function revalidateLocations(profile?: RevalidateProfile
|
|
160
|
-
declare function revalidateLocation(id: string, profile?: RevalidateProfile
|
|
161
|
-
declare function revalidatePricing(profile?: RevalidateProfile
|
|
162
|
-
declare function revalidateAddOns(profile?: RevalidateProfile
|
|
163
|
-
declare function revalidateAddOn(id: string, profile?: RevalidateProfile
|
|
164
|
-
declare function revalidateSubscriptions(profile?: RevalidateProfile
|
|
165
|
-
declare function revalidateSubscription(id: string, profile?: RevalidateProfile
|
|
166
|
-
declare function revalidateStock(productId?: string, profile?: RevalidateProfile
|
|
167
|
-
declare function revalidateByTag(tag: string, profile?: RevalidateProfile
|
|
151
|
+
declare function revalidateProducts(profile?: RevalidateProfile): Promise<void>;
|
|
152
|
+
declare function revalidateProduct(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
153
|
+
declare function revalidateCategories(profile?: RevalidateProfile): Promise<void>;
|
|
154
|
+
declare function revalidateCategory(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
155
|
+
declare function revalidateCollections(profile?: RevalidateProfile): Promise<void>;
|
|
156
|
+
declare function revalidateCollection(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
157
|
+
declare function revalidateBusiness(profile?: RevalidateProfile): Promise<void>;
|
|
158
|
+
declare function revalidateBrand(profile?: RevalidateProfile): Promise<void>;
|
|
159
|
+
declare function revalidateLocations(profile?: RevalidateProfile): Promise<void>;
|
|
160
|
+
declare function revalidateLocation(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
161
|
+
declare function revalidatePricing(profile?: RevalidateProfile): Promise<void>;
|
|
162
|
+
declare function revalidateAddOns(profile?: RevalidateProfile): Promise<void>;
|
|
163
|
+
declare function revalidateAddOn(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
164
|
+
declare function revalidateSubscriptions(profile?: RevalidateProfile): Promise<void>;
|
|
165
|
+
declare function revalidateSubscription(id: string, profile?: RevalidateProfile): Promise<void>;
|
|
166
|
+
declare function revalidateStock(productId?: string, profile?: RevalidateProfile): Promise<void>;
|
|
167
|
+
declare function revalidateByTag(tag: string, profile?: RevalidateProfile): Promise<void>;
|
|
168
168
|
|
|
169
169
|
declare function updateProducts(): Promise<void>;
|
|
170
170
|
declare function updateProduct(id: string): Promise<void>;
|
|
@@ -185,20 +185,4 @@ declare function updateStock(productId?: string): Promise<void>;
|
|
|
185
185
|
declare function updateByTag(tag: string): Promise<void>;
|
|
186
186
|
declare function refreshPage(): Promise<void>;
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
type RevalidateProfile = string | {
|
|
190
|
-
expire: number;
|
|
191
|
-
};
|
|
192
|
-
interface RevalidateRouteOptions {
|
|
193
|
-
/** Defaults to `process.env.CIMPLIFY_REVALIDATE_SECRET`. */
|
|
194
|
-
secret?: string;
|
|
195
|
-
/** Defaults to a lazy import of `next/cache.revalidateTag`. Override for tests. */
|
|
196
|
-
revalidateTag?: (tag: string, profile: RevalidateProfile) => void;
|
|
197
|
-
/** Defaults to `Date.now`. Override for tests. */
|
|
198
|
-
now?: () => number;
|
|
199
|
-
/** Profile used when the request body doesn't include one. Defaults to `'max'`. */
|
|
200
|
-
defaultProfile?: RevalidateProfile;
|
|
201
|
-
}
|
|
202
|
-
declare function revalidateRouteHandler(req: Request, options?: RevalidateRouteOptions): Promise<Response>;
|
|
203
|
-
|
|
204
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|
|
188
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|
package/dist/server.js
CHANGED
|
@@ -234,91 +234,6 @@ async function refreshPage() {
|
|
|
234
234
|
fn();
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// src/server/revalidate-route.ts
|
|
238
|
-
var TIMESTAMP_HEADER = "x-cimplify-timestamp";
|
|
239
|
-
var SIGNATURE_HEADER = "x-cimplify-signature";
|
|
240
|
-
var SIGNATURE_PREFIX = "sha256=";
|
|
241
|
-
var MAX_SKEW_MS = 5 * 60 * 1e3;
|
|
242
|
-
var SECRET_ENV = "CIMPLIFY_REVALIDATE_SECRET";
|
|
243
|
-
var DEFAULT_PROFILE2 = CACHE_LIFE_DEFAULT;
|
|
244
|
-
async function revalidateRouteHandler(req, options = {}) {
|
|
245
|
-
const secret = options.secret ?? envSecret();
|
|
246
|
-
if (!secret) return text(`revalidate disabled: ${SECRET_ENV} not set`, 500);
|
|
247
|
-
const timestamp = req.headers.get(TIMESTAMP_HEADER);
|
|
248
|
-
const signature = req.headers.get(SIGNATURE_HEADER);
|
|
249
|
-
if (!timestamp || !signature) return text("missing auth headers", 401);
|
|
250
|
-
const ts = Number.parseInt(timestamp, 10);
|
|
251
|
-
const now = options.now ?? Date.now;
|
|
252
|
-
if (!Number.isFinite(ts) || Math.abs(now() - ts) > MAX_SKEW_MS) {
|
|
253
|
-
return text("stale or invalid timestamp", 401);
|
|
254
|
-
}
|
|
255
|
-
const body = await req.text();
|
|
256
|
-
if (!await verifyHmac(secret, `${timestamp}.${body}`, signature)) {
|
|
257
|
-
return text("invalid signature", 401);
|
|
258
|
-
}
|
|
259
|
-
let parsed;
|
|
260
|
-
try {
|
|
261
|
-
parsed = JSON.parse(body);
|
|
262
|
-
} catch {
|
|
263
|
-
return text("invalid json", 400);
|
|
264
|
-
}
|
|
265
|
-
const tags2 = Array.isArray(parsed.tags) ? parsed.tags.filter((t) => typeof t === "string" && t.length > 0) : [];
|
|
266
|
-
if (tags2.length === 0) return text("no tags", 400);
|
|
267
|
-
const profile = parseProfile(parsed.profile) ?? options.defaultProfile ?? DEFAULT_PROFILE2;
|
|
268
|
-
const revalidate2 = options.revalidateTag ?? await loadRevalidateTag();
|
|
269
|
-
for (const tag of tags2) revalidate2(tag, profile);
|
|
270
|
-
return Response.json({ ok: true, revalidated: tags2.length, profile });
|
|
271
|
-
}
|
|
272
|
-
function parseProfile(raw) {
|
|
273
|
-
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
274
|
-
if (raw && typeof raw === "object" && "expire" in raw && typeof raw.expire === "number") {
|
|
275
|
-
return { expire: raw.expire };
|
|
276
|
-
}
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
var cachedRevalidateTag = null;
|
|
280
|
-
async function loadRevalidateTag() {
|
|
281
|
-
if (cachedRevalidateTag) return cachedRevalidateTag;
|
|
282
|
-
const specifier = "next/cache";
|
|
283
|
-
const mod = await import(
|
|
284
|
-
/* webpackIgnore: true */
|
|
285
|
-
/* @vite-ignore */
|
|
286
|
-
specifier
|
|
287
|
-
);
|
|
288
|
-
cachedRevalidateTag = mod.revalidateTag;
|
|
289
|
-
return cachedRevalidateTag;
|
|
290
|
-
}
|
|
291
|
-
async function verifyHmac(secret, payload, signatureHeader) {
|
|
292
|
-
if (!signatureHeader.startsWith(SIGNATURE_PREFIX)) return false;
|
|
293
|
-
const providedBytes = hexToBytes(signatureHeader.slice(SIGNATURE_PREFIX.length));
|
|
294
|
-
if (!providedBytes) return false;
|
|
295
|
-
const enc = new TextEncoder();
|
|
296
|
-
const key = await crypto.subtle.importKey(
|
|
297
|
-
"raw",
|
|
298
|
-
enc.encode(secret),
|
|
299
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
300
|
-
false,
|
|
301
|
-
["verify"]
|
|
302
|
-
);
|
|
303
|
-
return crypto.subtle.verify("HMAC", key, providedBytes, enc.encode(payload));
|
|
304
|
-
}
|
|
305
|
-
function hexToBytes(hex) {
|
|
306
|
-
if (hex.length % 2 !== 0 || !/^[0-9a-f]+$/i.test(hex)) return null;
|
|
307
|
-
const buf = new ArrayBuffer(hex.length / 2);
|
|
308
|
-
const out = new Uint8Array(buf);
|
|
309
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
310
|
-
out[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
311
|
-
}
|
|
312
|
-
return out;
|
|
313
|
-
}
|
|
314
|
-
function envSecret() {
|
|
315
|
-
const proc = globalThis.process;
|
|
316
|
-
return proc?.env?.[SECRET_ENV];
|
|
317
|
-
}
|
|
318
|
-
function text(message, status) {
|
|
319
|
-
return new Response(message, { status, headers: { "content-type": "text/plain" } });
|
|
320
|
-
}
|
|
321
|
-
|
|
322
237
|
Object.defineProperty(exports, "CimplifyError", {
|
|
323
238
|
enumerable: true,
|
|
324
239
|
get: function () { return chunkXA3ZNR75_js.CimplifyError; }
|
|
@@ -341,7 +256,6 @@ exports.revalidateLocations = revalidateLocations;
|
|
|
341
256
|
exports.revalidatePricing = revalidatePricing;
|
|
342
257
|
exports.revalidateProduct = revalidateProduct;
|
|
343
258
|
exports.revalidateProducts = revalidateProducts;
|
|
344
|
-
exports.revalidateRouteHandler = revalidateRouteHandler;
|
|
345
259
|
exports.revalidateStock = revalidateStock;
|
|
346
260
|
exports.revalidateSubscription = revalidateSubscription;
|
|
347
261
|
exports.revalidateSubscriptions = revalidateSubscriptions;
|
package/dist/server.mjs
CHANGED
|
@@ -232,89 +232,4 @@ async function refreshPage() {
|
|
|
232
232
|
fn();
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
var TIMESTAMP_HEADER = "x-cimplify-timestamp";
|
|
237
|
-
var SIGNATURE_HEADER = "x-cimplify-signature";
|
|
238
|
-
var SIGNATURE_PREFIX = "sha256=";
|
|
239
|
-
var MAX_SKEW_MS = 5 * 60 * 1e3;
|
|
240
|
-
var SECRET_ENV = "CIMPLIFY_REVALIDATE_SECRET";
|
|
241
|
-
var DEFAULT_PROFILE2 = CACHE_LIFE_DEFAULT;
|
|
242
|
-
async function revalidateRouteHandler(req, options = {}) {
|
|
243
|
-
const secret = options.secret ?? envSecret();
|
|
244
|
-
if (!secret) return text(`revalidate disabled: ${SECRET_ENV} not set`, 500);
|
|
245
|
-
const timestamp = req.headers.get(TIMESTAMP_HEADER);
|
|
246
|
-
const signature = req.headers.get(SIGNATURE_HEADER);
|
|
247
|
-
if (!timestamp || !signature) return text("missing auth headers", 401);
|
|
248
|
-
const ts = Number.parseInt(timestamp, 10);
|
|
249
|
-
const now = options.now ?? Date.now;
|
|
250
|
-
if (!Number.isFinite(ts) || Math.abs(now() - ts) > MAX_SKEW_MS) {
|
|
251
|
-
return text("stale or invalid timestamp", 401);
|
|
252
|
-
}
|
|
253
|
-
const body = await req.text();
|
|
254
|
-
if (!await verifyHmac(secret, `${timestamp}.${body}`, signature)) {
|
|
255
|
-
return text("invalid signature", 401);
|
|
256
|
-
}
|
|
257
|
-
let parsed;
|
|
258
|
-
try {
|
|
259
|
-
parsed = JSON.parse(body);
|
|
260
|
-
} catch {
|
|
261
|
-
return text("invalid json", 400);
|
|
262
|
-
}
|
|
263
|
-
const tags2 = Array.isArray(parsed.tags) ? parsed.tags.filter((t) => typeof t === "string" && t.length > 0) : [];
|
|
264
|
-
if (tags2.length === 0) return text("no tags", 400);
|
|
265
|
-
const profile = parseProfile(parsed.profile) ?? options.defaultProfile ?? DEFAULT_PROFILE2;
|
|
266
|
-
const revalidate2 = options.revalidateTag ?? await loadRevalidateTag();
|
|
267
|
-
for (const tag of tags2) revalidate2(tag, profile);
|
|
268
|
-
return Response.json({ ok: true, revalidated: tags2.length, profile });
|
|
269
|
-
}
|
|
270
|
-
function parseProfile(raw) {
|
|
271
|
-
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
272
|
-
if (raw && typeof raw === "object" && "expire" in raw && typeof raw.expire === "number") {
|
|
273
|
-
return { expire: raw.expire };
|
|
274
|
-
}
|
|
275
|
-
return void 0;
|
|
276
|
-
}
|
|
277
|
-
var cachedRevalidateTag = null;
|
|
278
|
-
async function loadRevalidateTag() {
|
|
279
|
-
if (cachedRevalidateTag) return cachedRevalidateTag;
|
|
280
|
-
const specifier = "next/cache";
|
|
281
|
-
const mod = await import(
|
|
282
|
-
/* webpackIgnore: true */
|
|
283
|
-
/* @vite-ignore */
|
|
284
|
-
specifier
|
|
285
|
-
);
|
|
286
|
-
cachedRevalidateTag = mod.revalidateTag;
|
|
287
|
-
return cachedRevalidateTag;
|
|
288
|
-
}
|
|
289
|
-
async function verifyHmac(secret, payload, signatureHeader) {
|
|
290
|
-
if (!signatureHeader.startsWith(SIGNATURE_PREFIX)) return false;
|
|
291
|
-
const providedBytes = hexToBytes(signatureHeader.slice(SIGNATURE_PREFIX.length));
|
|
292
|
-
if (!providedBytes) return false;
|
|
293
|
-
const enc = new TextEncoder();
|
|
294
|
-
const key = await crypto.subtle.importKey(
|
|
295
|
-
"raw",
|
|
296
|
-
enc.encode(secret),
|
|
297
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
298
|
-
false,
|
|
299
|
-
["verify"]
|
|
300
|
-
);
|
|
301
|
-
return crypto.subtle.verify("HMAC", key, providedBytes, enc.encode(payload));
|
|
302
|
-
}
|
|
303
|
-
function hexToBytes(hex) {
|
|
304
|
-
if (hex.length % 2 !== 0 || !/^[0-9a-f]+$/i.test(hex)) return null;
|
|
305
|
-
const buf = new ArrayBuffer(hex.length / 2);
|
|
306
|
-
const out = new Uint8Array(buf);
|
|
307
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
308
|
-
out[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
309
|
-
}
|
|
310
|
-
return out;
|
|
311
|
-
}
|
|
312
|
-
function envSecret() {
|
|
313
|
-
const proc = globalThis.process;
|
|
314
|
-
return proc?.env?.[SECRET_ENV];
|
|
315
|
-
}
|
|
316
|
-
function text(message, status) {
|
|
317
|
-
return new Response(message, { status, headers: { "content-type": "text/plain" } });
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|
|
235
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
|