post-armor 1.0.9 → 1.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/README.md +54 -8
- package/dist/post-armor.d.ts +2 -1
- package/dist/post-armor.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,32 @@ declare global {
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
#### Supported HTTP Methods
|
|
110
|
+
|
|
111
|
+
- `POST`
|
|
112
|
+
- `PATCH`
|
|
113
|
+
- `PUT`
|
|
114
|
+
- `DELETE`
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
app.post("/fruits", armorGate, (req, res) => {
|
|
118
|
+
res.return(["apple", "banana", "orange"]); // Array response
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
app.patch("/update-user", armorGate, (req, res) => {
|
|
122
|
+
res.return("Updated successfully"); // String response
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
app.put("/update-user", armorGate, (req, res) => {
|
|
126
|
+
res.return({ success: true, message: "Updated" }); // Object response
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
app.delete("/delete-user", armorGate, (req, res) => {
|
|
130
|
+
const { user } = req.body;
|
|
131
|
+
res.return({ success: true, message: "Deleted successfully" });
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
109
135
|
### 2. Client-Side (React / Vue / Browser)
|
|
110
136
|
|
|
111
137
|
Use `armoredPost` to send secure requests. This is a wrapper around `fetch` that handles the encryption/decryption handshake.
|
|
@@ -118,6 +144,7 @@ async function sendData() {
|
|
|
118
144
|
const response = await armoredPost({
|
|
119
145
|
url: "http://localhost:3000/secure-api",
|
|
120
146
|
key: "YOUR_SECRET_KEY", // Must match server key
|
|
147
|
+
method: "POST",
|
|
121
148
|
body: { secret: "data" }
|
|
122
149
|
});
|
|
123
150
|
|
|
@@ -132,6 +159,22 @@ async function sendData() {
|
|
|
132
159
|
}
|
|
133
160
|
```
|
|
134
161
|
|
|
162
|
+
### 📐 Response Format
|
|
163
|
+
|
|
164
|
+
`armoredPost` resolves to an object with the following properties:
|
|
165
|
+
|
|
166
|
+
- **status** (`number`) – HTTP status code (e.g., `200`).
|
|
167
|
+
- **statusText** (`string`) – Human‑readable status message (e.g., "OK").
|
|
168
|
+
- **ok** (`boolean`) – `true` when the status is in the 200‑299 range.
|
|
169
|
+
- **type** (`string`) – "object" | "string" | "number" | "array" | "boolean" for the parsed response.
|
|
170
|
+
- **url** (`string`) – The request URL.
|
|
171
|
+
- **redirected** (`boolean`) – Whether the request was redirected.
|
|
172
|
+
- **headers** (`object`) – Plain‑object representation of response headers.
|
|
173
|
+
- **body** (`any`) – The decoded payload returned by the server (already parsed JSON).
|
|
174
|
+
|
|
175
|
+
This makes it easy to work with the response without additional `json()` calls.
|
|
176
|
+
|
|
177
|
+
|
|
135
178
|
---
|
|
136
179
|
|
|
137
180
|
## ⚙️ Configuration
|
|
@@ -153,14 +196,17 @@ async function sendData() {
|
|
|
153
196
|
|
|
154
197
|
### Client: `armoredPost(options)`
|
|
155
198
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
|
159
|
-
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
199
|
+
### Client Options (`armoredPost(options)`)
|
|
200
|
+
|
|
201
|
+
| Option | Type | Default | Description |
|
|
202
|
+
|--------------|--------|---------|-------------|
|
|
203
|
+
| `url` | `string` | **Required** | Target API URL. |
|
|
204
|
+
| `key` | `string` | **Required** | Shared secret key. |
|
|
205
|
+
| `body` | `any` | **Required** | JSON payload to send. |
|
|
206
|
+
| `headers` | `object`| `{}` | Additional headers to include. |
|
|
207
|
+
| `headerName` | `string`| `"post-armor-token"` | Custom header name. (Must match server) |
|
|
208
|
+
| `sourceName` | `string`| `"post-armor"` | Custom source name in payload metadata. (Must match server) |
|
|
209
|
+
| `method` | `string`| `"POST"` | HTTP method to use (e.g., `POST`, `PUT`, `PATCH`, `DELETE`). Case‑insensitive; defaults to `POST`. |
|
|
164
210
|
|
|
165
211
|
---
|
|
166
212
|
|
package/dist/post-armor.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface SecurePostOptions {
|
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
body: any;
|
|
8
8
|
key: string;
|
|
9
|
+
method?: string;
|
|
9
10
|
headerName?: string;
|
|
10
11
|
sourceName?: string;
|
|
11
12
|
}
|
|
@@ -14,7 +15,7 @@ export interface SecurePostOptions {
|
|
|
14
15
|
* @param options The options for the request.
|
|
15
16
|
* @returns A Promise that resolves to the response from the server.
|
|
16
17
|
*/
|
|
17
|
-
export declare function armoredPost({ url, headers, body, key, headerName, sourceName, }: SecurePostOptions): Promise<{
|
|
18
|
+
export declare function armoredPost({ url, headers, body, key, method, headerName, sourceName, }: SecurePostOptions): Promise<{
|
|
18
19
|
status: number;
|
|
19
20
|
statusText: string;
|
|
20
21
|
body: any;
|
package/dist/post-armor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const PA0_0x24552f=PA0_0x3326;(function(_0x42af54,_0x596ccb){const _0x1e3eb2=PA0_0x3326,_0x2b154d=_0x42af54();while(!![]){try{const _0xb7acfb=parseInt(_0x1e3eb2(0x1b5))/0x1*(parseInt(_0x1e3eb2(0x189))/0x2)+parseInt(_0x1e3eb2(0x1ad))/0x3+-parseInt(_0x1e3eb2(0x1a8))/0x4+parseInt(_0x1e3eb2(0x1a7))/0x5*(parseInt(_0x1e3eb2(0x1b9))/0x6)+parseInt(_0x1e3eb2(0x1ab))/0x7+parseInt(_0x1e3eb2(0x17e))/0x8+-parseInt(_0x1e3eb2(0x199))/0x9*(parseInt(_0x1e3eb2(0x1a3))/0xa);if(_0xb7acfb===_0x596ccb)break;else _0x2b154d['push'](_0x2b154d['shift']());}catch(_0x318ab8){_0x2b154d['push'](_0x2b154d['shift']());}}}(PA0_0x25f1,0x9e514));const LIB_VERSION='1.0.9';export function getTimestamp(){const _0x42a482=PA0_0x3326,_0x4cf06a=new Date();return _0x4cf06a[_0x42a482(0x18a)]('en-GB',{'timeZone':_0x42a482(0x1ac),'hour12':![],'hour':_0x42a482(0x19e),'minute':'2-digit','second':'2-digit'})[_0x42a482(0x18f)](/:/g,'');}function encryptTime(_0x28b467,_0x1be06d){const _0x2a0ab7=PA0_0x3326;let _0x1d3b16='';for(let _0x36b9f2=0x0;_0x36b9f2<_0x28b467[_0x2a0ab7(0x17a)];_0x36b9f2++){const _0x51923=_0x28b467[_0x2a0ab7(0x1a4)](_0x36b9f2)^_0x1be06d[_0x2a0ab7(0x1a4)](_0x36b9f2%_0x1be06d['length']);_0x1d3b16+=String[_0x2a0ab7(0x1c3)](_0x51923);}const _0x341d57=Math[_0x2a0ab7(0x194)]()[_0x2a0ab7(0x191)](0x24)[_0x2a0ab7(0x1b2)](0x2,0x7),_0x5ac3af=Math[_0x2a0ab7(0x194)]()[_0x2a0ab7(0x191)](0x24)[_0x2a0ab7(0x1b2)](0x2,0x7);return _0x1d3b16=_0x1d3b16[_0x2a0ab7(0x17b)]('')['reverse']()[_0x2a0ab7(0x179)](''),btoa(_0x341d57+_0x1d3b16+_0x5ac3af)[_0x2a0ab7(0x18f)](/=/g,'');}function decryptTime(_0x4f4574,_0x4021d8){const _0x1abb2b=PA0_0x3326;if(_0x4f4574[_0x1abb2b(0x17a)]<0xa)return'';let _0x4eadba=_0x4f4574[_0x1abb2b(0x1b2)](0x5,_0x4f4574[_0x1abb2b(0x17a)]-0x5);_0x4eadba=_0x4eadba['split']('')[_0x1abb2b(0x185)]()['join']('');let _0x51cfd9='';for(let _0x1be388=0x0;_0x1be388<_0x4eadba[_0x1abb2b(0x17a)];_0x1be388++){_0x51cfd9+=String[_0x1abb2b(0x1c3)](_0x4eadba[_0x1abb2b(0x1a4)](_0x1be388)^_0x4021d8['charCodeAt'](_0x1be388%_0x4021d8[_0x1abb2b(0x17a)]));}return _0x51cfd9;}export function getSecureToken(_0x5c9dea){const _0x522ec8=getTimestamp();return encryptTime(_0x522ec8,_0x5c9dea);}export function validateToken(_0x2a7003,_0x7b3bdd,_0x26ecb6=0x5){const _0x2a03a4=PA0_0x3326;try{if(!_0x2a7003)return![];const _0x1ce91c=_0x2a7003[_0x2a03a4(0x1a1)](_0x2a7003[_0x2a03a4(0x17a)]+(0x4-_0x2a7003[_0x2a03a4(0x17a)]%0x4)%0x4,'='),_0x47ec3d=atob(_0x1ce91c),_0x55bedb=decryptTime(_0x47ec3d,_0x7b3bdd);if(_0x55bedb[_0x2a03a4(0x17a)]!==0x6)return![];const _0x32764e=getTimestamp(),_0x361b72=_0x3c1a71=>{const _0x202059=_0x2a03a4,_0x44971a=parseInt(_0x3c1a71[_0x202059(0x1b2)](0x0,0x2),0xa),_0x1018bd=parseInt(_0x3c1a71['substring'](0x2,0x4),0xa),_0x242441=parseInt(_0x3c1a71[_0x202059(0x1b2)](0x4,0x6),0xa);return _0x44971a*0xe10+_0x1018bd*0x3c+_0x242441;},_0x5d6473=_0x361b72(_0x32764e),_0x1126f5=_0x361b72(_0x55bedb);let _0x511304=_0x5d6473-_0x1126f5;if(_0x511304<-0x13880)_0x511304+=0x15180;if(_0x511304>0x13880)_0x511304-=0x15180;return Math['abs'](_0x511304)<=_0x26ecb6;}catch(_0x23eeaa){return console[_0x2a03a4(0x184)](_0x2a03a4(0x1c0),_0x23eeaa?.[_0x2a03a4(0x1b6)]),![];}}const _preEncoder='PostArmor:';function encodeBody(_0x4f9cca){const _0x4fb661=PA0_0x3326,_0x617e67=btoa(JSON['stringify'](_0x4f9cca));return _preEncoder+_0x617e67['split']('')[_0x4fb661(0x187)](_0x4662f4=>String[_0x4fb661(0x1c3)](_0x4662f4[_0x4fb661(0x1a4)](0x0)+0x3))[_0x4fb661(0x179)]('');}function decodeBody(_0xd47b8e){const _0x4ac51d=PA0_0x3326,_0x31b84d=_0xd47b8e[_0x4ac51d(0x1b2)](_preEncoder[_0x4ac51d(0x17a)])[_0x4ac51d(0x17b)]('')[_0x4ac51d(0x187)](_0x41e9d7=>String[_0x4ac51d(0x1c3)](_0x41e9d7[_0x4ac51d(0x1a4)](0x0)-0x3))[_0x4ac51d(0x179)]('');return JSON[_0x4ac51d(0x1bf)](atob(_0x31b84d));}function PA0_0x3326(_0x353a3f,_0x3e9298){_0x353a3f=_0x353a3f-0x178;const _0x25f150=PA0_0x25f1();let _0x3326f7=_0x25f150[_0x353a3f];return _0x3326f7;}export async function armoredPost({url:_0x4bf1e1,headers:headers={},body:_0x13f295,key:_0x312d75,headerName:headerName=PA0_0x24552f(0x1b3),sourceName:sourceName=PA0_0x24552f(0x1b4)}){const _0x3f0730=PA0_0x24552f,_0x5249df={...headers,'Content-Type':_0x3f0730(0x1ae),[headerName]:getSecureToken(_0x312d75)},_0x13c476=new TextEncoder(),_0x1fde00=_0x13c476[_0x3f0730(0x1bb)](encodeBody(JSON[_0x3f0730(0x181)]({'body':_0x13f295,'_':{'source':sourceName,'version':LIB_VERSION}}))),_0x37d295=await fetch(_0x4bf1e1,{'method':'POST','headers':_0x5249df,'body':_0x1fde00});let _0x5275c7={'body':undefined,'type':_0x3f0730(0x1b0),'_':{'source':'','version':''}};const _0x2436ed=await _0x37d295['arrayBuffer'](),_0x3f3115=new TextDecoder(),_0x5dfd95=_0x3f3115[_0x3f0730(0x190)](_0x2436ed);if(_0x5dfd95[_0x3f0730(0x1b1)](_preEncoder)){try{_0x5275c7=JSON['parse'](decodeBody(_0x5dfd95));}catch(_0x172f5a){throw new Error(_0x3f0730(0x186));}if(_0x5275c7['_']?.[_0x3f0730(0x17c)]!==sourceName||_0x5275c7['_']?.[_0x3f0730(0x1c4)]!==LIB_VERSION)throw new Error(_0x3f0730(0x196)+sourceName+',\x20got\x20'+_0x5275c7['_']?.[_0x3f0730(0x17c)]);}else try{_0x5275c7[_0x3f0730(0x17d)]=JSON['parse'](_0x5dfd95);}catch(_0x3f6db5){_0x5275c7['body']=_0x5dfd95;}return{'status':_0x37d295['status'],'statusText':_0x37d295[_0x3f0730(0x18d)],'body':_0x5275c7['body']||undefined,'type':typeof _0x5275c7[_0x3f0730(0x17d)],'ok':_0x37d295['ok'],'url':_0x37d295[_0x3f0730(0x195)],'redirected':_0x37d295['redirected'],'headers':_0x37d295[_0x3f0730(0x178)]};}const ipReputation={};export function postArmor(_0x3b1e0f){const _0x4bb9bc=PA0_0x24552f,_0x5c15f1=_0x3b1e0f[_0x4bb9bc(0x1af)],_0x2a63c1=_0x3b1e0f[_0x4bb9bc(0x1a9)]??0x5,_0x4ffcdb=(_0x3b1e0f[_0x4bb9bc(0x1a0)]||_0x4bb9bc(0x1b3))[_0x4bb9bc(0x1b8)](),_0x2b0cbb=_0x3b1e0f['sourceName']||_0x4bb9bc(0x1b4),_0xbcabfe=_0x3b1e0f[_0x4bb9bc(0x1c2)]??!![],_0x978d80=_0x3b1e0f[_0x4bb9bc(0x1be)]??0x5,_0x11433c=_0x3b1e0f[_0x4bb9bc(0x1c1)]??0x3c*0x3c,_0x1f130c=_0x3b1e0f[_0x4bb9bc(0x1aa)]||[],_0x4ccd43=_0x3b1e0f[_0x4bb9bc(0x1b7)]||[],_0x27e880=_0x3b1e0f[_0x4bb9bc(0x1c7)]||_0x4bb9bc(0x197);if(!_0x5c15f1)throw new Error(_0x4bb9bc(0x1bd));const _0x5803bc=_0x1ecc6f=>{const _0x593ee9=_0x4bb9bc;return(_0x1ecc6f[_0x593ee9(0x178)]['x-forwarded-for']||_0x1ecc6f[_0x593ee9(0x18b)]?.[_0x593ee9(0x19b)]||_0x1ecc6f[_0x593ee9(0x1c5)]?.[_0x593ee9(0x19b)]||'')['split'](',')[0x0][_0x593ee9(0x192)]();},_0x17521a=_0x33c837=>{const _0x2a9ad8=_0x4bb9bc;if(_0x1f130c[_0x2a9ad8(0x17a)]>0x0&&!_0x1f130c[_0x2a9ad8(0x1c6)](_0x33c837))return!![];if(_0x4ccd43[_0x2a9ad8(0x1c6)](_0x33c837))return!![];const _0x8b6506=ipReputation[_0x33c837];if(_0x8b6506&&_0x8b6506['blockedUntil']>Date[_0x2a9ad8(0x198)]())return!![];return![];},_0x24cc5=_0x3473dd=>{const _0x5ca64e=_0x4bb9bc;if(!_0xbcabfe)return;!ipReputation[_0x3473dd]&&(ipReputation[_0x3473dd]={'count':0x0,'blockedUntil':0x0});const _0xc3af7=ipReputation[_0x3473dd];_0xc3af7[_0x5ca64e(0x1a5)]>0x0&&_0xc3af7[_0x5ca64e(0x1a5)]<Date[_0x5ca64e(0x198)]()&&(_0xc3af7[_0x5ca64e(0x19a)]=0x0,_0xc3af7['blockedUntil']=0x0),_0xc3af7[_0x5ca64e(0x19a)]++,_0xc3af7['count']>_0x978d80&&(_0xc3af7['blockedUntil']=Date[_0x5ca64e(0x198)]()+_0x11433c*0x3e8);};return(_0x1076f5,_0x598ded,_0x4582a0)=>{const _0x4522e5=_0x4bb9bc,_0x2e7a24=_0x5803bc(_0x1076f5);if(_0x17521a(_0x2e7a24)){_0x598ded[_0x4522e5(0x17f)](0x193)['json']({'error':_0x27e880});return;}try{const _0x54be8c=_0x1076f5[_0x4522e5(0x178)][_0x4ffcdb];if(!validateToken(_0x54be8c,_0x5c15f1,_0x2a63c1)){console[_0x4522e5(0x183)](_0x4522e5(0x18e)+_0x4ffcdb),_0x598ded['status'](0x191)[_0x4522e5(0x19f)]({'error':_0x4522e5(0x1a6)}),_0x24cc5(_0x2e7a24);return;}if(!_0x1076f5[_0x4522e5(0x17d)]||_0x1076f5[_0x4522e5(0x17d)]instanceof Uint8Array&&_0x1076f5[_0x4522e5(0x17d)]['length']===0x0){_0x598ded['status'](0x190)[_0x4522e5(0x19f)]({'error':_0x4522e5(0x188)}),_0x24cc5(_0x2e7a24);return;}let _0x2594f4;try{const _0x479e62=typeof _0x1076f5['body']===_0x4522e5(0x18c)?_0x1076f5[_0x4522e5(0x17d)]:_0x1076f5[_0x4522e5(0x17d)]instanceof Uint8Array||typeof Buffer!==_0x4522e5(0x1b0)&&Buffer[_0x4522e5(0x180)](_0x1076f5[_0x4522e5(0x17d)])?decodeBody(new TextDecoder()[_0x4522e5(0x190)](_0x1076f5['body'])):JSON[_0x4522e5(0x181)](_0x1076f5[_0x4522e5(0x17d)]);_0x2594f4=JSON[_0x4522e5(0x1bf)](_0x479e62);}catch(_0x398aa0){_0x598ded[_0x4522e5(0x17f)](0x190)['json']({'error':_0x4522e5(0x1ba)}),_0x24cc5(_0x2e7a24);return;}if(!_0x2594f4['_']||_0x2594f4['_']['source']!==_0x2b0cbb){_0x598ded[_0x4522e5(0x17f)](0x190)[_0x4522e5(0x19f)]({'error':_0x4522e5(0x1a2)}),_0x24cc5(_0x2e7a24);return;}_0x1076f5['body']=_0x2594f4['body'],_0x598ded[_0x4522e5(0x182)]=_0x14ab8b=>{const _0x4654f3=_0x4522e5,_0x32bb11=encodeBody(JSON[_0x4654f3(0x181)]({'body':_0x14ab8b,'_':{'source':_0x2b0cbb,'version':LIB_VERSION}}));_0x598ded[_0x4654f3(0x1bc)](new TextEncoder()['encode'](_0x32bb11));},_0x4582a0();}catch(_0x4a6eb2){console['error'](_0x4522e5(0x19d)+_0x1076f5[_0x4522e5(0x193)]+':',_0x4a6eb2?.['message']),_0x598ded['status'](0x190)[_0x4522e5(0x19f)]({'error':_0x4522e5(0x19c)});}};}function PA0_0x25f1(){const _0x3f3059=['count','remoteAddress','Internal\x20processing\x20error','[PostArmor]\x20Error\x20processing\x20request\x20on\x20','2-digit','json','headerName','padEnd','Invalid\x20request\x20source','440NBecrE','charCodeAt','blockedUntil','Unauthorized:\x20Invalid\x20secure\x20token','5kLFfCq','4131356DOIKGV','delay','allowedIPs','842114vuiSUj','Asia/Kolkata','2477511DJNIYt','application/octet-stream','key','undefined','startsWith','substring','post-armor-token','post-armor','868ZVOMKO','message','deniedIPs','toLowerCase','4674654FvVrbh','Malformed\x20request\x20payload','encode','send','PostArmor:\x20config.key\x20is\x20required','allowedBadActions','parse','Token\x20validation\x20error:','badIPDuration','blockBadIP','fromCharCode','version','socket','includes','badIPMessage','headers','join','length','split','source','body','3593880EYeNVB','status','isBuffer','stringify','return','warn','error','reverse','Failed\x20to\x20parse\x20armored\x20response','map','Missing\x20request\x20body','1654HZBgrk','toLocaleTimeString','connection','string','statusText','[PostArmor]\x20Invalid\x20or\x20expired\x20token\x20for\x20header\x20','replace','decode','toString','trim','path','random','url','Invalid\x20response\x20source:\x20expected\x20','Request\x20from\x20a\x20suspicious\x20IP\x20blocked.','now','247707dyaEtG'];PA0_0x25f1=function(){return _0x3f3059;};return PA0_0x25f1();}
|
|
1
|
+
const PA0_0x58f249=PA0_0x219c;function PA0_0xf0bc(){const _0xb0aafc=['body','x-forwarded-for','key','Unauthorized:\x20Invalid\x20secure\x20token','toLocaleTimeString','fromCharCode','Internal\x20processing\x20error','headers','Failed\x20to\x20parse\x20armored\x20response','817446kicLco','join','allowedIPs','charCodeAt','2-digit','split','replace','Token\x20validation\x20error:','393666HsTpLT','version','substring','blockedUntil','5oYuYvB','badIPMessage','count','map','startsWith','parse','1003628WRjrVK','deniedIPs','[PostArmor]\x20Invalid\x20or\x20expired\x20token\x20for\x20header\x20','string','json','arrayBuffer','reverse','encode','7861ctDoKx','now','stringify','delay','blockBadIP','Missing\x20request\x20body','decode','DELETE','Invalid\x20response\x20source:\x20expected\x20','status','warn','Malformed\x20request\x20payload','post-armor-token','en-GB','connection','source','PostArmor:\x20config.key\x20is\x20required','PATCH','message','POST','statusText','trim','2167338RhxeNU','post-armor','path','138042pGhmhM','error','send','452766dnnLpb','padEnd','random','2488QZScSQ','toString','toUpperCase','includes','Invalid\x20method:\x20','url','remoteAddress','PUT','length','isBuffer'];PA0_0xf0bc=function(){return _0xb0aafc;};return PA0_0xf0bc();}(function(_0x1ce22e,_0x41dffb){const _0x2377e9=PA0_0x219c,_0xf82111=_0x1ce22e();while(!![]){try{const _0x40f601=parseInt(_0x2377e9(0xc2))/0x1+parseInt(_0x2377e9(0xba))/0x2+-parseInt(_0x2377e9(0xf0))/0x3+parseInt(_0x2377e9(0xcc))/0x4*(parseInt(_0x2377e9(0xc6))/0x5)+-parseInt(_0x2377e9(0xea))/0x6+parseInt(_0x2377e9(0xd4))/0x7*(-parseInt(_0x2377e9(0xf3))/0x8)+parseInt(_0x2377e9(0xed))/0x9;if(_0x40f601===_0x41dffb)break;else _0xf82111['push'](_0xf82111['shift']());}catch(_0x3a8af9){_0xf82111['push'](_0xf82111['shift']());}}}(PA0_0xf0bc,0x32984));const LIB_VERSION='1.1.0';export function getTimestamp(){const _0x4c978f=PA0_0x219c,_0x17ddf8=new Date();return _0x17ddf8[_0x4c978f(0x101)](_0x4c978f(0xe1),{'timeZone':'Asia/Kolkata','hour12':![],'hour':_0x4c978f(0xbe),'minute':'2-digit','second':_0x4c978f(0xbe)})[_0x4c978f(0xc0)](/:/g,'');}function encryptTime(_0x2e8657,_0x123c9f){const _0x85be82=PA0_0x219c;let _0x545aa2='';for(let _0x43c954=0x0;_0x43c954<_0x2e8657[_0x85be82(0xfb)];_0x43c954++){const _0x4ecb6a=_0x2e8657['charCodeAt'](_0x43c954)^_0x123c9f[_0x85be82(0xbd)](_0x43c954%_0x123c9f[_0x85be82(0xfb)]);_0x545aa2+=String[_0x85be82(0x102)](_0x4ecb6a);}const _0xe608b8=Math[_0x85be82(0xf2)]()[_0x85be82(0xf4)](0x24)[_0x85be82(0xc4)](0x2,0x7),_0x594385=Math[_0x85be82(0xf2)]()[_0x85be82(0xf4)](0x24)['substring'](0x2,0x7);return _0x545aa2=_0x545aa2[_0x85be82(0xbf)]('')[_0x85be82(0xd2)]()[_0x85be82(0xbb)](''),btoa(_0xe608b8+_0x545aa2+_0x594385)[_0x85be82(0xc0)](/=/g,'');}function decryptTime(_0x456d8d,_0x5e284a){const _0x4d8a98=PA0_0x219c;if(_0x456d8d[_0x4d8a98(0xfb)]<0xa)return'';let _0x5e86e0=_0x456d8d['substring'](0x5,_0x456d8d[_0x4d8a98(0xfb)]-0x5);_0x5e86e0=_0x5e86e0['split']('')[_0x4d8a98(0xd2)]()[_0x4d8a98(0xbb)]('');let _0x486a62='';for(let _0x16043e=0x0;_0x16043e<_0x5e86e0['length'];_0x16043e++){_0x486a62+=String[_0x4d8a98(0x102)](_0x5e86e0[_0x4d8a98(0xbd)](_0x16043e)^_0x5e284a['charCodeAt'](_0x16043e%_0x5e284a[_0x4d8a98(0xfb)]));}return _0x486a62;}export function getSecureToken(_0x3bb237){const _0x51a5f5=getTimestamp();return encryptTime(_0x51a5f5,_0x3bb237);}export function validateToken(_0x3c0bb9,_0x35f181,_0xa08cdc=0x5){const _0x43685e=PA0_0x219c;try{if(!_0x3c0bb9)return![];const _0x5192d5=_0x3c0bb9[_0x43685e(0xf1)](_0x3c0bb9[_0x43685e(0xfb)]+(0x4-_0x3c0bb9[_0x43685e(0xfb)]%0x4)%0x4,'='),_0x2f0619=atob(_0x5192d5),_0x2dee59=decryptTime(_0x2f0619,_0x35f181);if(_0x2dee59[_0x43685e(0xfb)]!==0x6)return![];const _0x70804f=getTimestamp(),_0x558d2d=_0x1832f1=>{const _0x5c9f7c=_0x43685e,_0x2c7055=parseInt(_0x1832f1['substring'](0x0,0x2),0xa),_0x483a58=parseInt(_0x1832f1[_0x5c9f7c(0xc4)](0x2,0x4),0xa),_0x1ffee4=parseInt(_0x1832f1['substring'](0x4,0x6),0xa);return _0x2c7055*0xe10+_0x483a58*0x3c+_0x1ffee4;},_0x580456=_0x558d2d(_0x70804f),_0x1f8b22=_0x558d2d(_0x2dee59);let _0x892539=_0x580456-_0x1f8b22;if(_0x892539<-0x13880)_0x892539+=0x15180;if(_0x892539>0x13880)_0x892539-=0x15180;return Math['abs'](_0x892539)<=_0xa08cdc;}catch(_0x29cbe9){return console[_0x43685e(0xee)](_0x43685e(0xc1),_0x29cbe9?.['message']),![];}}function PA0_0x219c(_0x438cd8,_0x34bd0d){_0x438cd8=_0x438cd8-0xb7;const _0xf0bcf=PA0_0xf0bc();let _0x219c18=_0xf0bcf[_0x438cd8];return _0x219c18;}const _preEncoder='PostArmor:';function encodeBody(_0x2a53fd){const _0x5a4aba=PA0_0x219c,_0x507e98=btoa(JSON[_0x5a4aba(0xd6)](_0x2a53fd));return _preEncoder+_0x507e98[_0x5a4aba(0xbf)]('')['map'](_0x3faf54=>String[_0x5a4aba(0x102)](_0x3faf54['charCodeAt'](0x0)+0x3))['join']('');}function decodeBody(_0x23729c){const _0x549d5f=PA0_0x219c,_0x560c63=_0x23729c[_0x549d5f(0xc4)](_preEncoder[_0x549d5f(0xfb)])['split']('')[_0x549d5f(0xc9)](_0x254993=>String['fromCharCode'](_0x254993[_0x549d5f(0xbd)](0x0)-0x3))[_0x549d5f(0xbb)]('');return JSON['parse'](atob(_0x560c63));}export async function armoredPost({url:_0x4eba75,headers:headers={},body:_0x30ba85,key:_0x535b7a,method:method=PA0_0x58f249(0xe7),headerName:headerName=PA0_0x58f249(0xe0),sourceName:sourceName=PA0_0x58f249(0xeb)}){const _0x2d4408=PA0_0x58f249,_0x4b187a={...headers,'Content-Type':'application/octet-stream',[headerName]:getSecureToken(_0x535b7a)};if(![_0x2d4408(0xe7),_0x2d4408(0xfa),_0x2d4408(0xe5),_0x2d4408(0xdb)][_0x2d4408(0xf6)](method['toUpperCase']()))throw new Error(_0x2d4408(0xf7)+method);const _0x57a3f2=new TextEncoder(),_0x50021f=_0x57a3f2[_0x2d4408(0xd3)](encodeBody(JSON[_0x2d4408(0xd6)]({'body':_0x30ba85,'_':{'source':sourceName,'version':LIB_VERSION}}))),_0x3388eb=await fetch(_0x4eba75,{'method':method[_0x2d4408(0xf5)](),'headers':_0x4b187a,'body':_0x50021f});let _0xfe58f6={'body':undefined,'type':'undefined','_':{'source':'','version':''}};const _0x3ad5d9=await _0x3388eb[_0x2d4408(0xd1)](),_0x75fc23=new TextDecoder(),_0x54907a=_0x75fc23[_0x2d4408(0xda)](_0x3ad5d9);if(_0x54907a[_0x2d4408(0xca)](_preEncoder)){try{_0xfe58f6=JSON[_0x2d4408(0xcb)](decodeBody(_0x54907a));}catch(_0x55ffcb){throw new Error(_0x2d4408(0xb9));}if(_0xfe58f6['_']?.[_0x2d4408(0xe3)]!==sourceName||_0xfe58f6['_']?.[_0x2d4408(0xc3)]!==LIB_VERSION)throw new Error(_0x2d4408(0xdc)+sourceName+',\x20got\x20'+_0xfe58f6['_']?.['source']);}else try{_0xfe58f6[_0x2d4408(0xfd)]=JSON[_0x2d4408(0xcb)](_0x54907a);}catch(_0x21b06e){_0xfe58f6[_0x2d4408(0xfd)]=_0x54907a;}return{'status':_0x3388eb['status'],'statusText':_0x3388eb[_0x2d4408(0xe8)],'body':_0xfe58f6[_0x2d4408(0xfd)]||undefined,'type':typeof _0xfe58f6[_0x2d4408(0xfd)],'ok':_0x3388eb['ok'],'url':_0x3388eb[_0x2d4408(0xf8)],'redirected':_0x3388eb['redirected'],'headers':_0x3388eb[_0x2d4408(0xb8)]};}const ipReputation={};export function postArmor(_0x8b1b84){const _0x2fcfb3=PA0_0x58f249,_0x113176=_0x8b1b84[_0x2fcfb3(0xff)],_0x1790ec=_0x8b1b84[_0x2fcfb3(0xd7)]??0x5,_0x4a7b17=(_0x8b1b84['headerName']||_0x2fcfb3(0xe0))['toLowerCase'](),_0x1d3781=_0x8b1b84['sourceName']||_0x2fcfb3(0xeb),_0x3ee1fd=_0x8b1b84[_0x2fcfb3(0xd8)]??!![],_0x29626d=_0x8b1b84['allowedBadActions']??0x5,_0xceee09=_0x8b1b84['badIPDuration']??0x3c*0x3c,_0x588122=_0x8b1b84[_0x2fcfb3(0xbc)]||[],_0xd3db96=_0x8b1b84[_0x2fcfb3(0xcd)]||[],_0x344756=_0x8b1b84[_0x2fcfb3(0xc7)]||'Request\x20from\x20a\x20suspicious\x20IP\x20blocked.';if(!_0x113176)throw new Error(_0x2fcfb3(0xe4));const _0x5ec8c5=_0x3365ef=>{const _0x536cc0=_0x2fcfb3;return(_0x3365ef[_0x536cc0(0xb8)][_0x536cc0(0xfe)]||_0x3365ef[_0x536cc0(0xe2)]?.[_0x536cc0(0xf9)]||_0x3365ef['socket']?.[_0x536cc0(0xf9)]||'')[_0x536cc0(0xbf)](',')[0x0][_0x536cc0(0xe9)]();},_0x11ae2e=_0x71b36d=>{const _0x4c6712=_0x2fcfb3;if(_0x588122[_0x4c6712(0xfb)]>0x0&&!_0x588122[_0x4c6712(0xf6)](_0x71b36d))return!![];if(_0xd3db96[_0x4c6712(0xf6)](_0x71b36d))return!![];const _0x4af91c=ipReputation[_0x71b36d];if(_0x4af91c&&_0x4af91c[_0x4c6712(0xc5)]>Date[_0x4c6712(0xd5)]())return!![];return![];},_0x52bdbe=_0x352d71=>{const _0x3971c7=_0x2fcfb3;if(!_0x3ee1fd)return;!ipReputation[_0x352d71]&&(ipReputation[_0x352d71]={'count':0x0,'blockedUntil':0x0});const _0x69614a=ipReputation[_0x352d71];_0x69614a[_0x3971c7(0xc5)]>0x0&&_0x69614a['blockedUntil']<Date[_0x3971c7(0xd5)]()&&(_0x69614a['count']=0x0,_0x69614a['blockedUntil']=0x0),_0x69614a[_0x3971c7(0xc8)]++,_0x69614a[_0x3971c7(0xc8)]>_0x29626d&&(_0x69614a['blockedUntil']=Date[_0x3971c7(0xd5)]()+_0xceee09*0x3e8);};return(_0x58f386,_0x318e1d,_0xc5aa47)=>{const _0x112468=_0x2fcfb3,_0x4b008a=_0x5ec8c5(_0x58f386);if(_0x11ae2e(_0x4b008a)){_0x318e1d[_0x112468(0xdd)](0x193)[_0x112468(0xd0)]({'error':_0x344756});return;}try{const _0x9eadaa=_0x58f386['headers'][_0x4a7b17];if(!validateToken(_0x9eadaa,_0x113176,_0x1790ec)){console[_0x112468(0xde)](_0x112468(0xce)+_0x4a7b17),_0x318e1d[_0x112468(0xdd)](0x191)[_0x112468(0xd0)]({'error':_0x112468(0x100)}),_0x52bdbe(_0x4b008a);return;}if(!_0x58f386[_0x112468(0xfd)]||_0x58f386[_0x112468(0xfd)]instanceof Uint8Array&&_0x58f386[_0x112468(0xfd)][_0x112468(0xfb)]===0x0){_0x318e1d[_0x112468(0xdd)](0x190)[_0x112468(0xd0)]({'error':_0x112468(0xd9)}),_0x52bdbe(_0x4b008a);return;}let _0x5e6ecf;try{const _0x337d7a=typeof _0x58f386[_0x112468(0xfd)]===_0x112468(0xcf)?_0x58f386['body']:_0x58f386[_0x112468(0xfd)]instanceof Uint8Array||typeof Buffer!=='undefined'&&Buffer[_0x112468(0xfc)](_0x58f386['body'])?decodeBody(new TextDecoder()[_0x112468(0xda)](_0x58f386[_0x112468(0xfd)])):JSON['stringify'](_0x58f386['body']);_0x5e6ecf=JSON['parse'](_0x337d7a);}catch(_0x4d18ad){_0x318e1d[_0x112468(0xdd)](0x190)[_0x112468(0xd0)]({'error':_0x112468(0xdf)}),_0x52bdbe(_0x4b008a);return;}if(!_0x5e6ecf['_']||_0x5e6ecf['_'][_0x112468(0xe3)]!==_0x1d3781){_0x318e1d[_0x112468(0xdd)](0x190)[_0x112468(0xd0)]({'error':'Invalid\x20request\x20source'}),_0x52bdbe(_0x4b008a);return;}_0x58f386[_0x112468(0xfd)]=_0x5e6ecf[_0x112468(0xfd)],_0x318e1d['return']=_0x10c1bf=>{const _0xf61c96=_0x112468,_0x33b8c7=encodeBody(JSON[_0xf61c96(0xd6)]({'body':_0x10c1bf,'_':{'source':_0x1d3781,'version':LIB_VERSION}}));_0x318e1d[_0xf61c96(0xef)](new TextEncoder()['encode'](_0x33b8c7));},_0xc5aa47();}catch(_0x333ca5){console[_0x112468(0xee)]('[PostArmor]\x20Error\x20processing\x20request\x20on\x20'+_0x58f386[_0x112468(0xec)]+':',_0x333ca5?.[_0x112468(0xe6)]),_0x318e1d[_0x112468(0xdd)](0x190)[_0x112468(0xd0)]({'error':_0x112468(0xb7)});}};}
|
package/package.json
CHANGED