securequ 1.0.8 → 1.0.9

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.
Files changed (88) hide show
  1. package/client/index.js +213 -2
  2. package/client/index.js.map +1 -7
  3. package/client/index.mjs +213 -0
  4. package/client/index.mjs.map +1 -0
  5. package/include/lib/base64.js +47 -2
  6. package/include/lib/base64.js.map +1 -7
  7. package/include/lib/base64.mjs +47 -0
  8. package/include/lib/base64.mjs.map +1 -0
  9. package/include/lib/cache.js +74 -2
  10. package/include/lib/cache.js.map +1 -7
  11. package/include/lib/cache.mjs +74 -0
  12. package/include/lib/cache.mjs.map +1 -0
  13. package/include/lib/crypto.js +69 -2
  14. package/include/lib/crypto.js.map +1 -7
  15. package/include/lib/crypto.mjs +69 -0
  16. package/include/lib/crypto.mjs.map +1 -0
  17. package/include/lib/pako.js +28 -2
  18. package/include/lib/pako.js.map +1 -7
  19. package/include/lib/pako.mjs +28 -0
  20. package/include/lib/pako.mjs.map +1 -0
  21. package/include/lib/reverser.js +25 -2
  22. package/include/lib/reverser.js.map +1 -7
  23. package/include/lib/reverser.mjs +25 -0
  24. package/include/lib/reverser.mjs.map +1 -0
  25. package/include/lib/urlpath.js +10 -2
  26. package/include/lib/urlpath.js.map +1 -7
  27. package/include/lib/urlpath.mjs +10 -0
  28. package/include/lib/urlpath.mjs.map +1 -0
  29. package/include/responseValue.js +10 -2
  30. package/include/responseValue.js.map +1 -7
  31. package/include/responseValue.mjs +10 -0
  32. package/include/responseValue.mjs.map +1 -0
  33. package/include/signeture.js +20 -2
  34. package/include/signeture.js.map +1 -7
  35. package/include/signeture.mjs +20 -0
  36. package/include/signeture.mjs.map +1 -0
  37. package/index.d.ts +81 -3
  38. package/index.js +1 -2
  39. package/index.js.map +1 -7
  40. package/index.mjs +1 -0
  41. package/index.mjs.map +1 -0
  42. package/package.json +11 -27
  43. package/server/index.js +187 -2
  44. package/server/index.js.map +1 -7
  45. package/server/index.mjs +187 -0
  46. package/server/index.mjs.map +1 -0
  47. package/cjs/client/index.js +0 -2
  48. package/cjs/client/index.js.map +0 -7
  49. package/cjs/client/types.js +0 -2
  50. package/cjs/client/types.js.map +0 -7
  51. package/cjs/include/lib/base64.js +0 -2
  52. package/cjs/include/lib/base64.js.map +0 -7
  53. package/cjs/include/lib/cache.js +0 -2
  54. package/cjs/include/lib/cache.js.map +0 -7
  55. package/cjs/include/lib/crypto.js +0 -2
  56. package/cjs/include/lib/crypto.js.map +0 -7
  57. package/cjs/include/lib/pako.js +0 -2
  58. package/cjs/include/lib/pako.js.map +0 -7
  59. package/cjs/include/lib/reverser.js +0 -2
  60. package/cjs/include/lib/reverser.js.map +0 -7
  61. package/cjs/include/lib/urlpath.js +0 -2
  62. package/cjs/include/lib/urlpath.js.map +0 -7
  63. package/cjs/include/responseValue.js +0 -2
  64. package/cjs/include/responseValue.js.map +0 -7
  65. package/cjs/include/signeture.js +0 -2
  66. package/cjs/include/signeture.js.map +0 -7
  67. package/cjs/index.js +0 -2
  68. package/cjs/index.js.map +0 -7
  69. package/cjs/server/index.js +0 -2
  70. package/cjs/server/index.js.map +0 -7
  71. package/cjs/server/types.js +0 -2
  72. package/cjs/server/types.js.map +0 -7
  73. package/client/index.d.ts +0 -23
  74. package/client/types.d.ts +0 -20
  75. package/client/types.js +0 -1
  76. package/client/types.js.map +0 -7
  77. package/include/lib/base64.d.ts +0 -17
  78. package/include/lib/cache.d.ts +0 -36
  79. package/include/lib/crypto.d.ts +0 -22
  80. package/include/lib/pako.d.ts +0 -17
  81. package/include/lib/reverser.d.ts +0 -5
  82. package/include/lib/urlpath.d.ts +0 -7
  83. package/include/responseValue.d.ts +0 -5
  84. package/include/signeture.d.ts +0 -6
  85. package/server/index.d.ts +0 -16
  86. package/server/types.d.ts +0 -37
  87. package/server/types.js +0 -1
  88. package/server/types.js.map +0 -7
@@ -0,0 +1,47 @@
1
+ import {__spreadArray,__read}from'../../node_modules/tslib/tslib.es6.mjs';/**
2
+ * Encodes a Uint8Array to Base64 (for browser or Node.js).
3
+ * @param data - The Uint8Array data to encode.
4
+ * @returns The Base64-encoded string.
5
+ */
6
+ function encode(data) {
7
+ var base64 = "";
8
+ if (typeof window !== "undefined") {
9
+ base64 = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(Array.from(data)), false)));
10
+ }
11
+ else {
12
+ base64 = Buffer.from(data).toString("base64");
13
+ }
14
+ var paddingCount = (base64.match(/=+$/) || [''])[0].length;
15
+ if (paddingCount > 0) {
16
+ base64 = base64.replace(/=+$/, function () { return "$".concat(paddingCount); });
17
+ }
18
+ return base64;
19
+ }
20
+ /**
21
+ * Decodes a Base64 string to a Uint8Array (for browser or Node.js).
22
+ * @param base64String - The Base64 string to decode.
23
+ * @returns The decoded Uint8Array.
24
+ */
25
+ function decode(base64) {
26
+ try {
27
+ base64 = base64.replace(/\$(\d)/, function (_match, count) { return '='.repeat(parseInt(count)); });
28
+ if (typeof window !== "undefined") {
29
+ var binaryString = atob(base64);
30
+ var byteArray = new Uint8Array(binaryString.length);
31
+ for (var i = 0; i < binaryString.length; i++) {
32
+ byteArray[i] = binaryString.charCodeAt(i);
33
+ }
34
+ return byteArray;
35
+ }
36
+ else {
37
+ return Uint8Array.from(Buffer.from(base64, "base64"));
38
+ }
39
+ }
40
+ catch (error) {
41
+ throw new Error("Invalid Base64 string.");
42
+ }
43
+ }
44
+ var base64 = {
45
+ encode: encode,
46
+ decode: decode
47
+ };export{base64 as default};//# sourceMappingURL=base64.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.mjs","sources":["../../../src/include/lib/base64.ts"],"sourcesContent":["/**\n * Encodes a Uint8Array to Base64 (for browser or Node.js).\n * @param data - The Uint8Array data to encode.\n * @returns The Base64-encoded string.\n */\nfunction encode(data: Uint8Array): string {\n let base64 = \"\";\n if (typeof window !== \"undefined\") {\n base64 = btoa(String.fromCharCode(...Array.from(data)));\n } else {\n base64 = Buffer.from(data).toString(\"base64\");\n }\n let paddingCount = (base64.match(/=+$/) || [''])[0].length;\n if (paddingCount > 0) {\n base64 = base64.replace(/=+$/, () => `$${paddingCount}`);\n }\n return base64\n}\n\n/**\n * Decodes a Base64 string to a Uint8Array (for browser or Node.js).\n * @param base64String - The Base64 string to decode.\n * @returns The decoded Uint8Array.\n */\nfunction decode(base64: string): Uint8Array {\n try {\n base64 = base64.replace(/\\$(\\d)/, (_match, count) => '='.repeat(parseInt(count)));\n if (typeof window !== \"undefined\") {\n const binaryString = atob(base64);\n const byteArray = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n byteArray[i] = binaryString.charCodeAt(i);\n }\n return byteArray;\n } else {\n return Uint8Array.from(Buffer.from(base64, \"base64\"));\n }\n } catch (error) {\n throw new Error(\"Invalid Base64 string.\");\n }\n}\n\nconst base64 = {\n encode,\n decode\n}\n\nexport default base64;"],"names":[],"mappings":"0EAAA;;;;AAIG;AACH,SAAS,MAAM,CAAC,IAAgB,EAAA;IAC7B,IAAI,MAAM,GAAG,EAAE;AACf,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAnB,KAAA,CAAA,MAAM,EAAiB,aAAA,CAAA,EAAA,EAAA,MAAA,CAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAE;AACzD;AAAM,SAAA;AACJ,QAAA,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC/C;AACD,IAAA,IAAI,YAAY,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;IAC1D,IAAI,YAAY,GAAG,CAAC,EAAE;AACnB,QAAA,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,YAAM,EAAA,OAAA,WAAI,YAAY,CAAE,CAAlB,EAAkB,CAAC;AAC1D;AACD,IAAA,OAAO,MAAM;AAChB;AAEA;;;;AAIG;AACH,SAAS,MAAM,CAAC,MAAc,EAAA;IAC3B,IAAI;QACD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAC,MAAM,EAAE,KAAK,EAAA,EAAK,OAAA,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA,EAAA,CAAC;AACjF,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,YAAA,IAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;YACjC,IAAM,SAAS,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC;AACrD,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC3C,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;AAC3C;AACD,YAAA,OAAO,SAAS;AAClB;AAAM,aAAA;AACJ,YAAA,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACvD;AACH;AAAC,IAAA,OAAO,KAAK,EAAE;AACb,QAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC;AAC3C;AACJ;AAEA,IAAM,MAAM,GAAG;AACZ,IAAA,MAAM,EAAA,MAAA;AACN,IAAA,MAAM,EAAA;"}
@@ -1,2 +1,74 @@
1
- class r{constructor(t){this.store=new Map,this.defaultTTL=t.ttl,this.limit=t.limit}set(t,e){if(this.store.size>=this.limit){const s=this.store.keys().next().value;this.store.delete(s)}this.store.has(t)&&clearTimeout(this.store.get(t).timeout);const i=setTimeout(()=>{this.store.delete(t)},this.defaultTTL);this.store.set(t,{value:e,timeout:i,expiresAt:Date.now()+this.defaultTTL})}get(t){const e=this.store.get(t);return e?Date.now()>e.expiresAt?(this.store.delete(t),null):(this.set(t,e.value),e.value):null}delete(t){const e=this.store.get(t);e&&(clearTimeout(e.timeout),this.store.delete(t))}clear(){this.store.forEach(t=>clearTimeout(t.timeout)),this.store.clear()}size(){return this.store.size}}var u=r;export{u as default};
2
- //# sourceMappingURL=cache.js.map
1
+ 'use strict';var SecurequCache = /** @class */ (function () {
2
+ function SecurequCache(config) {
3
+ this.store = new Map();
4
+ this.defaultTTL = config.ttl;
5
+ this.limit = config.limit;
6
+ }
7
+ /**
8
+ * Set a value in the cache with a global TTL
9
+ * @param key - Cache key
10
+ * @param value - Cache value
11
+ */
12
+ SecurequCache.prototype.set = function (key, value) {
13
+ var _this = this;
14
+ // If the cache exceeds the limit, remove the oldest (least recently used) item
15
+ if (this.store.size >= this.limit) {
16
+ var firstKey = this.store.keys().next().value;
17
+ this.store.delete(firstKey);
18
+ }
19
+ // If the key already exists, remove the old timeout
20
+ if (this.store.has(key)) {
21
+ clearTimeout(this.store.get(key).timeout);
22
+ }
23
+ // Set the new expiration timeout
24
+ var timeout = setTimeout(function () {
25
+ _this.store.delete(key); // Delete expired cache entry
26
+ }, this.defaultTTL);
27
+ // Store the value and its expiration info
28
+ this.store.set(key, { value: value, timeout: timeout, expiresAt: Date.now() + this.defaultTTL });
29
+ };
30
+ /**
31
+ * Get a value from the cache and auto-renew the TTL if not expired
32
+ * @param key - Cache key
33
+ * @returns The cached value or null if expired
34
+ */
35
+ SecurequCache.prototype.get = function (key) {
36
+ var entry = this.store.get(key);
37
+ if (!entry) {
38
+ return null; // No data found in cache
39
+ }
40
+ // Check if the cache has expired
41
+ if (Date.now() > entry.expiresAt) {
42
+ this.store.delete(key); // Automatically delete expired cache entry
43
+ return null;
44
+ }
45
+ this.set(key, entry.value);
46
+ return entry.value;
47
+ };
48
+ /**
49
+ * Delete a key from the cache
50
+ * @param key - Cache key
51
+ */
52
+ SecurequCache.prototype.delete = function (key) {
53
+ var entry = this.store.get(key);
54
+ if (entry) {
55
+ clearTimeout(entry.timeout); // Clear the timeout
56
+ this.store.delete(key); // Delete from cache
57
+ }
58
+ };
59
+ /**
60
+ * Clear the entire cache
61
+ */
62
+ SecurequCache.prototype.clear = function () {
63
+ this.store.forEach(function (entry) { return clearTimeout(entry.timeout); }); // Clear all timeouts
64
+ this.store.clear(); // Clear the store
65
+ };
66
+ /**
67
+ * Get the current size of the cache
68
+ * @returns The number of items in the cache
69
+ */
70
+ SecurequCache.prototype.size = function () {
71
+ return this.store.size;
72
+ };
73
+ return SecurequCache;
74
+ }());module.exports=SecurequCache;//# sourceMappingURL=cache.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/include/lib/cache.ts"],
4
- "sourcesContent": ["class SecurequCache<T> {\n private store: Map<string, { value: T; timeout: NodeJS.Timeout; expiresAt: number }>;\n private defaultTTL: number; // Global TTL for all cache entries\n private limit: number; // Limit on the number of cache entries\n\n constructor(config: { ttl: number; limit: number }) {\n this.store = new Map();\n this.defaultTTL = config.ttl;\n this.limit = config.limit;\n }\n\n /**\n * Set a value in the cache with a global TTL\n * @param key - Cache key\n * @param value - Cache value\n */\n set(key: string, value: T): void {\n // If the cache exceeds the limit, remove the oldest (least recently used) item\n if (this.store.size >= this.limit) {\n const firstKey: any = this.store.keys().next().value;\n this.store.delete(firstKey);\n }\n\n // If the key already exists, remove the old timeout\n if (this.store.has(key)) {\n clearTimeout(this.store.get(key)!.timeout);\n }\n\n // Set the new expiration timeout\n const timeout = setTimeout(() => {\n this.store.delete(key); // Delete expired cache entry\n }, this.defaultTTL);\n\n // Store the value and its expiration info\n this.store.set(key, { value, timeout, expiresAt: Date.now() + this.defaultTTL });\n }\n\n /**\n * Get a value from the cache and auto-renew the TTL if not expired\n * @param key - Cache key\n * @returns The cached value or null if expired\n */\n get(key: string): T | null {\n const entry = this.store.get(key);\n\n if (!entry) {\n return null; // No data found in cache\n }\n\n // Check if the cache has expired\n if (Date.now() > entry.expiresAt) {\n this.store.delete(key); // Automatically delete expired cache entry\n return null;\n }\n\n this.set(key, entry.value);\n return entry.value;\n }\n\n /**\n * Delete a key from the cache\n * @param key - Cache key\n */\n delete(key: string): void {\n const entry = this.store.get(key);\n if (entry) {\n clearTimeout(entry.timeout); // Clear the timeout\n this.store.delete(key); // Delete from cache\n }\n }\n\n /**\n * Clear the entire cache\n */\n clear(): void {\n this.store.forEach((entry) => clearTimeout(entry.timeout)); // Clear all timeouts\n this.store.clear(); // Clear the store\n }\n\n /**\n * Get the current size of the cache\n * @returns The number of items in the cache\n */\n size(): number {\n return this.store.size;\n }\n}\n\n\nexport default SecurequCache"],
5
- "mappings": "AAAA,MAAMA,CAAiB,CAKpB,YAAYC,EAAwC,CACjD,KAAK,MAAQ,IAAI,IACjB,KAAK,WAAaA,EAAO,IACzB,KAAK,MAAQA,EAAO,KACvB,CAOA,IAAIC,EAAaC,EAAgB,CAE9B,GAAI,KAAK,MAAM,MAAQ,KAAK,MAAO,CAChC,MAAMC,EAAgB,KAAK,MAAM,KAAK,EAAE,KAAK,EAAE,MAC/C,KAAK,MAAM,OAAOA,CAAQ,CAC7B,CAGI,KAAK,MAAM,IAAIF,CAAG,GACnB,aAAa,KAAK,MAAM,IAAIA,CAAG,EAAG,OAAO,EAI5C,MAAMG,EAAU,WAAW,IAAM,CAC9B,KAAK,MAAM,OAAOH,CAAG,CACxB,EAAG,KAAK,UAAU,EAGlB,KAAK,MAAM,IAAIA,EAAK,CAAE,MAAAC,EAAO,QAAAE,EAAS,UAAW,KAAK,IAAI,EAAI,KAAK,UAAW,CAAC,CAClF,CAOA,IAAIH,EAAuB,CACxB,MAAMI,EAAQ,KAAK,MAAM,IAAIJ,CAAG,EAEhC,OAAKI,EAKD,KAAK,IAAI,EAAIA,EAAM,WACpB,KAAK,MAAM,OAAOJ,CAAG,EACd,OAGV,KAAK,IAAIA,EAAKI,EAAM,KAAK,EAClBA,EAAM,OAVH,IAWb,CAMA,OAAOJ,EAAmB,CACvB,MAAMI,EAAQ,KAAK,MAAM,IAAIJ,CAAG,EAC5BI,IACD,aAAaA,EAAM,OAAO,EAC1B,KAAK,MAAM,OAAOJ,CAAG,EAE3B,CAKA,OAAc,CACX,KAAK,MAAM,QAASI,GAAU,aAAaA,EAAM,OAAO,CAAC,EACzD,KAAK,MAAM,MAAM,CACpB,CAMA,MAAe,CACZ,OAAO,KAAK,MAAM,IACrB,CACH,CAGA,IAAOC,EAAQP",
6
- "names": ["SecurequCache", "config", "key", "value", "firstKey", "timeout", "entry", "cache_default"]
7
- }
1
+ {"version":3,"file":"cache.js","sources":["../../../src/include/lib/cache.ts"],"sourcesContent":["class SecurequCache<T> {\n private store: Map<string, { value: T; timeout: NodeJS.Timeout; expiresAt: number }>;\n private defaultTTL: number; // Global TTL for all cache entries\n private limit: number; // Limit on the number of cache entries\n\n constructor(config: { ttl: number; limit: number }) {\n this.store = new Map();\n this.defaultTTL = config.ttl;\n this.limit = config.limit;\n }\n\n /**\n * Set a value in the cache with a global TTL\n * @param key - Cache key\n * @param value - Cache value\n */\n set(key: string, value: T): void {\n // If the cache exceeds the limit, remove the oldest (least recently used) item\n if (this.store.size >= this.limit) {\n const firstKey: any = this.store.keys().next().value;\n this.store.delete(firstKey);\n }\n\n // If the key already exists, remove the old timeout\n if (this.store.has(key)) {\n clearTimeout(this.store.get(key)!.timeout);\n }\n\n // Set the new expiration timeout\n const timeout = setTimeout(() => {\n this.store.delete(key); // Delete expired cache entry\n }, this.defaultTTL);\n\n // Store the value and its expiration info\n this.store.set(key, { value, timeout, expiresAt: Date.now() + this.defaultTTL });\n }\n\n /**\n * Get a value from the cache and auto-renew the TTL if not expired\n * @param key - Cache key\n * @returns The cached value or null if expired\n */\n get(key: string): T | null {\n const entry = this.store.get(key);\n\n if (!entry) {\n return null; // No data found in cache\n }\n\n // Check if the cache has expired\n if (Date.now() > entry.expiresAt) {\n this.store.delete(key); // Automatically delete expired cache entry\n return null;\n }\n\n this.set(key, entry.value);\n return entry.value;\n }\n\n /**\n * Delete a key from the cache\n * @param key - Cache key\n */\n delete(key: string): void {\n const entry = this.store.get(key);\n if (entry) {\n clearTimeout(entry.timeout); // Clear the timeout\n this.store.delete(key); // Delete from cache\n }\n }\n\n /**\n * Clear the entire cache\n */\n clear(): void {\n this.store.forEach((entry) => clearTimeout(entry.timeout)); // Clear all timeouts\n this.store.clear(); // Clear the store\n }\n\n /**\n * Get the current size of the cache\n * @returns The number of items in the cache\n */\n size(): number {\n return this.store.size;\n }\n}\n\n\nexport default SecurequCache"],"names":[],"mappings":"aAAA,IAAA,aAAA,kBAAA,YAAA;AAKG,IAAA,SAAA,aAAA,CAAY,MAAsC,EAAA;AAC/C,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE;AACtB,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG;AAC5B,QAAA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK;;AAG5B;;;;AAIG;AACH,IAAA,aAAA,CAAA,SAAA,CAAA,GAAG,GAAH,UAAI,GAAW,EAAE,KAAQ,EAAA;QAAzB,IAmBC,KAAA,GAAA,IAAA;;QAjBE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;AAChC,YAAA,IAAM,QAAQ,GAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK;AACpD,YAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC7B;;QAGD,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACtB,YAAA,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,CAAC;AAC5C;;QAGD,IAAM,OAAO,GAAG,UAAU,CAAC,YAAA;YACxB,KAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1B,SAAC,EAAE,IAAI,CAAC,UAAU,CAAC;;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CAAA,SAAA,CAAA,IAAI,GAAJ,YAAA;AACG,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;KACxB;IACJ,OAAC,aAAA;AAAD,CAAC,EAAA"}
@@ -0,0 +1,74 @@
1
+ var SecurequCache = /** @class */ (function () {
2
+ function SecurequCache(config) {
3
+ this.store = new Map();
4
+ this.defaultTTL = config.ttl;
5
+ this.limit = config.limit;
6
+ }
7
+ /**
8
+ * Set a value in the cache with a global TTL
9
+ * @param key - Cache key
10
+ * @param value - Cache value
11
+ */
12
+ SecurequCache.prototype.set = function (key, value) {
13
+ var _this = this;
14
+ // If the cache exceeds the limit, remove the oldest (least recently used) item
15
+ if (this.store.size >= this.limit) {
16
+ var firstKey = this.store.keys().next().value;
17
+ this.store.delete(firstKey);
18
+ }
19
+ // If the key already exists, remove the old timeout
20
+ if (this.store.has(key)) {
21
+ clearTimeout(this.store.get(key).timeout);
22
+ }
23
+ // Set the new expiration timeout
24
+ var timeout = setTimeout(function () {
25
+ _this.store.delete(key); // Delete expired cache entry
26
+ }, this.defaultTTL);
27
+ // Store the value and its expiration info
28
+ this.store.set(key, { value: value, timeout: timeout, expiresAt: Date.now() + this.defaultTTL });
29
+ };
30
+ /**
31
+ * Get a value from the cache and auto-renew the TTL if not expired
32
+ * @param key - Cache key
33
+ * @returns The cached value or null if expired
34
+ */
35
+ SecurequCache.prototype.get = function (key) {
36
+ var entry = this.store.get(key);
37
+ if (!entry) {
38
+ return null; // No data found in cache
39
+ }
40
+ // Check if the cache has expired
41
+ if (Date.now() > entry.expiresAt) {
42
+ this.store.delete(key); // Automatically delete expired cache entry
43
+ return null;
44
+ }
45
+ this.set(key, entry.value);
46
+ return entry.value;
47
+ };
48
+ /**
49
+ * Delete a key from the cache
50
+ * @param key - Cache key
51
+ */
52
+ SecurequCache.prototype.delete = function (key) {
53
+ var entry = this.store.get(key);
54
+ if (entry) {
55
+ clearTimeout(entry.timeout); // Clear the timeout
56
+ this.store.delete(key); // Delete from cache
57
+ }
58
+ };
59
+ /**
60
+ * Clear the entire cache
61
+ */
62
+ SecurequCache.prototype.clear = function () {
63
+ this.store.forEach(function (entry) { return clearTimeout(entry.timeout); }); // Clear all timeouts
64
+ this.store.clear(); // Clear the store
65
+ };
66
+ /**
67
+ * Get the current size of the cache
68
+ * @returns The number of items in the cache
69
+ */
70
+ SecurequCache.prototype.size = function () {
71
+ return this.store.size;
72
+ };
73
+ return SecurequCache;
74
+ }());export{SecurequCache as default};//# sourceMappingURL=cache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.mjs","sources":["../../../src/include/lib/cache.ts"],"sourcesContent":["class SecurequCache<T> {\n private store: Map<string, { value: T; timeout: NodeJS.Timeout; expiresAt: number }>;\n private defaultTTL: number; // Global TTL for all cache entries\n private limit: number; // Limit on the number of cache entries\n\n constructor(config: { ttl: number; limit: number }) {\n this.store = new Map();\n this.defaultTTL = config.ttl;\n this.limit = config.limit;\n }\n\n /**\n * Set a value in the cache with a global TTL\n * @param key - Cache key\n * @param value - Cache value\n */\n set(key: string, value: T): void {\n // If the cache exceeds the limit, remove the oldest (least recently used) item\n if (this.store.size >= this.limit) {\n const firstKey: any = this.store.keys().next().value;\n this.store.delete(firstKey);\n }\n\n // If the key already exists, remove the old timeout\n if (this.store.has(key)) {\n clearTimeout(this.store.get(key)!.timeout);\n }\n\n // Set the new expiration timeout\n const timeout = setTimeout(() => {\n this.store.delete(key); // Delete expired cache entry\n }, this.defaultTTL);\n\n // Store the value and its expiration info\n this.store.set(key, { value, timeout, expiresAt: Date.now() + this.defaultTTL });\n }\n\n /**\n * Get a value from the cache and auto-renew the TTL if not expired\n * @param key - Cache key\n * @returns The cached value or null if expired\n */\n get(key: string): T | null {\n const entry = this.store.get(key);\n\n if (!entry) {\n return null; // No data found in cache\n }\n\n // Check if the cache has expired\n if (Date.now() > entry.expiresAt) {\n this.store.delete(key); // Automatically delete expired cache entry\n return null;\n }\n\n this.set(key, entry.value);\n return entry.value;\n }\n\n /**\n * Delete a key from the cache\n * @param key - Cache key\n */\n delete(key: string): void {\n const entry = this.store.get(key);\n if (entry) {\n clearTimeout(entry.timeout); // Clear the timeout\n this.store.delete(key); // Delete from cache\n }\n }\n\n /**\n * Clear the entire cache\n */\n clear(): void {\n this.store.forEach((entry) => clearTimeout(entry.timeout)); // Clear all timeouts\n this.store.clear(); // Clear the store\n }\n\n /**\n * Get the current size of the cache\n * @returns The number of items in the cache\n */\n size(): number {\n return this.store.size;\n }\n}\n\n\nexport default SecurequCache"],"names":[],"mappings":"AAAA,IAAA,aAAA,kBAAA,YAAA;AAKG,IAAA,SAAA,aAAA,CAAY,MAAsC,EAAA;AAC/C,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE;AACtB,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG;AAC5B,QAAA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK;;AAG5B;;;;AAIG;AACH,IAAA,aAAA,CAAA,SAAA,CAAA,GAAG,GAAH,UAAI,GAAW,EAAE,KAAQ,EAAA;QAAzB,IAmBC,KAAA,GAAA,IAAA;;QAjBE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;AAChC,YAAA,IAAM,QAAQ,GAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK;AACpD,YAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC7B;;QAGD,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACtB,YAAA,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,CAAC;AAC5C;;QAGD,IAAM,OAAO,GAAG,UAAU,CAAC,YAAA;YACxB,KAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1B,SAAC,EAAE,IA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AAGG;AACH,IAAA,aAAA,CAAA,SAAA,CAAA,IAAI,GAAJ,YAAA;AACG,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;KACxB;IACJ,OAAC,aAAA;AAAD,CAAC,EAAA"}
@@ -1,2 +1,69 @@
1
- import t from"tweetnacl";import y from"./base64";import h from"./pako";function a(e,n){e=typeof e=="object"?JSON.stringify(e):e,n=c(n).substring(0,32);const o=new TextEncoder().encode(n),r=t.randomBytes(t.secretbox.nonceLength),s=h.compress(e,!0),i=t.secretbox(s,r,o);return y.encode(new Uint8Array([...r,...i]))}function u(e,n){try{n=c(n).substring(0,32);const o=new TextEncoder().encode(n),r=y.decode(e),s=r.slice(0,t.secretbox.nonceLength),i=r.slice(t.secretbox.nonceLength),d=t.secretbox.open(i,s,o);if(!d)throw new Error("Decryption failed!");const g=h.decompress(d);try{return JSON.parse(g)}catch{return g}}catch{throw new Error("Invalid encrypted data.")}}let p=new Map;function c(e){if(p.has(e))return p.get(e);const n=new TextEncoder().encode(e),o=t.hash(n),r=Array.from(o).map(s=>s.toString(16).padStart(2,"0")).join("");return p.set(e,r),r}const m=e=>c(e).substring(0,32),f={encrypt:a,decrypt:u,hash:c,makeSecret:m};var E=f;export{E as default};
2
- //# sourceMappingURL=crypto.js.map
1
+ 'use strict';var tslib_es6=require('../../node_modules/tslib/tslib.es6.js'),nacl=require('tweetnacl'),base64=require('./base64.js'),pako=require('./pako.js');/**
2
+ * Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.
3
+ * @param data - The plaintext data to encrypt.
4
+ * @param secret - The secret key as a string.
5
+ * @returns A Base64 encoded string (nonce + compressed ciphertext).
6
+ */
7
+ function encrypt(data, secret) {
8
+ data = typeof data === "object" ? JSON.stringify(data) : data;
9
+ secret = hash(secret).substring(0, 32);
10
+ var key = new TextEncoder().encode(secret);
11
+ var nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
12
+ var compressed = pako.default.compress(data, true); // Ensure it returns Uint8Array
13
+ var encrypted = nacl.secretbox(compressed, nonce, key);
14
+ return base64.encode(new Uint8Array(tslib_es6.__spreadArray(tslib_es6.__spreadArray([], tslib_es6.__read(nonce), false), tslib_es6.__read(encrypted), false)));
15
+ }
16
+ /**
17
+ * Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).
18
+ * @param data - The Base64 encoded string (nonce + compressed ciphertext).
19
+ * @param secret - The secret key as a string.
20
+ * @returns The decrypted plaintext string.
21
+ */
22
+ function decrypt(data, secret) {
23
+ try {
24
+ secret = hash(secret).substring(0, 32);
25
+ var key = new TextEncoder().encode(secret);
26
+ var encryptedBytes = base64.decode(data);
27
+ var nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);
28
+ var ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);
29
+ var decrypted = nacl.secretbox.open(ciphertext, nonce, key);
30
+ if (!decrypted)
31
+ throw new Error("Decryption failed!");
32
+ var decompressed = pako.default.decompress(decrypted); // Decompress as string
33
+ try {
34
+ return JSON.parse(decompressed);
35
+ }
36
+ catch (error) {
37
+ return decompressed;
38
+ }
39
+ }
40
+ catch (error) {
41
+ throw new Error("Invalid encrypted data.");
42
+ }
43
+ }
44
+ /**
45
+ * Hashes a string using NaCl's hash function.
46
+ * @param data - The input string to hash.
47
+ * @returns The hash of the input string.
48
+ */
49
+ var hashed = new Map();
50
+ function hash(data) {
51
+ if (hashed.has(data))
52
+ return hashed.get(data);
53
+ var inputBytes = new TextEncoder().encode(data);
54
+ var hashedData = nacl.hash(inputBytes);
55
+ var d = Array.from(hashedData)
56
+ .map(function (byte) { return byte.toString(16).padStart(2, '0'); })
57
+ .join('');
58
+ hashed.set(data, d);
59
+ return d;
60
+ }
61
+ var makeSecret = function (secret) {
62
+ return hash(secret).substring(0, 32);
63
+ };
64
+ var crypto = {
65
+ encrypt: encrypt,
66
+ decrypt: decrypt,
67
+ hash: hash,
68
+ makeSecret: makeSecret
69
+ };module.exports=crypto;//# sourceMappingURL=crypto.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/include/lib/crypto.ts"],
4
- "sourcesContent": ["import nacl from \"tweetnacl\";\nimport base64 from \"./base64\";\nimport pako from \"./pako\";\n\n/**\n * Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.\n * @param data - The plaintext data to encrypt.\n * @param secret - The secret key as a string.\n * @returns A Base64 encoded string (nonce + compressed ciphertext).\n */\nfunction encrypt(data: string | object, secret: string): string {\n data = typeof data === \"object\" ? JSON.stringify(data) : data\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);\n const compressed = pako.compress(data, true) as Uint8Array // Ensure it returns Uint8Array\n const encrypted = nacl.secretbox(compressed, nonce, key);\n return base64.encode(new Uint8Array([...nonce, ...encrypted]));\n}\n\n/**\n * Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).\n * @param data - The Base64 encoded string (nonce + compressed ciphertext).\n * @param secret - The secret key as a string.\n * @returns The decrypted plaintext string.\n */\nfunction decrypt(data: string, secret: string): string {\n try {\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const encryptedBytes = base64.decode(data);\n const nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);\n const ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);\n const decrypted = nacl.secretbox.open(ciphertext, nonce, key);\n if (!decrypted) throw new Error(\"Decryption failed!\");\n const decompressed = pako.decompress(decrypted); // Decompress as string\n try {\n return JSON.parse(decompressed);\n } catch (error) {\n return decompressed;\n }\n } catch (error) {\n throw new Error(\"Invalid encrypted data.\");\n }\n}\n\n/**\n * Hashes a string using NaCl's hash function.\n * @param data - The input string to hash.\n * @returns The hash of the input string.\n */\nlet hashed = new Map<string, string>();\nfunction hash(data: string): string {\n if (hashed.has(data)) return hashed.get(data) as string\n const inputBytes = new TextEncoder().encode(data);\n const hashedData = nacl.hash(inputBytes);\n const d = Array.from(hashedData)\n .map(byte => byte.toString(16).padStart(2, '0'))\n .join('');\n hashed.set(data, d)\n return d\n}\n\nconst makeSecret = (secret: string) => {\n return hash(secret).substring(0, 32);\n}\n\nconst crypto = {\n encrypt,\n decrypt,\n hash,\n makeSecret\n};\n\nexport default crypto;\n"],
5
- "mappings": "AAAA,OAAOA,MAAU,YACjB,OAAOC,MAAY,WACnB,OAAOC,MAAU,SAQjB,SAASC,EAAQC,EAAuBC,EAAwB,CAC7DD,EAAO,OAAOA,GAAS,SAAW,KAAK,UAAUA,CAAI,EAAIA,EACzDC,EAASC,EAAKD,CAAM,EAAE,UAAU,EAAG,EAAE,EACrC,MAAME,EAAM,IAAI,YAAY,EAAE,OAAOF,CAAM,EACrCG,EAAQR,EAAK,YAAYA,EAAK,UAAU,WAAW,EACnDS,EAAaP,EAAK,SAASE,EAAM,EAAI,EACrCM,EAAYV,EAAK,UAAUS,EAAYD,EAAOD,CAAG,EACvD,OAAON,EAAO,OAAO,IAAI,WAAW,CAAC,GAAGO,EAAO,GAAGE,CAAS,CAAC,CAAC,CAChE,CAQA,SAASC,EAAQP,EAAcC,EAAwB,CACpD,GAAI,CACDA,EAASC,EAAKD,CAAM,EAAE,UAAU,EAAG,EAAE,EACrC,MAAME,EAAM,IAAI,YAAY,EAAE,OAAOF,CAAM,EACrCO,EAAiBX,EAAO,OAAOG,CAAI,EACnCI,EAAQI,EAAe,MAAM,EAAGZ,EAAK,UAAU,WAAW,EAC1Da,EAAaD,EAAe,MAAMZ,EAAK,UAAU,WAAW,EAC5Dc,EAAYd,EAAK,UAAU,KAAKa,EAAYL,EAAOD,CAAG,EAC5D,GAAI,CAACO,EAAW,MAAM,IAAI,MAAM,oBAAoB,EACpD,MAAMC,EAAeb,EAAK,WAAWY,CAAS,EAC9C,GAAI,CACD,OAAO,KAAK,MAAMC,CAAY,CACjC,MAAgB,CACb,OAAOA,CACV,CACH,MAAgB,CACb,MAAM,IAAI,MAAM,yBAAyB,CAC5C,CACH,CAOA,IAAIC,EAAS,IAAI,IACjB,SAASV,EAAKF,EAAsB,CACjC,GAAIY,EAAO,IAAIZ,CAAI,EAAG,OAAOY,EAAO,IAAIZ,CAAI,EAC5C,MAAMa,EAAa,IAAI,YAAY,EAAE,OAAOb,CAAI,EAC1Cc,EAAalB,EAAK,KAAKiB,CAAU,EACjCE,EAAI,MAAM,KAAKD,CAAU,EAC3B,IAAIE,GAAQA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAC9C,KAAK,EAAE,EACX,OAAAJ,EAAO,IAAIZ,EAAMe,CAAC,EACXA,CACV,CAEA,MAAME,EAAchB,GACVC,EAAKD,CAAM,EAAE,UAAU,EAAG,EAAE,EAGhCiB,EAAS,CACZ,QAAAnB,EACA,QAAAQ,EACA,KAAAL,EACA,WAAAe,CACH,EAEA,IAAOE,EAAQD",
6
- "names": ["nacl", "base64", "pako", "encrypt", "data", "secret", "hash", "key", "nonce", "compressed", "encrypted", "decrypt", "encryptedBytes", "ciphertext", "decrypted", "decompressed", "hashed", "inputBytes", "hashedData", "d", "byte", "makeSecret", "crypto", "crypto_default"]
7
- }
1
+ {"version":3,"file":"crypto.js","sources":["../../../src/include/lib/crypto.ts"],"sourcesContent":["import nacl from \"tweetnacl\";\nimport base64 from \"./base64\";\nimport pako from \"./pako\";\n\n/**\n * Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.\n * @param data - The plaintext data to encrypt.\n * @param secret - The secret key as a string.\n * @returns A Base64 encoded string (nonce + compressed ciphertext).\n */\nfunction encrypt(data: string | object, secret: string): string {\n data = typeof data === \"object\" ? JSON.stringify(data) : data\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);\n const compressed = pako.compress(data, true) as Uint8Array // Ensure it returns Uint8Array\n const encrypted = nacl.secretbox(compressed, nonce, key);\n return base64.encode(new Uint8Array([...nonce, ...encrypted]));\n}\n\n/**\n * Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).\n * @param data - The Base64 encoded string (nonce + compressed ciphertext).\n * @param secret - The secret key as a string.\n * @returns The decrypted plaintext string.\n */\nfunction decrypt(data: string, secret: string): string {\n try {\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const encryptedBytes = base64.decode(data);\n const nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);\n const ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);\n const decrypted = nacl.secretbox.open(ciphertext, nonce, key);\n if (!decrypted) throw new Error(\"Decryption failed!\");\n const decompressed = pako.decompress(decrypted); // Decompress as string\n try {\n return JSON.parse(decompressed);\n } catch (error) {\n return decompressed;\n }\n } catch (error) {\n throw new Error(\"Invalid encrypted data.\");\n }\n}\n\n/**\n * Hashes a string using NaCl's hash function.\n * @param data - The input string to hash.\n * @returns The hash of the input string.\n */\nlet hashed = new Map<string, string>();\nfunction hash(data: string): string {\n if (hashed.has(data)) return hashed.get(data) as string\n const inputBytes = new TextEncoder().encode(data);\n const hashedData = nacl.hash(inputBytes);\n const d = Array.from(hashedData)\n .map(byte => byte.toString(16).padStart(2, '0'))\n .join('');\n hashed.set(data, d)\n return d\n}\n\nconst makeSecret = (secret: string) => {\n return hash(secret).substring(0, 32);\n}\n\nconst crypto = {\n encrypt,\n decrypt,\n hash,\n makeSecret\n};\n\nexport default crypto;\n"],"names":["pako","__spreadArray","__read"],"mappings":"8JAIA;;;;;AAKG;AACH,SAAS,OAAO,CAAC,IAAqB,EAAE,MAAc,EAAA;AACnD,IAAA,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI;AAC7D,IAAA,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IACtC,IAAM,GAAG,GAAG,IAAI,WAAW,EA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_modules/tslib/tslib.es6.mjs';import nacl from'tweetnacl';import base64 from'./base64.mjs';import pako from'./pako.mjs';/**
2
+ * Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.
3
+ * @param data - The plaintext data to encrypt.
4
+ * @param secret - The secret key as a string.
5
+ * @returns A Base64 encoded string (nonce + compressed ciphertext).
6
+ */
7
+ function encrypt(data, secret) {
8
+ data = typeof data === "object" ? JSON.stringify(data) : data;
9
+ secret = hash(secret).substring(0, 32);
10
+ var key = new TextEncoder().encode(secret);
11
+ var nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
12
+ var compressed = pako.compress(data, true); // Ensure it returns Uint8Array
13
+ var encrypted = nacl.secretbox(compressed, nonce, key);
14
+ return base64.encode(new Uint8Array(__spreadArray(__spreadArray([], __read(nonce), false), __read(encrypted), false)));
15
+ }
16
+ /**
17
+ * Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).
18
+ * @param data - The Base64 encoded string (nonce + compressed ciphertext).
19
+ * @param secret - The secret key as a string.
20
+ * @returns The decrypted plaintext string.
21
+ */
22
+ function decrypt(data, secret) {
23
+ try {
24
+ secret = hash(secret).substring(0, 32);
25
+ var key = new TextEncoder().encode(secret);
26
+ var encryptedBytes = base64.decode(data);
27
+ var nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);
28
+ var ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);
29
+ var decrypted = nacl.secretbox.open(ciphertext, nonce, key);
30
+ if (!decrypted)
31
+ throw new Error("Decryption failed!");
32
+ var decompressed = pako.decompress(decrypted); // Decompress as string
33
+ try {
34
+ return JSON.parse(decompressed);
35
+ }
36
+ catch (error) {
37
+ return decompressed;
38
+ }
39
+ }
40
+ catch (error) {
41
+ throw new Error("Invalid encrypted data.");
42
+ }
43
+ }
44
+ /**
45
+ * Hashes a string using NaCl's hash function.
46
+ * @param data - The input string to hash.
47
+ * @returns The hash of the input string.
48
+ */
49
+ var hashed = new Map();
50
+ function hash(data) {
51
+ if (hashed.has(data))
52
+ return hashed.get(data);
53
+ var inputBytes = new TextEncoder().encode(data);
54
+ var hashedData = nacl.hash(inputBytes);
55
+ var d = Array.from(hashedData)
56
+ .map(function (byte) { return byte.toString(16).padStart(2, '0'); })
57
+ .join('');
58
+ hashed.set(data, d);
59
+ return d;
60
+ }
61
+ var makeSecret = function (secret) {
62
+ return hash(secret).substring(0, 32);
63
+ };
64
+ var crypto = {
65
+ encrypt: encrypt,
66
+ decrypt: decrypt,
67
+ hash: hash,
68
+ makeSecret: makeSecret
69
+ };export{crypto as default};//# sourceMappingURL=crypto.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.mjs","sources":["../../../src/include/lib/crypto.ts"],"sourcesContent":["import nacl from \"tweetnacl\";\nimport base64 from \"./base64\";\nimport pako from \"./pako\";\n\n/**\n * Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.\n * @param data - The plaintext data to encrypt.\n * @param secret - The secret key as a string.\n * @returns A Base64 encoded string (nonce + compressed ciphertext).\n */\nfunction encrypt(data: string | object, secret: string): string {\n data = typeof data === \"object\" ? JSON.stringify(data) : data\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);\n const compressed = pako.compress(data, true) as Uint8Array // Ensure it returns Uint8Array\n const encrypted = nacl.secretbox(compressed, nonce, key);\n return base64.encode(new Uint8Array([...nonce, ...encrypted]));\n}\n\n/**\n * Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).\n * @param data - The Base64 encoded string (nonce + compressed ciphertext).\n * @param secret - The secret key as a string.\n * @returns The decrypted plaintext string.\n */\nfunction decrypt(data: string, secret: string): string {\n try {\n secret = hash(secret).substring(0, 32)\n const key = new TextEncoder().encode(secret);\n const encryptedBytes = base64.decode(data);\n const nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);\n const ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);\n const decrypted = nacl.secretbox.open(ciphertext, nonce, key);\n if (!decrypted) throw new Error(\"Decryption failed!\");\n const decompressed = pako.decompress(decrypted); // Decompress as string\n try {\n return JSON.parse(decompressed);\n } catch (error) {\n return decompressed;\n }\n } catch (error) {\n throw new Error(\"Invalid encrypted data.\");\n }\n}\n\n/**\n * Hashes a string using NaCl's hash function.\n * @param data - The input string to hash.\n * @returns The hash of the input string.\n */\nlet hashed = new Map<string, string>();\nfunction hash(data: string): string {\n if (hashed.has(data)) return hashed.get(data) as string\n const inputBytes = new TextEncoder().encode(data);\n const hashedData = nacl.hash(inputBytes);\n const d = Array.from(hashedData)\n .map(byte => byte.toString(16).padStart(2, '0'))\n .join('');\n hashed.set(data, d)\n return d\n}\n\nconst makeSecret = (secret: string) => {\n return hash(secret).substring(0, 32);\n}\n\nconst crypto = {\n encrypt,\n decrypt,\n hash,\n makeSecret\n};\n\nexport default crypto;\n"],"names":[],"mappings":"oKAIA;;;;;AAKG;AACH,SAAS,OAAO,CAAC,IAAqB,EAAE,MAAc,EAAA;AACnD,IAAA,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI;AAC7D,IAAA,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IACtC,IAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AAC5C,IAAA,IAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;AAC1D,IAAA,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAe,CAAA;AAC1D,IAAA,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC;AACxD,IAAA,OAAO,MAAM,CAAC,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,EAAA;AACvB,IAAA,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAW;IACvD,IAAM,UAAU,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IACjD,IAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;AACxC,IAAA,IAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU;SAC3B,GAAG,CAAC,UAAA,IAAI,EAAA,EAAI,OAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,EAAA;SAC9C,IAAI,CAAC,EAAE,CAAC;AACZ,IAAA,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACnB,IAAA,OAAO,CAAC;AACX;AAEA,IAAM,UAAU,GAAG,UAAC,MAAc,EAAA;IAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACvC,CAAC;AAED,IAAM,MAAM,GAAG;AACZ,IAAA,OAAO,EAAA,OAAA;AACP,IAAA,OAAO,EAAA,OAAA;AACP,IAAA,IAAI,EAAA,IAAA;AACJ,IAAA,UAAU,EAAA;"}
@@ -1,2 +1,28 @@
1
- import n from"pako";import t from"./base64";function c(e,r){const s=new TextEncoder().encode(e),o=n.gzip(s);return r?o:t.encode(o)}function i(e){typeof e=="string"&&(e=t.decode(e));const r=n.ungzip(e);return new TextDecoder().decode(r)}var f={compress:c,decompress:i};export{c as compress,i as decompress,f as default};
2
- //# sourceMappingURL=pako.js.map
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pako$1=require('pako'),base64=require('./base64.js');/**
2
+ * Compresses a string message using Pako (Gzip).
3
+ * @param message - The plaintext string message to compress.
4
+ * @returns A Base64 encoded string of the compressed data.
5
+ */
6
+ function compress(data, returnUnit8) {
7
+ var encoded = new TextEncoder().encode(data);
8
+ var compressed = pako$1.gzip(encoded);
9
+ if (returnUnit8)
10
+ return compressed;
11
+ return base64.encode(compressed);
12
+ }
13
+ /**
14
+ * Decompresses a Base64 encoded compressed message using Pako (Gzip).
15
+ * @param data - The Base64 encoded compressed data.
16
+ * @returns The decompressed plaintext string.
17
+ */
18
+ function decompress(data) {
19
+ if (typeof data === 'string') {
20
+ data = base64.decode(data);
21
+ }
22
+ var decompressed = pako$1.ungzip(data);
23
+ return new TextDecoder().decode(decompressed);
24
+ }
25
+ var pako = {
26
+ compress: compress,
27
+ decompress: decompress
28
+ };exports.compress=compress;exports.decompress=decompress;exports.default=pako;//# sourceMappingURL=pako.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/include/lib/pako.ts"],
4
- "sourcesContent": ["import pako from \"pako\";\nimport base64 from \"./base64\";\n\n/**\n * Compresses a string message using Pako (Gzip).\n * @param message - The plaintext string message to compress.\n * @returns A Base64 encoded string of the compressed data.\n */\nexport function compress(data: string, returnUnit8?: boolean): string | Uint8Array {\n const encoded = new TextEncoder().encode(data);\n const compressed = pako.gzip(encoded);\n if (returnUnit8) return compressed;\n return base64.encode(compressed);\n}\n\n/**\n * Decompresses a Base64 encoded compressed message using Pako (Gzip).\n * @param data - The Base64 encoded compressed data.\n * @returns The decompressed plaintext string.\n */\nexport function decompress(data: string | Uint8Array): string {\n if (typeof data === 'string') {\n data = base64.decode(data);\n }\n const decompressed = pako.ungzip(data);\n return new TextDecoder().decode(decompressed);\n}\n\nexport default {\n compress,\n decompress\n}"],
5
- "mappings": "AAAA,OAAOA,MAAU,OACjB,OAAOC,MAAY,WAOZ,SAASC,EAASC,EAAcC,EAA4C,CAChF,MAAMC,EAAU,IAAI,YAAY,EAAE,OAAOF,CAAI,EACvCG,EAAaN,EAAK,KAAKK,CAAO,EACpC,OAAID,EAAoBE,EACjBL,EAAO,OAAOK,CAAU,CAClC,CAOO,SAASC,EAAWJ,EAAmC,CACvD,OAAOA,GAAS,WACjBA,EAAOF,EAAO,OAAOE,CAAI,GAE5B,MAAMK,EAAeR,EAAK,OAAOG,CAAI,EACrC,OAAO,IAAI,YAAY,EAAE,OAAOK,CAAY,CAC/C,CAEA,IAAOC,EAAQ,CACZ,SAAAP,EACA,WAAAK,CACH",
6
- "names": ["pako", "base64", "compress", "data", "returnUnit8", "encoded", "compressed", "decompress", "decompressed", "pako_default"]
7
- }
1
+ {"version":3,"file":"pako.js","sources":["../../../src/include/lib/pako.ts"],"sourcesContent":["import pako from \"pako\";\nimport base64 from \"./base64\";\n\n/**\n * Compresses a string message using Pako (Gzip).\n * @param message - The plaintext string message to compress.\n * @returns A Base64 encoded string of the compressed data.\n */\nexport function compress(data: string, returnUnit8?: boolean): string | Uint8Array {\n const encoded = new TextEncoder().encode(data);\n const compressed = pako.gzip(encoded);\n if (returnUnit8) return compressed;\n return base64.encode(compressed);\n}\n\n/**\n * Decompresses a Base64 encoded compressed message using Pako (Gzip).\n * @param data - The Base64 encoded compressed data.\n * @returns The decompressed plaintext string.\n */\nexport function decompress(data: string | Uint8Array): string {\n if (typeof data === 'string') {\n data = base64.decode(data);\n }\n const decompressed = pako.ungzip(data);\n return new TextDecoder().decode(decompressed);\n}\n\nexport default {\n compress,\n decompress\n}"],"names":["pako"],"mappings":"+HAGA;;;;AAIG;AACa,SAAA,QAAQ,CAAC,IAAY,EAAE,WAAqB,EAAA;IACzD,IAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9C,IAAM,UAAU,GAAGA,MAAI,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC,IAAA,IAAI,WAAW;AAAE,QAAA,OAAO,UAAU;AAClC,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;AACnC;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,IAAyB,EAAA;AACjD,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC3B,QAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AAC5B;IACD,IAAM,YAAY,GAAGA,MAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACtC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;AAChD;AAEA,WAAe;AACZ,IAAA,QAAQ,EAAA,QAAA;AACR,IAAA,UAAU,EAAA;CACZ"}
@@ -0,0 +1,28 @@
1
+ import pako$1 from'pako';import base64 from'./base64.mjs';/**
2
+ * Compresses a string message using Pako (Gzip).
3
+ * @param message - The plaintext string message to compress.
4
+ * @returns A Base64 encoded string of the compressed data.
5
+ */
6
+ function compress(data, returnUnit8) {
7
+ var encoded = new TextEncoder().encode(data);
8
+ var compressed = pako$1.gzip(encoded);
9
+ if (returnUnit8)
10
+ return compressed;
11
+ return base64.encode(compressed);
12
+ }
13
+ /**
14
+ * Decompresses a Base64 encoded compressed message using Pako (Gzip).
15
+ * @param data - The Base64 encoded compressed data.
16
+ * @returns The decompressed plaintext string.
17
+ */
18
+ function decompress(data) {
19
+ if (typeof data === 'string') {
20
+ data = base64.decode(data);
21
+ }
22
+ var decompressed = pako$1.ungzip(data);
23
+ return new TextDecoder().decode(decompressed);
24
+ }
25
+ var pako = {
26
+ compress: compress,
27
+ decompress: decompress
28
+ };export{compress,decompress,pako as default};//# sourceMappingURL=pako.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pako.mjs","sources":["../../../src/include/lib/pako.ts"],"sourcesContent":["import pako from \"pako\";\nimport base64 from \"./base64\";\n\n/**\n * Compresses a string message using Pako (Gzip).\n * @param message - The plaintext string message to compress.\n * @returns A Base64 encoded string of the compressed data.\n */\nexport function compress(data: string, returnUnit8?: boolean): string | Uint8Array {\n const encoded = new TextEncoder().encode(data);\n const compressed = pako.gzip(encoded);\n if (returnUnit8) return compressed;\n return base64.encode(compressed);\n}\n\n/**\n * Decompresses a Base64 encoded compressed message using Pako (Gzip).\n * @param data - The Base64 encoded compressed data.\n * @returns The decompressed plaintext string.\n */\nexport function decompress(data: string | Uint8Array): string {\n if (typeof data === 'string') {\n data = base64.decode(data);\n }\n const decompressed = pako.ungzip(data);\n return new TextDecoder().decode(decompressed);\n}\n\nexport default {\n compress,\n decompress\n}"],"names":["pako"],"mappings":"0DAGA;;;;AAIG;AACa,SAAA,QAAQ,CAAC,IAAY,EAAE,WAAqB,EAAA;IACzD,IAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9C,IAAM,UAAU,GAAGA,MAAI,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC,IAAA,IAAI,WAAW;AAAE,QAAA,OAAO,UAAU;AAClC,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;AACnC;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,IAAyB,EAAA;AACjD,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC3B,QAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AAC5B;IACD,IAAM,YAAY,GAAGA,MAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACtC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;AAChD;AAEA,WAAe;AACZ,IAAA,QAAQ,EAAA,QAAA;AACR,IAAA,UAAU,EAAA;CACZ"}
@@ -1,2 +1,25 @@
1
- const n={},e="ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let t=0;t<e.length;t++)n[e[t]]=e[(t+1)%e.length],n[e[t].toLowerCase()]=e[(t+1)%e.length].toLowerCase();let o="?.,!@#$%^&*()_+-=[]{}|;:<>/";for(let t=0;t<o.length;t++)n[o[t]]=o[t];const i=t=>t.split("").map(r=>n[r]||r).join(""),l=t=>t.split("").map(r=>{for(let s in n)if(n[s]===r)return s;return r}).join("");var a={encrypt:i,decrypt:l};export{a as default};
2
- //# sourceMappingURL=reverser.js.map
1
+ 'use strict';var substitutionPattern = {};
2
+ var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
3
+ for (var i = 0; i < alphabet.length; i++) {
4
+ substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];
5
+ substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();
6
+ }
7
+ var speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';
8
+ for (var i = 0; i < speacialCharters.length; i++) {
9
+ substitutionPattern[speacialCharters[i]] = speacialCharters[i];
10
+ }
11
+ var encrypt = function (text) { return text.split('').map(function (char) { return substitutionPattern[char] || char; }).join(''); };
12
+ var decrypt = function (text) {
13
+ return text.split('').map(function (char) {
14
+ for (var key in substitutionPattern) {
15
+ if (substitutionPattern[key] === char) {
16
+ return key;
17
+ }
18
+ }
19
+ return char;
20
+ }).join('');
21
+ };
22
+ var reverser = {
23
+ encrypt: encrypt,
24
+ decrypt: decrypt
25
+ };module.exports=reverser;//# sourceMappingURL=reverser.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/include/lib/reverser.ts"],
4
- "sourcesContent": ["const substitutionPattern: any = {};\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nfor (let i = 0; i < alphabet.length; i++) {\n substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];\n substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();\n}\n\nlet speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';\nfor (let i = 0; i < speacialCharters.length; i++) {\n substitutionPattern[speacialCharters[i]] = speacialCharters[i];\n}\n\nconst encrypt = (text: string) => text.split('').map((char) => substitutionPattern[char] || char).join('')\nconst decrypt = (text: string) => {\n return text.split('').map((char) => {\n for (let key in substitutionPattern) {\n if (substitutionPattern[key] === char) {\n return key;\n }\n }\n return char;\n }).join('');\n}\n\nexport default {\n encrypt,\n decrypt\n}"],
5
- "mappings": "AAAA,MAAMA,EAA2B,CAAC,EAC5BC,EAAW,6BACjB,QAASC,EAAI,EAAGA,EAAID,EAAS,OAAQC,IAClCF,EAAoBC,EAASC,CAAC,CAAC,EAAID,GAAUC,EAAI,GAAKD,EAAS,MAAM,EACrED,EAAoBC,EAASC,CAAC,EAAE,YAAY,CAAC,EAAID,GAAUC,EAAI,GAAKD,EAAS,MAAM,EAAE,YAAY,EAGpG,IAAIE,EAAmB,8BACvB,QAASD,EAAI,EAAGA,EAAIC,EAAiB,OAAQD,IAC1CF,EAAoBG,EAAiBD,CAAC,CAAC,EAAIC,EAAiBD,CAAC,EAGhE,MAAME,EAAWC,GAAiBA,EAAK,MAAM,EAAE,EAAE,IAAKC,GAASN,EAAoBM,CAAI,GAAKA,CAAI,EAAE,KAAK,EAAE,EACnGC,EAAWF,GACPA,EAAK,MAAM,EAAE,EAAE,IAAKC,GAAS,CACjC,QAASE,KAAOR,EACb,GAAIA,EAAoBQ,CAAG,IAAMF,EAC9B,OAAOE,EAGb,OAAOF,CACV,CAAC,EAAE,KAAK,EAAE,EAGb,IAAOG,EAAQ,CACZ,QAAAL,EACA,QAAAG,CACH",
6
- "names": ["substitutionPattern", "alphabet", "i", "speacialCharters", "encrypt", "text", "char", "decrypt", "key", "reverser_default"]
7
- }
1
+ {"version":3,"file":"reverser.js","sources":["../../../src/include/lib/reverser.ts"],"sourcesContent":["const substitutionPattern: any = {};\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nfor (let i = 0; i < alphabet.length; i++) {\n substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];\n substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();\n}\n\nlet speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';\nfor (let i = 0; i < speacialCharters.length; i++) {\n substitutionPattern[speacialCharters[i]] = speacialCharters[i];\n}\n\nconst encrypt = (text: string) => text.split('').map((char) => substitutionPattern[char] || char).join('')\nconst decrypt = (text: string) => {\n return text.split('').map((char) => {\n for (let key in substitutionPattern) {\n if (substitutionPattern[key] === char) {\n return key;\n }\n }\n return char;\n }).join('');\n}\n\nexport default {\n encrypt,\n decrypt\n}"],"names":[],"mappings":"aAAA,IAAM,mBAAmB,GAAQ,EAAE;AACnC,IAAM,QAAQ,GAAG,4BAA4B;AAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,IAAA,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;IACtE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;AACpG;AAED,IAAI,gBAAgB,GAAG,6BAA6B;AACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IAC/C,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;AAChE;AAED,IAAM,OAAO,GAAG,UAAC,IAAY,IAAK,OAAA,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,OAAA,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAjC,EAAiC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,EAAA;AAC1G,IAAM,OAAO,GAAG,UAAC,IAAY,EAAA;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAA;AAC5B,QAAA,KAAK,IAAI,GAAG,IAAI,mBAAmB,EAAE;AAClC,YAAA,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AACpC,gBAAA,OAAO,GAAG;AACZ;AACH;AACD,QAAA,OAAO,IAAI;AACd,KAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACd,CAAC;AAED,eAAe;AACZ,IAAA,OAAO,EAAA,OAAA;AACP,IAAA,OAAO,EAAA;CACT"}
@@ -0,0 +1,25 @@
1
+ var substitutionPattern = {};
2
+ var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
3
+ for (var i = 0; i < alphabet.length; i++) {
4
+ substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];
5
+ substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();
6
+ }
7
+ var speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';
8
+ for (var i = 0; i < speacialCharters.length; i++) {
9
+ substitutionPattern[speacialCharters[i]] = speacialCharters[i];
10
+ }
11
+ var encrypt = function (text) { return text.split('').map(function (char) { return substitutionPattern[char] || char; }).join(''); };
12
+ var decrypt = function (text) {
13
+ return text.split('').map(function (char) {
14
+ for (var key in substitutionPattern) {
15
+ if (substitutionPattern[key] === char) {
16
+ return key;
17
+ }
18
+ }
19
+ return char;
20
+ }).join('');
21
+ };
22
+ var reverser = {
23
+ encrypt: encrypt,
24
+ decrypt: decrypt
25
+ };export{reverser as default};//# sourceMappingURL=reverser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverser.mjs","sources":["../../../src/include/lib/reverser.ts"],"sourcesContent":["const substitutionPattern: any = {};\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nfor (let i = 0; i < alphabet.length; i++) {\n substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];\n substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();\n}\n\nlet speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';\nfor (let i = 0; i < speacialCharters.length; i++) {\n substitutionPattern[speacialCharters[i]] = speacialCharters[i];\n}\n\nconst encrypt = (text: string) => text.split('').map((char) => substitutionPattern[char] || char).join('')\nconst decrypt = (text: string) => {\n return text.split('').map((char) => {\n for (let key in substitutionPattern) {\n if (substitutionPattern[key] === char) {\n return key;\n }\n }\n return char;\n }).join('');\n}\n\nexport default {\n encrypt,\n decrypt\n}"],"names":[],"mappings":"AAAA,IAAM,mBAAmB,GAAQ,EAAE;AACnC,IAAM,QAAQ,GAAG,4BAA4B;AAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,IAAA,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;IACtE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;AACpG;AAED,IAAI,gBAAgB,GAAG,6BAA6B;AACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IAC/C,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;AAChE;AAED,IAAM,OAAO,GAAG,UAAC,IAAY,IAAK,OAAA,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,OAAA,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAjC,EAAiC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,EAAA;AAC1G,IAAM,OAAO,GAAG,UAAC,IAAY,EAAA;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAA;AAC5B,QAAA,KAAK,IAAI,GAAG,IAAI,mBAAmB,EAAE;AAClC,YAAA,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AACpC,gBAAA,OAAO,GAAG;AACZ;AACH;AACD,QAAA,OAAO,IAAI;AACd,KAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACd,CAAC;AAED,eAAe;AACZ,IAAA,OAAO,EAAA,OAAA;AACP,IAAA,OAAO,EAAA;CACT"}
@@ -1,2 +1,10 @@
1
- import r from"./reverser";function t(e){return encodeURIComponent(r.encrypt(e.toLowerCase()))}function n(e){return r.decrypt(decodeURIComponent(e))}var c={encrypt:t,decrypt:n};export{c as default};
2
- //# sourceMappingURL=urlpath.js.map
1
+ 'use strict';var reverser=require('./reverser.js');function encrypt(input) {
2
+ return encodeURIComponent(reverser.encrypt(input.toLowerCase()));
3
+ }
4
+ function decrypt(encryptedString) {
5
+ return reverser.decrypt(decodeURIComponent(encryptedString));
6
+ }
7
+ var urlpath = {
8
+ encrypt: encrypt,
9
+ decrypt: decrypt
10
+ };module.exports=urlpath;//# sourceMappingURL=urlpath.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/include/lib/urlpath.ts"],
4
- "sourcesContent": ["import reverser from \"./reverser\"\n\nfunction encrypt(input: string): string {\n return encodeURIComponent(reverser.encrypt(input.toLowerCase()))\n}\n\nfunction decrypt(encryptedString: string): string {\n return reverser.decrypt(decodeURIComponent(encryptedString))\n}\n\nexport default {\n encrypt,\n decrypt\n}"],
5
- "mappings": "AAAA,OAAOA,MAAc,aAErB,SAASC,EAAQC,EAAuB,CACrC,OAAO,mBAAmBF,EAAS,QAAQE,EAAM,YAAY,CAAC,CAAC,CAClE,CAEA,SAASC,EAAQC,EAAiC,CAC/C,OAAOJ,EAAS,QAAQ,mBAAmBI,CAAe,CAAC,CAC9D,CAEA,IAAOC,EAAQ,CACZ,QAAAJ,EACA,QAAAE,CACH",
6
- "names": ["reverser", "encrypt", "input", "decrypt", "encryptedString", "urlpath_default"]
7
- }
1
+ {"version":3,"file":"urlpath.js","sources":["../../../src/include/lib/urlpath.ts"],"sourcesContent":["import reverser from \"./reverser\"\n\nfunction encrypt(input: string): string {\n return encodeURIComponent(reverser.encrypt(input.toLowerCase()))\n}\n\nfunction decrypt(encryptedString: string): string {\n return reverser.decrypt(decodeURIComponent(encryptedString))\n}\n\nexport default {\n encrypt,\n decrypt\n}"],"names":[],"mappings":"mDAEA,SAAS,OAAO,CAAC,KAAa,EAAA;AAC3B,IAAA,OAAO,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACnE;AAEA,SAAS,OAAO,CAAC,eAAuB,EAAA;IACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAC/D;AAEA,cAAe;AACZ,IAAA,OAAO,EAAA,OAAA;AACP,IAAA,OAAO,EAAA;CACT"}