@snappy-stack/core 0.1.0 → 0.1.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.
@@ -1,5 +1,5 @@
1
1
  'use server';
2
- import { getPayload } from '@/lib/payload';
2
+ import { getPayload } from '../lib/payload';
3
3
  import { cookies } from 'next/headers';
4
4
  import { redirect } from 'next/navigation';
5
5
  // SHIM: In a real app, this is passed from the outside.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * RUNTIME: Sticky Heartbeat
3
+ * This runs in the browser via SnappyProvider.
4
+ */
5
+ export declare const runStickyHeartbeat: (onVerified: (config: any) => void) => Promise<void>;
@@ -0,0 +1,59 @@
1
+ import { API_PRODUCTION_URL, __SECURITY_STATE__ } from './security.shared';
2
+ /**
3
+ * RUNTIME: Sticky Heartbeat
4
+ * This runs in the browser via SnappyProvider.
5
+ */
6
+ export const runStickyHeartbeat = async (onVerified) => {
7
+ if (typeof window === 'undefined')
8
+ return;
9
+ try {
10
+ const token = window.SNAPPY_LICENSE_TOKEN || process.env.NEXT_PUBLIC_SNAPPY_LICENSE_TOKEN;
11
+ const apiUrl = process.env.NEXT_PUBLIC_SNAPPY_API_URL || API_PRODUCTION_URL;
12
+ if (!token)
13
+ return;
14
+ const machineId = localStorage.getItem('snappy-machine-id') ||
15
+ 'br-' + Math.random().toString(36).substring(2) + Date.now().toString(36);
16
+ localStorage.setItem('snappy-machine-id', machineId);
17
+ const res = await fetch(`${apiUrl}/api/heartbeat`, {
18
+ method: 'POST',
19
+ headers: { 'Content-Type': 'application/json' },
20
+ body: JSON.stringify({
21
+ token,
22
+ domain: window.location.hostname,
23
+ machineId,
24
+ isLocal: window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1',
25
+ version: '0.1.0-runtime'
26
+ }),
27
+ });
28
+ const data = await res.json();
29
+ if (data.ok) {
30
+ onVerified({
31
+ branding: data.branding,
32
+ enforcement: data.enforcement,
33
+ status: data.status
34
+ });
35
+ // Kill the page if terminated
36
+ if (data.status === 'terminated') {
37
+ __SECURITY_STATE__.isValid = false; // Trigger Poison Pill
38
+ document.body.innerHTML = `
39
+ <div style="background:#000;color:#fff;height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:sans-serif;text-align:center;padding:20px;">
40
+ <h1 style="font-size:4rem;font-weight:900;letter-spacing:-0.05em;margin:0;">ACCESS DENIED</h1>
41
+ <p style="opacity:0.5;max-width:400px;line-height:1.6;">Your SNAPPY license has been terminated. Please contact support@wicky.id</p>
42
+ </div>
43
+ `;
44
+ }
45
+ else if (data.status === 'suspended') {
46
+ __SECURITY_STATE__.isValid = false; // Trigger Poison Pill silently for suspended
47
+ }
48
+ else {
49
+ __SECURITY_STATE__.isValid = true;
50
+ }
51
+ }
52
+ else {
53
+ __SECURITY_STATE__.isValid = false; // Unverified = Poison Pill active
54
+ }
55
+ }
56
+ catch (err) {
57
+ __SECURITY_STATE__.isValid = false; // Network block = Poison Pill active
58
+ }
59
+ };
@@ -1 +1 @@
1
- const a0_0x3f2d2b=a0_0x4ecb;(function(_0x16de9d,_0x78c661){const _0x364032=a0_0x4ecb,_0x322477=_0x16de9d();while(!![]){try{const _0x155822=parseInt(_0x364032(0xf3))/0x1*(parseInt(_0x364032(0x103))/0x2)+parseInt(_0x364032(0xb5))/0x3+parseInt(_0x364032(0xcb))/0x4+-parseInt(_0x364032(0x100))/0x5+parseInt(_0x364032(0xdd))/0x6*(-parseInt(_0x364032(0x107))/0x7)+-parseInt(_0x364032(0xc7))/0x8*(-parseInt(_0x364032(0xd6))/0x9)+-parseInt(_0x364032(0xda))/0xa*(-parseInt(_0x364032(0x10b))/0xb);if(_0x155822===_0x78c661)break;else _0x322477['push'](_0x322477['shift']());}catch(_0x154680){_0x322477['push'](_0x322477['shift']());}}}(a0_0x50f0,0xf3909));const a0_0x13ab5f=(function(){let _0x2258f3=!![];return function(_0x103624,_0x5efa70){const _0x64f275=_0x2258f3?function(){const _0x385a36=a0_0x4ecb;if(_0x5efa70){const _0x232072=_0x5efa70[_0x385a36(0xc4)](_0x103624,arguments);return _0x5efa70=null,_0x232072;}}:function(){};return _0x2258f3=![],_0x64f275;};}()),a0_0x43957f=a0_0x13ab5f(this,function(){const _0x2ed0cb=a0_0x4ecb;return a0_0x43957f[_0x2ed0cb(0xfc)]()[_0x2ed0cb(0xd2)](_0x2ed0cb(0xef))[_0x2ed0cb(0xfc)]()[_0x2ed0cb(0x106)](a0_0x43957f)[_0x2ed0cb(0xd2)](_0x2ed0cb(0xef));});a0_0x43957f();import a0_0x2efc43 from'fs';import a0_0x194616 from'path';import{Users}from'../collections/Users';import{LoginTokens}from'../collections/LoginTokens';function a0_0x4ecb(_0x1792c6,_0x8362ab){_0x1792c6=_0x1792c6-0xb2;const _0x4431e3=a0_0x50f0();let _0x43957f=_0x4431e3[_0x1792c6];return _0x43957f;}import{Branding}from'../globals/Branding';const API_PRODUCTION_URL=a0_0x3f2d2b(0xd3);export const __SECURITY_STATE__={'isValid':!![]};export const checkLicense=async()=>{const _0xa56a36=a0_0x3f2d2b,_0x4b513a=process.env.SNAPPY_LICENSE_TOKEN,_0x4f18a3=process.env.SNAPPY_API_URL||API_PRODUCTION_URL,_0x1bec68=process[_0xa56a36(0xea)](),_0x3d2085=a0_0x194616[_0xa56a36(0xc5)](_0x1bec68,_0xa56a36(0x102));let _0x16b575;try{a0_0x2efc43[_0xa56a36(0xee)](_0x3d2085)?_0x16b575=a0_0x2efc43[_0xa56a36(0xd5)](_0x3d2085,_0xa56a36(0xd0))[_0xa56a36(0xb2)]():(_0x16b575=Math[_0xa56a36(0xeb)]()[_0xa56a36(0xfc)](0x24)[_0xa56a36(0xbe)](0x2)+Date[_0xa56a36(0xf2)]()[_0xa56a36(0xfc)](0x24),a0_0x2efc43[_0xa56a36(0xbf)](_0x3d2085,_0x16b575));}catch(_0x12bc5f){_0x16b575=_0xa56a36(0xfb);}const _0x1e833c=process.env.VERCEL_URL||_0xa56a36(0xce),_0x4f0cec=_0x1e833c[_0xa56a36(0x109)](_0xa56a36(0xce))||_0x1e833c[_0xa56a36(0x109)](_0xa56a36(0xe7));if(!_0x4b513a){if(process.env.NODE_ENV===_0xa56a36(0xbd))console[_0xa56a36(0xd8)](_0xa56a36(0xe1)),process[_0xa56a36(0x108)](0x1);else{console[_0xa56a36(0xb6)](_0xa56a36(0xf1));return;}}try{const _0x34574b=await fetch(_0x4f18a3+_0xa56a36(0xdc),{'method':_0xa56a36(0xb8),'headers':{'Content-Type':_0xa56a36(0xf7)},'body':JSON[_0xa56a36(0xff)]({'token':_0x4b513a,'domain':_0x1e833c,'machineId':_0x16b575,'isLocal':_0x4f0cec,'version':_0xa56a36(0xe0)})}),_0x3dc881=await _0x34574b[_0xa56a36(0xdb)]();!_0x3dc881['ok']&&(_0x3dc881[_0xa56a36(0xf0)]===_0xa56a36(0xc0)?console[_0xa56a36(0xd8)](_0xa56a36(0xf5)+_0x3dc881[_0xa56a36(0xd8)]+_0xa56a36(0xc8)):console[_0xa56a36(0xd8)](_0xa56a36(0xbb)+(_0x3dc881[_0xa56a36(0xd8)]||_0xa56a36(0xfe))),process[_0xa56a36(0x108)](0x1)),(_0x3dc881[_0xa56a36(0xf0)]===_0xa56a36(0xe5)||_0x3dc881[_0xa56a36(0xf0)]===_0xa56a36(0xba))&&(console[_0xa56a36(0xd8)](_0xa56a36(0x105)+_0x3dc881[_0xa56a36(0xf0)][_0xa56a36(0x101)]()+_0xa56a36(0xe4)),process[_0xa56a36(0x108)](0x1)),console[_0xa56a36(0xbc)](_0xa56a36(0xd9)+_0x3dc881[_0xa56a36(0xf0)][_0xa56a36(0x101)]()+_0xa56a36(0xb3));}catch(_0x30edce){console[_0xa56a36(0xb6)](_0xa56a36(0xfa)+_0x30edce[_0xa56a36(0xb4)]+_0xa56a36(0xe3));}try{const _0x225358=Buffer[_0xa56a36(0xde)](_0xa56a36(0xb9),_0xa56a36(0xf4))[_0xa56a36(0xfc)](_0xa56a36(0xd0)),_0x57773d=Buffer[_0xa56a36(0xde)](_0xa56a36(0xed),_0xa56a36(0xf4))[_0xa56a36(0xfc)](_0xa56a36(0xd0)),_0xed05de=a0_0x194616[_0xa56a36(0xc5)](_0x1bec68,_0x225358),_0x4cd5ec=a0_0x194616[_0xa56a36(0xc5)](_0x1bec68,_0x57773d),_0x15e8cb=/^(?!.*\/\/.*<Credit).*<Credit/m;if(a0_0x2efc43[_0xa56a36(0xee)](_0xed05de)){const _0x2fded1=a0_0x2efc43[_0xa56a36(0xd5)](_0xed05de,_0xa56a36(0xd0));!_0x15e8cb[_0xa56a36(0xc1)](_0x2fded1)&&(console[_0xa56a36(0xd8)](_0xa56a36(0xc2)),process[_0xa56a36(0x108)](0x1));}if(a0_0x2efc43[_0xa56a36(0xee)](_0x4cd5ec)){const _0x30ec88=a0_0x2efc43[_0xa56a36(0xd5)](_0x4cd5ec,_0xa56a36(0xd0));!_0x15e8cb[_0xa56a36(0xc1)](_0x30ec88)&&(console[_0xa56a36(0xd8)](_0xa56a36(0xf9)),process[_0xa56a36(0x108)](0x1));}}catch(_0x12e88a){}};export const initializeSnappy=_0x79cfea=>{const _0x489eb1=a0_0x3f2d2b,_0x2d8677=_0x79cfea[_0x489eb1(0xe9)]||[],_0x366acf=_0x79cfea[_0x489eb1(0xc6)]||[],_0x149223=_0x2d8677[_0x489eb1(0x10a)](_0x52b653=>_0x52b653[_0x489eb1(0xd4)]!==_0x489eb1(0xd1)&&_0x52b653[_0x489eb1(0xd4)]!==_0x489eb1(0xe8)),_0x3940f5=_0x366acf[_0x489eb1(0x10a)](_0x3db380=>_0x3db380[_0x489eb1(0xd4)]!==_0x489eb1(0xca));return checkLicense(),{..._0x79cfea,'admin':{..._0x79cfea[_0x489eb1(0xc9)]||{},'disable':!![],'user':_0x489eb1(0xd1)},'collections':[..._0x149223,Users,LoginTokens],'globals':[..._0x3940f5,Branding]};};function a0_0x50f0(){const _0x42af41=['log','production','substring','writeFileSync','collision','test','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Structural\x20Integrity\x20Compromised:\x20Credit\x20tag\x20missing\x20or\x20commented\x20out\x20in\x20DesktopFooter.','snappy-machine-id','apply','join','globals','5384AEQvHp','.\x20You\x20have\x20exceeded\x20your\x20Dev\x20Seat\x20limit.','admin','branding','6240724CMDZFE','getItem','innerHTML','localhost','location','utf-8','users','search','https://snappycore.wicky.id','slug','readFileSync','16209zwIKGI','SNAPPY_LICENSE_TOKEN','error','✅\x20[SNAPPY\x20CORE]\x20Engine\x20verified:\x20','190QqvBym','json','/api/heartbeat','11946QfZgWm','from','hostname','0.1.0-build','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Missing\x20SNAPPY_LICENSE_TOKEN.\x20Production\x20builds\x20are\x20disabled\x20without\x20a\x20valid\x20license.','0.1.0-runtime','.\x20Running\x20in\x20offline\x20fallback\x20mode.',':\x20This\x20instance\x20has\x20been\x20remotely\x20deactivated.','suspended','br-','127.0.0.1','login-tokens','collections','cwd','random','undefined','c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL01vYmlsZUZvb3Rlci50c3g=','existsSync','(((.+)+)+)+$','status','⚠️\x20[SNAPPY\x20CORE]\x20Missing\x20SNAPPY_LICENSE_TOKEN.\x20Development\x20mode\x20active.','now','6MKttpR','base64','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20Collision:\x20','setItem','application/json','body','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Structural\x20Integrity\x20Compromised:\x20Credit\x20tag\x20missing\x20or\x20commented\x20out\x20in\x20MobileFooter.','⚠️\x20[SNAPPY\x20CORE]\x20License\x20server\x20unreachable:\x20','unknown-machine','toString','enforcement','Unknown\x20error','stringify','8653680yqcXFs','toUpperCase','.snappy-machine-id','105382prbGFb','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22background:#000;color:#fff;height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:sans-serif;text-align:center;padding:20px;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<h1\x20style=\x22font-size:4rem;font-weight:900;letter-spacing:-0.05em;margin:0;\x22>ACCESS\x20DENIED</h1>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<p\x20style=\x22opacity:0.5;max-width:400px;line-height:1.6;\x22>Your\x20SNAPPY\x20license\x20has\x20been\x20terminated.\x20Please\x20contact\x20support@wicky.id</p>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20','constructor','4235dbWVmc','exit','includes','filter','151965NIIyKl','trim','\x20mode.','message','1746141mzohXW','warn','isValid','POST','c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL0Rlc2t0b3BGb290ZXIudHN4','terminated','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20Invalid:\x20'];a0_0x50f0=function(){return _0x42af41;};return a0_0x50f0();}export const runStickyHeartbeat=async _0x11b50a=>{const _0x1cb218=a0_0x3f2d2b;if(typeof window===_0x1cb218(0xec))return;try{const _0x55aab3=window[_0x1cb218(0xd7)]||process.env.NEXT_PUBLIC_SNAPPY_LICENSE_TOKEN,_0x27d645=process.env.NEXT_PUBLIC_SNAPPY_API_URL||API_PRODUCTION_URL;if(!_0x55aab3)return;const _0x26da28=localStorage[_0x1cb218(0xcc)](_0x1cb218(0xc3))||_0x1cb218(0xe6)+Math[_0x1cb218(0xeb)]()[_0x1cb218(0xfc)](0x24)[_0x1cb218(0xbe)](0x2)+Date[_0x1cb218(0xf2)]()[_0x1cb218(0xfc)](0x24);localStorage[_0x1cb218(0xf6)](_0x1cb218(0xc3),_0x26da28);const _0x2ed0d8=await fetch(_0x27d645+_0x1cb218(0xdc),{'method':_0x1cb218(0xb8),'headers':{'Content-Type':_0x1cb218(0xf7)},'body':JSON[_0x1cb218(0xff)]({'token':_0x55aab3,'domain':window[_0x1cb218(0xcf)][_0x1cb218(0xdf)],'machineId':_0x26da28,'isLocal':window[_0x1cb218(0xcf)][_0x1cb218(0xdf)]===_0x1cb218(0xce)||window[_0x1cb218(0xcf)][_0x1cb218(0xdf)]===_0x1cb218(0xe7),'version':_0x1cb218(0xe2)})}),_0x533f85=await _0x2ed0d8[_0x1cb218(0xdb)]();if(_0x533f85['ok']){_0x11b50a({'branding':_0x533f85[_0x1cb218(0xca)],'enforcement':_0x533f85[_0x1cb218(0xfd)],'status':_0x533f85[_0x1cb218(0xf0)]});if(_0x533f85[_0x1cb218(0xf0)]===_0x1cb218(0xba))__SECURITY_STATE__[_0x1cb218(0xb7)]=![],document[_0x1cb218(0xf8)][_0x1cb218(0xcd)]=_0x1cb218(0x104);else _0x533f85[_0x1cb218(0xf0)]===_0x1cb218(0xe5)?__SECURITY_STATE__[_0x1cb218(0xb7)]=![]:__SECURITY_STATE__[_0x1cb218(0xb7)]=!![];}else __SECURITY_STATE__[_0x1cb218(0xb7)]=![];}catch(_0x167998){__SECURITY_STATE__[_0x1cb218(0xb7)]=![];}};
1
+ (function(_0x329274,_0x125080){const _0x52b9b1=a0_0x1e5b,_0xcce834=_0x329274();while(!![]){try{const _0x2b653e=parseInt(_0x52b9b1(0x145))/0x1*(parseInt(_0x52b9b1(0xff))/0x2)+-parseInt(_0x52b9b1(0x114))/0x3+-parseInt(_0x52b9b1(0x11a))/0x4+-parseInt(_0x52b9b1(0x134))/0x5*(parseInt(_0x52b9b1(0x130))/0x6)+-parseInt(_0x52b9b1(0x10a))/0x7+-parseInt(_0x52b9b1(0x148))/0x8*(-parseInt(_0x52b9b1(0x12f))/0x9)+parseInt(_0x52b9b1(0x133))/0xa;if(_0x2b653e===_0x125080)break;else _0xcce834['push'](_0xcce834['shift']());}catch(_0x26bd23){_0xcce834['push'](_0xcce834['shift']());}}}(a0_0x24b5,0x4607f));const a0_0xec48e7=a0_0x5c8b;function a0_0x24b5(){const _0x5854d6=['push','readFileSync','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22background:#000;color:#fff;height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:sans-serif;text-align:center;padding:20px;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<h1\x20style=\x22font-size:4rem;font-weight:900;letter-spacing:-0.05em;margin:0;\x22>ACCESS\x20DENIED</h1>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<p\x20style=\x22opacity:0.5;max-width:400px;line-height:1.6;\x22>Your\x20SNAPPY\x20license\x20has\x20been\x20terminated.\x20Please\x20contact\x20support@wicky.id</p>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20','unknown-machine','random','4107747mpzOvo','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Structural\x20Integrity\x20Compromised:\x20Credit\x20tag\x20missing\x20or\x20commented\x20out\x20in\x20MobileFooter.','c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL01vYmlsZUZvb3Rlci50c3g=','body','admin','collections','4072810TzdAgU','18ImoXqx','606762gcGjrz','3pzlfWa','constructor','5403780aOSPpQ','20TZYTjq','location','\x20mode.','toUpperCase',':\x20This\x20instance\x20has\x20been\x20remotely\x20deactivated.','https://snappycore.wicky.id','existsSync','.\x20Running\x20in\x20offline\x20fallback\x20mode.','hostname','message','⚠️\x20[SNAPPY\x20CORE]\x20Missing\x20SNAPPY_LICENSE_TOKEN.\x20Development\x20mode\x20active.','apply','5hdBPAE','cwd','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20Collision:\x20','terminated','br-','521491xLGJpP','1464RuCjQZ','stringify','2223736sYJRLs','localhost','includes','filter','utf-8','collision','5201306EQtpKt','writeFileSync','0.1.0-runtime','POST','error','branding','innerHTML','exit','⚠️\x20[SNAPPY\x20CORE]\x20License\x20server\x20unreachable:\x20','warn','base64','production','shift','getItem','SNAPPY_LICENSE_TOKEN','isValid','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20','suspended','search','setItem','/api/heartbeat','log','undefined','2efmamk','433308ETeBJC','3609858MwLDQP','enforcement','application/json','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Structural\x20Integrity\x20Compromised:\x20Credit\x20tag\x20missing\x20or\x20commented\x20out\x20in\x20DesktopFooter.','Unknown\x20error','globals','users','test','from','3415160CuqzcN','now','.snappy-machine-id','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20Missing\x20SNAPPY_LICENSE_TOKEN.\x20Production\x20builds\x20are\x20disabled\x20without\x20a\x20valid\x20license.','0.1.0-build','trim','toString','1569wpLBTp','✅\x20[SNAPPY\x20CORE]\x20Engine\x20verified:\x20','login-tokens','94239ElVSvd','2148sujgWi','snappy-machine-id','20628YAkpKx','❌\x20[SNAPPY\x20CORE\x20FATAL]\x20License\x20Invalid:\x20','json','1628620NgYSsU','substring','status','join','.\x20You\x20have\x20exceeded\x20your\x20Dev\x20Seat\x20limit.','c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL0Rlc2t0b3BGb290ZXIudHN4','(((.+)+)+)+$','slug','127.0.0.1'];a0_0x24b5=function(){return _0x5854d6;};return a0_0x24b5();}function a0_0x1e5b(_0x3c4a02,_0x5264d3){_0x3c4a02=_0x3c4a02-0xe7;const _0x412744=a0_0x24b5();let _0x4209b4=_0x412744[_0x3c4a02];return _0x4209b4;}(function(_0x46e865,_0x1af98a){const _0x43e075=a0_0x1e5b,_0x5dcff6=a0_0x5c8b,_0x1ba85a=_0x46e865();while(!![]){try{const _0x28ea05=parseInt(_0x5dcff6(0xcd))/0x1*(-parseInt(_0x5dcff6(0xd4))/0x2)+-parseInt(_0x5dcff6(0xf6))/0x3*(parseInt(_0x5dcff6(0xf2))/0x4)+-parseInt(_0x5dcff6(0xd9))/0x5*(parseInt(_0x5dcff6(0x103))/0x6)+parseInt(_0x5dcff6(0x102))/0x7+-parseInt(_0x5dcff6(0x10b))/0x8*(-parseInt(_0x5dcff6(0xfd))/0x9)+parseInt(_0x5dcff6(0x10f))/0xa+parseInt(_0x5dcff6(0xda))/0xb;if(_0x28ea05===_0x1af98a)break;else _0x1ba85a[_0x43e075(0x123)](_0x1ba85a[_0x43e075(0xf4)]());}catch(_0x290b5a){_0x1ba85a[_0x43e075(0x123)](_0x1ba85a[_0x43e075(0xf4)]());}}}(a0_0x182b,0x56688));function a0_0x182b(){const _0x151a18=a0_0x1e5b,_0x5a0e55=[_0x151a18(0xf2),_0x151a18(0x109),_0x151a18(0x10e),_0x151a18(0x140),_0x151a18(0xe8),_0x151a18(0x10b),_0x151a18(0x14b),_0x151a18(0x13a),_0x151a18(0xee),_0x151a18(0x104),_0x151a18(0x120),_0x151a18(0xf0),_0x151a18(0x13c),_0x151a18(0x137),_0x151a18(0xed),_0x151a18(0xfe),_0x151a18(0x112),_0x151a18(0xf9),_0x151a18(0xfa),_0x151a18(0x13b),_0x151a18(0x14c),_0x151a18(0x141),_0x151a18(0x126),_0x151a18(0x102),_0x151a18(0x14a),_0x151a18(0xf5),_0x151a18(0x105),_0x151a18(0x116),_0x151a18(0x115),_0x151a18(0x121),_0x151a18(0x10c),_0x151a18(0xec),_0x151a18(0x111),_0x151a18(0x12a),_0x151a18(0x11d),_0x151a18(0x11f),_0x151a18(0x13d),_0x151a18(0x13f),_0x151a18(0xfc),_0x151a18(0x117),_0x151a18(0x129),_0x151a18(0x143),_0x151a18(0x136),_0x151a18(0x122),_0x151a18(0x128),_0x151a18(0x101),_0x151a18(0xf8),_0x151a18(0x10f),_0x151a18(0x12c),_0x151a18(0xfd),_0x151a18(0xf7),_0x151a18(0x108),_0x151a18(0x103),_0x151a18(0x146),_0x151a18(0xeb),_0x151a18(0x12b),_0x151a18(0xf3),_0x151a18(0x12e),_0x151a18(0x135),_0x151a18(0x11e),_0x151a18(0x125),_0x151a18(0x127),_0x151a18(0x138),_0x151a18(0xf6),_0x151a18(0x142),_0x151a18(0xf1),_0x151a18(0x107),_0x151a18(0x11c),_0x151a18(0xe7),_0x151a18(0x139),_0x151a18(0xe9),_0x151a18(0x124),_0x151a18(0x132),_0x151a18(0x11b),_0x151a18(0xef),_0x151a18(0xea),_0x151a18(0x119),_0x151a18(0x113),_0x151a18(0x149),_0x151a18(0x144),_0x151a18(0x12d),_0x151a18(0x131),_0x151a18(0x13e),_0x151a18(0x118),_0x151a18(0xfb),_0x151a18(0x147),_0x151a18(0x106),_0x151a18(0x10d),_0x151a18(0x100),_0x151a18(0x110)];return a0_0x182b=function(){return _0x5a0e55;},a0_0x182b();}const a0_0x4cc3a1=(function(){const _0x222575=(function(){let _0x1fb4c0=!![];return function(_0x2d6a77,_0x4323d9){const _0x588e9f=_0x1fb4c0?function(){const _0x1b2453=a0_0x1e5b;if(_0x4323d9){const _0x41f316=_0x4323d9[_0x1b2453(0x13f)](_0x2d6a77,arguments);return _0x4323d9=null,_0x41f316;}}:function(){};return _0x1fb4c0=![],_0x588e9f;};}()),_0x2b2e1c=_0x222575(this,function(){const _0x5939c9=a0_0x1e5b;return _0x2b2e1c[_0x5939c9(0x110)]()[_0x5939c9(0xfa)](_0x5939c9(0x120))[_0x5939c9(0x110)]()[_0x5939c9(0x132)](_0x2b2e1c)[_0x5939c9(0xfa)](_0x5939c9(0x120));});_0x2b2e1c();let _0x78c8e4=!![];return function(_0x32fa72,_0x42fac7){const _0x7e6c36=_0x78c8e4?function(){const _0x31b751=a0_0x5c8b;if(_0x42fac7){const _0x224d08=_0x42fac7[_0x31b751(0xfb)](_0x32fa72,arguments);return _0x42fac7=null,_0x224d08;}}:function(){};return _0x78c8e4=![],_0x7e6c36;};}()),a0_0x49bdbc=a0_0x4cc3a1(this,function(){const _0x5d3da9=a0_0x5c8b;return a0_0x49bdbc[_0x5d3da9(0xd5)]()[_0x5d3da9(0xe8)](_0x5d3da9(0xe0))[_0x5d3da9(0xd5)]()[_0x5d3da9(0xc4)](a0_0x49bdbc)[_0x5d3da9(0xe8)](_0x5d3da9(0xe0));});a0_0x49bdbc();import a0_0x16f909 from'fs';import a0_0x382ad8 from'path';import{Users}from'../collections/Users';function a0_0x5c8b(_0x5da825,_0x469068){_0x5da825=_0x5da825-0xb6;const _0x5a1600=a0_0x182b();let _0x41bcb0=_0x5a1600[_0x5da825];return _0x41bcb0;}import{LoginTokens}from'../collections/LoginTokens';import{Branding}from'../globals/Branding';const API_PRODUCTION_URL=a0_0xec48e7(0xc1);export const __SECURITY_STATE__={'isValid':!![]};export const checkLicense=async()=>{const _0x160177=a0_0xec48e7,_0x390234=process.env.SNAPPY_LICENSE_TOKEN,_0x1d1ea1=process.env.SNAPPY_API_URL||API_PRODUCTION_URL,_0x2c78ac=process[_0x160177(0xeb)](),_0x1cc652=a0_0x382ad8[_0x160177(0xf8)](_0x2c78ac,_0x160177(0xf4));let _0x47ca46;try{a0_0x16f909[_0x160177(0xdd)](_0x1cc652)?_0x47ca46=a0_0x16f909[_0x160177(0xc3)](_0x1cc652,_0x160177(0xea))[_0x160177(0x105)]():(_0x47ca46=Math[_0x160177(0xb9)]()[_0x160177(0xd5)](0x24)[_0x160177(0xc5)](0x2)+Date[_0x160177(0xdb)]()[_0x160177(0xd5)](0x24),a0_0x16f909[_0x160177(0xc2)](_0x1cc652,_0x47ca46));}catch(_0x22351e){_0x47ca46=_0x160177(0xec);}const _0x546112=process.env.VERCEL_URL||_0x160177(0xca),_0x39eb1f=_0x546112[_0x160177(0xee)](_0x160177(0xca))||_0x546112[_0x160177(0xee)](_0x160177(0x101));if(!_0x390234){if(process.env.NODE_ENV===_0x160177(0x10e))console[_0x160177(0xf5)](_0x160177(0xd3)),process[_0x160177(0xc6)](0x1);else{console[_0x160177(0xbd)](_0x160177(0xce));return;}}try{const _0x3737a0=await fetch(_0x1d1ea1+_0x160177(0xfc),{'method':_0x160177(0x10c),'headers':{'Content-Type':_0x160177(0x10a)},'body':JSON[_0x160177(0xd1)]({'token':_0x390234,'domain':_0x546112,'machineId':_0x47ca46,'isLocal':_0x39eb1f,'version':_0x160177(0xd8)})}),_0x3f9ff3=await _0x3737a0[_0x160177(0xc8)]();!_0x3f9ff3['ok']&&(_0x3f9ff3[_0x160177(0xbf)]===_0x160177(0xc0)?console[_0x160177(0xf5)](_0x160177(0xbc)+_0x3f9ff3[_0x160177(0xf5)]+_0x160177(0xb7)):console[_0x160177(0xf5)](_0x160177(0xcf)+(_0x3f9ff3[_0x160177(0xf5)]||_0x160177(0xf0))),process[_0x160177(0xc6)](0x1)),(_0x3f9ff3[_0x160177(0xbf)]===_0x160177(0xe7)||_0x3f9ff3[_0x160177(0xbf)]===_0x160177(0xff))&&(console[_0x160177(0xf5)](_0x160177(0x104)+_0x3f9ff3[_0x160177(0xbf)][_0x160177(0xe3)]()+_0x160177(0xba)),process[_0x160177(0xc6)](0x1)),console[_0x160177(0x107)](_0x160177(0xe6)+_0x3f9ff3[_0x160177(0xbf)][_0x160177(0xe3)]()+_0x160177(0x100));}catch(_0x2a2f5c){console[_0x160177(0xbd)](_0x160177(0xe1)+_0x2a2f5c[_0x160177(0xfa)]+_0x160177(0xe9));}try{const _0x58e427=Buffer[_0x160177(0xd7)](_0x160177(0xf9),_0x160177(0xd6))[_0x160177(0xd5)](_0x160177(0xea)),_0x47a42f=Buffer[_0x160177(0xd7)](_0x160177(0xf7),_0x160177(0xd6))[_0x160177(0xd5)](_0x160177(0xea)),_0x2ddfbc=a0_0x382ad8[_0x160177(0xf8)](_0x2c78ac,_0x58e427),_0x38d9c3=a0_0x382ad8[_0x160177(0xf8)](_0x2c78ac,_0x47a42f),_0xc5bea6=/^(?!.*\/\/.*<Credit).*<Credit/m;if(a0_0x16f909[_0x160177(0xdd)](_0x2ddfbc)){const _0x5ae95c=a0_0x16f909[_0x160177(0xc3)](_0x2ddfbc,_0x160177(0xea));!_0xc5bea6[_0x160177(0x109)](_0x5ae95c)&&(console[_0x160177(0xf5)](_0x160177(0xdf)),process[_0x160177(0xc6)](0x1));}if(a0_0x16f909[_0x160177(0xdd)](_0x38d9c3)){const _0x572eb8=a0_0x16f909[_0x160177(0xc3)](_0x38d9c3,_0x160177(0xea));!_0xc5bea6[_0x160177(0x109)](_0x572eb8)&&(console[_0x160177(0xf5)](_0x160177(0xfe)),process[_0x160177(0xc6)](0x1));}}catch(_0x45944a){}};export const initializeSnappy=_0x1f5c17=>{const _0xd9b6d6=a0_0xec48e7,_0x373978=_0x1f5c17[_0xd9b6d6(0xcc)]||[],_0x4d07e5=_0x1f5c17[_0xd9b6d6(0xd2)]||[],_0x2625de=_0x373978[_0xd9b6d6(0xdc)](_0x711d15=>_0x711d15[_0xd9b6d6(0xf3)]!==_0xd9b6d6(0xbe)&&_0x711d15[_0xd9b6d6(0xf3)]!==_0xd9b6d6(0xc9)),_0x533e14=_0x4d07e5[_0xd9b6d6(0xdc)](_0x4b9010=>_0x4b9010[_0xd9b6d6(0xf3)]!==_0xd9b6d6(0xe4));return checkLicense(),{..._0x1f5c17,'admin':{..._0x1f5c17[_0xd9b6d6(0x106)]||{},'disable':!![],'user':_0xd9b6d6(0xbe)},'collections':[..._0x2625de,Users,LoginTokens],'globals':[..._0x533e14,Branding]};};export const runStickyHeartbeat=async _0x13c742=>{const _0x805a9d=a0_0xec48e7;if(typeof window===_0x805a9d(0xe5))return;try{const _0x171638=window[_0x805a9d(0xbb)]||process.env.NEXT_PUBLIC_SNAPPY_LICENSE_TOKEN,_0x574982=process.env.NEXT_PUBLIC_SNAPPY_API_URL||API_PRODUCTION_URL;if(!_0x171638)return;const _0x10d1e0=localStorage[_0x805a9d(0xef)](_0x805a9d(0xf1))||_0x805a9d(0xcb)+Math[_0x805a9d(0xb9)]()[_0x805a9d(0xd5)](0x24)[_0x805a9d(0xc5)](0x2)+Date[_0x805a9d(0xdb)]()[_0x805a9d(0xd5)](0x24);localStorage[_0x805a9d(0xd0)](_0x805a9d(0xf1),_0x10d1e0);const _0x165e5a=await fetch(_0x574982+_0x805a9d(0xfc),{'method':_0x805a9d(0x10c),'headers':{'Content-Type':_0x805a9d(0x10a)},'body':JSON[_0x805a9d(0xd1)]({'token':_0x171638,'domain':window[_0x805a9d(0xb6)][_0x805a9d(0xe2)],'machineId':_0x10d1e0,'isLocal':window[_0x805a9d(0xb6)][_0x805a9d(0xe2)]===_0x805a9d(0xca)||window[_0x805a9d(0xb6)][_0x805a9d(0xe2)]===_0x805a9d(0x101),'version':_0x805a9d(0xc7)})}),_0x378f8d=await _0x165e5a[_0x805a9d(0xc8)]();if(_0x378f8d['ok']){_0x13c742({'branding':_0x378f8d[_0x805a9d(0xe4)],'enforcement':_0x378f8d[_0x805a9d(0xed)],'status':_0x378f8d[_0x805a9d(0xbf)]});if(_0x378f8d[_0x805a9d(0xbf)]===_0x805a9d(0xff))__SECURITY_STATE__[_0x805a9d(0x108)]=![],document[_0x805a9d(0x10d)][_0x805a9d(0xde)]=_0x805a9d(0xb8);else _0x378f8d[_0x805a9d(0xbf)]===_0x805a9d(0xe7)?__SECURITY_STATE__[_0x805a9d(0x108)]=![]:__SECURITY_STATE__[_0x805a9d(0x108)]=!![];}else __SECURITY_STATE__[_0x805a9d(0x108)]=![];}catch(_0xd82c78){__SECURITY_STATE__[_0x805a9d(0x108)]=![];}};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * [SNAPPY CORE] Internal Security & Initializer
3
+ * - SURGICAL OBFUSCATION TARGET: This file is the primary lock.
4
+ */
5
+ /**
6
+ * BUILD-TIME: Core License Check
7
+ */
8
+ export declare const checkLicense: () => Promise<void>;
9
+ /**
10
+ * INITIALIZATION: Secure Config Wrapper
11
+ */
12
+ export declare const initializeSnappy: (incomingConfig: any) => any;
@@ -0,0 +1,126 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { Users } from '../collections/Users';
4
+ import { LoginTokens } from '../collections/LoginTokens';
5
+ import { Branding } from '../globals/Branding';
6
+ import { API_PRODUCTION_URL } from './security.shared';
7
+ /**
8
+ * [SNAPPY CORE] Internal Security & Initializer
9
+ * - SURGICAL OBFUSCATION TARGET: This file is the primary lock.
10
+ */
11
+ /**
12
+ * BUILD-TIME: Core License Check
13
+ */
14
+ export const checkLicense = async () => {
15
+ const token = process.env.SNAPPY_LICENSE_TOKEN;
16
+ const apiUrl = process.env.SNAPPY_API_URL || API_PRODUCTION_URL;
17
+ // 1. Machine ID Logic
18
+ const rootDir = process.cwd();
19
+ const machineIdPath = path.join(rootDir, '.snappy-machine-id');
20
+ let machineId;
21
+ try {
22
+ if (fs.existsSync(machineIdPath)) {
23
+ machineId = fs.readFileSync(machineIdPath, 'utf-8').trim();
24
+ }
25
+ else {
26
+ machineId = Math.random().toString(36).substring(2) + Date.now().toString(36);
27
+ fs.writeFileSync(machineIdPath, machineId);
28
+ }
29
+ }
30
+ catch (e) {
31
+ machineId = 'unknown-machine';
32
+ }
33
+ // 2. Identify Domain
34
+ const domain = process.env.VERCEL_URL || 'localhost';
35
+ const isLocal = domain.includes('localhost') || domain.includes('127.0.0.1');
36
+ if (!token) {
37
+ if (process.env.NODE_ENV === 'production') {
38
+ console.error('❌ [SNAPPY CORE FATAL] Missing SNAPPY_LICENSE_TOKEN. Production builds are disabled without a valid license.');
39
+ process.exit(1);
40
+ }
41
+ else {
42
+ console.warn('⚠️ [SNAPPY CORE] Missing SNAPPY_LICENSE_TOKEN. Development mode active.');
43
+ return;
44
+ }
45
+ }
46
+ // 3. Heartbeat & Remote Verification
47
+ try {
48
+ const response = await fetch(`${apiUrl}/api/heartbeat`, {
49
+ method: 'POST',
50
+ headers: { 'Content-Type': 'application/json' },
51
+ body: JSON.stringify({
52
+ token,
53
+ domain,
54
+ machineId,
55
+ isLocal,
56
+ version: '0.1.0-build',
57
+ }),
58
+ });
59
+ const data = (await response.json());
60
+ if (!data.ok) {
61
+ if (data.status === 'collision') {
62
+ console.error(`❌ [SNAPPY CORE FATAL] License Collision: ${data.error}. You have exceeded your Dev Seat limit.`);
63
+ }
64
+ else {
65
+ console.error(`❌ [SNAPPY CORE FATAL] License Invalid: ${data.error || 'Unknown error'}`);
66
+ }
67
+ process.exit(1);
68
+ }
69
+ if (data.status === 'suspended' || data.status === 'terminated') {
70
+ console.error(`❌ [SNAPPY CORE FATAL] License ${data.status.toUpperCase()}: This instance has been remotely deactivated.`);
71
+ process.exit(1);
72
+ }
73
+ console.log(`✅ [SNAPPY CORE] Engine verified: ${data.status.toUpperCase()} mode.`);
74
+ }
75
+ catch (err) {
76
+ console.warn(`⚠️ [SNAPPY CORE] License server unreachable: ${err.message}. Running in offline fallback mode.`);
77
+ }
78
+ // 4. Structural Integrity Check
79
+ try {
80
+ // Shadow Realm: Base64 encoded paths
81
+ const dFP = Buffer.from('c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL0Rlc2t0b3BGb290ZXIudHN4', 'base64').toString('utf-8');
82
+ const mFP = Buffer.from('c3JjL2NvbXBvbmVudHMvbGF5b3V0L3BhcnRzL01vYmlsZUZvb3Rlci50c3g=', 'base64').toString('utf-8');
83
+ const desktopFooterPath = path.join(rootDir, dFP);
84
+ const mobileFooterPath = path.join(rootDir, mFP);
85
+ // Regex check: Ensure `<Credit` exists and is NOT preceded by `//` on the same line
86
+ const regexCheck = /^(?!.*\/\/.*<Credit).*<Credit/m;
87
+ if (fs.existsSync(desktopFooterPath)) {
88
+ const desktopContent = fs.readFileSync(desktopFooterPath, 'utf-8');
89
+ if (!regexCheck.test(desktopContent)) {
90
+ console.error('❌ [SNAPPY CORE FATAL] Structural Integrity Compromised: Credit tag missing or commented out in DesktopFooter.');
91
+ process.exit(1);
92
+ }
93
+ }
94
+ if (fs.existsSync(mobileFooterPath)) {
95
+ const mobileContent = fs.readFileSync(mobileFooterPath, 'utf-8');
96
+ if (!regexCheck.test(mobileContent)) {
97
+ console.error('❌ [SNAPPY CORE FATAL] Structural Integrity Compromised: Credit tag missing or commented out in MobileFooter.');
98
+ process.exit(1);
99
+ }
100
+ }
101
+ }
102
+ catch (e) {
103
+ // Silent fail
104
+ }
105
+ };
106
+ /**
107
+ * INITIALIZATION: Secure Config Wrapper
108
+ */
109
+ export const initializeSnappy = (incomingConfig) => {
110
+ const collections = incomingConfig.collections || [];
111
+ const globals = incomingConfig.globals || [];
112
+ const filteredCollections = collections.filter((c) => c.slug !== 'users' && c.slug !== 'login-tokens');
113
+ const filteredGlobals = globals.filter((g) => g.slug !== 'branding');
114
+ // Trigger Build-Time Security
115
+ checkLicense();
116
+ return {
117
+ ...incomingConfig,
118
+ admin: {
119
+ ...(incomingConfig.admin || {}),
120
+ disable: true,
121
+ user: 'users',
122
+ },
123
+ collections: [...filteredCollections, Users, LoginTokens],
124
+ globals: [...filteredGlobals, Branding],
125
+ };
126
+ };
@@ -0,0 +1,4 @@
1
+ export declare const API_PRODUCTION_URL = "https://snappycore.wicky.id";
2
+ export declare const __SECURITY_STATE__: {
3
+ isValid: boolean;
4
+ };
@@ -0,0 +1,5 @@
1
+ export const API_PRODUCTION_URL = 'https://snappycore.wicky.id';
2
+ // POISON PILL STATE: Silent degradation flag
3
+ export const __SECURITY_STATE__ = {
4
+ isValid: true
5
+ };
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useState } from 'react';
4
- import { runStickyHeartbeat } from '../internal/security';
4
+ import { runStickyHeartbeat } from '../internal/security.client';
5
5
  const SnappyContext = createContext(null);
6
6
  export const useSnappy = () => useContext(SnappyContext);
7
7
  export const SnappyProvider = ({ children }) => {
package/dist/utils/cn.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
- import { __SECURITY_STATE__ } from '../internal/security';
3
+ import { __SECURITY_STATE__ } from '../internal/security.shared';
4
4
  /**
5
5
  * [SNAPPY CORE] Centralized Tailwind Class Merger
6
6
  * This isn't just a utility—it's the Poison Pill trigger.
@@ -1,4 +1,4 @@
1
- import { initializeSnappy } from './internal/security';
1
+ import { initializeSnappy } from './internal/security.server';
2
2
  /**
3
3
  * SNAPPY CORE Wrapper
4
4
  * This connects your Next.js project to the Snappy Engine.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snappy-stack/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "description": "The independent core engine for SNAPPY Stack projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",