cipher-kit 2.1.1 → 2.1.2
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-LTVOIZP5.cjs → chunk-66WIL32E.cjs} +145 -150
- package/dist/chunk-66WIL32E.cjs.map +1 -0
- package/dist/{chunk-X4CS7UXE.cjs → chunk-HTRGOBZF.cjs} +10 -2
- package/dist/chunk-HTRGOBZF.cjs.map +1 -0
- package/dist/{chunk-FSEA3UXJ.js → chunk-JLFVTZY4.js} +4 -8
- package/dist/chunk-JLFVTZY4.js.map +1 -0
- package/dist/{chunk-6C4NIWQ4.js → chunk-LU7QOSQH.js} +9 -3
- package/dist/chunk-LU7QOSQH.js.map +1 -0
- package/dist/{chunk-PWTFVMW6.js → chunk-S6SNCTU6.js} +4 -8
- package/dist/chunk-S6SNCTU6.js.map +1 -0
- package/dist/{chunk-56PVVFVM.cjs → chunk-ZNM5M6RD.cjs} +140 -145
- package/dist/chunk-ZNM5M6RD.cjs.map +1 -0
- package/dist/{export-DUgIcobC.d.ts → export-BaM_OTFk.d.ts} +13 -31
- package/dist/{export-C4DbO5zM.d.ts → export-CCTGAosO.d.ts} +13 -31
- package/dist/{export-CpZ7s25O.d.cts → export-FYHgb-8E.d.cts} +13 -31
- package/dist/{export-DO9n7Np-.d.cts → export-KFT0YyMg.d.cts} +13 -31
- package/dist/index.cjs +19 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -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-cJEdGlj1.d.cts → validate-lkJAHCeJ.d.cts} +39 -11
- package/dist/{validate-cJEdGlj1.d.ts → validate-lkJAHCeJ.d.ts} +39 -11
- 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-56PVVFVM.cjs.map +0 -1
- package/dist/chunk-6C4NIWQ4.js.map +0 -1
- package/dist/chunk-FSEA3UXJ.js.map +0 -1
- package/dist/chunk-LTVOIZP5.cjs.map +0 -1
- package/dist/chunk-PWTFVMW6.js.map +0 -1
- package/dist/chunk-X4CS7UXE.cjs.map +0 -1
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as Result, e as CreateSecretKeyOptions, N as NodeSecretKey, f as EncryptOptions, g as DecryptOptions, H as HashOptions, h as HashPasswordOptions, V as VerifyPasswordOptions, c as Encoding } from './validate-lkJAHCeJ.cjs';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Type guard to check if the provided value is a SecretKey object for Node.js environment.
|
|
6
|
-
*
|
|
7
|
-
* ### 🍼 Explain Like I'm Five
|
|
8
|
-
* Checking if the key in your hand is the right kind of key for the lock.
|
|
9
|
-
*
|
|
10
|
-
* @param x - The value to check.
|
|
11
|
-
* @returns True if the value is a SecretKey object for Node.js, false otherwise.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* isNodeSecretKey(nodeKey); // true
|
|
16
|
-
* isNodeSecretKey(webKey); // false
|
|
17
|
-
* isNodeSecretKey({}); // false
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function isNodeSecretKey(x: unknown): x is SecretKey<"node">;
|
|
21
4
|
/**
|
|
22
5
|
* Safely generates a UUID (v4) (non-throwing).
|
|
23
6
|
*
|
|
@@ -77,7 +60,7 @@ declare function generateUuid(): string;
|
|
|
77
60
|
* ```
|
|
78
61
|
*/
|
|
79
62
|
declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOptions): Result<{
|
|
80
|
-
result:
|
|
63
|
+
result: NodeSecretKey;
|
|
81
64
|
}>;
|
|
82
65
|
/**
|
|
83
66
|
* Derives a `SecretKey` from the provided string for encryption/decryption (throwing).
|
|
@@ -101,7 +84,7 @@ declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOpt
|
|
|
101
84
|
* const secretKey = createSecretKey("my-secret"); // SecretKey object
|
|
102
85
|
* ```
|
|
103
86
|
*/
|
|
104
|
-
declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions):
|
|
87
|
+
declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions): NodeSecretKey;
|
|
105
88
|
/**
|
|
106
89
|
* Safely encrypts a UTF-8 string using the provided `SecretKey` (non-throwing).
|
|
107
90
|
*
|
|
@@ -125,7 +108,7 @@ declare function createSecretKey(secret: string, options?: CreateSecretKeyOption
|
|
|
125
108
|
* else console.error(error); // { message: "...", description: "..." }
|
|
126
109
|
* ```
|
|
127
110
|
*/
|
|
128
|
-
declare function tryEncrypt(data: string, secretKey:
|
|
111
|
+
declare function tryEncrypt(data: string, secretKey: NodeSecretKey, options?: EncryptOptions): Result<string>;
|
|
129
112
|
/**
|
|
130
113
|
* Encrypts a UTF-8 string using the provided `SecretKey` (throwing).
|
|
131
114
|
*
|
|
@@ -147,7 +130,7 @@ declare function tryEncrypt(data: string, secretKey: SecretKey<"node">, options?
|
|
|
147
130
|
* const encrypted = encrypt("Hello, World!", secretKey); // "iv.cipher.tag." (Encrypted string)
|
|
148
131
|
* ```
|
|
149
132
|
*/
|
|
150
|
-
declare function encrypt(data: string, secretKey:
|
|
133
|
+
declare function encrypt(data: string, secretKey: NodeSecretKey, options?: EncryptOptions): string;
|
|
151
134
|
/**
|
|
152
135
|
* Safely decrypts the input string using the provided `SecretKey` (non-throwing).
|
|
153
136
|
*
|
|
@@ -172,7 +155,7 @@ declare function encrypt(data: string, secretKey: SecretKey<"node">, options?: E
|
|
|
172
155
|
* else console.error(error); // { message: "...", description: "..." }
|
|
173
156
|
* ```
|
|
174
157
|
*/
|
|
175
|
-
declare function tryDecrypt(encrypted: string, secretKey:
|
|
158
|
+
declare function tryDecrypt(encrypted: string, secretKey: NodeSecretKey, options?: DecryptOptions): Result<string>;
|
|
176
159
|
/**
|
|
177
160
|
* Decrypts the input string using the provided `SecretKey` (throwing).
|
|
178
161
|
*
|
|
@@ -195,7 +178,7 @@ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<"node">, opt
|
|
|
195
178
|
* const decrypted = decrypt(encrypted, secretKey); // "Hello, World!" (Decrypted string)
|
|
196
179
|
* ```
|
|
197
180
|
*/
|
|
198
|
-
declare function decrypt(encrypted: string, secretKey:
|
|
181
|
+
declare function decrypt(encrypted: string, secretKey: NodeSecretKey, options?: DecryptOptions): string;
|
|
199
182
|
/**
|
|
200
183
|
* Safely encrypts a plain object using the provided `SecretKey` (non-throwing).
|
|
201
184
|
*
|
|
@@ -223,7 +206,7 @@ declare function decrypt(encrypted: string, secretKey: SecretKey<"node">, option
|
|
|
223
206
|
* else console.error(error); // { message: "...", description: "..." }
|
|
224
207
|
* ```
|
|
225
208
|
*/
|
|
226
|
-
declare function tryEncryptObj<T extends object = Record<string, unknown>>(obj: T, secretKey:
|
|
209
|
+
declare function tryEncryptObj<T extends object = Record<string, unknown>>(obj: T, secretKey: NodeSecretKey, options?: EncryptOptions): Result<string>;
|
|
227
210
|
/**
|
|
228
211
|
* Encrypts a plain object using the provided `SecretKey` (throwing).
|
|
229
212
|
*
|
|
@@ -249,7 +232,7 @@ declare function tryEncryptObj<T extends object = Record<string, unknown>>(obj:
|
|
|
249
232
|
* const encrypted = encryptObj({ a: 1 }, secretKey); // "iv.cipher.tag." (Encrypted string)
|
|
250
233
|
* ```
|
|
251
234
|
*/
|
|
252
|
-
declare function encryptObj<T extends object = Record<string, unknown>>(obj: T, secretKey:
|
|
235
|
+
declare function encryptObj<T extends object = Record<string, unknown>>(obj: T, secretKey: NodeSecretKey, options?: EncryptOptions): string;
|
|
253
236
|
/**
|
|
254
237
|
* Safely decrypts an encrypted JSON string into a plain object (non-throwing).
|
|
255
238
|
*
|
|
@@ -275,7 +258,7 @@ declare function encryptObj<T extends object = Record<string, unknown>>(obj: T,
|
|
|
275
258
|
* else console.error(error); // { message: "...", description: "..." }
|
|
276
259
|
* ```
|
|
277
260
|
*/
|
|
278
|
-
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
261
|
+
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: NodeSecretKey, options?: DecryptOptions): Result<{
|
|
279
262
|
result: T;
|
|
280
263
|
}>;
|
|
281
264
|
/**
|
|
@@ -301,7 +284,7 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
|
|
|
301
284
|
* const obj = decryptObj<{ a: number }>(encrypted, secretKey); // obj.a === 1
|
|
302
285
|
* ```
|
|
303
286
|
*/
|
|
304
|
-
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
287
|
+
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: NodeSecretKey, options?: DecryptOptions): T;
|
|
305
288
|
/**
|
|
306
289
|
* Safely hashes a UTF-8 string (non-throwing).
|
|
307
290
|
*
|
|
@@ -571,7 +554,6 @@ declare const nodeCryptoKit_encryptObj: typeof encryptObj;
|
|
|
571
554
|
declare const nodeCryptoKit_generateUuid: typeof generateUuid;
|
|
572
555
|
declare const nodeCryptoKit_hash: typeof hash;
|
|
573
556
|
declare const nodeCryptoKit_hashPassword: typeof hashPassword;
|
|
574
|
-
declare const nodeCryptoKit_isNodeSecretKey: typeof isNodeSecretKey;
|
|
575
557
|
declare const nodeCryptoKit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
|
|
576
558
|
declare const nodeCryptoKit_tryConvertEncoding: typeof tryConvertEncoding;
|
|
577
559
|
declare const nodeCryptoKit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
|
|
@@ -585,7 +567,7 @@ declare const nodeCryptoKit_tryHash: typeof tryHash;
|
|
|
585
567
|
declare const nodeCryptoKit_tryHashPassword: typeof tryHashPassword;
|
|
586
568
|
declare const nodeCryptoKit_verifyPassword: typeof verifyPassword;
|
|
587
569
|
declare namespace nodeCryptoKit {
|
|
588
|
-
export { nodeCryptoKit_convertBytesToStr as convertBytesToStr, nodeCryptoKit_convertEncoding as convertEncoding, nodeCryptoKit_convertStrToBytes as convertStrToBytes, nodeCryptoKit_createSecretKey as createSecretKey, nodeCryptoKit_decrypt as decrypt, nodeCryptoKit_decryptObj as decryptObj, nodeCryptoKit_encrypt as encrypt, nodeCryptoKit_encryptObj as encryptObj, nodeCryptoKit_generateUuid as generateUuid, nodeCryptoKit_hash as hash, nodeCryptoKit_hashPassword as hashPassword,
|
|
570
|
+
export { nodeCryptoKit_convertBytesToStr as convertBytesToStr, nodeCryptoKit_convertEncoding as convertEncoding, nodeCryptoKit_convertStrToBytes as convertStrToBytes, nodeCryptoKit_createSecretKey as createSecretKey, nodeCryptoKit_decrypt as decrypt, nodeCryptoKit_decryptObj as decryptObj, nodeCryptoKit_encrypt as encrypt, nodeCryptoKit_encryptObj as encryptObj, nodeCryptoKit_generateUuid as generateUuid, nodeCryptoKit_hash as hash, nodeCryptoKit_hashPassword as hashPassword, nodeCryptoKit_tryConvertBytesToStr as tryConvertBytesToStr, nodeCryptoKit_tryConvertEncoding as tryConvertEncoding, nodeCryptoKit_tryConvertStrToBytes as tryConvertStrToBytes, nodeCryptoKit_tryCreateSecretKey as tryCreateSecretKey, nodeCryptoKit_tryDecrypt as tryDecrypt, nodeCryptoKit_tryDecryptObj as tryDecryptObj, nodeCryptoKit_tryEncrypt as tryEncrypt, nodeCryptoKit_tryEncryptObj as tryEncryptObj, nodeCryptoKit_tryGenerateUuid as tryGenerateUuid, nodeCryptoKit_tryHash as tryHash, nodeCryptoKit_tryHashPassword as tryHashPassword, nodeCryptoKit_verifyPassword as verifyPassword };
|
|
589
571
|
}
|
|
590
572
|
|
|
591
|
-
export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h,
|
|
573
|
+
export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, decryptObj as k, tryHash as l, hash as m, nodeCryptoKit as n, tryHashPassword as o, hashPassword as p, tryConvertStrToBytes as q, convertStrToBytes as r, tryConvertBytesToStr as s, tryGenerateUuid as t, convertBytesToStr as u, verifyPassword as v, tryConvertEncoding as w, convertEncoding as x };
|
package/dist/index.cjs
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkZNM5M6RD_cjs = require('./chunk-ZNM5M6RD.cjs');
|
|
4
|
+
var chunk66WIL32E_cjs = require('./chunk-66WIL32E.cjs');
|
|
5
|
+
var chunkHTRGOBZF_cjs = require('./chunk-HTRGOBZF.cjs');
|
|
6
6
|
|
|
7
7
|
// src/export.ts
|
|
8
|
-
var nodeKit =
|
|
9
|
-
var webKit =
|
|
8
|
+
var nodeKit = chunkZNM5M6RD_cjs.kit_exports;
|
|
9
|
+
var webKit = chunk66WIL32E_cjs.kit_exports;
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkHTRGOBZF_cjs.ENCRYPTED_REGEX; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "isNodeSecretKey", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkHTRGOBZF_cjs.isNodeSecretKey; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "isWebSecretKey", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkHTRGOBZF_cjs.isWebSecretKey; }
|
|
14
22
|
});
|
|
15
23
|
Object.defineProperty(exports, "matchEncryptedPattern", {
|
|
16
24
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkHTRGOBZF_cjs.matchEncryptedPattern; }
|
|
18
26
|
});
|
|
19
27
|
Object.defineProperty(exports, "parseToObj", {
|
|
20
28
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkHTRGOBZF_cjs.parseToObj; }
|
|
22
30
|
});
|
|
23
31
|
Object.defineProperty(exports, "stringifyObj", {
|
|
24
32
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkHTRGOBZF_cjs.stringifyObj; }
|
|
26
34
|
});
|
|
27
35
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
28
36
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkHTRGOBZF_cjs.tryParseToObj; }
|
|
30
38
|
});
|
|
31
39
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
32
40
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkHTRGOBZF_cjs.tryStringifyObj; }
|
|
34
42
|
});
|
|
35
43
|
exports.nodeKit = nodeKit;
|
|
36
44
|
exports.webKit = webKit;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/export.ts"],"names":["kit_exports"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/export.ts"],"names":["kit_exports"],"mappings":";;;;;;;AAsCO,IAAM,OAAA,GAAUA;AAwBhB,IAAM,MAAA,GAASA","file":"index.cjs","sourcesContent":["import * as nodeCryptoKit from \"./node/kit\";\r\nimport * as webCryptoKit from \"./web/kit\";\r\n\r\nexport {\r\n parseToObj,\r\n stringifyObj,\r\n tryParseToObj,\r\n tryStringifyObj,\r\n} from \"~/helpers/object\";\r\nexport {\r\n ENCRYPTED_REGEX,\r\n isNodeSecretKey,\r\n isWebSecretKey,\r\n matchEncryptedPattern,\r\n} from \"~/helpers/validate\";\r\nexport type * from \"./helpers/types\";\r\n\r\n/**\r\n * Node.js cryptography kit (Crypto Node.js API).\r\n *\r\n * Can be imported directly from 'cipher-kit/node' for smaller bundle size.\r\n *\r\n * - Uses Node's `crypto` module.\r\n * - Synchronous API (throwing) + safe wrappers that return `Result` (non-throwing).\r\n * - JSDoc comments with `Explain Like I'm Five` sections.\r\n *\r\n * #### Contains:\r\n * - Secret key creation from passphrase.\r\n * - Data encryption and decryption.\r\n * - Object encryption and decryption.\r\n * - Data hashing (digest).\r\n * - Password hashing and verification with time-safe comparison.\r\n * - Object serialization and deserialization (to/from JSON).\r\n * - Pattern matching to validate encrypted data format.\r\n *\r\n * ### 🍼 Explain Like I'm Five\r\n * It's like a toolkit that helps you keep your and your users' secrets safe when using Node.js.\r\n */\r\nexport const nodeKit = nodeCryptoKit;\r\n\r\n/**\r\n * Web, Deno, Bun and Cloudflare Workers cryptography kit (Crypto Web API).\r\n *\r\n * Can be imported directly from 'cipher-kit/web-api' for smaller bundle size.\r\n *\r\n * - Uses the Web Crypto API (`crypto.subtle`).\r\n * - Async API (Promise) + safe wrappers that return `Result`.\r\n * - JSDoc comments with `Explain Like I'm Five` sections.\r\n *\r\n * #### Contains:\r\n * - Secret key creation from passphrase.\r\n * - Data encryption and decryption.\r\n * - Object encryption and decryption.\r\n * - Data hashing (digest).\r\n * - Password hashing and verification with time-safe comparison.\r\n * - Object serialization and deserialization (to/from JSON).\r\n * - Pattern matching to validate encrypted data format.\r\n *\r\n * ### 🍼 Explain Like I'm Five\r\n * It's like a toolkit that helps you keep your and your users' secrets safe when using the web\r\n * or other Node.js alternatives like Deno, Bun, or Cloudflare Workers.\r\n */\r\nexport const webKit = webCryptoKit;\r\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as nodeCryptoKit } from './export-
|
|
2
|
-
import { w as webCryptoKit } from './export-
|
|
3
|
-
export { C as CipherEncoding,
|
|
1
|
+
import { n as nodeCryptoKit } from './export-KFT0YyMg.cjs';
|
|
2
|
+
import { w as webCryptoKit } from './export-FYHgb-8E.cjs';
|
|
3
|
+
export { C as CipherEncoding, e as CreateSecretKeyOptions, g as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, c as Encoding, f as EncryptOptions, d as EncryptionAlgorithm, H as HashOptions, h as HashPasswordOptions, N as NodeSecretKey, V as VerifyPasswordOptions, W as WebSecretKey, i as isNodeSecretKey, b as isWebSecretKey, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-lkJAHCeJ.cjs';
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
import 'node:crypto';
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as nodeCryptoKit } from './export-
|
|
2
|
-
import { w as webCryptoKit } from './export-
|
|
3
|
-
export { C as CipherEncoding,
|
|
1
|
+
import { n as nodeCryptoKit } from './export-BaM_OTFk.js';
|
|
2
|
+
import { w as webCryptoKit } from './export-CCTGAosO.js';
|
|
3
|
+
export { C as CipherEncoding, e as CreateSecretKeyOptions, g as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, c as Encoding, f as EncryptOptions, d as EncryptionAlgorithm, H as HashOptions, h as HashPasswordOptions, N as NodeSecretKey, V as VerifyPasswordOptions, W as WebSecretKey, i as isNodeSecretKey, b as isWebSecretKey, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-lkJAHCeJ.js';
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
import 'node:crypto';
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { kit_exports } from './chunk-
|
|
2
|
-
import { kit_exports as kit_exports$1 } from './chunk-
|
|
3
|
-
export { ENCRYPTED_REGEX, matchEncryptedPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-
|
|
1
|
+
import { kit_exports } from './chunk-S6SNCTU6.js';
|
|
2
|
+
import { kit_exports as kit_exports$1 } from './chunk-JLFVTZY4.js';
|
|
3
|
+
export { ENCRYPTED_REGEX, isNodeSecretKey, isWebSecretKey, matchEncryptedPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-LU7QOSQH.js';
|
|
4
4
|
|
|
5
5
|
// src/export.ts
|
|
6
6
|
var nodeKit = kit_exports;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/export.ts"],"names":["kit_exports"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/export.ts"],"names":["kit_exports"],"mappings":";;;;;AAsCO,IAAM,OAAA,GAAU;AAwBhB,IAAM,MAAA,GAASA","file":"index.js","sourcesContent":["import * as nodeCryptoKit from \"./node/kit\";\r\nimport * as webCryptoKit from \"./web/kit\";\r\n\r\nexport {\r\n parseToObj,\r\n stringifyObj,\r\n tryParseToObj,\r\n tryStringifyObj,\r\n} from \"~/helpers/object\";\r\nexport {\r\n ENCRYPTED_REGEX,\r\n isNodeSecretKey,\r\n isWebSecretKey,\r\n matchEncryptedPattern,\r\n} from \"~/helpers/validate\";\r\nexport type * from \"./helpers/types\";\r\n\r\n/**\r\n * Node.js cryptography kit (Crypto Node.js API).\r\n *\r\n * Can be imported directly from 'cipher-kit/node' for smaller bundle size.\r\n *\r\n * - Uses Node's `crypto` module.\r\n * - Synchronous API (throwing) + safe wrappers that return `Result` (non-throwing).\r\n * - JSDoc comments with `Explain Like I'm Five` sections.\r\n *\r\n * #### Contains:\r\n * - Secret key creation from passphrase.\r\n * - Data encryption and decryption.\r\n * - Object encryption and decryption.\r\n * - Data hashing (digest).\r\n * - Password hashing and verification with time-safe comparison.\r\n * - Object serialization and deserialization (to/from JSON).\r\n * - Pattern matching to validate encrypted data format.\r\n *\r\n * ### 🍼 Explain Like I'm Five\r\n * It's like a toolkit that helps you keep your and your users' secrets safe when using Node.js.\r\n */\r\nexport const nodeKit = nodeCryptoKit;\r\n\r\n/**\r\n * Web, Deno, Bun and Cloudflare Workers cryptography kit (Crypto Web API).\r\n *\r\n * Can be imported directly from 'cipher-kit/web-api' for smaller bundle size.\r\n *\r\n * - Uses the Web Crypto API (`crypto.subtle`).\r\n * - Async API (Promise) + safe wrappers that return `Result`.\r\n * - JSDoc comments with `Explain Like I'm Five` sections.\r\n *\r\n * #### Contains:\r\n * - Secret key creation from passphrase.\r\n * - Data encryption and decryption.\r\n * - Object encryption and decryption.\r\n * - Data hashing (digest).\r\n * - Password hashing and verification with time-safe comparison.\r\n * - Object serialization and deserialization (to/from JSON).\r\n * - Pattern matching to validate encrypted data format.\r\n *\r\n * ### 🍼 Explain Like I'm Five\r\n * It's like a toolkit that helps you keep your and your users' secrets safe when using the web\r\n * or other Node.js alternatives like Deno, Bun, or Cloudflare Workers.\r\n */\r\nexport const webKit = webCryptoKit;\r\n"]}
|
package/dist/node.cjs
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZNM5M6RD_cjs = require('./chunk-ZNM5M6RD.cjs');
|
|
4
|
+
var chunkHTRGOBZF_cjs = require('./chunk-HTRGOBZF.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 chunkZNM5M6RD_cjs.convertBytesToStr; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "convertEncoding", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkZNM5M6RD_cjs.convertEncoding; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "convertStrToBytes", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkZNM5M6RD_cjs.convertStrToBytes; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createSecretKey", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkZNM5M6RD_cjs.createSecretKey; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "decrypt", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkZNM5M6RD_cjs.decrypt; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "decryptObj", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkZNM5M6RD_cjs.decryptObj; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encrypt", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkZNM5M6RD_cjs.encrypt; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "encryptObj", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkZNM5M6RD_cjs.encryptObj; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "generateUuid", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkZNM5M6RD_cjs.generateUuid; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "hash", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkZNM5M6RD_cjs.hash; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "hashPassword", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(exports, "isNodeSecretKey", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () { return chunk56PVVFVM_cjs.isNodeSecretKey; }
|
|
50
|
+
get: function () { return chunkZNM5M6RD_cjs.hashPassword; }
|
|
55
51
|
});
|
|
56
52
|
Object.defineProperty(exports, "tryConvertBytesToStr", {
|
|
57
53
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkZNM5M6RD_cjs.tryConvertBytesToStr; }
|
|
59
55
|
});
|
|
60
56
|
Object.defineProperty(exports, "tryConvertEncoding", {
|
|
61
57
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkZNM5M6RD_cjs.tryConvertEncoding; }
|
|
63
59
|
});
|
|
64
60
|
Object.defineProperty(exports, "tryConvertStrToBytes", {
|
|
65
61
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkZNM5M6RD_cjs.tryConvertStrToBytes; }
|
|
67
63
|
});
|
|
68
64
|
Object.defineProperty(exports, "tryCreateSecretKey", {
|
|
69
65
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkZNM5M6RD_cjs.tryCreateSecretKey; }
|
|
71
67
|
});
|
|
72
68
|
Object.defineProperty(exports, "tryDecrypt", {
|
|
73
69
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkZNM5M6RD_cjs.tryDecrypt; }
|
|
75
71
|
});
|
|
76
72
|
Object.defineProperty(exports, "tryDecryptObj", {
|
|
77
73
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkZNM5M6RD_cjs.tryDecryptObj; }
|
|
79
75
|
});
|
|
80
76
|
Object.defineProperty(exports, "tryEncrypt", {
|
|
81
77
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkZNM5M6RD_cjs.tryEncrypt; }
|
|
83
79
|
});
|
|
84
80
|
Object.defineProperty(exports, "tryEncryptObj", {
|
|
85
81
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkZNM5M6RD_cjs.tryEncryptObj; }
|
|
87
83
|
});
|
|
88
84
|
Object.defineProperty(exports, "tryGenerateUuid", {
|
|
89
85
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkZNM5M6RD_cjs.tryGenerateUuid; }
|
|
91
87
|
});
|
|
92
88
|
Object.defineProperty(exports, "tryHash", {
|
|
93
89
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkZNM5M6RD_cjs.tryHash; }
|
|
95
91
|
});
|
|
96
92
|
Object.defineProperty(exports, "tryHashPassword", {
|
|
97
93
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkZNM5M6RD_cjs.tryHashPassword; }
|
|
99
95
|
});
|
|
100
96
|
Object.defineProperty(exports, "verifyPassword", {
|
|
101
97
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkZNM5M6RD_cjs.verifyPassword; }
|
|
103
99
|
});
|
|
104
100
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
105
101
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkHTRGOBZF_cjs.ENCRYPTED_REGEX; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "isNodeSecretKey", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkHTRGOBZF_cjs.isNodeSecretKey; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "matchEncryptedPattern", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkHTRGOBZF_cjs.matchEncryptedPattern; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "parseToObj", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkHTRGOBZF_cjs.parseToObj; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "stringifyObj", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkHTRGOBZF_cjs.stringifyObj; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkHTRGOBZF_cjs.tryParseToObj; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkHTRGOBZF_cjs.tryStringifyObj; }
|
|
127
127
|
});
|
|
128
128
|
//# sourceMappingURL=node.cjs.map
|
|
129
129
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CipherEncoding,
|
|
2
|
-
export {
|
|
1
|
+
export { C as CipherEncoding, e as CreateSecretKeyOptions, g as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, c as Encoding, f as EncryptOptions, d as EncryptionAlgorithm, H as HashOptions, h as HashPasswordOptions, N as NodeSecretKey, V as VerifyPasswordOptions, W as WebSecretKey, i as isNodeSecretKey, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-lkJAHCeJ.cjs';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, r as convertStrToBytes, c as createSecretKey, f as decrypt, k as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, m as hash, p as hashPassword, s as tryConvertBytesToStr, w as tryConvertEncoding, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, l as tryHash, o as tryHashPassword, v as verifyPassword } from './export-KFT0YyMg.cjs';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CipherEncoding,
|
|
2
|
-
export {
|
|
1
|
+
export { C as CipherEncoding, e as CreateSecretKeyOptions, g as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, c as Encoding, f as EncryptOptions, d as EncryptionAlgorithm, H as HashOptions, h as HashPasswordOptions, N as NodeSecretKey, V as VerifyPasswordOptions, W as WebSecretKey, i as isNodeSecretKey, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-lkJAHCeJ.js';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, r as convertStrToBytes, c as createSecretKey, f as decrypt, k as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, m as hash, p as hashPassword, s as tryConvertBytesToStr, w as tryConvertEncoding, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, l as tryHash, o as tryHashPassword, v as verifyPassword } from './export-BaM_OTFk.js';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword,
|
|
2
|
-
export { ENCRYPTED_REGEX, matchEncryptedPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-
|
|
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-S6SNCTU6.js';
|
|
2
|
+
export { ENCRYPTED_REGEX, isNodeSecretKey, matchEncryptedPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-LU7QOSQH.js';
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
|
4
4
|
//# sourceMappingURL=node.js.map
|
|
@@ -91,19 +91,9 @@ declare const ENCRYPTION_ALGORITHMS: Readonly<{
|
|
|
91
91
|
}>;
|
|
92
92
|
|
|
93
93
|
declare const __brand: unique symbol;
|
|
94
|
-
/** A brand type to distinguish between different types */
|
|
95
94
|
type Brand<T> = {
|
|
96
95
|
readonly [__brand]: T;
|
|
97
96
|
};
|
|
98
|
-
/**
|
|
99
|
-
* A platform-specific secret key for encryption/decryption.
|
|
100
|
-
*
|
|
101
|
-
* ### 🍼 Explain Like I'm Five
|
|
102
|
-
* You have a treasure (your secret data) and want to keep it safe.
|
|
103
|
-
* For that you create a key (the secret key) and lock your treasure with it.
|
|
104
|
-
*
|
|
105
|
-
* @template Platform - 'web' or 'node' to specify the platform of the secret key.
|
|
106
|
-
*/
|
|
107
97
|
type SecretKey<Platform extends "web" | "node"> = {
|
|
108
98
|
/** The platform the key is for ('web' or 'node'). */
|
|
109
99
|
readonly platform: Platform;
|
|
@@ -114,6 +104,10 @@ type SecretKey<Platform extends "web" | "node"> = {
|
|
|
114
104
|
/** The actual secret key object (CryptoKey for web, KeyObject for node). */
|
|
115
105
|
readonly key: Platform extends "web" ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
|
|
116
106
|
} & Brand<`secretKey-${Platform}`>;
|
|
107
|
+
/** A secret key for Node.js platform. */
|
|
108
|
+
type NodeSecretKey = SecretKey<"node">;
|
|
109
|
+
/** A secret key for Web platform. */
|
|
110
|
+
type WebSecretKey = SecretKey<"web">;
|
|
117
111
|
/** Supported **cipher text** encodings for encrypted/hash outputs. */
|
|
118
112
|
type CipherEncoding = (typeof CIPHER_ENCODING)[number];
|
|
119
113
|
/** Supported data encodings for **plain text/bytes** conversions. */
|
|
@@ -320,6 +314,40 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
320
314
|
*/
|
|
321
315
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
322
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Type guard to check if the provided value is a SecretKey object for Node.js environment.
|
|
319
|
+
*
|
|
320
|
+
* ### 🍼 Explain Like I'm Five
|
|
321
|
+
* Checking if the key in your hand is the right kind of key for the lock.
|
|
322
|
+
*
|
|
323
|
+
* @param x - The value to check.
|
|
324
|
+
* @returns True if the value is a SecretKey object for Node.js, false otherwise.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* isNodeSecretKey(nodeKey); // true
|
|
329
|
+
* isNodeSecretKey(webKey); // false
|
|
330
|
+
* isNodeSecretKey({}); // false
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
declare function isNodeSecretKey(x: unknown): x is NodeSecretKey;
|
|
334
|
+
/**
|
|
335
|
+
* Type guard to check if the provided value is a SecretKey object for Web (Deno, Bun, Cloudflare included) environment.
|
|
336
|
+
*
|
|
337
|
+
* ### 🍼 Explain Like I'm Five
|
|
338
|
+
* Checking if the key in your hand is the right kind of key for the lock.
|
|
339
|
+
*
|
|
340
|
+
* @param x - The value to check.
|
|
341
|
+
* @returns True if the value is a SecretKey object for Web, false otherwise.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* isWebSecretKey(webKey); // true
|
|
346
|
+
* isWebSecretKey(nodeKey); // false
|
|
347
|
+
* isWebSecretKey({}); // false
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare function isWebSecretKey(x: unknown): x is WebSecretKey;
|
|
323
351
|
/**
|
|
324
352
|
* Regular expressions for encrypted data patterns.
|
|
325
353
|
*
|
|
@@ -368,4 +396,4 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
368
396
|
*/
|
|
369
397
|
declare function matchEncryptedPattern(data: string, format: "node" | "web" | "general"): boolean;
|
|
370
398
|
|
|
371
|
-
export { type CipherEncoding as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type
|
|
399
|
+
export { type CipherEncoding as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type NodeSecretKey as N, type Result as R, type VerifyPasswordOptions as V, type WebSecretKey as W, tryStringifyObj as a, isWebSecretKey as b, type Encoding as c, type EncryptionAlgorithm as d, type CreateSecretKeyOptions as e, type EncryptOptions as f, type DecryptOptions as g, type HashPasswordOptions as h, isNodeSecretKey as i, matchEncryptedPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|
|
@@ -91,19 +91,9 @@ declare const ENCRYPTION_ALGORITHMS: Readonly<{
|
|
|
91
91
|
}>;
|
|
92
92
|
|
|
93
93
|
declare const __brand: unique symbol;
|
|
94
|
-
/** A brand type to distinguish between different types */
|
|
95
94
|
type Brand<T> = {
|
|
96
95
|
readonly [__brand]: T;
|
|
97
96
|
};
|
|
98
|
-
/**
|
|
99
|
-
* A platform-specific secret key for encryption/decryption.
|
|
100
|
-
*
|
|
101
|
-
* ### 🍼 Explain Like I'm Five
|
|
102
|
-
* You have a treasure (your secret data) and want to keep it safe.
|
|
103
|
-
* For that you create a key (the secret key) and lock your treasure with it.
|
|
104
|
-
*
|
|
105
|
-
* @template Platform - 'web' or 'node' to specify the platform of the secret key.
|
|
106
|
-
*/
|
|
107
97
|
type SecretKey<Platform extends "web" | "node"> = {
|
|
108
98
|
/** The platform the key is for ('web' or 'node'). */
|
|
109
99
|
readonly platform: Platform;
|
|
@@ -114,6 +104,10 @@ type SecretKey<Platform extends "web" | "node"> = {
|
|
|
114
104
|
/** The actual secret key object (CryptoKey for web, KeyObject for node). */
|
|
115
105
|
readonly key: Platform extends "web" ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
|
|
116
106
|
} & Brand<`secretKey-${Platform}`>;
|
|
107
|
+
/** A secret key for Node.js platform. */
|
|
108
|
+
type NodeSecretKey = SecretKey<"node">;
|
|
109
|
+
/** A secret key for Web platform. */
|
|
110
|
+
type WebSecretKey = SecretKey<"web">;
|
|
117
111
|
/** Supported **cipher text** encodings for encrypted/hash outputs. */
|
|
118
112
|
type CipherEncoding = (typeof CIPHER_ENCODING)[number];
|
|
119
113
|
/** Supported data encodings for **plain text/bytes** conversions. */
|
|
@@ -320,6 +314,40 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
320
314
|
*/
|
|
321
315
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
322
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Type guard to check if the provided value is a SecretKey object for Node.js environment.
|
|
319
|
+
*
|
|
320
|
+
* ### 🍼 Explain Like I'm Five
|
|
321
|
+
* Checking if the key in your hand is the right kind of key for the lock.
|
|
322
|
+
*
|
|
323
|
+
* @param x - The value to check.
|
|
324
|
+
* @returns True if the value is a SecretKey object for Node.js, false otherwise.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* isNodeSecretKey(nodeKey); // true
|
|
329
|
+
* isNodeSecretKey(webKey); // false
|
|
330
|
+
* isNodeSecretKey({}); // false
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
declare function isNodeSecretKey(x: unknown): x is NodeSecretKey;
|
|
334
|
+
/**
|
|
335
|
+
* Type guard to check if the provided value is a SecretKey object for Web (Deno, Bun, Cloudflare included) environment.
|
|
336
|
+
*
|
|
337
|
+
* ### 🍼 Explain Like I'm Five
|
|
338
|
+
* Checking if the key in your hand is the right kind of key for the lock.
|
|
339
|
+
*
|
|
340
|
+
* @param x - The value to check.
|
|
341
|
+
* @returns True if the value is a SecretKey object for Web, false otherwise.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* isWebSecretKey(webKey); // true
|
|
346
|
+
* isWebSecretKey(nodeKey); // false
|
|
347
|
+
* isWebSecretKey({}); // false
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare function isWebSecretKey(x: unknown): x is WebSecretKey;
|
|
323
351
|
/**
|
|
324
352
|
* Regular expressions for encrypted data patterns.
|
|
325
353
|
*
|
|
@@ -368,4 +396,4 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
368
396
|
*/
|
|
369
397
|
declare function matchEncryptedPattern(data: string, format: "node" | "web" | "general"): boolean;
|
|
370
398
|
|
|
371
|
-
export { type CipherEncoding as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type
|
|
399
|
+
export { type CipherEncoding as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type NodeSecretKey as N, type Result as R, type VerifyPasswordOptions as V, type WebSecretKey as W, tryStringifyObj as a, isWebSecretKey as b, type Encoding as c, type EncryptionAlgorithm as d, type CreateSecretKeyOptions as e, type EncryptOptions as f, type DecryptOptions as g, type HashPasswordOptions as h, isNodeSecretKey as i, matchEncryptedPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|