@enhance-eng/sandbox 0.1.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/LICENSE +21 -0
- package/README.md +48 -0
- package/bin/enhance-sandbox.js +2 -0
- package/dist/assets/overlay-bootstrap.b4f6bc7e22bc.js +1 -0
- package/dist/assets/overlay.816d478d8101.js +47 -0
- package/dist/assets/sw-enhance.13e926e196ee.js +1 -0
- package/dist/cli.js +3 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +1 -0
- package/dist/manifest.json +7 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Enhance
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @enhance-eng/sandbox
|
|
2
|
+
|
|
3
|
+
`@enhance-eng/sandbox` delivers the Enhance permissive preview runtime, service worker, and overlay. Install it in a production app to opt-in to sandboxed front-end previews without touching your routing or deploy process.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @enhance-eng/sandbox
|
|
9
|
+
# or pnpm add @enhance-eng/sandbox
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
After installing, copy the runtime assets into your web root:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx enhance-sandbox prepare-sw --public-dir ./public --filename sw-enhance.js
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The command writes a service worker (`sw-enhance.<hash>.js`) and overlay bundles (`overlay-bootstrap.<hash>.js`, `overlay.<hash>.js`) into `./public/assets`.
|
|
19
|
+
|
|
20
|
+
## Initialise
|
|
21
|
+
|
|
22
|
+
Load the runtime at the top of your client entry point:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { Enhance } from '@enhance-eng/sandbox';
|
|
26
|
+
|
|
27
|
+
Enhance.init({
|
|
28
|
+
sandboxBaseURL: 'https://sandbox.example.com/project/branch',
|
|
29
|
+
projectId: 'project',
|
|
30
|
+
branchId: 'branch',
|
|
31
|
+
callbackBypass: ['/auth/callback']
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
When the page loads with `?enhance=1`, the runtime registers the service worker, triggers a one-time reload, and swaps document and asset requests to the sandbox host. OAuth callbacks, APIs, and third-party origins bypass the worker untouched.
|
|
36
|
+
|
|
37
|
+
## CLI
|
|
38
|
+
|
|
39
|
+
The package exposes an `enhance-sandbox` binary:
|
|
40
|
+
|
|
41
|
+
- `prepare-sw` – copy bundled assets into a public directory.
|
|
42
|
+
- `asset-manifest` – print the hashed filenames for templating or deploy verification.
|
|
43
|
+
|
|
44
|
+
Run `npx enhance-sandbox --help` to view all commands and options.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
Released under the [MIT License](./LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x2d2eea,_0x48342d){const _0x5c367a=_0x3b17,_0x5413b2=_0x2d2eea();while(!![]){try{const _0x4413d1=-parseInt(_0x5c367a(0x86))/(-0x5f8+0x89c+-0x2a3)*(parseInt(_0x5c367a(0x8c))/(-0xc65+0x18bb+-0xc54))+parseInt(_0x5c367a(0x8d))/(0x1*-0x1972+0x169f+0x2d6)*(parseInt(_0x5c367a(0x87))/(-0x1177+-0x899*0x1+0x1a14))+-parseInt(_0x5c367a(0x88))/(-0x5e5*0x5+-0x17a7+0x3525)+parseInt(_0x5c367a(0x8b))/(-0x79*0x3d+-0x1*-0x235a+-0x67f)+parseInt(_0x5c367a(0x97))/(0x8aa+0x119a+-0x1a3d)*(parseInt(_0x5c367a(0x91))/(0xa06+-0x5b2+-0x19*0x2c))+parseInt(_0x5c367a(0x93))/(-0x77*0x11+0x25e7+-0x1df7)+parseInt(_0x5c367a(0x90))/(-0x1*0xfc5+-0xcb0*-0x1+0x31f)*(parseInt(_0x5c367a(0x84))/(0x2c7+-0x163d+-0x1*-0x1381));if(_0x4413d1===_0x48342d)break;else _0x5413b2['push'](_0x5413b2['shift']());}catch(_0x2082ca){_0x5413b2['push'](_0x5413b2['shift']());}}}(_0x444d,-0x262c3+0xd*0x761b+0x15ee));function _0x3b17(_0x1e321d,_0x197dd8){const _0x43fe16=_0x444d();return _0x3b17=function(_0x4b7b41,_0x41d908){_0x4b7b41=_0x4b7b41-(-0x9f3*0x1+-0xca9+-0xa*-0x250);let _0x44cd75=_0x43fe16[_0x4b7b41];if(_0x3b17['\x64\x55\x6a\x6f\x56\x42']===undefined){var _0x3604a8=function(_0x317f0e){const _0x31d1fb='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x199ca7='',_0x2b829e='';for(let _0x3c6a44=-0xfcd*-0x1+0x18b3+-0x2880,_0x28d43e,_0x264886,_0x161a96=-0x22c0+-0xda1+0x1*0x3061;_0x264886=_0x317f0e['\x63\x68\x61\x72\x41\x74'](_0x161a96++);~_0x264886&&(_0x28d43e=_0x3c6a44%(-0x2*-0x6f1+0x2000+-0x2dde)?_0x28d43e*(-0x2134+0x6f1*0x5+-0x141)+_0x264886:_0x264886,_0x3c6a44++%(0x1559+0x13d2+-0x2927))?_0x199ca7+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](-0xe5d+-0x56e*0x6+0x2ff0&_0x28d43e>>(-(0x524+-0x3d*0x7f+0x1921)*_0x3c6a44&-0x865*-0x3+-0x12*0x1b3+0x56d)):-0x2486+0x1*0x1792+0xcf4){_0x264886=_0x31d1fb['\x69\x6e\x64\x65\x78\x4f\x66'](_0x264886);}for(let _0x2601e9=0x1518+-0x2514+-0x3ff*-0x4,_0x3cfc8b=_0x199ca7['\x6c\x65\x6e\x67\x74\x68'];_0x2601e9<_0x3cfc8b;_0x2601e9++){_0x2b829e+='\x25'+('\x30\x30'+_0x199ca7['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x2601e9)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0xd2*0x10+0x1491+0x1*-0x21a1))['\x73\x6c\x69\x63\x65'](-(0xb3*-0x5+-0x1cb3+0x1*0x2034));}return decodeURIComponent(_0x2b829e);};_0x3b17['\x6c\x59\x75\x71\x43\x75']=_0x3604a8,_0x1e321d=arguments,_0x3b17['\x64\x55\x6a\x6f\x56\x42']=!![];}const _0x212277=_0x43fe16[0x7f6+0x9a3+0x55*-0x35],_0x1fa7fa=_0x4b7b41+_0x212277,_0xa1b952=_0x1e321d[_0x1fa7fa];return!_0xa1b952?(_0x44cd75=_0x3b17['\x6c\x59\x75\x71\x43\x75'](_0x44cd75),_0x1e321d[_0x1fa7fa]=_0x44cd75):_0x44cd75=_0xa1b952,_0x44cd75;},_0x3b17(_0x1e321d,_0x197dd8);}const bootstrapOverlay=async()=>{const _0x5d6973=_0x3b17,_0xee3f08={};_0xee3f08[_0x5d6973(0x96)]=function(_0x345fc6,_0x167ba0){return _0x345fc6===_0x167ba0;},_0xee3f08[_0x5d6973(0x8a)]=_0x5d6973(0x94),_0xee3f08[_0x5d6973(0x89)]=_0x5d6973(0x98),_0xee3f08[_0x5d6973(0x8f)]=_0x5d6973(0x8e);const _0x44efa8=_0xee3f08;if(_0x44efa8[_0x5d6973(0x96)](typeof window,_0x44efa8[_0x5d6973(0x8a)]))return;if(window[_0x5d6973(0x85)])return;try{const _0x496f83=await import(_0x44efa8[_0x5d6973(0x89)]);if(!_0x496f83||typeof _0x496f83[_0x5d6973(0x99)]!==_0x5d6973(0x92))return;if(window[_0x5d6973(0x85)])return;window[_0x5d6973(0x85)]=_0x496f83[_0x5d6973(0x99)]();}catch(_0x26f6ba){console[_0x5d6973(0x95)](_0x44efa8[_0x5d6973(0x8f)],_0x26f6ba);}};bootstrapOverlay();function _0x444d(){const _0xcd0733=['\x6d\x74\x61\x57\x6f\x74\x44\x67\x72\x33\x6a\x34\x73\x4c\x61','\x6d\x74\x69\x33\x6f\x74\x69\x32\x6f\x67\x35\x34\x72\x33\x44\x49\x42\x71','\x6d\x4a\x61\x34\x6e\x4a\x4b\x5a\x6e\x78\x76\x4a\x72\x68\x44\x53\x41\x47','\x77\x67\x7a\x34\x72\x67\x79','\x74\x4d\x35\x4c\x7a\x33\x65','\x6f\x74\x43\x33\x6d\x64\x79\x30\x44\x65\x6a\x4e\x77\x68\x50\x68','\x6e\x5a\x62\x58\x42\x4b\x58\x71\x73\x4b\x57','\x6d\x30\x72\x5a\x43\x4d\x7a\x49\x71\x47','\x77\x30\x76\x55\x41\x67\x66\x55\x79\x32\x76\x44\x69\x67\x39\x32\x7a\x78\x6a\x53\x79\x78\x4b\x47\x79\x4d\x39\x56\x44\x68\x6e\x30\x43\x4d\x66\x57\x69\x67\x7a\x48\x41\x77\x58\x4c\x7a\x61','\x7a\x65\x48\x30\x41\x4d\x69','\x6d\x74\x62\x50\x79\x4b\x7a\x6a\x43\x65\x79','\x6f\x74\x7a\x4e\x74\x75\x6e\x73\x72\x4b\x43','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x34','\x6d\x74\x61\x58\x6d\x64\x69\x33\x6e\x31\x4c\x69\x76\x4b\x72\x6c\x77\x47','\x44\x77\x35\x4b\x7a\x77\x7a\x50\x42\x4d\x76\x4b','\x44\x32\x66\x59\x42\x47','\x7a\x66\x48\x4f\x77\x4c\x71','\x6d\x74\x71\x34\x6f\x64\x6d\x30\x71\x75\x54\x62\x43\x4e\x62\x7a','\x6c\x49\x39\x56\x44\x4d\x76\x59\x42\x67\x66\x35\x6c\x4a\x47\x58\x6e\x4d\x71\x30\x6e\x5a\x48\x4b\x6f\x64\x65\x57\x6d\x73\x35\x51\x43\x57','\x79\x33\x6a\x4c\x79\x78\x72\x4c\x74\x33\x7a\x4c\x43\x4d\x58\x48\x45\x71','\x6d\x74\x43\x35\x6d\x5a\x71\x58\x6f\x68\x76\x4c\x73\x4b\x7a\x32\x41\x47','\x78\x31\x39\x4c\x42\x4d\x48\x48\x42\x4d\x6e\x4c\x74\x33\x7a\x4c\x43\x4d\x58\x48\x45\x71'];_0x444d=function(){return _0xcd0733;};return _0x444d();}
|