cipher-kit 2.0.0-beta.2 → 2.0.0-beta.4
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/dist/{chunk-SUGN4VDZ.js → chunk-LHB5NXYW.js} +85 -77
- package/dist/chunk-LHB5NXYW.js.map +1 -0
- package/dist/{chunk-AEQNI5EZ.js → chunk-N5T4PNG7.js} +75 -72
- package/dist/chunk-N5T4PNG7.js.map +1 -0
- package/dist/{chunk-3XGARINH.cjs → chunk-OL2AIXWK.cjs} +156 -152
- package/dist/chunk-OL2AIXWK.cjs.map +1 -0
- package/dist/{chunk-RXXVBCWL.cjs → chunk-UIV6DG54.cjs} +37 -38
- package/dist/chunk-UIV6DG54.cjs.map +1 -0
- package/dist/{chunk-WIZT7AYM.cjs → chunk-XIWV7XVI.cjs} +171 -162
- package/dist/chunk-XIWV7XVI.cjs.map +1 -0
- package/dist/{chunk-LOJKJJX5.js → chunk-YMNOTRET.js} +34 -37
- package/dist/chunk-YMNOTRET.js.map +1 -0
- package/dist/export-D1Vh79Qw.d.ts +417 -0
- package/dist/export-DGrELdz_.d.ts +416 -0
- package/dist/export-DXRl-ncG.d.cts +417 -0
- package/dist/export-Gd8hafl6.d.cts +416 -0
- package/dist/index.cjs +14 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -4
- package/dist/index.d.ts +52 -4
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +35 -35
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/validate-Cb7IOrPo.d.cts +373 -0
- package/dist/validate-Cb7IOrPo.d.ts +373 -0
- package/dist/web-api.cjs +35 -35
- package/dist/web-api.d.cts +2 -2
- package/dist/web-api.d.ts +2 -2
- package/dist/web-api.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3XGARINH.cjs.map +0 -1
- package/dist/chunk-AEQNI5EZ.js.map +0 -1
- package/dist/chunk-LOJKJJX5.js.map +0 -1
- package/dist/chunk-RXXVBCWL.cjs.map +0 -1
- package/dist/chunk-SUGN4VDZ.js.map +0 -1
- package/dist/chunk-WIZT7AYM.cjs.map +0 -1
- package/dist/export-Bq9tslUU.d.ts +0 -252
- package/dist/export-C0WDJZUy.d.ts +0 -251
- package/dist/export-LPOfeH2z.d.cts +0 -251
- package/dist/export-RD2Af4CJ.d.cts +0 -252
- package/dist/validate-CS4PFmY1.d.cts +0 -159
- package/dist/validate-CS4PFmY1.d.ts +0 -159
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import nodeCrypto, { webcrypto } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Standardized error object for the `Result` type.
|
|
5
|
+
* Always has a brief `message` and a more detailed `description`.
|
|
6
|
+
*/
|
|
7
|
+
interface ResultErr {
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Discriminated union for functions that can succeed or fail.
|
|
13
|
+
*
|
|
14
|
+
* - On **success**:
|
|
15
|
+
* - If `T` is an object - properties of `T` are **spread** into the result
|
|
16
|
+
* along with `success: true`.
|
|
17
|
+
* - Otherwise - `{ success: true, result: T }`.
|
|
18
|
+
* - On **failure**: `{ success: false, error: E }`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // Primitive result
|
|
23
|
+
* function getNum(): Result<number> { return $ok(42); }
|
|
24
|
+
* const r1 = getNum();
|
|
25
|
+
* if (r1.success) console.log(r1.result); // 42
|
|
26
|
+
*
|
|
27
|
+
* // Object result (spread)
|
|
28
|
+
* function getPair(): Result<{ a: number; b: string }> {
|
|
29
|
+
* return $ok({ a: 1, b: 'x' });
|
|
30
|
+
* }
|
|
31
|
+
* const r2 = getPair();
|
|
32
|
+
* if (r2.success) console.log(r2.a, r2.b); // 1 'x'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
type Result<T, E = ResultErr> = T extends object ? ({
|
|
36
|
+
readonly [K in keyof T]: T[K];
|
|
37
|
+
} & {
|
|
38
|
+
readonly success: true;
|
|
39
|
+
readonly error?: undefined;
|
|
40
|
+
}) | ({
|
|
41
|
+
readonly [K in keyof T]?: undefined;
|
|
42
|
+
} & {
|
|
43
|
+
readonly success: false;
|
|
44
|
+
readonly error: E;
|
|
45
|
+
}) : {
|
|
46
|
+
readonly success: true;
|
|
47
|
+
readonly result: T;
|
|
48
|
+
readonly error?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
readonly success: false;
|
|
51
|
+
readonly error: E;
|
|
52
|
+
readonly result?: undefined;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare const ENCODING: readonly ["base64", "base64url", "hex", "utf8", "latin1"];
|
|
56
|
+
declare const CIPHER_ENCODING: readonly ["base64", "base64url", "hex"];
|
|
57
|
+
declare const DIGEST_ALGORITHMS: Readonly<{
|
|
58
|
+
readonly sha256: {
|
|
59
|
+
readonly node: "sha256";
|
|
60
|
+
readonly web: "SHA-256";
|
|
61
|
+
};
|
|
62
|
+
readonly sha384: {
|
|
63
|
+
readonly node: "sha384";
|
|
64
|
+
readonly web: "SHA-384";
|
|
65
|
+
};
|
|
66
|
+
readonly sha512: {
|
|
67
|
+
readonly node: "sha512";
|
|
68
|
+
readonly web: "SHA-512";
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
71
|
+
declare const ENCRYPTION_ALGORITHMS: Readonly<{
|
|
72
|
+
readonly aes256gcm: {
|
|
73
|
+
readonly keyBytes: 32;
|
|
74
|
+
readonly ivLength: 12;
|
|
75
|
+
readonly node: "aes-256-gcm";
|
|
76
|
+
readonly web: "AES-GCM";
|
|
77
|
+
};
|
|
78
|
+
readonly aes192gcm: {
|
|
79
|
+
readonly keyBytes: 24;
|
|
80
|
+
readonly ivLength: 12;
|
|
81
|
+
readonly node: "aes-192-gcm";
|
|
82
|
+
readonly web: "AES-GCM";
|
|
83
|
+
};
|
|
84
|
+
readonly aes128gcm: {
|
|
85
|
+
readonly keyBytes: 16;
|
|
86
|
+
readonly ivLength: 12;
|
|
87
|
+
readonly node: "aes-128-gcm";
|
|
88
|
+
readonly web: "AES-GCM";
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
|
|
92
|
+
declare const __brand: unique symbol;
|
|
93
|
+
type Brand<T> = {
|
|
94
|
+
readonly [__brand]: T;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A platform-specific secret key for encryption/decryption.
|
|
98
|
+
*
|
|
99
|
+
* ### 🍼 Explain Like I'm Five
|
|
100
|
+
* You have a treasure (your secret data) and want to keep it safe.
|
|
101
|
+
* For that you create a key (the secret key) and lock your treasure with it.
|
|
102
|
+
*
|
|
103
|
+
* @template Platform - 'web' or 'node' to specify the platform of the secret key.
|
|
104
|
+
*/
|
|
105
|
+
type SecretKey<Platform extends 'web' | 'node'> = {
|
|
106
|
+
readonly platform: Platform;
|
|
107
|
+
readonly digest: keyof typeof DIGEST_ALGORITHMS;
|
|
108
|
+
readonly algorithm: keyof typeof ENCRYPTION_ALGORITHMS;
|
|
109
|
+
readonly key: Platform extends 'web' ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
|
|
110
|
+
} & Brand<`secretKey-${Platform}`>;
|
|
111
|
+
/** Supported **cipher text** encodings for encrypted/hash outputs. */
|
|
112
|
+
type CipherEncoding = (typeof CIPHER_ENCODING)[number];
|
|
113
|
+
/** Supported data encodings for **plain text/bytes** conversions. */
|
|
114
|
+
type Encoding = (typeof ENCODING)[number];
|
|
115
|
+
/** Supported symmetric encryption algorithms */
|
|
116
|
+
type EncryptionAlgorithm = keyof typeof ENCRYPTION_ALGORITHMS;
|
|
117
|
+
/** Supported digest algorithms for hashing */
|
|
118
|
+
type DigestAlgorithm = keyof typeof DIGEST_ALGORITHMS;
|
|
119
|
+
/**
|
|
120
|
+
* Options for creating a `SecretKey`
|
|
121
|
+
*
|
|
122
|
+
* ### 🍼 Explain Like I'm Five
|
|
123
|
+
* You want to create a special key to lock your treasure box.
|
|
124
|
+
* You can choose how strong the lock is (algorithm), how to make the key (digest),
|
|
125
|
+
* and add some extra secret stuff (salt and info) to make your key unique.
|
|
126
|
+
*
|
|
127
|
+
* - `algorithm` (default: `'aes256gcm'`)
|
|
128
|
+
* - `digest` (HKDF hash; default: `'sha256'`)
|
|
129
|
+
* - `salt` (default: `'cipher-kit-salt'`, must be ≥ 8 chars)
|
|
130
|
+
* - `info` (default: `'cipher-kit'`)
|
|
131
|
+
*/
|
|
132
|
+
interface CreateSecretKeyOptions {
|
|
133
|
+
algorithm?: EncryptionAlgorithm;
|
|
134
|
+
digest?: DigestAlgorithm;
|
|
135
|
+
salt?: string;
|
|
136
|
+
info?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Options for encryption.
|
|
140
|
+
*
|
|
141
|
+
* ### 🍼 Explain Like I'm Five
|
|
142
|
+
* After locking your message, how should we write the locked message down?
|
|
143
|
+
*
|
|
144
|
+
* - `encoding`: output ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
145
|
+
*/
|
|
146
|
+
interface EncryptOptions {
|
|
147
|
+
/** Encoding format for the output ciphertext (default: `'base64url'`). */
|
|
148
|
+
encoding?: CipherEncoding;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Options for decryption.
|
|
152
|
+
*
|
|
153
|
+
* ### 🍼 Explain Like I'm Five
|
|
154
|
+
* To unlock the message, we must know how it was written down.
|
|
155
|
+
*
|
|
156
|
+
* - `encoding`: input ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
157
|
+
*/
|
|
158
|
+
interface DecryptOptions {
|
|
159
|
+
/** Encoding format for the input ciphertext (default: `'base64url'`). */
|
|
160
|
+
encoding?: CipherEncoding;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Options for hashing arbitrary data.
|
|
164
|
+
*
|
|
165
|
+
* ### 🍼 Explain Like I'm Five
|
|
166
|
+
* You want to create a unique fingerprint (hash) of your data.
|
|
167
|
+
* You can choose how to create the fingerprint (digest) and how to write it down (encoding).
|
|
168
|
+
*
|
|
169
|
+
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha256'`)
|
|
170
|
+
* - `encoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
171
|
+
*/
|
|
172
|
+
interface HashOptions {
|
|
173
|
+
/** Digest algorithm to use (default: `'sha256'`). */
|
|
174
|
+
digest?: DigestAlgorithm;
|
|
175
|
+
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
176
|
+
encoding?: CipherEncoding;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Options for password hashing (PBKDF2).
|
|
180
|
+
*
|
|
181
|
+
* ### 🍼 Explain Like I'm Five
|
|
182
|
+
* We turn your password into a strong secret by mixing it with salt,
|
|
183
|
+
* stirring many times (iterations), and making a long result (keyLength).
|
|
184
|
+
*
|
|
185
|
+
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
186
|
+
* - `encoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
187
|
+
* - `saltLength`: size of the random salt in bytes (default: `16` bytes)
|
|
188
|
+
* - `iterations`: number of iterations (default: `320000`)
|
|
189
|
+
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
190
|
+
*/
|
|
191
|
+
interface HashPasswordOptions {
|
|
192
|
+
/** Digest algorithm to use (default: `'sha512'`). */
|
|
193
|
+
digest?: DigestAlgorithm;
|
|
194
|
+
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
195
|
+
encoding?: CipherEncoding;
|
|
196
|
+
/** Length of the salt in bytes (default: `16` bytes, min: `8` bytes). */
|
|
197
|
+
saltLength?: number;
|
|
198
|
+
/** Number of iterations for key derivation (default: `320000`, min: `1000`). */
|
|
199
|
+
iterations?: number;
|
|
200
|
+
/** Length of the derived key in bytes (default: `64` bytes, min: `16` bytes). */
|
|
201
|
+
keyLength?: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Options for verifying a password hash (PBKDF2) (must match the parameters used to hash).
|
|
205
|
+
*
|
|
206
|
+
* ### 🍼 Explain Like I'm Five
|
|
207
|
+
* To check a password, we must use the same recipe—same mixer, same number of stirs,
|
|
208
|
+
* same size—so the new result matches the old one.
|
|
209
|
+
*
|
|
210
|
+
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
211
|
+
* - `encoding`: input ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
212
|
+
* - `iterations`: number of iterations (default: `320000`)
|
|
213
|
+
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
214
|
+
*/
|
|
215
|
+
interface VerifyPasswordOptions {
|
|
216
|
+
/** Digest algorithm to use (default: `'sha512'`). */
|
|
217
|
+
digest?: DigestAlgorithm;
|
|
218
|
+
/** Encoding format of the input hash (default: `'base64url'`). */
|
|
219
|
+
encoding?: CipherEncoding;
|
|
220
|
+
/** Number of iterations for key derivation (default: `320000`). */
|
|
221
|
+
iterations?: number;
|
|
222
|
+
/** Length of the derived key in bytes (default: `64` bytes). */
|
|
223
|
+
keyLength?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Safely serializes a plain object to JSON without throwing.
|
|
228
|
+
*
|
|
229
|
+
* Wraps `JSON.stringify` and returns a `Result` containing the JSON string or an error.
|
|
230
|
+
* Only plain objects (POJOs) are accepted. Class instances, Maps, Sets, etc. are rejected.
|
|
231
|
+
*
|
|
232
|
+
* ### 🍼 Explain Like I'm Five
|
|
233
|
+
* You have a box of toys (your object) and take a photo of it (a JSON string)
|
|
234
|
+
* so you can send it to a friend.
|
|
235
|
+
*
|
|
236
|
+
* @template T - Plain object type to serialize.
|
|
237
|
+
* @param obj - The object to stringify (must be a plain object).
|
|
238
|
+
* @returns A `Result` with the JSON string on success, or an error.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const res = tryStringifyObj({ a: 1 });
|
|
243
|
+
* if (res.success) {
|
|
244
|
+
* console.log(res.result); // {"a":1}
|
|
245
|
+
* } else {
|
|
246
|
+
* console.error(res.error.message, res.error.description);
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string>;
|
|
251
|
+
/**
|
|
252
|
+
* Serializes a plain object to JSON (throwing).
|
|
253
|
+
*
|
|
254
|
+
* Wraps `JSON.stringify` and returns the result or throws an error.
|
|
255
|
+
* Only plain objects (POJOs) are accepted. Class instances, Maps, Sets, etc. are rejected.
|
|
256
|
+
*
|
|
257
|
+
* ### 🍼 Explain Like I'm Five
|
|
258
|
+
* You have a box of toys (your object) and take a photo of it (a JSON string)
|
|
259
|
+
* so you can send it to a friend.
|
|
260
|
+
*
|
|
261
|
+
* @template T - Plain object type to serialize.
|
|
262
|
+
* @param obj - The object to stringify (must be a plain object).
|
|
263
|
+
* @returns JSON string representation of the object.
|
|
264
|
+
* @throws {Error} If `obj` is not a plain object or serialization fails.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* try {
|
|
269
|
+
* const json = stringifyObj({ a: 1 }); // {"a":1}
|
|
270
|
+
* } catch (error: unknown) {
|
|
271
|
+
* console.error(error);
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string;
|
|
276
|
+
/**
|
|
277
|
+
* Safely parses a JSON string to a plain object (non-throwing).
|
|
278
|
+
*
|
|
279
|
+
* Wraps `JSON.parse` and returns a `Result` containing the parsed object, or an error.
|
|
280
|
+
*
|
|
281
|
+
* ### 🍼 Explain Like I'm Five
|
|
282
|
+
* You rebuild your toy box (an object) from a photo you took (a JSON string).
|
|
283
|
+
*
|
|
284
|
+
* @template T - The expected object type.
|
|
285
|
+
* @param str - The JSON string to parse.
|
|
286
|
+
* @returns A `Result` with the parsed object on success, or an error.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* const res = tryParseToObj<{ a: number }>('{"a":1}');
|
|
291
|
+
* if (res.success) {
|
|
292
|
+
* console.log(res.result.a); // 1
|
|
293
|
+
* } else {
|
|
294
|
+
* console.error(res.error.message, res.error.description);
|
|
295
|
+
* }
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
declare function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{
|
|
299
|
+
result: T;
|
|
300
|
+
}>;
|
|
301
|
+
/**
|
|
302
|
+
* Parses a JSON string to a plain object (throwing).
|
|
303
|
+
*
|
|
304
|
+
* Wraps `JSON.parse` and returns the parsed object, or throws on failure.
|
|
305
|
+
*
|
|
306
|
+
* ### 🍼 Explain Like I'm Five
|
|
307
|
+
* You rebuild your toy box (an object) from a photo you took (a JSON string).
|
|
308
|
+
*
|
|
309
|
+
* @template T - The expected object type.
|
|
310
|
+
* @param str - The JSON string to parse.
|
|
311
|
+
* @returns The parsed plain object.
|
|
312
|
+
* @throws {Error} If the string can’t be parsed or doesn’t represent a plain object.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* try {
|
|
317
|
+
* const obj = parseToObj<{ a: number }>('{"a":1}'); // obj.a === 1
|
|
318
|
+
* } catch (error: unknown) {
|
|
319
|
+
* console.error(error);
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Regular expressions for encrypted data patterns.
|
|
327
|
+
*
|
|
328
|
+
* - **node**: `"iv.cipher.tag."` (three dot-separated parts plus a trailing dot)
|
|
329
|
+
* - **web**: `"iv.cipherWithTag."` (two parts plus a trailing dot)
|
|
330
|
+
* - **general**: accepts both shapes (2 or 3 parts) with a trailing dot
|
|
331
|
+
*
|
|
332
|
+
* Each part is any non-empty string without dots.
|
|
333
|
+
*
|
|
334
|
+
* ### 🍼 Explain Like I'm Five
|
|
335
|
+
* You have a secret code you want to check. Before you check it,
|
|
336
|
+
* you make sure it looks how a secret code should look.
|
|
337
|
+
*/
|
|
338
|
+
declare const ENCRYPTED_REGEX: Readonly<{
|
|
339
|
+
node: RegExp;
|
|
340
|
+
web: RegExp;
|
|
341
|
+
general: RegExp;
|
|
342
|
+
}>;
|
|
343
|
+
/**
|
|
344
|
+
* Checks if a string matches an expected encrypted payload shape.
|
|
345
|
+
*
|
|
346
|
+
* - **node**: `"iv.cipher.tag."` (three dot-separated parts plus a trailing dot)
|
|
347
|
+
* - **web**: `"iv.cipherWithTag."` (two parts plus a trailing dot)
|
|
348
|
+
* - **general**: accepts both shapes (2 or 3 parts) with a trailing dot
|
|
349
|
+
*
|
|
350
|
+
* Each part is any non-empty string without dots.
|
|
351
|
+
*
|
|
352
|
+
* This validates only the **shape**, not whether content is valid base64/hex, etc.
|
|
353
|
+
*
|
|
354
|
+
* ### 🍼 Explain Like I'm Five
|
|
355
|
+
* You have a secret code you want to check. Before you check it,
|
|
356
|
+
* you make sure it looks how a secret code should look.
|
|
357
|
+
*
|
|
358
|
+
* @param data - The string to test.
|
|
359
|
+
* @param format - Which layout to check: `'node'`, `'web'`, or `'general'`.
|
|
360
|
+
* @returns `true` if the string matches the pattern; otherwise `false`.
|
|
361
|
+
* @throws {Error} If an unknown `format` is provided.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* matchPattern("abc.def.ghi.", "node"); // true
|
|
366
|
+
* matchPattern("abc.def.", "web"); // true
|
|
367
|
+
* matchPattern("abc.def.", "node"); // false
|
|
368
|
+
* matchPattern("abc.def.ghi.", "general"); // true
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
declare function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean;
|
|
372
|
+
|
|
373
|
+
export { type CipherEncoding as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type Result as R, type SecretKey as S, type VerifyPasswordOptions as V, tryStringifyObj as a, type Encoding as b, type EncryptionAlgorithm as c, type CreateSecretKeyOptions as d, type EncryptOptions as e, type DecryptOptions as f, type HashPasswordOptions as g, matchPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|
package/dist/web-api.cjs
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkXIWV7XVI_cjs = require('./chunk-XIWV7XVI.cjs');
|
|
4
|
+
var chunkUIV6DG54_cjs = require('./chunk-UIV6DG54.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "convertBytesToStr", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkXIWV7XVI_cjs.convertBytesToStr; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "convertEncoding", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkXIWV7XVI_cjs.convertEncoding; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "convertStrToBytes", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkXIWV7XVI_cjs.convertStrToBytes; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createSecretKey", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkXIWV7XVI_cjs.createSecretKey; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "decrypt", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkXIWV7XVI_cjs.decrypt; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "decryptObj", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkXIWV7XVI_cjs.decryptObj; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encrypt", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkXIWV7XVI_cjs.encrypt; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "encryptObj", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkXIWV7XVI_cjs.encryptObj; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "generateUuid", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkXIWV7XVI_cjs.generateUuid; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "hash", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkXIWV7XVI_cjs.hash; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "hashPassword", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkXIWV7XVI_cjs.hashPassword; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "isWebSecretKey", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkXIWV7XVI_cjs.isWebSecretKey; }
|
|
51
55
|
});
|
|
52
56
|
Object.defineProperty(exports, "tryConvertBytesToStr", {
|
|
53
57
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkXIWV7XVI_cjs.tryConvertBytesToStr; }
|
|
55
59
|
});
|
|
56
60
|
Object.defineProperty(exports, "tryConvertEncoding", {
|
|
57
61
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkXIWV7XVI_cjs.tryConvertEncoding; }
|
|
59
63
|
});
|
|
60
64
|
Object.defineProperty(exports, "tryConvertStrToBytes", {
|
|
61
65
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkXIWV7XVI_cjs.tryConvertStrToBytes; }
|
|
63
67
|
});
|
|
64
68
|
Object.defineProperty(exports, "tryCreateSecretKey", {
|
|
65
69
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkXIWV7XVI_cjs.tryCreateSecretKey; }
|
|
67
71
|
});
|
|
68
72
|
Object.defineProperty(exports, "tryDecrypt", {
|
|
69
73
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkXIWV7XVI_cjs.tryDecrypt; }
|
|
71
75
|
});
|
|
72
76
|
Object.defineProperty(exports, "tryDecryptObj", {
|
|
73
77
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkXIWV7XVI_cjs.tryDecryptObj; }
|
|
75
79
|
});
|
|
76
80
|
Object.defineProperty(exports, "tryEncrypt", {
|
|
77
81
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkXIWV7XVI_cjs.tryEncrypt; }
|
|
79
83
|
});
|
|
80
84
|
Object.defineProperty(exports, "tryEncryptObj", {
|
|
81
85
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkXIWV7XVI_cjs.tryEncryptObj; }
|
|
83
87
|
});
|
|
84
88
|
Object.defineProperty(exports, "tryGenerateUuid", {
|
|
85
89
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkXIWV7XVI_cjs.tryGenerateUuid; }
|
|
87
91
|
});
|
|
88
92
|
Object.defineProperty(exports, "tryHash", {
|
|
89
93
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkXIWV7XVI_cjs.tryHash; }
|
|
91
95
|
});
|
|
92
96
|
Object.defineProperty(exports, "tryHashPassword", {
|
|
93
97
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkXIWV7XVI_cjs.tryHashPassword; }
|
|
95
99
|
});
|
|
96
100
|
Object.defineProperty(exports, "verifyPassword", {
|
|
97
101
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkXIWV7XVI_cjs.verifyPassword; }
|
|
99
103
|
});
|
|
100
104
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
101
105
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, "isSecretKey", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function () { return chunkRXXVBCWL_cjs.isSecretKey; }
|
|
106
|
+
get: function () { return chunkUIV6DG54_cjs.ENCRYPTED_REGEX; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "matchPattern", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkUIV6DG54_cjs.matchPattern; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "parseToObj", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkUIV6DG54_cjs.parseToObj; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "stringifyObj", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkUIV6DG54_cjs.stringifyObj; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkUIV6DG54_cjs.tryParseToObj; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkUIV6DG54_cjs.tryStringifyObj; }
|
|
127
127
|
});
|
|
128
128
|
//# sourceMappingURL=web-api.cjs.map
|
|
129
129
|
//# sourceMappingURL=web-api.cjs.map
|
package/dist/web-api.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CreateSecretKeyOptions,
|
|
2
|
-
export { u as convertBytesToStr,
|
|
1
|
+
export { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-Cb7IOrPo.cjs';
|
|
2
|
+
export { u as convertBytesToStr, y as convertEncoding, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, n as hash, p as hashPassword, i as isWebSecretKey, s as tryConvertBytesToStr, x as tryConvertEncoding, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-Gd8hafl6.cjs';
|
|
3
3
|
import 'node:crypto';
|
package/dist/web-api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CreateSecretKeyOptions,
|
|
2
|
-
export { u as convertBytesToStr,
|
|
1
|
+
export { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-Cb7IOrPo.js';
|
|
2
|
+
export { u as convertBytesToStr, y as convertEncoding, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, n as hash, p as hashPassword, i as isWebSecretKey, s as tryConvertBytesToStr, x as tryConvertEncoding, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-DGrELdz_.js';
|
|
3
3
|
import 'node:crypto';
|
package/dist/web-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-
|
|
2
|
-
export { ENCRYPTED_REGEX,
|
|
1
|
+
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, isWebSecretKey, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-LHB5NXYW.js';
|
|
2
|
+
export { ENCRYPTED_REGEX, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-YMNOTRET.js';
|
|
3
3
|
//# sourceMappingURL=web-api.js.map
|
|
4
4
|
//# sourceMappingURL=web-api.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cipher-kit",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "🔐 Secure, Lightweight, and Cross-Platform Encryption, Decryption, and Hashing for Web, Node.js, Deno, Bun, and Cloudflare Workers",
|
|
5
5
|
"homepage": "https://github.com/WolfieLeader/npm/tree/main/packages/cipher-kit#readme",
|
|
6
6
|
"repository": {
|