securequ 1.0.10 → 1.0.12
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/client/index.d.ts +25 -0
- package/client/index.js +107 -173
- package/client/index.js.map +1 -1
- package/client/index.mjs +107 -173
- package/client/index.mjs.map +1 -1
- package/client/types.d.ts +17 -0
- package/include/lib/base64.js +12 -12
- package/include/lib/base64.js.map +1 -1
- package/include/lib/base64.mjs +12 -12
- package/include/lib/base64.mjs.map +1 -1
- package/include/lib/cache.js +20 -22
- package/include/lib/cache.js.map +1 -1
- package/include/lib/cache.mjs +20 -22
- package/include/lib/cache.mjs.map +1 -1
- package/include/lib/crypto.js +23 -23
- package/include/lib/crypto.js.map +1 -1
- package/include/lib/crypto.mjs +23 -23
- package/include/lib/crypto.mjs.map +1 -1
- package/include/lib/pako.js +5 -5
- package/include/lib/pako.js.map +1 -1
- package/include/lib/pako.mjs +5 -5
- package/include/lib/pako.mjs.map +1 -1
- package/include/lib/reverser.js +11 -11
- package/include/lib/reverser.js.map +1 -1
- package/include/lib/reverser.mjs +11 -11
- package/include/lib/reverser.mjs.map +1 -1
- package/include/lib/urlpath.js +2 -2
- package/include/lib/urlpath.js.map +1 -1
- package/include/lib/urlpath.mjs +2 -2
- package/include/lib/urlpath.mjs.map +1 -1
- package/include/responseValue.js +4 -4
- package/include/responseValue.js.map +1 -1
- package/include/responseValue.mjs +4 -4
- package/include/responseValue.mjs.map +1 -1
- package/include/signeture.js +12 -12
- package/include/signeture.js.map +1 -1
- package/include/signeture.mjs +12 -12
- package/include/signeture.mjs.map +1 -1
- package/index.d.ts +2 -81
- package/package.json +6 -11
- package/server/index.d.ts +18 -0
- package/server/index.js +105 -176
- package/server/index.js.map +1 -1
- package/server/index.mjs +105 -176
- package/server/index.mjs.map +1 -1
- package/server/types.d.ts +28 -0
package/include/lib/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,MAAM,aAAa,CAAA;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AAE,GAAG,KAAK,CAAC,SAAS,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvB,YAAA,OAAO,IAAI;AACb,QAAA;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC;QAC1B,OAAO,KAAK,CAAC,KAAK;IACrB;AAEA;;;AAGG;AACH,IAAA,MAAM,CAAC,GAAW,EAAA;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AACjC,QAAA,IAAI,KAAK,EAAE;AACR,YAAA,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACzB,QAAA;IACJ;AAEA;;AAEG;IACH,KAAK,GAAA;AACF,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB;AAEA;;;AAGG;IACH,IAAI,GAAA;AACD,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;IACzB;AACF"}
|
package/include/lib/cache.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
class SecurequCache {
|
|
2
|
+
constructor(config) {
|
|
3
3
|
this.store = new Map();
|
|
4
4
|
this.defaultTTL = config.ttl;
|
|
5
5
|
this.limit = config.limit;
|
|
@@ -9,11 +9,10 @@ var SecurequCache = /** @class */ (function () {
|
|
|
9
9
|
* @param key - Cache key
|
|
10
10
|
* @param value - Cache value
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
var _this = this;
|
|
12
|
+
set(key, value) {
|
|
14
13
|
// If the cache exceeds the limit, remove the oldest (least recently used) item
|
|
15
14
|
if (this.store.size >= this.limit) {
|
|
16
|
-
|
|
15
|
+
const firstKey = this.store.keys().next().value;
|
|
17
16
|
this.store.delete(firstKey);
|
|
18
17
|
}
|
|
19
18
|
// If the key already exists, remove the old timeout
|
|
@@ -21,19 +20,19 @@ var SecurequCache = /** @class */ (function () {
|
|
|
21
20
|
clearTimeout(this.store.get(key).timeout);
|
|
22
21
|
}
|
|
23
22
|
// Set the new expiration timeout
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const timeout = setTimeout(() => {
|
|
24
|
+
this.store.delete(key); // Delete expired cache entry
|
|
26
25
|
}, this.defaultTTL);
|
|
27
26
|
// Store the value and its expiration info
|
|
28
|
-
this.store.set(key, { value
|
|
29
|
-
}
|
|
27
|
+
this.store.set(key, { value, timeout, expiresAt: Date.now() + this.defaultTTL });
|
|
28
|
+
}
|
|
30
29
|
/**
|
|
31
30
|
* Get a value from the cache and auto-renew the TTL if not expired
|
|
32
31
|
* @param key - Cache key
|
|
33
32
|
* @returns The cached value or null if expired
|
|
34
33
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
get(key) {
|
|
35
|
+
const entry = this.store.get(key);
|
|
37
36
|
if (!entry) {
|
|
38
37
|
return null; // No data found in cache
|
|
39
38
|
}
|
|
@@ -44,31 +43,30 @@ var SecurequCache = /** @class */ (function () {
|
|
|
44
43
|
}
|
|
45
44
|
this.set(key, entry.value);
|
|
46
45
|
return entry.value;
|
|
47
|
-
}
|
|
46
|
+
}
|
|
48
47
|
/**
|
|
49
48
|
* Delete a key from the cache
|
|
50
49
|
* @param key - Cache key
|
|
51
50
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
delete(key) {
|
|
52
|
+
const entry = this.store.get(key);
|
|
54
53
|
if (entry) {
|
|
55
54
|
clearTimeout(entry.timeout); // Clear the timeout
|
|
56
55
|
this.store.delete(key); // Delete from cache
|
|
57
56
|
}
|
|
58
|
-
}
|
|
57
|
+
}
|
|
59
58
|
/**
|
|
60
59
|
* Clear the entire cache
|
|
61
60
|
*/
|
|
62
|
-
|
|
63
|
-
this.store.forEach(
|
|
61
|
+
clear() {
|
|
62
|
+
this.store.forEach((entry) => clearTimeout(entry.timeout)); // Clear all timeouts
|
|
64
63
|
this.store.clear(); // Clear the store
|
|
65
|
-
}
|
|
64
|
+
}
|
|
66
65
|
/**
|
|
67
66
|
* Get the current size of the cache
|
|
68
67
|
* @returns The number of items in the cache
|
|
69
68
|
*/
|
|
70
|
-
|
|
69
|
+
size() {
|
|
71
70
|
return this.store.size;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}());export{SecurequCache as default};//# sourceMappingURL=cache.mjs.map
|
|
71
|
+
}
|
|
72
|
+
}export{SecurequCache as default};//# sourceMappingURL=cache.mjs.map
|
|
@@ -1 +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,
|
|
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,MAAM,aAAa,CAAA;AAKhB,IAAA,WAAA,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;IAC5B;AAEA;;;;AAIG;IACH,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAA;;QAEtB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;AAChC,YAAA,MAAM,QAAQ,GAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK;AACpD,YAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAA;;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,QAAA;;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K,CAAC,KAAK,EAAE,CAAC;IACtB;AAEA;;;AAGG;IACH,IAAI,GAAA;AACD,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;IACzB;AACF"}
|
package/include/lib/crypto.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var nacl=require('tweetnacl'),base64=require('./base64.js'),pako=require('./pako.js');/**
|
|
2
2
|
* Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.
|
|
3
3
|
* @param data - The plaintext data to encrypt.
|
|
4
4
|
* @param secret - The secret key as a string.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
function encrypt(data, secret) {
|
|
8
8
|
data = typeof data === "object" ? JSON.stringify(data) : data;
|
|
9
9
|
secret = hash(secret).substring(0, 32);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return base64.encode(new Uint8Array(
|
|
10
|
+
const key = new TextEncoder().encode(secret);
|
|
11
|
+
const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
|
|
12
|
+
const compressed = pako.default.compress(data, true); // Ensure it returns Uint8Array
|
|
13
|
+
const encrypted = nacl.secretbox(compressed, nonce, key);
|
|
14
|
+
return base64.encode(new Uint8Array([...nonce, ...encrypted]));
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).
|
|
@@ -22,14 +22,14 @@ function encrypt(data, secret) {
|
|
|
22
22
|
function decrypt(data, secret) {
|
|
23
23
|
try {
|
|
24
24
|
secret = hash(secret).substring(0, 32);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const key = new TextEncoder().encode(secret);
|
|
26
|
+
const encryptedBytes = base64.decode(data);
|
|
27
|
+
const nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);
|
|
28
|
+
const ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);
|
|
29
|
+
const decrypted = nacl.secretbox.open(ciphertext, nonce, key);
|
|
30
30
|
if (!decrypted)
|
|
31
31
|
throw new Error("Decryption failed!");
|
|
32
|
-
|
|
32
|
+
const decompressed = pako.default.decompress(decrypted); // Decompress as string
|
|
33
33
|
try {
|
|
34
34
|
return JSON.parse(decompressed);
|
|
35
35
|
}
|
|
@@ -46,24 +46,24 @@ function decrypt(data, secret) {
|
|
|
46
46
|
* @param data - The input string to hash.
|
|
47
47
|
* @returns The hash of the input string.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
let hashed = new Map();
|
|
50
50
|
function hash(data) {
|
|
51
51
|
if (hashed.has(data))
|
|
52
52
|
return hashed.get(data);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.map(
|
|
53
|
+
const inputBytes = new TextEncoder().encode(data);
|
|
54
|
+
const hashedData = nacl.hash(inputBytes);
|
|
55
|
+
const d = Array.from(hashedData)
|
|
56
|
+
.map(byte => byte.toString(16).padStart(2, '0'))
|
|
57
57
|
.join('');
|
|
58
58
|
hashed.set(data, d);
|
|
59
59
|
return d;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const makeSecret = (secret) => {
|
|
62
62
|
return hash(secret).substring(0, 32);
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
encrypt
|
|
66
|
-
decrypt
|
|
67
|
-
hash
|
|
68
|
-
makeSecret
|
|
64
|
+
const crypto = {
|
|
65
|
+
encrypt,
|
|
66
|
+
decrypt,
|
|
67
|
+
hash,
|
|
68
|
+
makeSecret
|
|
69
69
|
};module.exports=crypto;//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +1 @@
|
|
|
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"
|
|
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"],"mappings":"mGAIA;;;;;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,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AAC5C,IAAA,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;AAC1D,IAAA,MAAM,UAAU,GAAGA,YAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAe,CAAA;AAC1D,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC;AACxD,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AACjE;AAEA;;;;;AAKG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,MAAc,EAAA;IAC1C,IAAI;AACD,QAAA,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAC5C,MAAM,cAAc,GAAG,MAAM,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,CAAC;SAC9C,IAAI,CAAC,EAAE,CAAC;AACZ,IAAA,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACnB,IAAA,OAAO,CAAC;AACX;AAEA,MAAM,UAAU,GAAG,CAAC,MAAc,KAAI;IACnC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,MAAM,GAAG;IACZ,OAAO;IACP,OAAO;IACP,IAAI;IACJ;"}
|
package/include/lib/crypto.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import nacl from'tweetnacl';import base64 from'./base64.mjs';import pako from'./pako.mjs';/**
|
|
2
2
|
* Encrypts data using TweetNaCl, compresses it with Pako (Gzip), and encodes it in Base64.
|
|
3
3
|
* @param data - The plaintext data to encrypt.
|
|
4
4
|
* @param secret - The secret key as a string.
|
|
@@ -7,11 +7,11 @@ import {__spreadArray,__read}from'../../node_modules/tslib/tslib.es6.mjs';import
|
|
|
7
7
|
function encrypt(data, secret) {
|
|
8
8
|
data = typeof data === "object" ? JSON.stringify(data) : data;
|
|
9
9
|
secret = hash(secret).substring(0, 32);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return base64.encode(new Uint8Array(
|
|
10
|
+
const key = new TextEncoder().encode(secret);
|
|
11
|
+
const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
|
|
12
|
+
const compressed = pako.compress(data, true); // Ensure it returns Uint8Array
|
|
13
|
+
const encrypted = nacl.secretbox(compressed, nonce, key);
|
|
14
|
+
return base64.encode(new Uint8Array([...nonce, ...encrypted]));
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Decrypts a Base64-encoded NaCl-encrypted data, decompresses it with Pako (Gzip).
|
|
@@ -22,14 +22,14 @@ function encrypt(data, secret) {
|
|
|
22
22
|
function decrypt(data, secret) {
|
|
23
23
|
try {
|
|
24
24
|
secret = hash(secret).substring(0, 32);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const key = new TextEncoder().encode(secret);
|
|
26
|
+
const encryptedBytes = base64.decode(data);
|
|
27
|
+
const nonce = encryptedBytes.slice(0, nacl.secretbox.nonceLength);
|
|
28
|
+
const ciphertext = encryptedBytes.slice(nacl.secretbox.nonceLength);
|
|
29
|
+
const decrypted = nacl.secretbox.open(ciphertext, nonce, key);
|
|
30
30
|
if (!decrypted)
|
|
31
31
|
throw new Error("Decryption failed!");
|
|
32
|
-
|
|
32
|
+
const decompressed = pako.decompress(decrypted); // Decompress as string
|
|
33
33
|
try {
|
|
34
34
|
return JSON.parse(decompressed);
|
|
35
35
|
}
|
|
@@ -46,24 +46,24 @@ function decrypt(data, secret) {
|
|
|
46
46
|
* @param data - The input string to hash.
|
|
47
47
|
* @returns The hash of the input string.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
let hashed = new Map();
|
|
50
50
|
function hash(data) {
|
|
51
51
|
if (hashed.has(data))
|
|
52
52
|
return hashed.get(data);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.map(
|
|
53
|
+
const inputBytes = new TextEncoder().encode(data);
|
|
54
|
+
const hashedData = nacl.hash(inputBytes);
|
|
55
|
+
const d = Array.from(hashedData)
|
|
56
|
+
.map(byte => byte.toString(16).padStart(2, '0'))
|
|
57
57
|
.join('');
|
|
58
58
|
hashed.set(data, d);
|
|
59
59
|
return d;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const makeSecret = (secret) => {
|
|
62
62
|
return hash(secret).substring(0, 32);
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
encrypt
|
|
66
|
-
decrypt
|
|
67
|
-
hash
|
|
68
|
-
makeSecret
|
|
64
|
+
const crypto = {
|
|
65
|
+
encrypt,
|
|
66
|
+
decrypt,
|
|
67
|
+
hash,
|
|
68
|
+
makeSecret
|
|
69
69
|
};export{crypto as default};//# sourceMappingURL=crypto.mjs.map
|
|
@@ -1 +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":"
|
|
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":"0FAIA;;;;;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,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AAC5C,IAAA,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;AAC1D,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAe,CAAA;AAC1D,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC;AACxD,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AACjE;AAEA;;;;;AAKG;AACH,SAAS,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AI,CAAC;IACjD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;AACxC,IAAA,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU;AAC3B,SAAA,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;SAC9C,IAAI,CAAC,EAAE,CAAC;AACZ,IAAA,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACnB,IAAA,OAAO,CAAC;AACX;AAEA,MAAM,UAAU,GAAG,CAAC,MAAc,KAAI;IACnC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,MAAM,GAAG;IACZ,OAAO;IACP,OAAO;IACP,IAAI;IACJ;"}
|
package/include/lib/pako.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @returns A Base64 encoded string of the compressed data.
|
|
5
5
|
*/
|
|
6
6
|
function compress(data, returnUnit8) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const encoded = new TextEncoder().encode(data);
|
|
8
|
+
const compressed = pako$1.gzip(encoded);
|
|
9
9
|
if (returnUnit8)
|
|
10
10
|
return compressed;
|
|
11
11
|
return base64.encode(compressed);
|
|
@@ -19,10 +19,10 @@ function decompress(data) {
|
|
|
19
19
|
if (typeof data === 'string') {
|
|
20
20
|
data = base64.decode(data);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const decompressed = pako$1.ungzip(data);
|
|
23
23
|
return new TextDecoder().decode(decompressed);
|
|
24
24
|
}
|
|
25
25
|
var pako = {
|
|
26
|
-
compress
|
|
27
|
-
decompress
|
|
26
|
+
compress,
|
|
27
|
+
decompress
|
|
28
28
|
};exports.compress=compress;exports.decompress=decompress;exports.default=pako;//# sourceMappingURL=pako.js.map
|
package/include/lib/pako.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AACG,SAAU,QAAQ,CAAC,IAAY,EAAE,WAAqB,EAAA;IACzD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9C,MAAM,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,IAAA;IACD,MAAM,YAAY,GAAGA,MAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACtC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;AAChD;AAEA,WAAe;IACZ,QAAQ;IACR;CACF"}
|
package/include/lib/pako.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import pako$1 from'pako';import base64 from'./base64.mjs';/**
|
|
|
4
4
|
* @returns A Base64 encoded string of the compressed data.
|
|
5
5
|
*/
|
|
6
6
|
function compress(data, returnUnit8) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const encoded = new TextEncoder().encode(data);
|
|
8
|
+
const compressed = pako$1.gzip(encoded);
|
|
9
9
|
if (returnUnit8)
|
|
10
10
|
return compressed;
|
|
11
11
|
return base64.encode(compressed);
|
|
@@ -19,10 +19,10 @@ function decompress(data) {
|
|
|
19
19
|
if (typeof data === 'string') {
|
|
20
20
|
data = base64.decode(data);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const decompressed = pako$1.ungzip(data);
|
|
23
23
|
return new TextDecoder().decode(decompressed);
|
|
24
24
|
}
|
|
25
25
|
var pako = {
|
|
26
|
-
compress
|
|
27
|
-
decompress
|
|
26
|
+
compress,
|
|
27
|
+
decompress
|
|
28
28
|
};export{compress,decompress,pako as default};//# sourceMappingURL=pako.mjs.map
|
package/include/lib/pako.mjs.map
CHANGED
|
@@ -1 +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;
|
|
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;AACG,SAAU,QAAQ,CAAC,IAAY,EAAE,WAAqB,EAAA;IACzD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9C,MAAM,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,IAAA;IACD,MAAM,YAAY,GAAGA,MAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACtC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;AAChD;AAEA,WAAe;IACZ,QAAQ;IACR;CACF"}
|
package/include/lib/reverser.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
for (
|
|
1
|
+
'use strict';const substitutionPattern = {};
|
|
2
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
3
|
+
for (let i = 0; i < alphabet.length; i++) {
|
|
4
4
|
substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];
|
|
5
5
|
substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
for (
|
|
7
|
+
let speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';
|
|
8
|
+
for (let i = 0; i < speacialCharters.length; i++) {
|
|
9
9
|
substitutionPattern[speacialCharters[i]] = speacialCharters[i];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return text.split('').map(
|
|
14
|
-
for (
|
|
11
|
+
const encrypt = (text) => text.split('').map((char) => substitutionPattern[char] || char).join('');
|
|
12
|
+
const decrypt = (text) => {
|
|
13
|
+
return text.split('').map((char) => {
|
|
14
|
+
for (let key in substitutionPattern) {
|
|
15
15
|
if (substitutionPattern[key] === char) {
|
|
16
16
|
return key;
|
|
17
17
|
}
|
|
@@ -20,6 +20,6 @@ var decrypt = function (text) {
|
|
|
20
20
|
}).join('');
|
|
21
21
|
};
|
|
22
22
|
var reverser = {
|
|
23
|
-
encrypt
|
|
24
|
-
decrypt
|
|
23
|
+
encrypt,
|
|
24
|
+
decrypt
|
|
25
25
|
};module.exports=reverser;//# sourceMappingURL=reverser.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,MAAM,mBAAmB,GAAQ,EAAE;AACnC,MAAM,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,MAAM,OAAO,GAAG,CAAC,IAAY,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1G,MAAM,OAAO,GAAG,CAAC,IAAY,KAAI;AAC9B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AAChC,QAAA,KAAK,IAAI,GAAG,IAAI,mBAAmB,EAAE;AAClC,YAAA,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AACpC,gBAAA,OAAO,GAAG;AACZ,YAAA;AACH,QAAA;AACD,QAAA,OAAO,IAAI;AACd,IAAA,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACd,CAAC;AAED,eAAe;IACZ,OAAO;IACP;CACF"}
|
package/include/lib/reverser.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
for (
|
|
1
|
+
const substitutionPattern = {};
|
|
2
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
3
|
+
for (let i = 0; i < alphabet.length; i++) {
|
|
4
4
|
substitutionPattern[alphabet[i]] = alphabet[(i + 1) % alphabet.length];
|
|
5
5
|
substitutionPattern[alphabet[i].toLowerCase()] = alphabet[(i + 1) % alphabet.length].toLowerCase();
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
for (
|
|
7
|
+
let speacialCharters = '?.,!@#$%^&*()_+-=[]{}|;:<>/';
|
|
8
|
+
for (let i = 0; i < speacialCharters.length; i++) {
|
|
9
9
|
substitutionPattern[speacialCharters[i]] = speacialCharters[i];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return text.split('').map(
|
|
14
|
-
for (
|
|
11
|
+
const encrypt = (text) => text.split('').map((char) => substitutionPattern[char] || char).join('');
|
|
12
|
+
const decrypt = (text) => {
|
|
13
|
+
return text.split('').map((char) => {
|
|
14
|
+
for (let key in substitutionPattern) {
|
|
15
15
|
if (substitutionPattern[key] === char) {
|
|
16
16
|
return key;
|
|
17
17
|
}
|
|
@@ -20,6 +20,6 @@ var decrypt = function (text) {
|
|
|
20
20
|
}).join('');
|
|
21
21
|
};
|
|
22
22
|
var reverser = {
|
|
23
|
-
encrypt
|
|
24
|
-
decrypt
|
|
23
|
+
encrypt,
|
|
24
|
+
decrypt
|
|
25
25
|
};export{reverser as default};//# sourceMappingURL=reverser.mjs.map
|
|
@@ -1 +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,
|
|
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,MAAM,mBAAmB,GAAQ,EAAE;AACnC,MAAM,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,MAAM,OAAO,GAAG,CAAC,IAAY,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1G,MAAM,OAAO,GAAG,CAAC,IAAY,KAAI;AAC9B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AAChC,QAAA,KAAK,IAAI,GAAG,IAAI,mBAAmB,EAAE;AAClC,YAAA,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AACpC,gBAAA,OAAO,GAAG;AACZ,YAAA;AACH,QAAA;AACD,QAAA,OAAO,IAAI;AACd,IAAA,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACd,CAAC;AAED,eAAe;IACZ,OAAO;IACP;CACF"}
|
package/include/lib/urlpath.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IACZ,OAAO;IACP;CACF"}
|
package/include/lib/urlpath.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlpath.mjs","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":"qCAEA,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;
|
|
1
|
+
{"version":3,"file":"urlpath.mjs","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":"qCAEA,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;IACZ,OAAO;IACP;CACF"}
|
package/include/responseValue.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict';var crypto=require('./lib/crypto.js');
|
|
1
|
+
'use strict';var crypto=require('./lib/crypto.js');const encrypt = (data, signerure) => {
|
|
2
2
|
return crypto.encrypt(data, crypto.makeSecret(signerure));
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
const decrypt = (value, signerure) => {
|
|
5
5
|
return crypto.decrypt(value, crypto.makeSecret(signerure));
|
|
6
6
|
};
|
|
7
7
|
var responseValue = {
|
|
8
|
-
encrypt
|
|
9
|
-
decrypt
|
|
8
|
+
encrypt,
|
|
9
|
+
decrypt
|
|
10
10
|
};module.exports=responseValue;//# sourceMappingURL=responseValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseValue.js","sources":["../../src/include/responseValue.ts"],"sourcesContent":["import crypto from \"./lib/crypto\";\n\nconst encrypt = (data: any, signerure: string): string => {\n return crypto.encrypt(data, crypto.makeSecret(signerure))\n}\n\nconst decrypt = (value: string, signerure: string) => {\n return crypto.decrypt(value, crypto.makeSecret(signerure))\n}\n\nexport default {\n encrypt,\n decrypt\n}"],"names":[],"mappings":"mDAEA,
|
|
1
|
+
{"version":3,"file":"responseValue.js","sources":["../../src/include/responseValue.ts"],"sourcesContent":["import crypto from \"./lib/crypto\";\n\nconst encrypt = (data: any, signerure: string): string => {\n return crypto.encrypt(data, crypto.makeSecret(signerure))\n}\n\nconst decrypt = (value: string, signerure: string) => {\n return crypto.decrypt(value, crypto.makeSecret(signerure))\n}\n\nexport default {\n encrypt,\n decrypt\n}"],"names":[],"mappings":"mDAEA,MAAM,OAAO,GAAG,CAAC,IAAS,EAAE,SAAiB,KAAY;AACtD,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,SAAiB,KAAI;AAClD,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC7D,CAAC;AAED,oBAAe;IACZ,OAAO;IACP;CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import crypto from'./lib/crypto.mjs';
|
|
1
|
+
import crypto from'./lib/crypto.mjs';const encrypt = (data, signerure) => {
|
|
2
2
|
return crypto.encrypt(data, crypto.makeSecret(signerure));
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
const decrypt = (value, signerure) => {
|
|
5
5
|
return crypto.decrypt(value, crypto.makeSecret(signerure));
|
|
6
6
|
};
|
|
7
7
|
var responseValue = {
|
|
8
|
-
encrypt
|
|
9
|
-
decrypt
|
|
8
|
+
encrypt,
|
|
9
|
+
decrypt
|
|
10
10
|
};export{responseValue as default};//# sourceMappingURL=responseValue.mjs.map
|