tiny-essentials 1.2.1 โ†’ 1.3.1

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 (145) hide show
  1. package/README.md +3 -3
  2. package/dist/TinyEssentials.js +2375 -77105
  3. package/dist/TinyEssentials.min.js +1 -1
  4. package/dist/TinyEssentials.min.js.LICENSE.txt +0 -2
  5. package/dist/TinyLevelUp.js +16 -8
  6. package/dist/legacy/firebase/cookieSession.cjs +1 -1
  7. package/dist/legacy/firebase/cookieSession.d.mts +2 -2
  8. package/dist/legacy/firebase/cookieSession.mjs +1 -1
  9. package/dist/legacy/firebase/databaseLogger.cjs +5 -5
  10. package/dist/legacy/firebase/databaseLogger.d.mts +2 -2
  11. package/dist/legacy/firebase/databaseLogger.mjs +5 -5
  12. package/dist/legacy/firebase/discord/api/addGuildMember.cjs +2 -2
  13. package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +3 -3
  14. package/dist/legacy/firebase/discord/api/addGuildMember.mjs +2 -2
  15. package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +2 -2
  16. package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +3 -3
  17. package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +2 -2
  18. package/dist/legacy/firebase/discord/api/getToken.cjs +2 -2
  19. package/dist/legacy/firebase/discord/api/getToken.d.mts +3 -3
  20. package/dist/legacy/firebase/discord/api/getToken.mjs +2 -2
  21. package/dist/legacy/firebase/discord/api/getUser.cjs +2 -2
  22. package/dist/legacy/firebase/discord/api/getUser.d.mts +3 -3
  23. package/dist/legacy/firebase/discord/api/getUser.mjs +2 -2
  24. package/dist/legacy/firebase/discord/api/getUserConnections.cjs +2 -2
  25. package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +3 -3
  26. package/dist/legacy/firebase/discord/api/getUserConnections.mjs +2 -2
  27. package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +2 -2
  28. package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +3 -3
  29. package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +2 -2
  30. package/dist/legacy/firebase/discord/api/refreshToken.cjs +2 -2
  31. package/dist/legacy/firebase/discord/api/refreshToken.d.mts +3 -3
  32. package/dist/legacy/firebase/discord/api/refreshToken.mjs +2 -2
  33. package/dist/legacy/firebase/discord/api/revokeToken.cjs +2 -2
  34. package/dist/legacy/firebase/discord/api/revokeToken.d.mts +3 -3
  35. package/dist/legacy/firebase/discord/api/revokeToken.mjs +2 -2
  36. package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +3 -3
  37. package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +4 -4
  38. package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +3 -3
  39. package/dist/legacy/firebase/discord/get/cookie-session.cjs +1 -1
  40. package/dist/legacy/firebase/discord/get/cookie-session.d.mts +2 -2
  41. package/dist/legacy/firebase/discord/get/cookie-session.mjs +1 -1
  42. package/dist/legacy/firebase/discord/get/errorValidator.cjs +1 -1
  43. package/dist/legacy/firebase/discord/get/errorValidator.d.mts +2 -2
  44. package/dist/legacy/firebase/discord/get/errorValidator.mjs +1 -1
  45. package/dist/legacy/firebase/discord/http/login.cjs +3 -3
  46. package/dist/legacy/firebase/discord/http/login.d.mts +4 -4
  47. package/dist/legacy/firebase/discord/http/login.mjs +3 -3
  48. package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
  49. package/dist/legacy/firebase/discord/http/logout.d.mts +5 -5
  50. package/dist/legacy/firebase/discord/http/logout.mjs +4 -4
  51. package/dist/legacy/firebase/discord/http/redirect.cjs +4 -4
  52. package/dist/legacy/firebase/discord/http/redirect.d.mts +5 -5
  53. package/dist/legacy/firebase/discord/http/redirect.mjs +4 -4
  54. package/dist/legacy/firebase/discord/http/refreshToken.cjs +4 -4
  55. package/dist/legacy/firebase/discord/http/refreshToken.d.mts +5 -5
  56. package/dist/legacy/firebase/discord/http/refreshToken.mjs +4 -4
  57. package/dist/legacy/firebase/discord/template/cookie-session.cjs +2 -2
  58. package/dist/legacy/firebase/discord/template/cookie-session.d.mts +5 -5
  59. package/dist/legacy/firebase/discord/template/cookie-session.mjs +2 -2
  60. package/dist/legacy/firebase/escape.cjs +1 -1
  61. package/dist/legacy/firebase/escape.d.mts +2 -2
  62. package/dist/legacy/firebase/escape.mjs +1 -1
  63. package/dist/legacy/firebase/index.cjs +6 -6
  64. package/dist/legacy/firebase/index.d.mts +7 -7
  65. package/dist/legacy/firebase/index.mjs +6 -6
  66. package/dist/legacy/firebase/logger.cjs +5 -5
  67. package/dist/legacy/firebase/logger.d.mts +4 -4
  68. package/dist/legacy/firebase/logger.mjs +5 -5
  69. package/dist/legacy/firebase/mySQL.cjs +2 -2
  70. package/dist/legacy/firebase/mySQL.d.mts +3 -3
  71. package/dist/legacy/firebase/mySQL.mjs +2 -2
  72. package/dist/legacy/firebase/mysqlConnector/create.cjs +4 -4
  73. package/dist/legacy/firebase/mysqlConnector/create.d.mts +5 -5
  74. package/dist/legacy/firebase/mysqlConnector/create.mjs +4 -4
  75. package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +2 -2
  76. package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +4 -4
  77. package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +2 -2
  78. package/dist/legacy/firebase/mysqlConnector/pagination.cjs +4 -4
  79. package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +6 -6
  80. package/dist/legacy/firebase/mysqlConnector/pagination.mjs +4 -4
  81. package/dist/legacy/firebase/transactionDBAsync.cjs +1 -1
  82. package/dist/legacy/firebase/transactionDBAsync.d.mts +2 -2
  83. package/dist/legacy/firebase/transactionDBAsync.mjs +1 -1
  84. package/dist/legacy/get/pagination.cjs +1 -1
  85. package/dist/legacy/get/pagination.d.mts +2 -2
  86. package/dist/legacy/get/pagination.mjs +1 -1
  87. package/dist/legacy/get/versionCheck.cjs +1 -1
  88. package/dist/legacy/get/versionCheck.d.mts +2 -2
  89. package/dist/legacy/get/versionCheck.mjs +1 -1
  90. package/dist/legacy/http/check_domain.cjs +2 -2
  91. package/dist/legacy/http/check_domain.d.mts +2 -2
  92. package/dist/legacy/http/check_domain.mjs +2 -2
  93. package/dist/legacy/http/csrfTokenAnalyze.cjs +2 -2
  94. package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
  95. package/dist/legacy/http/csrfTokenAnalyze.mjs +2 -2
  96. package/dist/legacy/http/domainValidator.cjs +3 -3
  97. package/dist/legacy/http/domainValidator.d.mts +4 -4
  98. package/dist/legacy/http/domainValidator.mjs +3 -3
  99. package/dist/legacy/http/userIP.cjs +1 -1
  100. package/dist/legacy/http/userIP.d.mts +2 -4
  101. package/dist/legacy/http/userIP.mjs +1 -1
  102. package/dist/legacy/index.d.mts +4 -4
  103. package/dist/legacy/libs/custom_module_loader.cjs +2 -2
  104. package/dist/legacy/libs/custom_module_loader.d.mts +2 -2
  105. package/dist/legacy/libs/custom_module_loader.mjs +2 -2
  106. package/dist/legacy/libs/userLevel.cjs +16 -8
  107. package/dist/legacy/libs/userLevel.d.mts +34 -12
  108. package/dist/legacy/libs/userLevel.mjs +14 -8
  109. package/dist/legacy/socket.io/antiFlood/install.cjs +3 -3
  110. package/dist/legacy/socket.io/antiFlood/install.d.mts +4 -6
  111. package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
  112. package/dist/legacy/socket.io/antiFlood/verify.cjs +4 -4
  113. package/dist/legacy/socket.io/antiFlood/verify.d.mts +5 -7
  114. package/dist/legacy/socket.io/antiFlood/verify.mjs +4 -4
  115. package/dist/legacy/socket.io/cookie-session.cjs +2 -2
  116. package/dist/legacy/socket.io/cookie-session.d.mts +3 -3
  117. package/dist/legacy/socket.io/cookie-session.mjs +2 -2
  118. package/dist/legacy/socket.io/discord.cjs +3 -3
  119. package/dist/legacy/socket.io/discord.d.mts +4 -4
  120. package/dist/legacy/socket.io/discord.mjs +3 -3
  121. package/dist/v1/index.cjs +0 -4
  122. package/dist/v1/index.d.mts +1 -3
  123. package/dist/v1/index.mjs +1 -3
  124. package/docs/README.md +1 -11
  125. package/package.json +2 -5
  126. package/dist/TinyCertCrypto.js +0 -31364
  127. package/dist/TinyCertCrypto.min.js +0 -2
  128. package/dist/TinyCertCrypto.min.js.LICENSE.txt +0 -8
  129. package/dist/TinyCrypto.js +0 -48138
  130. package/dist/TinyCrypto.min.js +0 -2
  131. package/dist/TinyCrypto.min.js.LICENSE.txt +0 -10
  132. package/dist/v1/build/TinyCertCrypto.cjs +0 -7
  133. package/dist/v1/build/TinyCertCrypto.d.mts +0 -2
  134. package/dist/v1/build/TinyCertCrypto.mjs +0 -2
  135. package/dist/v1/build/TinyCrypto.cjs +0 -7
  136. package/dist/v1/build/TinyCrypto.d.mts +0 -2
  137. package/dist/v1/build/TinyCrypto.mjs +0 -2
  138. package/dist/v1/libs/TinyCertCrypto.cjs +0 -573
  139. package/dist/v1/libs/TinyCertCrypto.d.mts +0 -193
  140. package/dist/v1/libs/TinyCertCrypto.mjs +0 -481
  141. package/dist/v1/libs/TinyCrypto.cjs +0 -640
  142. package/dist/v1/libs/TinyCrypto.d.mts +0 -306
  143. package/dist/v1/libs/TinyCrypto.mjs +0 -597
  144. package/docs/libs/TinyCertCrypto.md +0 -202
  145. package/docs/libs/TinyCrypto.md +0 -177
@@ -1,202 +0,0 @@
1
- # โœจ Tiny Cert Crypto
2
-
3
- A lightweight ๐Ÿ” utility for managing, generating, and handling **X.509 certificates** and **RSA key pairs**.
4
- Built with flexibility in mind โ€” runs seamlessly in both **Node.js** and **browser** environments! ๐ŸŒ
5
-
6
- ---
7
-
8
- ## ๐Ÿ“ฆ Features
9
-
10
- - ๐Ÿ› ๏ธ RSA key pair generation (**Node.js only**)
11
- - ๐Ÿงพ Self-signed X.509 certificate creation
12
- - ๐Ÿงฌ Support for PEM-based ๐Ÿ”‘ public/private keys and certificates
13
- - ๐ŸงŠ JSON encryption & decryption using Base64 encoding
14
- - ๐Ÿ•ต๏ธ Metadata extraction from certificates (issuer, subject, validity, etc.)
15
- - ๐Ÿ“ Flexible key loading: from memory, local files (Node.js), or URLs (browser)
16
-
17
- ---
18
-
19
- ## ๐Ÿš€ Getting Started
20
-
21
- ### ๐Ÿ“š Constructor
22
-
23
- ```js
24
- const instance = new TinyCertCrypto({
25
- publicCertPath: 'cert.pem', // Path to public cert (Node.js)
26
- privateKeyPath: 'key.pem', // Path to private key (Node.js)
27
- publicCertBuffer: null, // String or Buffer in memory (Node.js/browser)
28
- privateKeyBuffer: null, // String or Buffer in memory (Node.js/browser)
29
- cryptoType: 'RSA-OAEP', // Encryption algorithm (default: 'RSA-OAEP')
30
- });
31
- ```
32
-
33
- > ๐Ÿ” In **browser environments**, at least `publicCertPath` or `publicCertBuffer` must be provided.
34
-
35
- ---
36
-
37
- ## ๐Ÿงช Core Methods
38
-
39
- ### ๐Ÿ”ง `async init()`
40
- Initializes the certificate and key system from files, memory buffers, or URLs.
41
-
42
- - Loads the public certificate/key.
43
- - Optionally loads the private key.
44
- - Detects whether youโ€™re running in Node.js or the browser and adjusts behavior accordingly.
45
-
46
- ---
47
-
48
- ### ๐Ÿ“‘ `extractCertMetadata()`
49
- Returns parsed metadata from the loaded certificate.
50
-
51
- ```js
52
- {
53
- subject: { names: {}, shortNames: {}, raw: "CN=example.com,O=MyOrg" },
54
- issuer: { names: {}, shortNames: {}, raw: "CN=example.com,O=MyOrg" },
55
- serialNumber: '...',
56
- validFrom: Date,
57
- validTo: Date
58
- }
59
- ```
60
-
61
- ---
62
-
63
- ### ๐Ÿ›ก๏ธ `encryptJson(jsonObject)`
64
- Encrypts a JavaScript object using the loaded **public key**, returning a **Base64-encoded string**.
65
-
66
- ```js
67
- const encrypted = instance.encryptJson({ hello: "world" });
68
- ```
69
-
70
- ---
71
-
72
- ### ๐Ÿ”“ `decryptToJson(base64String)`
73
- Decrypts a Base64 string using the **private key**, returning the original JSON object.
74
-
75
- ```js
76
- const json = instance.decryptToJson(encrypted);
77
- ```
78
-
79
- ---
80
-
81
- ### ๐Ÿ” `hasKeys()`
82
- Returns `true` if both `publicKey` and `privateKey` are loaded.
83
-
84
- ---
85
-
86
- ### ๐Ÿ“œ `hasCert()`
87
- Returns `true` if a certificate (`publicCert`) is loaded.
88
-
89
- ---
90
-
91
- ### โ™ป๏ธ `reset()`
92
- Resets the internal state, clearing:
93
- - `publicKey`
94
- - `privateKey`
95
- - `publicCert`
96
- - `metadata`
97
- - `source`
98
-
99
- ---
100
-
101
- ### ๐Ÿ“ฆ `fetchNodeForge()` & `getNodeForge()`
102
- Handles lazy-loading and reuse of the `node-forge` module.
103
-
104
- Use if you want to access Forge directly without importing it yourself:
105
-
106
- ```js
107
- const forge = await instance.fetchNodeForge();
108
- ```
109
-
110
- ---
111
-
112
- ## ๐Ÿง  Internals & Design
113
-
114
- - ๐Ÿ” Uses regular expressions to detect PEM types (`CERTIFICATE`, `PUBLIC KEY`, `PRIVATE KEY`)
115
- - ๐Ÿงช Automatically parses PEM buffers and files depending on the runtime
116
- - ๐Ÿ” Encrypts data with the selected algorithm (`RSA-OAEP`, etc.)
117
- - ๐Ÿงฌ X.509 certificate metadata extraction is done via `node-forge`
118
-
119
- ---
120
-
121
- ## ๐Ÿงฐ Requirements
122
-
123
- | Environment | Requirement |
124
- |-------------|--------------------|
125
- | Node.js | `node-forge` |
126
- | Browser | Works with native `fetch()` and `TextDecoder` |
127
-
128
- ---
129
-
130
- ## ๐Ÿ˜บ Example Use Case
131
-
132
- ```js
133
- const crypto = new TinyCertCrypto({ publicCertPath: 'cert.pem', privateKeyPath: 'key.pem' });
134
- await crypto.init();
135
-
136
- const data = { secret: 'I love ponies' };
137
- const encrypted = crypto.encryptJson(data);
138
- const decrypted = crypto.decryptToJson(encrypted);
139
-
140
- console.log(decrypted); // { secret: 'I love ponies' }
141
- ```
142
-
143
- ---
144
-
145
- ### ๐Ÿงพ `async generateX509Cert(subjectFields, options = {})`
146
- Generates a new **RSA key pair** and a **self-signed X.509 certificate** using the provided subject information.
147
-
148
- ๐Ÿ” This is ideal for internal services, development environments, or cryptographic testing tools where a trusted CA is not required.
149
-
150
- ---
151
-
152
- **๐Ÿงฌ Parameters:**
153
-
154
- - `subjectFields` (`Object`) โ€“ Describes the identity fields that will be embedded into the certificate's subject and issuer:
155
- - Common fields include:
156
- - `CN`: Common Name (e.g. domain or hostname)
157
- - `O`: Organization Name
158
- - `OU`: Organizational Unit
159
- - `L`: Locality (City)
160
- - `ST`: State or Province
161
- - `C`: Country (2-letter code)
162
- - `emailAddress`: Optional email field
163
-
164
- - `options` (`Object`) โ€“ Optional configuration:
165
- - `keySize` (`number`) โ€“ RSA key size in bits (default: `2048`)
166
- - `validityInYears` (`number`) โ€“ Certificate validity period (default: `1`)
167
- - `randomBytesLength` (`number`) โ€“ Length of the serial number (default: `16`)
168
- - `digestAlgorithm` (`string`) โ€“ Digest algorithm used to sign the certificate (default: `'sha256'`)
169
- - `forgeInstance` (`object`) โ€“ Optionally inject a specific instance of `node-forge`
170
- - `cryptoType` (`string`) โ€“ Encryption scheme used for later operations (e.g., `'RSA-OAEP'`, `'RSAES-PKCS1-V1_5'`)
171
-
172
- ---
173
-
174
- **โœ… Returns:**
175
-
176
- An object containing all the generated artifacts:
177
-
178
- ```js
179
- {
180
- publicKey: '-----BEGIN PUBLIC KEY-----...',
181
- privateKey: '-----BEGIN PRIVATE KEY-----...',
182
- cert: '-----BEGIN CERTIFICATE-----...'
183
- }
184
- ```
185
-
186
- - `publicKey`: The newly generated **PEM-encoded RSA public key**
187
- - `privateKey`: The corresponding **PEM-encoded RSA private key**
188
- - `cert`: A **PEM-encoded X.509 certificate** that is **self-signed** with the private key and matches the provided subject
189
-
190
- ---
191
-
192
- **๐Ÿ“Œ Notes:**
193
-
194
- - ๐Ÿ”„ The `subject` and `issuer` of the certificate are the same (self-signed).
195
- - โณ The certificate `validFrom` is set to the current date, and `validTo` is based on the `validityInYears` option.
196
- - ๐Ÿ”ข A secure random `serialNumber` is generated using `crypto.randomBytes`.
197
-
198
- ---
199
-
200
- **โš ๏ธ Availability:**
201
-
202
- > This method is only available in **Node.js environments** due to its dependency on the native `crypto` module and synchronous file access via `fs`.
@@ -1,177 +0,0 @@
1
- # ๐Ÿ” Tiny Crypto
2
-
3
- **Tiny Crypto** is a flexible and browser-compatible encryption utility class built for AES-256-GCM encryption with full support for serialization and deserialization of complex JavaScript data types.
4
-
5
- Whether you're in Node.js or a browser, Tiny Crypto helps you easily encrypt/decrypt values, save/load configurations, and keep your secrets safe โ€” all while supporting real-world usage like RegExp, Date, Buffer, and even DOM elements (in browsers only)!
6
-
7
- ---
8
-
9
- ## โœจ Features
10
-
11
- - ๐Ÿ”’ AES-256-GCM symmetric encryption
12
- - ๐Ÿง  Automatic serialization of complex types (Date, RegExp, Set, Map, etc.)
13
- - ๐Ÿ“ค Save and load keys/configs from files
14
- - ๐ŸŒ Works in both **Node.js** and **Browsers**
15
- - โš ๏ธ Type validation on decryption
16
- - ๐Ÿ’พ Smart support for file APIs (e.g. `FileReader` in browser, `fs` in Node)
17
-
18
- ---
19
-
20
- ## ๐Ÿš€ Getting Started
21
-
22
- ```js
23
- const crypto = new TinyCrypto();
24
-
25
- // Encrypt some data
26
- const { encrypted, iv, authTag } = crypto.encrypt({ hello: 'world' });
27
-
28
- // Decrypt it back
29
- const decrypted = crypto.decrypt({ encrypted, iv, authTag });
30
-
31
- console.log(decrypted); // { hello: 'world' }
32
- ```
33
-
34
- ---
35
-
36
- ## ๐Ÿง  Supported Data Types
37
-
38
- When you encrypt a value, its type is recorded and restored when decrypted.
39
-
40
- Supports:
41
-
42
- - `String`, `Number`, `Boolean`, `BigInt`, `Null`, `Undefined`
43
- - `Array`, `Object`, `Map`, `Set`, `Buffer`
44
- - `RegExp`, `Date`, `Symbol`
45
- - `HTMLElement` _(browser only)_
46
-
47
- Does NOT support:
48
-
49
- - `Function`, `Promise`, `WeakMap`, `WeakSet` โ†’ โŒ Will throw!
50
-
51
- ---
52
-
53
- ## ๐Ÿ”ง API
54
-
55
- ### `constructor(options)`
56
-
57
- | Option | Type | Default | Description |
58
- | ---------------- | ------ | --------------- | --------------------------------- |
59
- | `algorithm` | string | `'aes-256-gcm'` | AES algorithm used for encryption |
60
- | `key` | Buffer | auto-generated | The secret key to use (32 bytes) |
61
- | `outputEncoding` | string | `'hex'` | Encoding used for outputs |
62
- | `inputEncoding` | string | `'utf8'` | Encoding used for plain data |
63
- | `authTagLength` | number | `16` | GCM auth tag length |
64
-
65
- ---
66
-
67
- ### `encrypt(data, iv?)`
68
-
69
- Encrypts a value and returns an object with `{ iv, encrypted, authTag }`.
70
-
71
- ```js
72
- const result = crypto.encrypt('Hello!');
73
- ```
74
-
75
- ---
76
-
77
- ### `decrypt({ iv, encrypted, authTag }, expectedType?)`
78
-
79
- Decrypts a previously encrypted value and returns the original data. You can optionally pass an `expectedType` to validate it.
80
-
81
- ```js
82
- const plain = crypto.decrypt(result, 'string');
83
- ```
84
-
85
- ---
86
-
87
- ### `getTypeFromEncrypted({ iv, encrypted, authTag })`
88
-
89
- Returns the type name of the encrypted data without fully decrypting it.
90
-
91
- ---
92
-
93
- ### `generateKey(length = 32)`
94
-
95
- Generates a secure random key. Default: 32 bytes (AES-256).
96
-
97
- ---
98
-
99
- ### `generateIV(length = 12)`
100
-
101
- Generates a secure random IV. Default: 12 bytes (GCM standard).
102
-
103
- ---
104
-
105
- ### `saveKeyToFile(filename = 'secret.key')`
106
-
107
- Saves the current key to a file (browser: prompts download).
108
-
109
- ---
110
-
111
- ### `loadKeyFromFile(file)`
112
-
113
- Loads a key from a file (browser: File object, Node: file path).
114
-
115
- ---
116
-
117
- ### `saveConfigToFile(filename = 'crypto-config.json')`
118
-
119
- Saves the current configuration as JSON.
120
-
121
- ---
122
-
123
- ### `loadConfigFromFile(file)`
124
-
125
- Loads configuration from a JSON file.
126
-
127
- ---
128
-
129
- ### `exportConfig()`
130
-
131
- Returns an object with the current settings:
132
-
133
- ```json
134
- {
135
- "algorithm": "aes-256-gcm",
136
- "outputEncoding": "hex",
137
- "inputEncoding": "utf8",
138
- "authTagLength": 16,
139
- "key": "..."
140
- }
141
- ```
142
-
143
- ---
144
-
145
- ### `importConfig(config)`
146
-
147
- Applies a configuration object. Throws if invalid types are provided.
148
-
149
- ---
150
-
151
- ## ๐Ÿงช Type Validation
152
-
153
- You can ensure the decrypted value matches the original type:
154
-
155
- ```js
156
- crypto.decrypt(result, 'map'); // โœ…
157
- crypto.decrypt(result, 'set'); // โŒ throws if type mismatch
158
- ```
159
-
160
- ---
161
-
162
- ## โ— Errors You Might See
163
-
164
- - `Unsupported data type for encryption: Function`
165
- - `Type mismatch: expected Map, but got Set`
166
- - `Invalid config JSON file`
167
- - `HTMLElement deserialization is only supported in browsers`
168
-
169
- ---
170
-
171
- ## ๐Ÿ›ก๏ธ Security Notice
172
-
173
- This utility is for learning and light usage. For production, ensure:
174
-
175
- - Proper key management (use secure vaults)
176
- - Safe IV reuse (IVs must be unique per encryption)
177
- - Your platform's crypto standards are followed