unpeek 2.0.0 → 3.0.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 +30 -8
- package/README.tr.md +30 -8
- package/dist/adapters/esbuild.cjs +13 -0
- package/dist/{esbuild.d.cts → adapters/esbuild.d.cts} +2 -2
- package/dist/{esbuild.d.ts → adapters/esbuild.d.ts} +2 -2
- package/dist/adapters/esbuild.js +11 -0
- package/dist/adapters/next/adapter.cjs +42 -0
- package/dist/{next → adapters/next}/adapter.d.cts +4 -4
- package/dist/{next → adapters/next}/adapter.d.ts +4 -4
- package/dist/adapters/next/adapter.js +42 -0
- package/dist/adapters/next/index.cjs +15 -0
- package/dist/adapters/next/index.d.cts +53 -0
- package/dist/adapters/next/index.d.ts +53 -0
- package/dist/adapters/next/index.js +15 -0
- package/dist/adapters/rollup.cjs +13 -0
- package/dist/{rollup.d.cts → adapters/rollup.d.cts} +2 -2
- package/dist/{rollup.d.ts → adapters/rollup.d.ts} +2 -2
- package/dist/adapters/rollup.js +11 -0
- package/dist/adapters/rspack.cjs +12 -0
- package/dist/adapters/rspack.d.cts +13 -0
- package/dist/adapters/rspack.d.ts +11 -0
- package/dist/adapters/rspack.js +12 -0
- package/dist/adapters/vite.cjs +13 -0
- package/dist/{vite.d.cts → adapters/vite.d.cts} +2 -2
- package/dist/{vite.d.ts → adapters/vite.d.ts} +2 -2
- package/dist/adapters/vite.js +11 -0
- package/dist/adapters/webpack.cjs +13 -0
- package/dist/{webpack.d.cts → adapters/webpack.d.cts} +2 -2
- package/dist/{webpack.d.ts → adapters/webpack.d.ts} +2 -2
- package/dist/adapters/webpack.js +11 -0
- package/dist/browser.cjs +8 -5
- package/dist/browser.d.cts +41 -3
- package/dist/browser.d.ts +41 -3
- package/dist/browser.js +10 -7
- package/dist/{chunk-GAVI2C44.cjs → chunk-6TDCSIRZ.cjs} +76 -47
- package/dist/{chunk-5LCMI2TL.js → chunk-APWMNVAZ.js} +221 -32
- package/dist/{chunk-5QD6FZPB.js → chunk-BPRSCRUZ.js} +71 -42
- package/dist/{chunk-X5MKMFMX.js → chunk-DUK2SECY.js} +7 -7
- package/dist/chunk-FCF2EGPM.js +80 -0
- package/dist/{chunk-7YVEHJVM.cjs → chunk-I6GXEHFR.cjs} +241 -52
- package/dist/{chunk-LXP73HJC.cjs → chunk-IAD5DV3D.cjs} +1048 -213
- package/dist/chunk-IEBVL5BT.cjs +80 -0
- package/dist/{chunk-GZB7PFLY.js → chunk-IICVBTR2.js} +25 -62
- package/dist/{chunk-UMPUYLLZ.js → chunk-IZIWDJRF.js} +936 -101
- package/dist/chunk-L6BOM5VS.cjs +40 -0
- package/dist/{chunk-OOXSZTRV.js → chunk-LA6J3BT3.js} +26 -1
- package/dist/{chunk-24K5NDXH.cjs → chunk-ONM2CSTU.cjs} +45 -82
- package/dist/{chunk-5M6Z7ZFT.cjs → chunk-RXUY3MPH.cjs} +10 -10
- package/dist/cli/index.js +7309 -32
- package/dist/{types-BBSRUEab.d.cts → config-CfXY_iDD.d.cts} +44 -86
- package/dist/{types-BBSRUEab.d.ts → config-CfXY_iDD.d.ts} +44 -86
- package/dist/config.cjs +4 -16
- package/dist/config.d.cts +1 -12
- package/dist/config.d.ts +1 -12
- package/dist/config.js +5 -17
- package/dist/index-CjRTNPlj.d.cts +46 -0
- package/dist/index-Cm1IloVm.d.ts +46 -0
- package/dist/index.cjs +636 -9
- package/dist/index.d.cts +9 -17
- package/dist/index.d.ts +9 -17
- package/dist/index.js +638 -11
- package/dist/plugins/unplugin.cjs +20 -0
- package/dist/plugins/unplugin.d.cts +17 -0
- package/dist/plugins/unplugin.d.ts +15 -0
- package/dist/{bundler → plugins}/unplugin.js +5 -5
- package/dist/types-DYQIzGf6.d.cts +112 -0
- package/dist/types-ZHAFdOd3.d.ts +112 -0
- package/package.json +48 -52
- package/dist/ast/index.cjs +0 -17
- package/dist/ast/index.d.cts +0 -18
- package/dist/ast/index.d.ts +0 -18
- package/dist/ast/index.js +0 -17
- package/dist/bundler/unplugin.cjs +0 -20
- package/dist/bundler/unplugin.d.cts +0 -16
- package/dist/bundler/unplugin.d.ts +0 -14
- package/dist/chunk-27HR647Q.js +0 -190
- package/dist/chunk-4TDLLEEU.cjs +0 -15
- package/dist/chunk-6N6S6WTQ.cjs +0 -423
- package/dist/chunk-J5CGNZDM.cjs +0 -190
- package/dist/chunk-KQWNFKT2.js +0 -423
- package/dist/chunk-R6EBIR3T.cjs +0 -14
- package/dist/chunk-S4S2WXGC.js +0 -14
- package/dist/cli/index.cjs +0 -324
- package/dist/cli/index.d.cts +0 -22
- package/dist/cli/index.d.ts +0 -22
- package/dist/esbuild.cjs +0 -15
- package/dist/esbuild.js +0 -13
- package/dist/next/adapter.cjs +0 -31
- package/dist/next/adapter.js +0 -31
- package/dist/next/index.cjs +0 -18
- package/dist/next/index.d.cts +0 -42
- package/dist/next/index.d.ts +0 -42
- package/dist/next/index.js +0 -18
- package/dist/rollup.cjs +0 -15
- package/dist/rollup.js +0 -13
- package/dist/runtime/index.cjs +0 -17
- package/dist/runtime/index.d.cts +0 -36
- package/dist/runtime/index.d.ts +0 -36
- package/dist/runtime/index.js +0 -17
- package/dist/vite.cjs +0 -15
- package/dist/vite.js +0 -13
- package/dist/webpack.cjs +0 -15
- package/dist/webpack.js +0 -13
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { vitePlugin } from '
|
|
1
|
+
import { vitePlugin } from '../plugins/unplugin.js';
|
|
2
2
|
import 'esbuild';
|
|
3
3
|
import 'rollup';
|
|
4
4
|
import 'webpack';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'unplugin';
|
|
7
|
-
import '
|
|
7
|
+
import '../config-CfXY_iDD.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkRXUY3MPHcjs = require('../chunk-RXUY3MPH.cjs');
|
|
4
|
+
require('../chunk-IAD5DV3D.cjs');
|
|
5
|
+
require('../chunk-L6BOM5VS.cjs');
|
|
6
|
+
|
|
7
|
+
// src/adapters/webpack.ts
|
|
8
|
+
var webpack_default = _chunkRXUY3MPHcjs.webpackPlugin;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.default = webpack_default;
|
|
12
|
+
|
|
13
|
+
module.exports = exports.default;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { webpackPlugin } from '
|
|
1
|
+
import { webpackPlugin } from '../plugins/unplugin.cjs';
|
|
2
2
|
import 'esbuild';
|
|
3
3
|
import 'rollup';
|
|
4
4
|
import 'webpack';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'unplugin';
|
|
7
|
-
import '
|
|
7
|
+
import '../config-CfXY_iDD.cjs';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { webpackPlugin } from '
|
|
1
|
+
import { webpackPlugin } from '../plugins/unplugin.js';
|
|
2
2
|
import 'esbuild';
|
|
3
3
|
import 'rollup';
|
|
4
4
|
import 'webpack';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'unplugin';
|
|
7
|
-
import '
|
|
7
|
+
import '../config-CfXY_iDD.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
package/dist/browser.cjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkIEBVL5BTcjs = require('./chunk-IEBVL5BT.cjs');
|
|
3
4
|
|
|
4
|
-
var _chunkLXP73HJCcjs = require('./chunk-LXP73HJC.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var _chunk6N6S6WTQcjs = require('./chunk-6N6S6WTQ.cjs');
|
|
12
11
|
|
|
12
|
+
var _chunkIAD5DV3Dcjs = require('./chunk-IAD5DV3D.cjs');
|
|
13
13
|
|
|
14
|
-
var _chunkR6EBIR3Tcjs = require('./chunk-R6EBIR3T.cjs');
|
|
15
|
-
require('./chunk-4TDLLEEU.cjs');
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
|
|
@@ -22,4 +21,8 @@ require('./chunk-4TDLLEEU.cjs');
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.PRESETS = _chunkIEBVL5BTcjs.PRESETS; exports.UnpeekError = _chunkL6BOM5VScjs.UnpeekError; exports.computeFnv1aHash = _chunkIAD5DV3Dcjs.computeFnv1aHash; exports.computeIntegrityHash = _chunkIAD5DV3Dcjs.computeIntegrityHash; exports.createDeterrentSnippet = _chunkIAD5DV3Dcjs.createDeterrentSnippet; exports.detectHotPaths = _chunkIAD5DV3Dcjs.detectHotPaths; exports.generateRuntimeShield = _chunkIAD5DV3Dcjs.generateRuntimeShield; exports.isUnpeekError = _chunkL6BOM5VScjs.isUnpeekError; exports.transformJavaScript = _chunkIAD5DV3Dcjs.transformJavaScript; exports.verifyCodeIntegrity = _chunkIAD5DV3Dcjs.verifyCodeIntegrity;
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { U as UnpeekConfig, S as ShieldConfig, a as ShieldPayload } from './config-CfXY_iDD.cjs';
|
|
2
|
+
export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions } from './config-CfXY_iDD.cjs';
|
|
3
|
+
import { H as HotPathReport } from './index-CjRTNPlj.cjs';
|
|
4
|
+
export { S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-CjRTNPlj.cjs';
|
|
5
|
+
|
|
6
|
+
declare function computeFnv1aHash(input: string, seed?: number): number;
|
|
7
|
+
|
|
8
|
+
declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Computes a 32-bit unsigned FNV-1a hash over the un-normalized source string.
|
|
12
|
+
* Any formatting change (such as DevTools Pretty-Print adding newlines or spaces)
|
|
13
|
+
* or monkeypatching alters the resulting hash.
|
|
14
|
+
*/
|
|
15
|
+
declare function computeIntegrityHash(source: string, seed?: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Verifies that a function or source string has not been pretty-printed or modified
|
|
18
|
+
* by comparing its un-normalized Function.prototype.toString() FNV-1a hash.
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyCodeIntegrity(fnOrSource: ((...args: unknown[]) => unknown) | string, expectedHash: number, seed?: number): boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generates a single-line, self-executing (IIFE), polymorphic, synchronous, SSR-safe (<1.5 KB)
|
|
24
|
+
* anti-tamper deterrent snippet that calculates a synchronous 32-bit FNV-1a hash of its own
|
|
25
|
+
* Function.prototype.toString() representation and writes the 16-bit key component (expectedDelta)
|
|
26
|
+
* to window[windowKeySymbol].
|
|
27
|
+
*
|
|
28
|
+
* Freedom To Operate (FTO) Compliance:
|
|
29
|
+
* Strictly avoids timer / setInterval active debugging checks, timing differential loops,
|
|
30
|
+
* and periodic debugger polling covered by third-party patents (e.g. Jscrambler US9979726B2).
|
|
31
|
+
* Operates purely via synchronous cryptographic state coupling via FNV-1a hash and tamper flags.
|
|
32
|
+
*
|
|
33
|
+
* When tampering is detected (formatting, pretty-print, webdriver, toString spoofing):
|
|
34
|
+
* window.__unpeek_tampered is set to true, String.prototype._u is poisoned to 14,
|
|
35
|
+
* window[sym] is poisoned to expectedDelta ^ 0x5a5b, and CustomEvent('unpeek:tamper') is dispatched.
|
|
36
|
+
*/
|
|
37
|
+
declare function createDeterrentSnippet(config: ShieldConfig): string;
|
|
38
|
+
|
|
39
|
+
declare function generateRuntimeShield(config: ShieldConfig): ShieldPayload;
|
|
40
|
+
|
|
41
|
+
export { HotPathReport, ShieldConfig, ShieldPayload, UnpeekConfig, computeFnv1aHash, computeIntegrityHash, createDeterrentSnippet, detectHotPaths, generateRuntimeShield, verifyCodeIntegrity };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { U as UnpeekConfig, S as ShieldConfig, a as ShieldPayload } from './config-CfXY_iDD.js';
|
|
2
|
+
export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions } from './config-CfXY_iDD.js';
|
|
3
|
+
import { H as HotPathReport } from './index-Cm1IloVm.js';
|
|
4
|
+
export { S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-Cm1IloVm.js';
|
|
5
|
+
|
|
6
|
+
declare function computeFnv1aHash(input: string, seed?: number): number;
|
|
7
|
+
|
|
8
|
+
declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Computes a 32-bit unsigned FNV-1a hash over the un-normalized source string.
|
|
12
|
+
* Any formatting change (such as DevTools Pretty-Print adding newlines or spaces)
|
|
13
|
+
* or monkeypatching alters the resulting hash.
|
|
14
|
+
*/
|
|
15
|
+
declare function computeIntegrityHash(source: string, seed?: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Verifies that a function or source string has not been pretty-printed or modified
|
|
18
|
+
* by comparing its un-normalized Function.prototype.toString() FNV-1a hash.
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyCodeIntegrity(fnOrSource: ((...args: unknown[]) => unknown) | string, expectedHash: number, seed?: number): boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generates a single-line, self-executing (IIFE), polymorphic, synchronous, SSR-safe (<1.5 KB)
|
|
24
|
+
* anti-tamper deterrent snippet that calculates a synchronous 32-bit FNV-1a hash of its own
|
|
25
|
+
* Function.prototype.toString() representation and writes the 16-bit key component (expectedDelta)
|
|
26
|
+
* to window[windowKeySymbol].
|
|
27
|
+
*
|
|
28
|
+
* Freedom To Operate (FTO) Compliance:
|
|
29
|
+
* Strictly avoids timer / setInterval active debugging checks, timing differential loops,
|
|
30
|
+
* and periodic debugger polling covered by third-party patents (e.g. Jscrambler US9979726B2).
|
|
31
|
+
* Operates purely via synchronous cryptographic state coupling via FNV-1a hash and tamper flags.
|
|
32
|
+
*
|
|
33
|
+
* When tampering is detected (formatting, pretty-print, webdriver, toString spoofing):
|
|
34
|
+
* window.__unpeek_tampered is set to true, String.prototype._u is poisoned to 14,
|
|
35
|
+
* window[sym] is poisoned to expectedDelta ^ 0x5a5b, and CustomEvent('unpeek:tamper') is dispatched.
|
|
36
|
+
*/
|
|
37
|
+
declare function createDeterrentSnippet(config: ShieldConfig): string;
|
|
38
|
+
|
|
39
|
+
declare function generateRuntimeShield(config: ShieldConfig): ShieldPayload;
|
|
40
|
+
|
|
41
|
+
export { HotPathReport, ShieldConfig, ShieldPayload, UnpeekConfig, computeFnv1aHash, computeIntegrityHash, createDeterrentSnippet, detectHotPaths, generateRuntimeShield, verifyCodeIntegrity };
|
package/dist/browser.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-UMPUYLLZ.js";
|
|
2
|
+
PRESETS
|
|
3
|
+
} from "./chunk-FCF2EGPM.js";
|
|
5
4
|
import {
|
|
6
5
|
computeFnv1aHash,
|
|
7
6
|
computeIntegrityHash,
|
|
8
7
|
createDeterrentSnippet,
|
|
8
|
+
detectHotPaths,
|
|
9
9
|
generateRuntimeShield,
|
|
10
|
+
transformJavaScript,
|
|
10
11
|
verifyCodeIntegrity
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IZIWDJRF.js";
|
|
12
13
|
import {
|
|
13
|
-
UnpeekError
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
UnpeekError,
|
|
15
|
+
isUnpeekError
|
|
16
|
+
} from "./chunk-LA6J3BT3.js";
|
|
16
17
|
export {
|
|
18
|
+
PRESETS,
|
|
17
19
|
UnpeekError,
|
|
18
20
|
computeFnv1aHash,
|
|
19
21
|
computeIntegrityHash,
|
|
20
22
|
createDeterrentSnippet,
|
|
21
23
|
detectHotPaths,
|
|
22
24
|
generateRuntimeShield,
|
|
25
|
+
isUnpeekError,
|
|
23
26
|
transformJavaScript,
|
|
24
27
|
verifyCodeIntegrity
|
|
25
28
|
};
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var _chunk7YVEHJVMcjs = require('./chunk-7YVEHJVM.cjs');
|
|
4
3
|
|
|
4
|
+
var _chunkI6GXEHFRcjs = require('./chunk-I6GXEHFR.cjs');
|
|
5
5
|
|
|
6
|
-
var _chunk6N6S6WTQcjs = require('./chunk-6N6S6WTQ.cjs');
|
|
7
6
|
|
|
7
|
+
var _chunkIAD5DV3Dcjs = require('./chunk-IAD5DV3D.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunk4TDLLEEUcjs = require('./chunk-4TDLLEEU.cjs');
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
|
|
13
|
+
|
|
14
|
+
// src/adapters/next/index.ts
|
|
13
15
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
14
16
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
15
17
|
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
16
18
|
var _url = require('url');
|
|
17
19
|
var _module = require('module');
|
|
20
|
+
var MAX_NEXT_OPTIONS_ENV_BYTES = 32767;
|
|
18
21
|
async function loadUpstreamAdapter(adapterPath) {
|
|
19
22
|
const resolved = _path2.default.isAbsolute(adapterPath) ? adapterPath : _path2.default.resolve(process.cwd(), adapterPath);
|
|
20
23
|
try {
|
|
21
24
|
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(_url.pathToFileURL.call(void 0, resolved).href)));
|
|
22
25
|
return _nullishCoalesce(mod.default, () => ( mod));
|
|
23
26
|
} catch (e) {
|
|
24
|
-
const req = _module.createRequire.call(void 0,
|
|
27
|
+
const req = _module.createRequire.call(void 0, _chunkL6BOM5VScjs.importMetaUrl);
|
|
25
28
|
const mod = req(resolved);
|
|
26
29
|
return _nullishCoalesce(mod.default, () => ( mod));
|
|
27
30
|
}
|
|
@@ -31,11 +34,31 @@ function recomputeHash(content, existingHash) {
|
|
|
31
34
|
const algo = len === 64 ? "sha256" : len === 40 ? "sha1" : len === 32 ? "md5" : "sha256";
|
|
32
35
|
return _crypto2.default.createHash(algo).update(content).digest("hex");
|
|
33
36
|
}
|
|
37
|
+
function isNonProductionPhase(phase) {
|
|
38
|
+
return phase !== void 0 && phase !== "phase-production-build" && phase !== "phase-export";
|
|
39
|
+
}
|
|
40
|
+
async function delegateToUpstreamOnBuildComplete(upstreamPath, context) {
|
|
41
|
+
if (!upstreamPath) return;
|
|
42
|
+
try {
|
|
43
|
+
const upstream = await loadUpstreamAdapter(upstreamPath);
|
|
44
|
+
if (upstream && typeof upstream !== "function" && typeof upstream.onBuildComplete === "function") {
|
|
45
|
+
await upstream.onBuildComplete(context);
|
|
46
|
+
} else if (typeof upstream === "function") {
|
|
47
|
+
await upstream(context);
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.warn("[unpeek:next] Failed to delegate to upstream adapter onBuildComplete:", err);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
34
53
|
function createUnpeekNextAdapter(options = {}) {
|
|
35
54
|
const upstreamPath = options.upstreamAdapterPath || process.env.UNPEEK_UPSTREAM_ADAPTER_PATH || process.env.NEXT_ADAPTER_PATH;
|
|
55
|
+
let recordedPhase;
|
|
36
56
|
return {
|
|
37
57
|
name: "unpeek",
|
|
38
58
|
async modifyConfig(config, context) {
|
|
59
|
+
if (context && typeof context.phase === "string") {
|
|
60
|
+
recordedPhase = context.phase;
|
|
61
|
+
}
|
|
39
62
|
if (upstreamPath) {
|
|
40
63
|
try {
|
|
41
64
|
const upstream = await loadUpstreamAdapter(upstreamPath);
|
|
@@ -53,8 +76,28 @@ function createUnpeekNextAdapter(options = {}) {
|
|
|
53
76
|
const distDir = _path2.default.resolve(cwd, context.distDir || ".next");
|
|
54
77
|
const staticDir = _path2.default.join(distDir, "static");
|
|
55
78
|
const targetDir = _fs2.default.existsSync(staticDir) ? staticDir : distDir;
|
|
56
|
-
const
|
|
57
|
-
|
|
79
|
+
const phase = _nullishCoalesce(context.phase, () => ( recordedPhase));
|
|
80
|
+
if (isNonProductionPhase(phase)) {
|
|
81
|
+
await delegateToUpstreamOnBuildComplete(upstreamPath, context);
|
|
82
|
+
return {
|
|
83
|
+
framework: "nextjs",
|
|
84
|
+
outDir: targetDir,
|
|
85
|
+
processedFiles: 0,
|
|
86
|
+
movedSourceMaps: 0,
|
|
87
|
+
originalBytes: 0,
|
|
88
|
+
protectedBytes: 0,
|
|
89
|
+
originalGzipBytes: 0,
|
|
90
|
+
protectedGzipBytes: 0,
|
|
91
|
+
gzipDeltaPercent: 0,
|
|
92
|
+
totalHotFunctionsSkipped: 0,
|
|
93
|
+
totalColdFunctionsProtected: 0,
|
|
94
|
+
totalEncryptedStrings: 0,
|
|
95
|
+
totalMangledSymbols: 0,
|
|
96
|
+
elapsedMs: 0
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const deterministicSeed = typeof options.seed === "number" ? options.seed : context.buildId ? _chunkIAD5DV3Dcjs.computeFnv1aHash.call(void 0, context.buildId, 1597463007) : 1597463007;
|
|
100
|
+
const summary = await _chunkI6GXEHFRcjs.protectProject.call(void 0, {
|
|
58
101
|
...options,
|
|
59
102
|
cwd,
|
|
60
103
|
outDir: targetDir,
|
|
@@ -98,25 +141,14 @@ function createUnpeekNextAdapter(options = {}) {
|
|
|
98
141
|
}
|
|
99
142
|
}
|
|
100
143
|
}
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
const upstream = await loadUpstreamAdapter(upstreamPath);
|
|
104
|
-
if (upstream && typeof upstream !== "function" && typeof upstream.onBuildComplete === "function") {
|
|
105
|
-
await upstream.onBuildComplete(context);
|
|
106
|
-
} else if (typeof upstream === "function") {
|
|
107
|
-
await upstream(context);
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.warn("[unpeek:next] Failed to delegate to upstream adapter onBuildComplete:", err);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
144
|
+
await delegateToUpstreamOnBuildComplete(upstreamPath, context);
|
|
113
145
|
return summary;
|
|
114
146
|
}
|
|
115
147
|
};
|
|
116
148
|
}
|
|
117
149
|
function getUnpeekAdapterPath() {
|
|
118
150
|
try {
|
|
119
|
-
const req = typeof
|
|
151
|
+
const req = typeof _chunkL6BOM5VScjs.__require !== "undefined" ? _chunkL6BOM5VScjs.__require : _module.createRequire.call(void 0, _chunkL6BOM5VScjs.importMetaUrl);
|
|
120
152
|
try {
|
|
121
153
|
const resolved = req.resolve("unpeek/next/adapter");
|
|
122
154
|
if (_fs2.default.existsSync(resolved)) {
|
|
@@ -125,16 +157,16 @@ function getUnpeekAdapterPath() {
|
|
|
125
157
|
} catch (e3) {
|
|
126
158
|
}
|
|
127
159
|
const isCjs = typeof __dirname !== "undefined";
|
|
128
|
-
const currentDir = isCjs ? __dirname : _path2.default.dirname(_url.fileURLToPath.call(void 0,
|
|
160
|
+
const currentDir = isCjs ? __dirname : _path2.default.dirname(_url.fileURLToPath.call(void 0, _chunkL6BOM5VScjs.importMetaUrl));
|
|
129
161
|
const candidates = [
|
|
130
|
-
_path2.default.resolve(currentDir, isCjs ? "next/adapter.cjs" : "next/adapter.js"),
|
|
131
|
-
_path2.default.resolve(currentDir, isCjs ? "next/adapter.js" : "next/adapter.cjs"),
|
|
162
|
+
_path2.default.resolve(currentDir, isCjs ? "adapters/next/adapter.cjs" : "adapters/next/adapter.js"),
|
|
163
|
+
_path2.default.resolve(currentDir, isCjs ? "adapters/next/adapter.js" : "adapters/next/adapter.cjs"),
|
|
132
164
|
_path2.default.resolve(currentDir, isCjs ? "adapter.cjs" : "adapter.js"),
|
|
133
165
|
_path2.default.resolve(currentDir, isCjs ? "adapter.js" : "adapter.cjs"),
|
|
134
|
-
_path2.default.resolve(currentDir, "../dist/next/adapter.cjs"),
|
|
135
|
-
_path2.default.resolve(currentDir, "../dist/next/adapter.js"),
|
|
136
|
-
_path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/next/adapter.cjs"),
|
|
137
|
-
_path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/next/adapter.js")
|
|
166
|
+
_path2.default.resolve(currentDir, "../dist/adapters/next/adapter.cjs"),
|
|
167
|
+
_path2.default.resolve(currentDir, "../dist/adapters/next/adapter.js"),
|
|
168
|
+
_path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/adapters/next/adapter.cjs"),
|
|
169
|
+
_path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/adapters/next/adapter.js")
|
|
138
170
|
];
|
|
139
171
|
for (const cand of candidates) {
|
|
140
172
|
if (_fs2.default.existsSync(cand)) {
|
|
@@ -143,22 +175,8 @@ function getUnpeekAdapterPath() {
|
|
|
143
175
|
}
|
|
144
176
|
return candidates[0];
|
|
145
177
|
} catch (e4) {
|
|
146
|
-
return _path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/next/adapter.js");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function readUnpeekNextOptionsFromEnv() {
|
|
150
|
-
const raw = process.env.UNPEEK_NEXT_OPTIONS;
|
|
151
|
-
if (!raw) {
|
|
152
|
-
return void 0;
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
const parsed = JSON.parse(raw);
|
|
156
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
157
|
-
return parsed;
|
|
158
|
-
}
|
|
159
|
-
} catch (e5) {
|
|
178
|
+
return _path2.default.resolve(process.cwd(), "node_modules/unpeek/dist/adapters/next/adapter.js");
|
|
160
179
|
}
|
|
161
|
-
return void 0;
|
|
162
180
|
}
|
|
163
181
|
function applyWithUnpeek(config = {}, options) {
|
|
164
182
|
const existingAdapter = config.adapterPath || process.env.NEXT_ADAPTER_PATH;
|
|
@@ -169,7 +187,15 @@ function applyWithUnpeek(config = {}, options) {
|
|
|
169
187
|
process.env.UNPEEK_UPSTREAM_ADAPTER_PATH = options.upstreamAdapterPath;
|
|
170
188
|
}
|
|
171
189
|
if (options) {
|
|
172
|
-
|
|
190
|
+
const serialized = _chunkI6GXEHFRcjs.serializeNextOptions.call(void 0, options);
|
|
191
|
+
const byteLength = Buffer.byteLength(serialized, "utf8");
|
|
192
|
+
if (byteLength > MAX_NEXT_OPTIONS_ENV_BYTES) {
|
|
193
|
+
throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
|
|
194
|
+
"ERR_NEXT_ADAPTER",
|
|
195
|
+
`Serialized UNPEEK_NEXT_OPTIONS (${byteLength} bytes) exceeds the ${MAX_NEXT_OPTIONS_ENV_BYTES}-byte process.env limit.`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
process.env.UNPEEK_NEXT_OPTIONS = serialized;
|
|
173
199
|
} else {
|
|
174
200
|
delete process.env.UNPEEK_NEXT_OPTIONS;
|
|
175
201
|
}
|
|
@@ -181,10 +207,14 @@ function applyWithUnpeek(config = {}, options) {
|
|
|
181
207
|
}
|
|
182
208
|
function withUnpeek(nextConfig = {}, options) {
|
|
183
209
|
if (typeof nextConfig === "function") {
|
|
184
|
-
return
|
|
210
|
+
return async (...args) => {
|
|
185
211
|
const resolved = await nextConfig(...args);
|
|
212
|
+
const phase = typeof args[0] === "string" ? args[0] : void 0;
|
|
213
|
+
if (isNonProductionPhase(phase)) {
|
|
214
|
+
return resolved;
|
|
215
|
+
}
|
|
186
216
|
return applyWithUnpeek(resolved, options);
|
|
187
|
-
}
|
|
217
|
+
};
|
|
188
218
|
}
|
|
189
219
|
return applyWithUnpeek(nextConfig, options);
|
|
190
220
|
}
|
|
@@ -193,5 +223,4 @@ function withUnpeek(nextConfig = {}, options) {
|
|
|
193
223
|
|
|
194
224
|
|
|
195
225
|
|
|
196
|
-
|
|
197
|
-
exports.createUnpeekNextAdapter = createUnpeekNextAdapter; exports.getUnpeekAdapterPath = getUnpeekAdapterPath; exports.readUnpeekNextOptionsFromEnv = readUnpeekNextOptionsFromEnv; exports.withUnpeek = withUnpeek;
|
|
226
|
+
exports.createUnpeekNextAdapter = createUnpeekNextAdapter; exports.getUnpeekAdapterPath = getUnpeekAdapterPath; exports.withUnpeek = withUnpeek;
|