post-armor 1.0.1 → 1.0.8

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 CHANGED
@@ -52,7 +52,6 @@ app.use(express.raw({ type: "application/octet-stream" }));
52
52
  const armorGate = postArmor({
53
53
  key: "YOUR_SECRET_KEY", // Must match client key
54
54
  delay: 5, // Allowed time difference in seconds
55
- strict: true // Enforce strict response typing
56
55
  });
57
56
 
58
57
  // 3. Protect your route
@@ -61,7 +60,7 @@ app.post("/secure-api", armorGate, (req, res) => {
61
60
  console.log("Received:", req.body);
62
61
 
63
62
  // Send an armored response back
64
- res.return("object", { success: true, message: "Secure data" });
63
+ res.return({ success: true, message: "Secure data" });
65
64
  });
66
65
 
67
66
  app.listen(3000, () => console.log("Server running"));
@@ -74,7 +73,7 @@ To get IntelliSense for `res.return`, add this to your `types.d.ts` or main serv
74
73
  declare global {
75
74
  namespace Express {
76
75
  interface Response {
77
- return: (type: "string" | "number" | "boolean" | "object" | "any", body: any) => void;
76
+ return: (body: any) => void;
78
77
  }
79
78
  }
80
79
  }
@@ -116,7 +115,6 @@ async function sendData() {
116
115
  |---|---|---|---|
117
116
  | `key` | `string` | **Required** | Shared secret key for encryption. |
118
117
  | `delay` | `number` | `5` | Validity window in seconds. |
119
- | `strict` | `boolean` | `true` | Enforce strict type checking on `res.return`. |
120
118
  | `headerName` | `string` | `"post-armor-token"` | Custom header name for the secure token. |
121
119
  | `sourceName` | `string` | `"post-armor"` | Custom source name in payload metadata. |
122
120
 
@@ -128,7 +126,8 @@ async function sendData() {
128
126
  | `key` | `string` | **Required** | Shared secret key. |
129
127
  | `body` | `any` | **Required** | JSON payload to send. |
130
128
  | `headers` | `object` | `{}` | Additional headers to include. |
131
- | `headerName` | `string` | `"post-armor-token"` | Custom header name. |
129
+ | `headerName` | `string` | `"post-armor-token"` | Custom header name. (Must match server) |
130
+ | `sourceName` | `string` | `"post-armor"` | Custom source name in payload metadata. (Must match server) |
132
131
 
133
132
  ---
134
133
 
@@ -141,3 +140,7 @@ async function sendData() {
141
140
 
142
141
  ## License
143
142
  MIT
143
+
144
+ ---
145
+
146
+ **Powered By:** [Evelocore](https://evelocore.com) • [K.Prabhasha](https://kp.evelocore.com)
@@ -30,7 +30,6 @@ export declare function armoredPost({ url, headers, body, key, headerName, sourc
30
30
  export interface PostArmorConfig {
31
31
  key: string;
32
32
  delay?: number;
33
- strict?: boolean;
34
33
  headerName?: string;
35
34
  sourceName?: string;
36
35
  }
@@ -1 +1 @@
1
- const PA0_0x99efa7=PA0_0x4301;(function(_0x195680,_0x353f06){const _0x1965f0=PA0_0x4301,_0x33c9c8=_0x195680();while(!![]){try{const _0x54edcf=-parseInt(_0x1965f0(0x147))/0x1*(parseInt(_0x1965f0(0x129))/0x2)+-parseInt(_0x1965f0(0x134))/0x3*(parseInt(_0x1965f0(0x128))/0x4)+parseInt(_0x1965f0(0x138))/0x5+-parseInt(_0x1965f0(0x15b))/0x6+-parseInt(_0x1965f0(0x130))/0x7*(parseInt(_0x1965f0(0x151))/0x8)+parseInt(_0x1965f0(0x13a))/0x9*(parseInt(_0x1965f0(0x132))/0xa)+parseInt(_0x1965f0(0x144))/0xb;if(_0x54edcf===_0x353f06)break;else _0x33c9c8['push'](_0x33c9c8['shift']());}catch(_0xc7f508){_0x33c9c8['push'](_0x33c9c8['shift']());}}}(PA0_0x236c,0x8abb1));const LIB_VERSION=PA0_0x99efa7(0x143);export function getTimestamp(){const _0x93af31=PA0_0x99efa7,_0x28688e=new Date();return _0x28688e[_0x93af31(0x160)](_0x93af31(0x13c),{'timeZone':_0x93af31(0x149),'hour12':![],'hour':'2-digit','minute':_0x93af31(0x14c),'second':_0x93af31(0x14c)})['replace'](/:/g,'');}function PA0_0x236c(){const _0x46746d=['Asia/Kolkata','charCodeAt','delay','2-digit','error','post-armor-token','length','url','235256gtPLSf','toString','Invalid\x20response\x20type:\x20expected\x20','split','encode','send',',\x20got\x20','parse','application/octet-stream','Failed\x20to\x20parse\x20armored\x20response','2847036Eqrmft','stringify','replace','substring','return','toLocaleTimeString','decode','sourceName','padEnd','join','message','908xCEduq','1022mNdPwF','source','toLowerCase','abs','body','warn','headers','259cBFVCy','Invalid\x20response\x20source:\x20expected\x20','1762990TMiQpO','[PostArmor]\x20Error\x20processing\x20request\x20on\x20','3765UfHsqn','PostArmor:','POST','undefined','369805eGyiMs','post-armor','45KTRWum','PostArmor:\x20config.key\x20is\x20required','en-GB','isBuffer','Invalid\x20request\x20source','reverse','strict','random','path','1.0.0','19946696ddPWaD','json','status','691gmtySn','Token\x20validation\x20error:'];PA0_0x236c=function(){return _0x46746d;};return PA0_0x236c();}function encryptTime(_0x5e85e0,_0x4d6615){const _0x180593=PA0_0x99efa7;let _0x448572='';for(let _0x2d7619=0x0;_0x2d7619<_0x5e85e0[_0x180593(0x14f)];_0x2d7619++){const _0x374d68=_0x5e85e0[_0x180593(0x14a)](_0x2d7619)^_0x4d6615[_0x180593(0x14a)](_0x2d7619%_0x4d6615[_0x180593(0x14f)]);_0x448572+=String['fromCharCode'](_0x374d68);}const _0xd53bc5=Math['random']()[_0x180593(0x152)](0x24)['substring'](0x2,0x7),_0xa35a24=Math[_0x180593(0x141)]()[_0x180593(0x152)](0x24)[_0x180593(0x15e)](0x2,0x7);return _0x448572=_0x448572[_0x180593(0x154)]('')[_0x180593(0x13f)]()['join'](''),btoa(_0xd53bc5+_0x448572+_0xa35a24)[_0x180593(0x15d)](/=/g,'');}function decryptTime(_0x234f31,_0x22431f){const _0x469a9d=PA0_0x99efa7;if(_0x234f31[_0x469a9d(0x14f)]<0xa)return'';let _0x2ca3a1=_0x234f31[_0x469a9d(0x15e)](0x5,_0x234f31['length']-0x5);_0x2ca3a1=_0x2ca3a1[_0x469a9d(0x154)]('')[_0x469a9d(0x13f)]()[_0x469a9d(0x126)]('');let _0x889fdc='';for(let _0x4d365f=0x0;_0x4d365f<_0x2ca3a1['length'];_0x4d365f++){_0x889fdc+=String['fromCharCode'](_0x2ca3a1[_0x469a9d(0x14a)](_0x4d365f)^_0x22431f[_0x469a9d(0x14a)](_0x4d365f%_0x22431f[_0x469a9d(0x14f)]));}return _0x889fdc;}export function getSecureToken(_0x26dac8){const _0x8b78ce=getTimestamp();return encryptTime(_0x8b78ce,_0x26dac8);}export function validateToken(_0xc6d012,_0x504c18,_0x200e7b=0x5){const _0x53adbc=PA0_0x99efa7;try{if(!_0xc6d012)return![];const _0x374ab6=_0xc6d012[_0x53adbc(0x125)](_0xc6d012[_0x53adbc(0x14f)]+(0x4-_0xc6d012[_0x53adbc(0x14f)]%0x4)%0x4,'='),_0x18160c=atob(_0x374ab6),_0x269fe8=decryptTime(_0x18160c,_0x504c18);if(_0x269fe8[_0x53adbc(0x14f)]!==0x6)return![];const _0x4ca66d=getTimestamp(),_0x575fa8=_0x37f56b=>{const _0x1f9765=_0x53adbc,_0x580f2c=parseInt(_0x37f56b['substring'](0x0,0x2),0xa),_0x6ea4c6=parseInt(_0x37f56b[_0x1f9765(0x15e)](0x2,0x4),0xa),_0x46829=parseInt(_0x37f56b[_0x1f9765(0x15e)](0x4,0x6),0xa);return _0x580f2c*0xe10+_0x6ea4c6*0x3c+_0x46829;},_0x48cd26=_0x575fa8(_0x4ca66d),_0x5a13e6=_0x575fa8(_0x269fe8);let _0x123198=_0x48cd26-_0x5a13e6;if(_0x123198<-0x13880)_0x123198+=0x15180;if(_0x123198>0x13880)_0x123198-=0x15180;return Math[_0x53adbc(0x12c)](_0x123198)<=_0x200e7b;}catch(_0x15b275){return console['error'](_0x53adbc(0x148),_0x15b275?.[_0x53adbc(0x127)]),![];}}const _preEncoder=PA0_0x99efa7(0x135);function PA0_0x4301(_0xd3e5e0,_0x2c254a){_0xd3e5e0=_0xd3e5e0-0x124;const _0x236c06=PA0_0x236c();let _0x430167=_0x236c06[_0xd3e5e0];return _0x430167;}function encodeBody(_0x553c3d){const _0x5f1629=PA0_0x99efa7;return btoa(_preEncoder+JSON[_0x5f1629(0x15c)](_0x553c3d));}function decodeBody(_0x3a83fb){const _0x51e877=PA0_0x99efa7;return JSON[_0x51e877(0x158)](atob(_0x3a83fb)[_0x51e877(0x15e)](_preEncoder[_0x51e877(0x14f)]));}export async function armoredPost({url:_0x504887,headers:headers={},body:_0x27cbe7,key:_0x5a4341,headerName:headerName=PA0_0x99efa7(0x14e),sourceName:sourceName='post-armor'}){const _0xc59596=PA0_0x99efa7,_0x14cb9b={...headers,'Content-Type':_0xc59596(0x159),[headerName]:getSecureToken(_0x5a4341)},_0x1b7d64=new TextEncoder(),_0xb776bd=_0x1b7d64['encode'](encodeBody(JSON[_0xc59596(0x15c)]({'body':_0x27cbe7,'_':{'source':sourceName,'version':LIB_VERSION}}))),_0x17237b=await fetch(_0x504887,{'method':_0xc59596(0x136),'headers':_0x14cb9b,'body':_0xb776bd});let _0x1f206f={'body':undefined,'type':_0xc59596(0x137),'_':{'source':'','version':''}};if(_0x17237b[_0xc59596(0x146)]==0xc8){const _0x581dae=await _0x17237b['arrayBuffer'](),_0x671481=new TextDecoder(),_0x435d1f=_0x671481[_0xc59596(0x161)](_0x581dae);try{_0x1f206f=JSON[_0xc59596(0x158)](_0x435d1f);}catch(_0x1483b4){throw new Error(_0xc59596(0x15a));}if(_0x1f206f['_']?.[_0xc59596(0x12a)]!==sourceName||_0x1f206f['_']?.['version']!==LIB_VERSION)throw new Error(_0xc59596(0x131)+sourceName+',\x20got\x20'+_0x1f206f['_']?.[_0xc59596(0x12a)]);}return{'status':_0x17237b['status'],'statusText':_0x17237b['statusText'],'body':_0x1f206f[_0xc59596(0x12d)]||undefined,'type':typeof _0x1f206f['body'],'ok':_0x17237b['ok'],'url':_0x17237b[_0xc59596(0x150)],'redirected':_0x17237b['redirected'],'headers':_0x17237b[_0xc59596(0x12f)]};}export function postArmor(_0x12ba4c){const _0x4cb066=PA0_0x99efa7,_0x5833bb=_0x12ba4c['key'],_0x1b0dce=_0x12ba4c[_0x4cb066(0x14b)]??0x5,_0xffd34a=_0x12ba4c[_0x4cb066(0x140)]??!![],_0x3cdafb=(_0x12ba4c['headerName']||_0x4cb066(0x14e))[_0x4cb066(0x12b)](),_0x158a0d=_0x12ba4c[_0x4cb066(0x124)]||_0x4cb066(0x139);if(!_0x5833bb)throw new Error(_0x4cb066(0x13b));return(_0x4b3abd,_0x9782a0,_0x20c104)=>{const _0x7f8998=_0x4cb066;try{const _0x1e41f4=_0x4b3abd[_0x7f8998(0x12f)][_0x3cdafb];if(!validateToken(_0x1e41f4,_0x5833bb,_0x1b0dce)){console[_0x7f8998(0x12e)]('[PostArmor]\x20Invalid\x20or\x20expired\x20token\x20for\x20header\x20'+_0x3cdafb),_0x9782a0[_0x7f8998(0x146)](0x191)[_0x7f8998(0x145)]({'error':'Unauthorized:\x20Invalid\x20secure\x20token'});return;}if(!_0x4b3abd[_0x7f8998(0x12d)]||_0x4b3abd['body']instanceof Uint8Array&&_0x4b3abd[_0x7f8998(0x12d)][_0x7f8998(0x14f)]===0x0){_0x9782a0['status'](0x190)[_0x7f8998(0x145)]({'error':'Missing\x20request\x20body'});return;}let _0xd0c52;try{const _0x25c268=typeof _0x4b3abd[_0x7f8998(0x12d)]==='string'?_0x4b3abd[_0x7f8998(0x12d)]:_0x4b3abd[_0x7f8998(0x12d)]instanceof Uint8Array||typeof Buffer!=='undefined'&&Buffer[_0x7f8998(0x13d)](_0x4b3abd['body'])?decodeBody(new TextDecoder()[_0x7f8998(0x161)](_0x4b3abd[_0x7f8998(0x12d)])):JSON[_0x7f8998(0x15c)](_0x4b3abd[_0x7f8998(0x12d)]);_0xd0c52=JSON[_0x7f8998(0x158)](_0x25c268);}catch(_0x486f75){_0x9782a0[_0x7f8998(0x146)](0x190)['json']({'error':'Malformed\x20request\x20payload'});return;}if(!_0xd0c52['_']||_0xd0c52['_']['source']!==_0x158a0d){_0x9782a0[_0x7f8998(0x146)](0x190)[_0x7f8998(0x145)]({'error':_0x7f8998(0x13e)});return;}_0x4b3abd[_0x7f8998(0x12d)]=_0xd0c52['body'],_0x9782a0[_0x7f8998(0x15f)]=(_0x483946,_0x26b338)=>{const _0x50fec8=_0x7f8998;if(_0xffd34a&&_0x483946!=='any'&&typeof _0x26b338!==_0x483946)throw new Error(_0x50fec8(0x153)+_0x483946+_0x50fec8(0x157)+typeof _0x26b338);const _0x55c67f=JSON[_0x50fec8(0x15c)]({'body':_0x26b338,'_':{'source':_0x158a0d,'version':LIB_VERSION}});_0x9782a0[_0x50fec8(0x156)](new TextEncoder()[_0x50fec8(0x155)](_0x55c67f));},_0x20c104();}catch(_0x9ad975){console[_0x7f8998(0x14d)](_0x7f8998(0x133)+_0x4b3abd[_0x7f8998(0x142)]+':',_0x9ad975?.['message']),_0x9782a0['status'](0x190)[_0x7f8998(0x145)]({'error':'Internal\x20processing\x20error'});}};}
1
+ const PA0_0x1940d2=PA0_0x3295;(function(_0x337f53,_0x2732b3){const _0x18b874=PA0_0x3295,_0x3311de=_0x337f53();while(!![]){try{const _0x6fed01=parseInt(_0x18b874(0x14e))/0x1+parseInt(_0x18b874(0x14c))/0x2*(parseInt(_0x18b874(0x18a))/0x3)+parseInt(_0x18b874(0x151))/0x4*(-parseInt(_0x18b874(0x173))/0x5)+-parseInt(_0x18b874(0x178))/0x6*(-parseInt(_0x18b874(0x166))/0x7)+-parseInt(_0x18b874(0x152))/0x8*(-parseInt(_0x18b874(0x162))/0x9)+parseInt(_0x18b874(0x168))/0xa+parseInt(_0x18b874(0x16d))/0xb*(-parseInt(_0x18b874(0x183))/0xc);if(_0x6fed01===_0x2732b3)break;else _0x3311de['push'](_0x3311de['shift']());}catch(_0x5065cd){_0x3311de['push'](_0x3311de['shift']());}}}(PA0_0x2983,0xceb7c));function PA0_0x3295(_0x4b1f5b,_0x4033be){_0x4b1f5b=_0x4b1f5b-0x14c;const _0x2983cd=PA0_0x2983();let _0x329504=_0x2983cd[_0x4b1f5b];return _0x329504;}const LIB_VERSION=PA0_0x1940d2(0x17b);export function getTimestamp(){const _0x173611=PA0_0x1940d2,_0x304f8e=new Date();return _0x304f8e[_0x173611(0x167)](_0x173611(0x187),{'timeZone':_0x173611(0x15d),'hour12':![],'hour':_0x173611(0x16f),'minute':_0x173611(0x16f),'second':_0x173611(0x16f)})[_0x173611(0x179)](/:/g,'');}function encryptTime(_0x23f249,_0x78cf9f){const _0x13a45f=PA0_0x1940d2;let _0xaf5ad3='';for(let _0x57b992=0x0;_0x57b992<_0x23f249[_0x13a45f(0x171)];_0x57b992++){const _0x4abf9a=_0x23f249[_0x13a45f(0x170)](_0x57b992)^_0x78cf9f['charCodeAt'](_0x57b992%_0x78cf9f[_0x13a45f(0x171)]);_0xaf5ad3+=String[_0x13a45f(0x155)](_0x4abf9a);}const _0x452a1b=Math[_0x13a45f(0x165)]()[_0x13a45f(0x16b)](0x24)[_0x13a45f(0x172)](0x2,0x7),_0x543cc3=Math[_0x13a45f(0x165)]()[_0x13a45f(0x16b)](0x24)['substring'](0x2,0x7);return _0xaf5ad3=_0xaf5ad3[_0x13a45f(0x14f)]('')[_0x13a45f(0x164)]()[_0x13a45f(0x17a)](''),btoa(_0x452a1b+_0xaf5ad3+_0x543cc3)['replace'](/=/g,'');}function decryptTime(_0x4f690a,_0x4b60bd){const _0x4f3d7c=PA0_0x1940d2;if(_0x4f690a[_0x4f3d7c(0x171)]<0xa)return'';let _0xbfe056=_0x4f690a['substring'](0x5,_0x4f690a[_0x4f3d7c(0x171)]-0x5);_0xbfe056=_0xbfe056[_0x4f3d7c(0x14f)]('')[_0x4f3d7c(0x164)]()[_0x4f3d7c(0x17a)]('');let _0x1a0ed3='';for(let _0x2d65cf=0x0;_0x2d65cf<_0xbfe056['length'];_0x2d65cf++){_0x1a0ed3+=String['fromCharCode'](_0xbfe056[_0x4f3d7c(0x170)](_0x2d65cf)^_0x4b60bd[_0x4f3d7c(0x170)](_0x2d65cf%_0x4b60bd['length']));}return _0x1a0ed3;}export function getSecureToken(_0x2ece4c){const _0xabee1b=getTimestamp();return encryptTime(_0xabee1b,_0x2ece4c);}export function validateToken(_0x371af4,_0x253065,_0x51d261=0x5){const _0x4d9ba3=PA0_0x1940d2;try{if(!_0x371af4)return![];const _0x14da18=_0x371af4['padEnd'](_0x371af4[_0x4d9ba3(0x171)]+(0x4-_0x371af4[_0x4d9ba3(0x171)]%0x4)%0x4,'='),_0x2c14b4=atob(_0x14da18),_0x4e1aca=decryptTime(_0x2c14b4,_0x253065);if(_0x4e1aca[_0x4d9ba3(0x171)]!==0x6)return![];const _0x2bc911=getTimestamp(),_0x473cac=_0x4a8328=>{const _0xe3947c=_0x4d9ba3,_0x408a74=parseInt(_0x4a8328['substring'](0x0,0x2),0xa),_0x34f699=parseInt(_0x4a8328[_0xe3947c(0x172)](0x2,0x4),0xa),_0x5779ea=parseInt(_0x4a8328[_0xe3947c(0x172)](0x4,0x6),0xa);return _0x408a74*0xe10+_0x34f699*0x3c+_0x5779ea;},_0x158ab8=_0x473cac(_0x2bc911),_0x1b8eda=_0x473cac(_0x4e1aca);let _0x55033a=_0x158ab8-_0x1b8eda;if(_0x55033a<-0x13880)_0x55033a+=0x15180;if(_0x55033a>0x13880)_0x55033a-=0x15180;return Math[_0x4d9ba3(0x150)](_0x55033a)<=_0x51d261;}catch(_0x2ea81d){return console['error'](_0x4d9ba3(0x18d),_0x2ea81d?.[_0x4d9ba3(0x177)]),![];}}const _preEncoder='PostArmor:';function encodeBody(_0x850b37){const _0x902ae4=PA0_0x1940d2,_0x22a68b=btoa(JSON['stringify'](_0x850b37));return _preEncoder+_0x22a68b[_0x902ae4(0x14f)]('')[_0x902ae4(0x17e)](_0x7610c8=>String[_0x902ae4(0x155)](_0x7610c8['charCodeAt'](0x0)+0x3))[_0x902ae4(0x17a)]('');}function PA0_0x2983(){const _0xdb20dd=['1.0.7','undefined','delay','map','return','headers',',\x20got\x20','Unauthorized:\x20Invalid\x20secure\x20token','41240172aqAXUr','Malformed\x20request\x20payload','version','Missing\x20request\x20body','en-GB','status','error','1779PLqqVK','source','string','Token\x20validation\x20error:','post-armor','3082kjZikQ','parse','782679NTBmgc','split','abs','424124fUJgHP','9256EQYCgs','sourceName','json','fromCharCode','[PostArmor]\x20Error\x20processing\x20request\x20on\x20','PostArmor:\x20config.key\x20is\x20required','[PostArmor]\x20Invalid\x20or\x20expired\x20token\x20for\x20header\x20','decode','encode','path','post-armor-token','Asia/Kolkata','headerName','statusText','arrayBuffer','body','12789dIeliX','POST','reverse','random','24416emBSYi','toLocaleTimeString','5646710FCbrKG','stringify','Internal\x20processing\x20error','toString','application/octet-stream','11Rwtfvg','key','2-digit','charCodeAt','length','substring','45SokGin','send','warn','Failed\x20to\x20parse\x20armored\x20response','message','2292RSaMoN','replace','join'];PA0_0x2983=function(){return _0xdb20dd;};return PA0_0x2983();}function decodeBody(_0x2c581d){const _0x2b67a9=PA0_0x1940d2,_0x4835a1=_0x2c581d[_0x2b67a9(0x172)](_preEncoder['length'])[_0x2b67a9(0x14f)]('')[_0x2b67a9(0x17e)](_0x22c300=>String[_0x2b67a9(0x155)](_0x22c300[_0x2b67a9(0x170)](0x0)-0x3))[_0x2b67a9(0x17a)]('');return JSON[_0x2b67a9(0x14d)](atob(_0x4835a1));}export async function armoredPost({url:_0xa00e1d,headers:headers={},body:_0x2daace,key:_0x131df0,headerName:headerName=PA0_0x1940d2(0x15c),sourceName:sourceName='post-armor'}){const _0x239e46=PA0_0x1940d2,_0x3053ff={...headers,'Content-Type':_0x239e46(0x16c),[headerName]:getSecureToken(_0x131df0)},_0x36fd1a=new TextEncoder(),_0x171862=_0x36fd1a[_0x239e46(0x15a)](encodeBody(JSON[_0x239e46(0x169)]({'body':_0x2daace,'_':{'source':sourceName,'version':LIB_VERSION}}))),_0x37f9e5=await fetch(_0xa00e1d,{'method':_0x239e46(0x163),'headers':_0x3053ff,'body':_0x171862});let _0x487e1e={'body':undefined,'type':_0x239e46(0x17c),'_':{'source':'','version':''}};const _0x50be9a=await _0x37f9e5[_0x239e46(0x160)](),_0x5ebd1a=new TextDecoder(),_0x2894d3=_0x5ebd1a[_0x239e46(0x159)](_0x50be9a);if(_0x2894d3['startsWith'](_preEncoder)){try{_0x487e1e=JSON[_0x239e46(0x14d)](decodeBody(_0x2894d3));}catch(_0x5417f9){throw new Error(_0x239e46(0x176));}if(_0x487e1e['_']?.[_0x239e46(0x18b)]!==sourceName||_0x487e1e['_']?.[_0x239e46(0x185)]!==LIB_VERSION)throw new Error('Invalid\x20response\x20source:\x20expected\x20'+sourceName+_0x239e46(0x181)+_0x487e1e['_']?.['source']);}return{'status':_0x37f9e5[_0x239e46(0x188)],'statusText':_0x37f9e5[_0x239e46(0x15f)],'body':_0x487e1e[_0x239e46(0x161)]||undefined,'type':typeof _0x487e1e['body'],'ok':_0x37f9e5['ok'],'url':_0x37f9e5['url'],'redirected':_0x37f9e5['redirected'],'headers':_0x37f9e5[_0x239e46(0x180)]};}export function postArmor(_0x4fa6e3){const _0x5478ba=PA0_0x1940d2,_0xf14d18=_0x4fa6e3[_0x5478ba(0x16e)],_0x58d254=_0x4fa6e3[_0x5478ba(0x17d)]??0x5,_0x330bec=(_0x4fa6e3[_0x5478ba(0x15e)]||_0x5478ba(0x15c))['toLowerCase'](),_0xe61106=_0x4fa6e3[_0x5478ba(0x153)]||_0x5478ba(0x18e);if(!_0xf14d18)throw new Error(_0x5478ba(0x157));return(_0x3f5095,_0xf9ae4e,_0x1f01fe)=>{const _0x22179c=_0x5478ba;try{const _0x40c299=_0x3f5095['headers'][_0x330bec];if(!validateToken(_0x40c299,_0xf14d18,_0x58d254)){console[_0x22179c(0x175)](_0x22179c(0x158)+_0x330bec),_0xf9ae4e['status'](0x191)[_0x22179c(0x154)]({'error':_0x22179c(0x182)});return;}if(!_0x3f5095[_0x22179c(0x161)]||_0x3f5095[_0x22179c(0x161)]instanceof Uint8Array&&_0x3f5095[_0x22179c(0x161)][_0x22179c(0x171)]===0x0){_0xf9ae4e[_0x22179c(0x188)](0x190)[_0x22179c(0x154)]({'error':_0x22179c(0x186)});return;}let _0x3365e1;try{const _0x33c853=typeof _0x3f5095[_0x22179c(0x161)]===_0x22179c(0x18c)?_0x3f5095[_0x22179c(0x161)]:_0x3f5095[_0x22179c(0x161)]instanceof Uint8Array||typeof Buffer!=='undefined'&&Buffer['isBuffer'](_0x3f5095[_0x22179c(0x161)])?decodeBody(new TextDecoder()['decode'](_0x3f5095[_0x22179c(0x161)])):JSON[_0x22179c(0x169)](_0x3f5095['body']);_0x3365e1=JSON[_0x22179c(0x14d)](_0x33c853);}catch(_0x53ef3b){_0xf9ae4e[_0x22179c(0x188)](0x190)['json']({'error':_0x22179c(0x184)});return;}if(!_0x3365e1['_']||_0x3365e1['_'][_0x22179c(0x18b)]!==_0xe61106){_0xf9ae4e[_0x22179c(0x188)](0x190)[_0x22179c(0x154)]({'error':'Invalid\x20request\x20source'});return;}_0x3f5095['body']=_0x3365e1['body'],_0xf9ae4e[_0x22179c(0x17f)]=_0x200c62=>{const _0x32b5f4=_0x22179c,_0x259cc2=encodeBody(JSON['stringify']({'body':_0x200c62,'_':{'source':_0xe61106,'version':LIB_VERSION}}));_0xf9ae4e[_0x32b5f4(0x174)](new TextEncoder()[_0x32b5f4(0x15a)](_0x259cc2));},_0x1f01fe();}catch(_0x165100){console[_0x22179c(0x189)](_0x22179c(0x156)+_0x3f5095[_0x22179c(0x15b)]+':',_0x165100?.['message']),_0xf9ae4e[_0x22179c(0x188)](0x190)[_0x22179c(0x154)]({'error':_0x22179c(0x16a)});}};}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "post-armor",
3
- "version": "1.0.1",
3
+ "version": "1.0.8",
4
4
  "description": "Zero-dependency binary request obfuscation and time-locked security middleware for Node.js and Browsers.",
5
5
  "type": "module",
6
6
  "main": "./dist/post-armor.js",
@@ -18,7 +18,21 @@
18
18
  },
19
19
  "author": "K.Prabhasha",
20
20
  "license": "MIT",
21
- "keywords": ["post-armor", "security", "middleware", "encryption", "obfuscation", "time-locked", "binary", "request", "nodejs", "express", "browser", "react", "vue"],
21
+ "keywords": [
22
+ "post-armor",
23
+ "security",
24
+ "middleware",
25
+ "encryption",
26
+ "obfuscation",
27
+ "time-locked",
28
+ "binary",
29
+ "request",
30
+ "nodejs",
31
+ "express",
32
+ "browser",
33
+ "react",
34
+ "vue"
35
+ ],
22
36
  "scripts": {
23
37
  "dev": "tsx watch receive.ts",
24
38
  "build": "tsc",
@@ -35,4 +49,4 @@
35
49
  "tsx": "^4.21.0",
36
50
  "typescript": "^5.3.3"
37
51
  }
38
- }
52
+ }