@qlover/fe-corekit 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- var t=function(){function t(t){this.config=t,this.plugins=[]}return t.prototype.use=function(t){this.plugins.find((function(n){return n===t||n.pluginName===t.pluginName||n.constructor===t.constructor}))&&t.onlyOne?console.warn("Plugin ".concat(t.pluginName," is already used, skip adding")):this.plugins.push(t)},t}(),n=function(t,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},n(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}"function"==typeof SuppressedError&&SuppressedError;var o,e=function(t){function n(n,r){var o=this.constructor,e=t.call(this,r instanceof Error?r.message:r||n)||this;return e.id=n,r instanceof Error&&"stack"in r&&(e.stack=r.stack),Object.setPrototypeOf(e,o.prototype),e}return r(n,t),n}(Error),i=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(e);!function(t){t.REQUEST_ERROR="REQUEST_ERROR",t.ENV_FETCH_NOT_SUPPORT="ENV_FETCH_NOT_SUPPORT",t.FETCHER_NONE="FETCHER_NONE",t.RESPONSE_NOT_OK="RESPONSE_NOT_OK",t.ABORT_ERROR="ABORT_ERROR",t.URL_NONE="URL_NONE"}(o||(o={}));export{t as Executor,e as ExecutorError,i as RequestError,o as RequestErrorID};
@@ -1 +0,0 @@
1
- !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).FeUtilsInterface={})}(this,(function(t){"use strict";var r=function(){function t(t){this.config=t,this.plugins=[]}return t.prototype.use=function(t){this.plugins.find((function(r){return r===t||r.pluginName===t.pluginName||r.constructor===t.constructor}))&&t.onlyOne?console.warn("Plugin ".concat(t.pluginName," is already used, skip adding")):this.plugins.push(t)},t}(),n=function(t,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},n(t,r)};function o(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}"function"==typeof SuppressedError&&SuppressedError;var e,i=function(t){function r(r,n){var o=this.constructor,e=t.call(this,n instanceof Error?n.message:n||r)||this;return e.id=r,n instanceof Error&&"stack"in n&&(e.stack=n.stack),Object.setPrototypeOf(e,o.prototype),e}return o(r,t),r}(Error),s=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return o(r,t),r}(i);t.RequestErrorID=void 0,(e=t.RequestErrorID||(t.RequestErrorID={})).REQUEST_ERROR="REQUEST_ERROR",e.ENV_FETCH_NOT_SUPPORT="ENV_FETCH_NOT_SUPPORT",e.FETCHER_NONE="FETCHER_NONE",e.RESPONSE_NOT_OK="RESPONSE_NOT_OK",e.ABORT_ERROR="ABORT_ERROR",e.URL_NONE="URL_NONE",t.Executor=r,t.ExecutorError=i,t.RequestError=s}));
@@ -1 +0,0 @@
1
- "use strict";var t=require("crypto"),e=require("buffer"),i=require("zlib"),n=function(){function n(t,e){void 0===e&&(e="base64"),this.encoding=e,this.ALGORITHM="aes-128-cbc",this.IV_LENGTH=16,this.KEY_LENGTH=16,this.KEY=this.validateKey(t)}return n.prototype.validateKey=function(t){var i=e.Buffer.from(t.slice(0,this.KEY_LENGTH));if(i.length!==this.KEY_LENGTH)throw new RangeError("Invalid key length. Expected ".concat(this.KEY_LENGTH," bytes, got ").concat(i.length," bytes"));return i},n.prototype.encrypt=function(e){var n=t.randomBytes(this.IV_LENGTH),r=t.createCipheriv(this.ALGORITHM,this.KEY,n),o=i.deflateSync(e),c=r.update(o,void 0,this.encoding);return c+=r.final(this.encoding),"".concat(c,":").concat(n.toString(this.encoding))},n.prototype.decrypt=function(n){var r=n.split(":"),o=r[0],c=r[1],s=t.createDecipheriv(this.ALGORITHM,this.KEY,e.Buffer.from(c,this.encoding)),a=e.Buffer.from(s.update(o,this.encoding,"binary"),"binary");return a=e.Buffer.concat([a,s.final()]),i.inflateSync(a).toString()},n}(),r=function(){function i(t,e){void 0===e&&(e="base64"),this.encoding=e,this.ALGORITHM="aes-256-cbc",this.KEY_LENGTH=32,this.KEY=this.validateKey(t)}return i.prototype.validateKey=function(t){var i=e.Buffer.from(t.slice(0,this.KEY_LENGTH));if(i.length!==this.KEY_LENGTH)throw new RangeError("Invalid key length. Expected ".concat(this.KEY_LENGTH," bytes, got ").concat(i.length," bytes"));return i},i.prototype.encrypt=function(e){var i=t.randomBytes(16),n=t.createCipheriv(this.ALGORITHM,this.KEY,i),r=n.update(e,"utf8",this.encoding);return r+=n.final(this.encoding),"".concat(r,":").concat(i.toString(this.encoding))},i.prototype.decrypt=function(i){var n=i.split(":"),r=n[0],o=n[1],c=t.createDecipheriv(this.ALGORITHM,this.KEY,e.Buffer.from(o,this.encoding)),s=c.update(r,this.encoding,"utf8");return s+=c.final("utf8")},i}();exports.StringEntrypt=r,exports.StringZlibEncrypt=n;
@@ -1,152 +0,0 @@
1
- /**
2
- * Generic interface for encryption/decryption operations
3
- * Provides a standard contract for implementing encryption strategies
4
- *
5
- * @template ValueType - Type of value to encrypt/decrypt
6
- * @template EncryptResult - Type of encrypted result
7
- *
8
- * @example
9
- * ```typescript
10
- * // String encryption implementation
11
- * class StringEncryptor implements Encryptor<string, string> {
12
- * encrypt(value: string): string {
13
- * // Encryption logic
14
- * }
15
- *
16
- * decrypt(encryptedData: string): string {
17
- * // Decryption logic
18
- * }
19
- * }
20
- * ```
21
- */
22
- interface Encryptor<ValueType, EncryptResult> {
23
- /**
24
- * Encrypts the provided value
25
- * @param value - Value to encrypt
26
- * @returns Encrypted result
27
- */
28
- encrypt(value: ValueType): EncryptResult;
29
- /**
30
- * Decrypts the encrypted data
31
- * @param encryptedData - Data to decrypt
32
- * @returns Original value
33
- */
34
- decrypt(encryptedData: EncryptResult): ValueType;
35
- }
36
-
37
- /**
38
- * String encryption implementation with Zlib compression
39
- * Combines AES encryption with data compression
40
- *
41
- * Features:
42
- * - AES-128-CBC encryption
43
- * - Zlib compression
44
- * - IV support
45
- * - Configurable encoding
46
- *
47
- * @implements {Encryptor<string, string>}
48
- *
49
- * @example
50
- * ```typescript
51
- * const encryptor = new StringZlibEncrypt('my-16-char-key!!');
52
- *
53
- * // Encrypt and compress
54
- * const encrypted = encryptor.encrypt('large text data');
55
- *
56
- * // Decrypt and decompress
57
- * const decrypted = encryptor.decrypt(encrypted);
58
- * ```
59
- */
60
- declare class StringZlibEncrypt implements Encryptor<string, string> {
61
- private readonly encoding;
62
- private ALGORITHM;
63
- private KEY;
64
- private IV_LENGTH;
65
- private KEY_LENGTH;
66
- /**
67
- * Creates a new StringZlibEncrypt instance
68
- * @param encryptionKey - Key used for encryption/decryption
69
- * @param encoding - Output encoding format
70
- * @throws {RangeError} If key length is invalid
71
- */
72
- constructor(encryptionKey: string, encoding?: globalThis.BufferEncoding);
73
- /**
74
- * Validates and processes encryption key
75
- * Ensures key meets length requirements
76
- *
77
- * @param key - Raw encryption key
78
- * @returns Validated key buffer
79
- * @throws {RangeError} If key length is invalid
80
- */
81
- private validateKey;
82
- /**
83
- * Encrypts and compresses a string value
84
- * Applies compression before encryption
85
- *
86
- * @param value - String to encrypt
87
- * @returns Encrypted and compressed string with IV
88
- */
89
- encrypt(value: string): string;
90
- /**
91
- * Decrypts and decompresses an encrypted string
92
- * Applies decryption before decompression
93
- *
94
- * @param encryptedData - Encrypted string with IV
95
- * @returns Original string
96
- */
97
- decrypt(encryptedData: string): string;
98
- }
99
-
100
- /**
101
- * Represents a string encryption utility using AES-256-CBC algorithm.
102
- *
103
- * This class provides methods to encrypt and decrypt string values securely.
104
- * It ensures that the encryption key meets the required length for AES-256.
105
- *
106
- * @example
107
- * ```typescript
108
- * const encryptor = new StringEntrypt('your-encryption-key');
109
- * const encrypted = encryptor.encrypt('your-string');
110
- * const decrypted = encryptor.decrypt(encrypted);
111
- * ```
112
- */
113
- declare class StringEntrypt implements Encryptor<string, string> {
114
- private readonly encoding;
115
- private ALGORITHM;
116
- private KEY;
117
- private KEY_LENGTH;
118
- /**
119
- * Creates a new StringEntrypt instance
120
- * @param encryptionKey - Key used for encryption/decryption
121
- * @param encoding - Output encoding format
122
- * @throws {RangeError} If key length is invalid
123
- */
124
- constructor(encryptionKey: string, encoding?: globalThis.BufferEncoding);
125
- /**
126
- * Validates and processes encryption key
127
- * Ensures key meets length requirements
128
- *
129
- * @param key - Raw encryption key
130
- * @returns Validated key buffer
131
- * @throws {RangeError} If key length is invalid
132
- */
133
- private validateKey;
134
- /**
135
- * Encrypts a string value
136
- * Uses random IV for each encryption
137
- *
138
- * @param value - String to encrypt
139
- * @returns Encrypted string with IV
140
- */
141
- encrypt(value: string): string;
142
- /**
143
- * Decrypts an encrypted string
144
- * Extracts IV from encrypted data
145
- *
146
- * @param encryptedData - Encrypted string with IV
147
- * @returns Original string
148
- */
149
- decrypt(encryptedData: string): string;
150
- }
151
-
152
- export { StringEntrypt, StringZlibEncrypt };
@@ -1 +0,0 @@
1
- import t from"crypto";import{Buffer as i}from"buffer";import e from"zlib";var n=function(){function n(t,i){void 0===i&&(i="base64"),this.encoding=i,this.ALGORITHM="aes-128-cbc",this.IV_LENGTH=16,this.KEY_LENGTH=16,this.KEY=this.validateKey(t)}return n.prototype.validateKey=function(t){var e=i.from(t.slice(0,this.KEY_LENGTH));if(e.length!==this.KEY_LENGTH)throw new RangeError("Invalid key length. Expected ".concat(this.KEY_LENGTH," bytes, got ").concat(e.length," bytes"));return e},n.prototype.encrypt=function(i){var n=t.randomBytes(this.IV_LENGTH),o=t.createCipheriv(this.ALGORITHM,this.KEY,n),r=e.deflateSync(i),c=o.update(r,void 0,this.encoding);return c+=o.final(this.encoding),"".concat(c,":").concat(n.toString(this.encoding))},n.prototype.decrypt=function(n){var o=n.split(":"),r=o[0],c=o[1],a=t.createDecipheriv(this.ALGORITHM,this.KEY,i.from(c,this.encoding)),s=i.from(a.update(r,this.encoding,"binary"),"binary");return s=i.concat([s,a.final()]),e.inflateSync(s).toString()},n}(),o=function(){function e(t,i){void 0===i&&(i="base64"),this.encoding=i,this.ALGORITHM="aes-256-cbc",this.KEY_LENGTH=32,this.KEY=this.validateKey(t)}return e.prototype.validateKey=function(t){var e=i.from(t.slice(0,this.KEY_LENGTH));if(e.length!==this.KEY_LENGTH)throw new RangeError("Invalid key length. Expected ".concat(this.KEY_LENGTH," bytes, got ").concat(e.length," bytes"));return e},e.prototype.encrypt=function(i){var e=t.randomBytes(16),n=t.createCipheriv(this.ALGORITHM,this.KEY,e),o=n.update(i,"utf8",this.encoding);return o+=n.final(this.encoding),"".concat(o,":").concat(e.toString(this.encoding))},e.prototype.decrypt=function(e){var n=e.split(":"),o=n[0],r=n[1],c=t.createDecipheriv(this.ALGORITHM,this.KEY,i.from(r,this.encoding)),a=c.update(o,this.encoding,"utf8");return a+=c.final("utf8")},e}();export{o as StringEntrypt,n as StringZlibEncrypt};