cipher-kit 0.0.7 → 0.0.8
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-UYBB4K56.js → chunk-2VWYNA5O.js} +5 -9
- package/dist/chunk-2VWYNA5O.js.map +1 -0
- package/dist/{chunk-65XPPPAR.cjs → chunk-3E7B77NS.cjs} +52 -57
- package/dist/chunk-3E7B77NS.cjs.map +1 -0
- package/dist/{chunk-PKIT6YQN.js → chunk-FVUCOHD7.js} +5 -9
- package/dist/chunk-FVUCOHD7.js.map +1 -0
- package/dist/{chunk-IMSNCUFU.cjs → chunk-GAAPPJTK.cjs} +16 -2
- package/dist/chunk-GAAPPJTK.cjs.map +1 -0
- package/dist/{chunk-RF735UV3.cjs → chunk-RWMHFO5T.cjs} +40 -45
- package/dist/chunk-RWMHFO5T.cjs.map +1 -0
- package/dist/{chunk-F52DT5C4.js → chunk-V7MXS2IX.js} +11 -3
- package/dist/chunk-V7MXS2IX.js.map +1 -0
- package/dist/index.cjs +30 -26
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +3 -3
- package/dist/node.cjs +21 -21
- package/dist/node.d.cts +4 -5
- package/dist/node.d.ts +4 -5
- package/dist/node.js +2 -2
- package/dist/{types-C7UlGfO2.d.cts → utils-Bryp07ny.d.cts} +7 -5
- package/dist/{types-C7UlGfO2.d.ts → utils-Bryp07ny.d.ts} +7 -5
- package/dist/web-api.cjs +21 -21
- package/dist/web-api.d.cts +3 -4
- package/dist/web-api.d.ts +3 -4
- package/dist/web-api.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-65XPPPAR.cjs.map +0 -1
- package/dist/chunk-F52DT5C4.js.map +0 -1
- package/dist/chunk-IMSNCUFU.cjs.map +0 -1
- package/dist/chunk-PKIT6YQN.js.map +0 -1
- package/dist/chunk-RF735UV3.cjs.map +0 -1
- package/dist/chunk-UYBB4K56.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGAAPPJTK_cjs = require('./chunk-GAAPPJTK.cjs');
|
|
4
4
|
var buffer = require('buffer');
|
|
5
5
|
var nodeCrypto = require('crypto');
|
|
6
6
|
|
|
@@ -10,122 +10,119 @@ var nodeCrypto__default = /*#__PURE__*/_interopDefault(nodeCrypto);
|
|
|
10
10
|
|
|
11
11
|
function encode(data, format = "utf8") {
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
13
|
+
return chunkGAAPPJTK_cjs.$ok({ bytes: buffer.Buffer.from(data, format) });
|
|
14
14
|
} catch (error) {
|
|
15
|
-
return
|
|
15
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to encode data", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
function decode(data, format = "utf8") {
|
|
19
19
|
try {
|
|
20
|
-
return
|
|
20
|
+
return chunkGAAPPJTK_cjs.$ok(buffer.Buffer.from(data).toString(format));
|
|
21
21
|
} catch (error) {
|
|
22
|
-
return
|
|
22
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to decode data", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
function generateUuid() {
|
|
26
26
|
try {
|
|
27
|
-
return
|
|
27
|
+
return chunkGAAPPJTK_cjs.$ok(nodeCrypto__default.default.randomUUID());
|
|
28
28
|
} catch (error) {
|
|
29
|
-
return
|
|
29
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to generate UUID with Crypto NodeJS", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function isNodeKey(key) {
|
|
33
|
-
return key instanceof nodeCrypto__default.default.KeyObject;
|
|
34
|
-
}
|
|
35
32
|
function hash(data) {
|
|
36
|
-
if (!
|
|
37
|
-
return
|
|
33
|
+
if (!chunkGAAPPJTK_cjs.$isStr(data)) {
|
|
34
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Empty data for hashing", desc: "Data must be a non-empty string" });
|
|
38
35
|
}
|
|
39
36
|
try {
|
|
40
37
|
const hashed = nodeCrypto__default.default.createHash("sha256").update(data).digest();
|
|
41
38
|
return decode(hashed, "base64url");
|
|
42
39
|
} catch (error) {
|
|
43
|
-
return
|
|
40
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to hash data with Crypto NodeJS", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
function createSecretKey(key) {
|
|
47
44
|
if (typeof key === "string") {
|
|
48
|
-
if (!
|
|
45
|
+
if (!chunkGAAPPJTK_cjs.$isStr(key, 1)) return chunkGAAPPJTK_cjs.$err({ msg: "Empty key for Crypto NodeJS", desc: "Invalid secret key" });
|
|
49
46
|
try {
|
|
50
47
|
const hashedKey = nodeCrypto__default.default.createHash("sha256").update(key).digest();
|
|
51
48
|
const secretKey = nodeCrypto__default.default.createSecretKey(hashedKey);
|
|
52
|
-
return
|
|
49
|
+
return chunkGAAPPJTK_cjs.$ok({ secretKey });
|
|
53
50
|
} catch (error) {
|
|
54
|
-
return
|
|
51
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to create secret key with Crypto NodeJS", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
|
-
if (!isNodeKey(key)) return
|
|
58
|
-
return
|
|
54
|
+
if (!chunkGAAPPJTK_cjs.isNodeKey(key)) return chunkGAAPPJTK_cjs.$err({ msg: "Invalid secret key", desc: "Expected a crypto.KeyObject" });
|
|
55
|
+
return chunkGAAPPJTK_cjs.$ok({ secretKey: key });
|
|
59
56
|
}
|
|
60
57
|
function encrypt(data, secretKey) {
|
|
61
|
-
if (!
|
|
62
|
-
return
|
|
58
|
+
if (!chunkGAAPPJTK_cjs.$isStr(data)) {
|
|
59
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Empty data for encryption", desc: "Data must be a non-empty string" });
|
|
63
60
|
}
|
|
64
|
-
if (!isNodeKey(secretKey)) {
|
|
65
|
-
return
|
|
61
|
+
if (!chunkGAAPPJTK_cjs.isNodeKey(secretKey)) {
|
|
62
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Invalid encryption key", desc: "Expected a crypto.KeyObject" });
|
|
66
63
|
}
|
|
67
64
|
try {
|
|
68
65
|
const iv = nodeCrypto__default.default.randomBytes(12);
|
|
69
|
-
const cipher = nodeCrypto__default.default.createCipheriv(
|
|
66
|
+
const cipher = nodeCrypto__default.default.createCipheriv(chunkGAAPPJTK_cjs.NODE_ALGORITHM, secretKey, iv);
|
|
70
67
|
const encrypted = buffer.Buffer.concat([cipher.update(data, "utf8"), cipher.final()]);
|
|
71
68
|
const tag = cipher.getAuthTag();
|
|
72
69
|
const { result: decodedIv, error: ivError } = decode(iv, "base64url");
|
|
73
70
|
const { result: decodedEncrypted, error: encryptedError } = decode(encrypted, "base64url");
|
|
74
71
|
const { result: decodedTag, error: tagError } = decode(tag, "base64url");
|
|
75
72
|
if (ivError || encryptedError || tagError) {
|
|
76
|
-
return
|
|
73
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to encode encrypted data", desc: "Encoding error" });
|
|
77
74
|
}
|
|
78
|
-
return
|
|
75
|
+
return chunkGAAPPJTK_cjs.$ok(`${decodedIv}.${decodedEncrypted}.${decodedTag}.`);
|
|
79
76
|
} catch (error) {
|
|
80
|
-
return
|
|
77
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to encrypt data with Crypto NodeJS", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
function decrypt(encrypted, secretKey) {
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
81
|
+
if (chunkGAAPPJTK_cjs.isInNodeEncryptionFormat(encrypted) === false) {
|
|
82
|
+
return chunkGAAPPJTK_cjs.$err({
|
|
86
83
|
msg: "Invalid encrypted data format",
|
|
87
84
|
desc: 'Encrypted data must be in the format "iv.encrypted.tag."'
|
|
88
85
|
});
|
|
89
86
|
}
|
|
90
87
|
const [iv, encryptedData, tag] = encrypted.split(".", 4);
|
|
91
|
-
if (!
|
|
92
|
-
return
|
|
88
|
+
if (!chunkGAAPPJTK_cjs.$isStr(iv, 1) || !chunkGAAPPJTK_cjs.$isStr(encryptedData, 1) || !chunkGAAPPJTK_cjs.$isStr(tag, 1)) {
|
|
89
|
+
return chunkGAAPPJTK_cjs.$err({
|
|
93
90
|
msg: "Invalid parameters for decryption",
|
|
94
91
|
desc: "IV, encrypted data, and tag must be non-empty strings"
|
|
95
92
|
});
|
|
96
93
|
}
|
|
97
|
-
if (!isNodeKey(secretKey)) {
|
|
98
|
-
return
|
|
94
|
+
if (!chunkGAAPPJTK_cjs.isNodeKey(secretKey)) {
|
|
95
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Invalid decryption key", desc: "Expected a crypto.KeyObject" });
|
|
99
96
|
}
|
|
100
97
|
const { bytes: ivBytes, error: ivError } = encode(iv, "base64url");
|
|
101
98
|
const { bytes: encryptedBytes, error: encryptedError } = encode(encryptedData, "base64url");
|
|
102
99
|
const { bytes: tagBytes, error: tagError } = encode(tag, "base64url");
|
|
103
100
|
if (ivError || encryptedError || tagError) {
|
|
104
|
-
return
|
|
101
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to encode IV or encrypted data", desc: "Encoding error" });
|
|
105
102
|
}
|
|
106
103
|
try {
|
|
107
|
-
const decipher = nodeCrypto__default.default.createDecipheriv(
|
|
104
|
+
const decipher = nodeCrypto__default.default.createDecipheriv(chunkGAAPPJTK_cjs.NODE_ALGORITHM, secretKey, ivBytes);
|
|
108
105
|
decipher.setAuthTag(tagBytes);
|
|
109
106
|
const decrypted = buffer.Buffer.concat([decipher.update(encryptedBytes), decipher.final()]);
|
|
110
107
|
return decode(decrypted, "utf8");
|
|
111
108
|
} catch (error) {
|
|
112
|
-
return
|
|
109
|
+
return chunkGAAPPJTK_cjs.$err({ msg: "Failed to decrypt data with Crypto NodeJS", desc: chunkGAAPPJTK_cjs.$stringifyError(error) });
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
function encryptObj(data, secretKey) {
|
|
116
|
-
const { result, error } =
|
|
117
|
-
if (error) return
|
|
113
|
+
const { result, error } = chunkGAAPPJTK_cjs.stringifyObj(data);
|
|
114
|
+
if (error) return chunkGAAPPJTK_cjs.$err(error);
|
|
118
115
|
return encrypt(result, secretKey);
|
|
119
116
|
}
|
|
120
117
|
function decryptObj(encrypted, secretKey) {
|
|
121
118
|
const { result, error } = decrypt(encrypted, secretKey);
|
|
122
|
-
if (error) return
|
|
123
|
-
return
|
|
119
|
+
if (error) return chunkGAAPPJTK_cjs.$err(error);
|
|
120
|
+
return chunkGAAPPJTK_cjs.parseToObj(result);
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
// src/node/export.ts
|
|
127
124
|
var export_exports = {};
|
|
128
|
-
|
|
125
|
+
chunkGAAPPJTK_cjs.__export(export_exports, {
|
|
129
126
|
createSecretKey: () => createSecretKey,
|
|
130
127
|
decode: () => decode,
|
|
131
128
|
decrypt: () => decrypt,
|
|
@@ -134,8 +131,7 @@ chunkIMSNCUFU_cjs.__export(export_exports, {
|
|
|
134
131
|
encrypt: () => encrypt,
|
|
135
132
|
encryptObj: () => encryptObj,
|
|
136
133
|
generateUuid: () => generateUuid,
|
|
137
|
-
hash: () => hash
|
|
138
|
-
isNodeKey: () => isNodeKey
|
|
134
|
+
hash: () => hash
|
|
139
135
|
});
|
|
140
136
|
|
|
141
137
|
exports.createSecretKey = createSecretKey;
|
|
@@ -148,6 +144,5 @@ exports.encryptObj = encryptObj;
|
|
|
148
144
|
exports.export_exports = export_exports;
|
|
149
145
|
exports.generateUuid = generateUuid;
|
|
150
146
|
exports.hash = hash;
|
|
151
|
-
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
153
|
-
//# sourceMappingURL=chunk-RF735UV3.cjs.map
|
|
147
|
+
//# sourceMappingURL=chunk-RWMHFO5T.cjs.map
|
|
148
|
+
//# sourceMappingURL=chunk-RWMHFO5T.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/encode.ts","../src/node/encrypt.ts","../src/node/export.ts"],"names":["$ok","Buffer","$err","$stringifyError","nodeCrypto","$isStr","isNodeKey","NODE_ALGORITHM","isInNodeEncryptionFormat","stringifyObj","parseToObj","__export"],"mappings":";;;;;;;;;;AAIO,SAAS,MAAA,CAAO,IAAA,EAAc,MAAA,GAAyB,MAAA,EAAmC;AAC/F,EAAA,IAAI;AACF,IAAA,OAAOA,qBAAA,CAAI,EAAE,KAAA,EAAOC,aAAA,CAAO,KAAK,IAAA,EAAM,MAAM,GAAG,CAAA;AAAA,EACjD,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,sBAAA,CAAK,EAAE,GAAA,EAAK,uBAAA,EAAyB,MAAMC,iCAAA,CAAgB,KAAK,GAAG,CAAA;AAAA,EAC5E;AACF;AAEO,SAAS,MAAA,CAAO,IAAA,EAAc,MAAA,GAAyB,MAAA,EAAwB;AACpF,EAAA,IAAI;AACF,IAAA,OAAOH,sBAAIC,aAAA,CAAO,IAAA,CAAK,IAAI,CAAA,CAAE,QAAA,CAAS,MAAM,CAAC,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,sBAAA,CAAK,EAAE,GAAA,EAAK,uBAAA,EAAyB,MAAMC,iCAAA,CAAgB,KAAK,GAAG,CAAA;AAAA,EAC5E;AACF;ACXO,SAAS,YAAA,GAA+B;AAC7C,EAAA,IAAI;AACF,IAAA,OAAOH,qBAAA,CAAII,2BAAA,CAAW,UAAA,EAAY,CAAA;AAAA,EACpC,SAAS,KAAA,EAAO;AACd,IAAA,OAAOF,sBAAA,CAAK,EAAE,GAA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,EAAA,IAAI,KAAA,EAAO,OAAOA,sBAAA,CAAK,KAAK,CAAA;AAC5B,EAAA,OAAOQ,6BAAW,MAAM,CAAA;AAC1B;;;ACzHA,IAAA,cAAA,GAAA;AAAAC,0BAAA,CAAA,cAAA,EAAA;AAAA,EAAA,eAAA,EAAA,MAAA,eAAA;AAAA,EAAA,MAAA,EAAA,MAAA,MAAA;AAAA,EAAA,OAAA,EAAA,MAAA,OAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,MAAA,EAAA,MAAA,MAAA;AAAA,EAAA,OAAA,EAAA,MAAA,OAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"chunk-RWMHFO5T.cjs","sourcesContent":["import { Buffer } from 'node:buffer';\r\nimport { $err, $ok, $stringifyError, type Result } from '~/error';\r\nimport type { EncodingFormat } from '~/types';\r\n\r\nexport function encode(data: string, format: EncodingFormat = 'utf8'): Result<{ bytes: Buffer }> {\r\n try {\r\n return $ok({ bytes: Buffer.from(data, format) });\r\n } catch (error) {\r\n return $err({ msg: 'Failed to encode data', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function decode(data: Buffer, format: EncodingFormat = 'utf8'): Result<string> {\r\n try {\r\n return $ok(Buffer.from(data).toString(format));\r\n } catch (error) {\r\n return $err({ msg: 'Failed to decode data', desc: $stringifyError(error) });\r\n }\r\n}\r\n","import { Buffer } from 'node:buffer';\r\nimport nodeCrypto from 'node:crypto';\r\nimport { $err, $ok, $stringifyError, type Result } from '~/error';\r\nimport type { NodeKey } from '~/types';\r\nimport { $isStr, isInNodeEncryptionFormat, isNodeKey, NODE_ALGORITHM, parseToObj, stringifyObj } from '~/utils';\r\nimport { decode, encode } from './encode';\r\n\r\nexport function generateUuid(): Result<string> {\r\n try {\r\n return $ok(nodeCrypto.randomUUID());\r\n } catch (error) {\r\n return $err({ msg: 'Failed to generate UUID with Crypto NodeJS', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function hash(data: string): Result<string> {\r\n if (!$isStr(data)) {\r\n return $err({ msg: 'Empty data for hashing', desc: 'Data must be a non-empty string' });\r\n }\r\n\r\n try {\r\n const hashed = nodeCrypto.createHash('sha256').update(data).digest();\r\n return decode(hashed, 'base64url');\r\n } catch (error) {\r\n return $err({ msg: 'Failed to hash data with Crypto NodeJS', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function createSecretKey(key: string | NodeKey): Result<{ secretKey: NodeKey }> {\r\n if (typeof key === 'string') {\r\n if (!$isStr(key, 1)) return $err({ msg: 'Empty key for Crypto NodeJS', desc: 'Invalid secret key' });\r\n\r\n try {\r\n const hashedKey = nodeCrypto.createHash('sha256').update(key).digest();\r\n const secretKey = nodeCrypto.createSecretKey(hashedKey);\r\n return $ok({ secretKey });\r\n } catch (error) {\r\n return $err({ msg: 'Failed to create secret key with Crypto NodeJS', desc: $stringifyError(error) });\r\n }\r\n }\r\n\r\n if (!isNodeKey(key)) return $err({ msg: 'Invalid secret key', desc: 'Expected a crypto.KeyObject' });\r\n return $ok({ secretKey: key });\r\n}\r\n\r\nexport function encrypt(data: string, secretKey: NodeKey): Result<string> {\r\n if (!$isStr(data)) {\r\n return $err({ msg: 'Empty data for encryption', desc: 'Data must be a non-empty string' });\r\n }\r\n\r\n if (!isNodeKey(secretKey)) {\r\n return $err({ msg: 'Invalid encryption key', desc: 'Expected a crypto.KeyObject' });\r\n }\r\n\r\n try {\r\n const iv = nodeCrypto.randomBytes(12);\r\n const cipher = nodeCrypto.createCipheriv(NODE_ALGORITHM, secretKey, iv);\r\n const encrypted = Buffer.concat([cipher.update(data, 'utf8'), cipher.final()]);\r\n const tag = cipher.getAuthTag();\r\n\r\n const { result: decodedIv, error: ivError } = decode(iv, 'base64url');\r\n const { result: decodedEncrypted, error: encryptedError } = decode(encrypted, 'base64url');\r\n const { result: decodedTag, error: tagError } = decode(tag, 'base64url');\r\n if (ivError || encryptedError || tagError) {\r\n return $err({ msg: 'Failed to encode encrypted data', desc: 'Encoding error' });\r\n }\r\n\r\n return $ok(`${decodedIv}.${decodedEncrypted}.${decodedTag}.`);\r\n } catch (error) {\r\n return $err({ msg: 'Failed to encrypt data with Crypto NodeJS', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function decrypt(encrypted: string, secretKey: NodeKey): Result<string> {\r\n if (isInNodeEncryptionFormat(encrypted) === false) {\r\n return $err({\r\n msg: 'Invalid encrypted data format',\r\n desc: 'Encrypted data must be in the format \"iv.encrypted.tag.\"',\r\n });\r\n }\r\n\r\n const [iv, encryptedData, tag] = encrypted.split('.', 4);\r\n if (!$isStr(iv, 1) || !$isStr(encryptedData, 1) || !$isStr(tag, 1)) {\r\n return $err({\r\n msg: 'Invalid parameters for decryption',\r\n desc: 'IV, encrypted data, and tag must be non-empty strings',\r\n });\r\n }\r\n\r\n if (!isNodeKey(secretKey)) {\r\n return $err({ msg: 'Invalid decryption key', desc: 'Expected a crypto.KeyObject' });\r\n }\r\n\r\n const { bytes: ivBytes, error: ivError } = encode(iv, 'base64url');\r\n const { bytes: encryptedBytes, error: encryptedError } = encode(encryptedData, 'base64url');\r\n const { bytes: tagBytes, error: tagError } = encode(tag, 'base64url');\r\n if (ivError || encryptedError || tagError) {\r\n return $err({ msg: 'Failed to encode IV or encrypted data', desc: 'Encoding error' });\r\n }\r\n\r\n try {\r\n const decipher = nodeCrypto.createDecipheriv(NODE_ALGORITHM, secretKey, ivBytes);\r\n decipher.setAuthTag(tagBytes);\r\n\r\n const decrypted = Buffer.concat([decipher.update(encryptedBytes), decipher.final()]);\r\n return decode(decrypted, 'utf8');\r\n } catch (error) {\r\n return $err({ msg: 'Failed to decrypt data with Crypto NodeJS', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function encryptObj(data: Record<string, unknown>, secretKey: NodeKey): Result<string> {\r\n const { result, error } = stringifyObj(data);\r\n if (error) return $err(error);\r\n return encrypt(result, secretKey);\r\n}\r\n\r\nexport function decryptObj(encrypted: string, secretKey: NodeKey): Result<{ result: Record<string, unknown> }> {\r\n const { result, error } = decrypt(encrypted, secretKey);\r\n if (error) return $err(error);\r\n return parseToObj(result);\r\n}\r\n","export { decode, encode } from './encode';\r\nexport { createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash } from './encrypt';\r\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import nodeCrypto from 'crypto';
|
|
2
|
+
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __export = (target, all) => {
|
|
3
5
|
for (var name in all)
|
|
@@ -44,6 +46,12 @@ function $isStr(value, min = 0) {
|
|
|
44
46
|
function $isObj(value) {
|
|
45
47
|
return typeof value === "object" && value !== null && value !== void 0 && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
46
48
|
}
|
|
49
|
+
function isWebApiKey(key) {
|
|
50
|
+
return key !== null && key !== void 0 && typeof key === "object" && "type" in key && typeof key.type === "string" && "algorithm" in key && typeof key.algorithm === "object" && "extractable" in key && typeof key.extractable === "boolean" && "usages" in key && Array.isArray(key.usages) && key.usages.every((usage) => typeof usage === "string");
|
|
51
|
+
}
|
|
52
|
+
function isNodeKey(key) {
|
|
53
|
+
return key instanceof nodeCrypto.KeyObject;
|
|
54
|
+
}
|
|
47
55
|
function stringifyObj(obj) {
|
|
48
56
|
if (!$isObj(obj)) return $err({ msg: "Invalid object", desc: "Input is not a plain object" });
|
|
49
57
|
try {
|
|
@@ -65,6 +73,6 @@ function parseToObj(str) {
|
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
export { $err, $isStr, $ok, $stringifyError, ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, __export, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, parseToObj, stringifyObj };
|
|
69
|
-
//# sourceMappingURL=chunk-
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
export { $err, $isStr, $ok, $stringifyError, ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, __export, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, isNodeKey, isWebApiKey, parseToObj, stringifyObj };
|
|
77
|
+
//# sourceMappingURL=chunk-V7MXS2IX.js.map
|
|
78
|
+
//# sourceMappingURL=chunk-V7MXS2IX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/utils.ts"],"names":[],"mappings":";;;;;;;;;AAeO,SAAS,IAAO,MAAA,EAAuB;AAC5C,EAAA,IAAI,MAAA,CAAO,MAAM,CAAA,EAAG,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,GAAI,MAAA,EAAsB;AACtE,EAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,MAAA,EAAO;AACjC;AAIO,SAAS,KAAK,SAAA,EAAgF;AACnG,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,KAAA;AAAA,IACT,OACE,KAAA,IAAS,SAAA,IAAa,UAAU,SAAA,GAC5B,EAAE,SAAS,SAAA,CAAU,GAAA,EAAK,aAAa,SAAA,CAAU,IAAA,KACjD,EAAE,OAAA,EAAS,UAAU,OAAA,EAAS,WAAA,EAAa,UAAU,WAAA;AAAY,GACzE;AACF;AAEO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;;;AChCO,IAAM,cAAA,GAAiB;AACvB,IAAM,iBAAA,GAAoB;AAE1B,IAAM,gBAAA,GAAmB,OAAO,MAAA,CAAO;AAAA,EAC5C,OAAA,EAAS,6DAAA;AAAA,EAC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k-V7MXS2IX.js","sourcesContent":["import { $isObj } from './utils';\r\n\r\nexport interface ResultErr {\r\n readonly message: string;\r\n readonly description: string;\r\n}\r\n\r\nexport type Result<T, E = ResultErr> = T extends object\r\n ?\r\n | ({ readonly [K in keyof T]: T[K] } & { readonly success: true; readonly error?: undefined })\r\n | ({ readonly [K in keyof T]?: undefined } & { readonly success: false; readonly error: E })\r\n :\r\n | { readonly success: true; readonly result: T; readonly error?: undefined }\r\n | { readonly success: false; readonly error: E; readonly result?: undefined };\r\n\r\nexport function $ok<T>(result?: T): Result<T> {\r\n if ($isObj(result)) return { success: true, ...(result as T & object) } as Result<T>;\r\n return { success: true, result } as Result<T>;\r\n}\r\n\r\nexport function $err(typeOrErr: { msg: string; desc: string }): Result<never, ResultErr>;\r\nexport function $err(typeOrErr: ResultErr): Result<never, ResultErr>;\r\nexport function $err(typeOrErr: { msg: string; desc: string } | ResultErr): Result<never, ResultErr> {\r\n return {\r\n success: false,\r\n error:\r\n 'msg' in typeOrErr && 'desc' in typeOrErr\r\n ? { message: typeOrErr.msg, description: typeOrErr.desc }\r\n : { message: typeOrErr.message, description: typeOrErr.description },\r\n } as Result<never, ResultErr>;\r\n}\r\n\r\nexport function $stringifyError(error: unknown): string {\r\n if (error instanceof Error) return error.message;\r\n if (typeof error === 'string') return error;\r\n return String(error);\r\n}\r\n","import nodeCrypto from 'node:crypto';\r\nimport type { WebApiKey } from '~/types';\r\nimport { $err, $ok, $stringifyError, type Result } from './error';\r\n\r\nexport const NODE_ALGORITHM = 'aes-256-gcm';\r\nexport const WEB_API_ALGORITHM = 'AES-GCM';\r\n\r\nexport const ENCRYPTION_REGEX = Object.freeze({\r\n GENERAL: /^(?:[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)?\\.)$/,\r\n NODE: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n WEB_API: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n});\r\n\r\nexport function isInEncryptionFormat(data: string): boolean {\r\n return typeof data === 'string' && ENCRYPTION_REGEX.GENERAL.test(data);\r\n}\r\n\r\nexport function isInNodeEncryptionFormat(data: string): boolean {\r\n return typeof data === 'string' && ENCRYPTION_REGEX.NODE.test(data);\r\n}\r\n\r\nexport function isInWebApiEncryptionFormat(data: string): boolean {\r\n return typeof data === 'string' && ENCRYPTION_REGEX.WEB_API.test(data);\r\n}\r\n\r\nexport function $isStr(value: unknown, min = 0): value is string {\r\n return (value !== null || value !== undefined) && typeof value === 'string' && value.trim().length >= min;\r\n}\r\n\r\nexport function $isObj(value: unknown): value is Record<string, unknown> {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n value !== undefined &&\r\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)\r\n );\r\n}\r\n\r\nexport function isWebApiKey(key: unknown): key is WebApiKey {\r\n return (\r\n key !== null &&\r\n key !== undefined &&\r\n typeof key === 'object' &&\r\n 'type' in key &&\r\n typeof key.type === 'string' &&\r\n 'algorithm' in key &&\r\n typeof key.algorithm === 'object' &&\r\n 'extractable' in key &&\r\n typeof key.extractable === 'boolean' &&\r\n 'usages' in key &&\r\n Array.isArray(key.usages) &&\r\n key.usages.every((usage) => typeof usage === 'string')\r\n );\r\n}\r\n\r\nexport function isNodeKey(key: unknown): key is nodeCrypto.KeyObject {\r\n return key instanceof nodeCrypto.KeyObject;\r\n}\r\n\r\nexport function stringifyObj(obj: Record<string, unknown>): Result<string> {\r\n if (!$isObj(obj)) return $err({ msg: 'Invalid object', desc: 'Input is not a plain object' });\r\n\r\n try {\r\n return $ok(JSON.stringify(obj));\r\n } catch (error) {\r\n return $err({ msg: 'Stringify error', desc: $stringifyError(error) });\r\n }\r\n}\r\n\r\nexport function parseToObj(str: string): Result<{ result: Record<string, unknown> }> {\r\n if (!$isStr(str)) return $err({ msg: 'Invalid input', desc: 'Input is not a valid string' });\r\n\r\n try {\r\n const obj = JSON.parse(str);\r\n if (!$isObj(obj)) {\r\n return $err({ msg: 'Invalid object format', desc: 'Parsed data is not a plain object' });\r\n }\r\n\r\n return $ok({ result: obj });\r\n } catch (error) {\r\n return $err({ msg: 'Invalid format', desc: $stringifyError(error) });\r\n }\r\n}\r\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,90 +1,94 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkRWMHFO5T_cjs = require('./chunk-RWMHFO5T.cjs');
|
|
4
|
+
var chunk3E7B77NS_cjs = require('./chunk-3E7B77NS.cjs');
|
|
5
|
+
var chunkGAAPPJTK_cjs = require('./chunk-GAAPPJTK.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "createSecretKey", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkRWMHFO5T_cjs.createSecretKey; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "decode", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkRWMHFO5T_cjs.decode; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "decrypt", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkRWMHFO5T_cjs.decrypt; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "decryptObj", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkRWMHFO5T_cjs.decryptObj; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "encode", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkRWMHFO5T_cjs.encode; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "encrypt", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkRWMHFO5T_cjs.encrypt; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "encryptObj", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkRWMHFO5T_cjs.encryptObj; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "generateUuid", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkRWMHFO5T_cjs.generateUuid; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "hash", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, "isNodeKey", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return chunkRF735UV3_cjs.isNodeKey; }
|
|
43
|
+
get: function () { return chunkRWMHFO5T_cjs.hash; }
|
|
48
44
|
});
|
|
49
45
|
Object.defineProperty(exports, "nodeKit", {
|
|
50
46
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkRWMHFO5T_cjs.export_exports; }
|
|
52
48
|
});
|
|
53
49
|
Object.defineProperty(exports, "webApiKit", {
|
|
54
50
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunk3E7B77NS_cjs.export_exports; }
|
|
56
52
|
});
|
|
57
53
|
Object.defineProperty(exports, "ENCRYPTION_REGEX", {
|
|
58
54
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkGAAPPJTK_cjs.ENCRYPTION_REGEX; }
|
|
60
56
|
});
|
|
61
57
|
Object.defineProperty(exports, "NODE_ALGORITHM", {
|
|
62
58
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkGAAPPJTK_cjs.NODE_ALGORITHM; }
|
|
64
60
|
});
|
|
65
61
|
Object.defineProperty(exports, "WEB_API_ALGORITHM", {
|
|
66
62
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkGAAPPJTK_cjs.WEB_API_ALGORITHM; }
|
|
68
64
|
});
|
|
69
65
|
Object.defineProperty(exports, "isInEncryptionFormat", {
|
|
70
66
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunkGAAPPJTK_cjs.isInEncryptionFormat; }
|
|
72
68
|
});
|
|
73
69
|
Object.defineProperty(exports, "isInNodeEncryptionFormat", {
|
|
74
70
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkGAAPPJTK_cjs.isInNodeEncryptionFormat; }
|
|
76
72
|
});
|
|
77
73
|
Object.defineProperty(exports, "isInWebApiEncryptionFormat", {
|
|
78
74
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkGAAPPJTK_cjs.isInWebApiEncryptionFormat; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "isNodeKey", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return chunkGAAPPJTK_cjs.isNodeKey; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "isWebApiKey", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return chunkGAAPPJTK_cjs.isWebApiKey; }
|
|
80
84
|
});
|
|
81
85
|
Object.defineProperty(exports, "parseToObj", {
|
|
82
86
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunkGAAPPJTK_cjs.parseToObj; }
|
|
84
88
|
});
|
|
85
89
|
Object.defineProperty(exports, "stringifyObj", {
|
|
86
90
|
enumerable: true,
|
|
87
|
-
get: function () { return
|
|
91
|
+
get: function () { return chunkGAAPPJTK_cjs.stringifyObj; }
|
|
88
92
|
});
|
|
89
93
|
//# sourceMappingURL=index.cjs.map
|
|
90
94
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM,
|
|
2
|
-
import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash
|
|
3
|
-
import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1
|
|
1
|
+
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, e as NodeKey, W as WEB_API_ALGORITHM, f as WebApiKey, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, b as isInWebApiEncryptionFormat, c as isNodeKey, d as isWebApiKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.cjs';
|
|
2
|
+
import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './node.cjs';
|
|
3
|
+
import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1 } from './web-api.cjs';
|
|
4
4
|
import 'node:crypto';
|
|
5
5
|
import 'node:buffer';
|
|
6
6
|
|
|
@@ -13,14 +13,12 @@ declare const _export$1_encrypt: typeof encrypt;
|
|
|
13
13
|
declare const _export$1_encryptObj: typeof encryptObj;
|
|
14
14
|
declare const _export$1_generateUuid: typeof generateUuid;
|
|
15
15
|
declare const _export$1_hash: typeof hash;
|
|
16
|
-
declare const _export$1_isNodeKey: typeof isNodeKey;
|
|
17
16
|
declare namespace _export$1 {
|
|
18
|
-
export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash
|
|
17
|
+
export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash };
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
declare const _export_isWebApiKey: typeof isWebApiKey;
|
|
22
20
|
declare namespace _export {
|
|
23
|
-
export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash
|
|
21
|
+
export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash };
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash,
|
|
24
|
+
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, _export$1 as nodeKit, _export as webApiKit };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM,
|
|
2
|
-
import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash
|
|
3
|
-
import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1
|
|
1
|
+
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, e as NodeKey, W as WEB_API_ALGORITHM, f as WebApiKey, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, b as isInWebApiEncryptionFormat, c as isNodeKey, d as isWebApiKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.js';
|
|
2
|
+
import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './node.js';
|
|
3
|
+
import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1 } from './web-api.js';
|
|
4
4
|
import 'node:crypto';
|
|
5
5
|
import 'node:buffer';
|
|
6
6
|
|
|
@@ -13,14 +13,12 @@ declare const _export$1_encrypt: typeof encrypt;
|
|
|
13
13
|
declare const _export$1_encryptObj: typeof encryptObj;
|
|
14
14
|
declare const _export$1_generateUuid: typeof generateUuid;
|
|
15
15
|
declare const _export$1_hash: typeof hash;
|
|
16
|
-
declare const _export$1_isNodeKey: typeof isNodeKey;
|
|
17
16
|
declare namespace _export$1 {
|
|
18
|
-
export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash
|
|
17
|
+
export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash };
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
declare const _export_isWebApiKey: typeof isWebApiKey;
|
|
22
20
|
declare namespace _export {
|
|
23
|
-
export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash
|
|
21
|
+
export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash };
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash,
|
|
24
|
+
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, _export$1 as nodeKit, _export as webApiKit };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash,
|
|
2
|
-
export { export_exports as webApiKit } from './chunk-
|
|
3
|
-
export { ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, parseToObj, stringifyObj } from './chunk-
|
|
1
|
+
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, export_exports as nodeKit } from './chunk-FVUCOHD7.js';
|
|
2
|
+
export { export_exports as webApiKit } from './chunk-2VWYNA5O.js';
|
|
3
|
+
export { ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, isNodeKey, isWebApiKey, parseToObj, stringifyObj } from './chunk-V7MXS2IX.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/node.cjs
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkRWMHFO5T_cjs = require('./chunk-RWMHFO5T.cjs');
|
|
4
|
+
var chunkGAAPPJTK_cjs = require('./chunk-GAAPPJTK.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "createSecretKey", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkRWMHFO5T_cjs.createSecretKey; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "decode", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkRWMHFO5T_cjs.decode; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "decrypt", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkRWMHFO5T_cjs.decrypt; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "decryptObj", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkRWMHFO5T_cjs.decryptObj; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "encode", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkRWMHFO5T_cjs.encode; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "encrypt", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkRWMHFO5T_cjs.encrypt; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encryptObj", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkRWMHFO5T_cjs.encryptObj; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "generateUuid", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkRWMHFO5T_cjs.generateUuid; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "hash", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "isNodeKey", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () { return chunkRF735UV3_cjs.isNodeKey; }
|
|
42
|
+
get: function () { return chunkRWMHFO5T_cjs.hash; }
|
|
47
43
|
});
|
|
48
44
|
Object.defineProperty(exports, "ENCRYPTION_REGEX", {
|
|
49
45
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkGAAPPJTK_cjs.ENCRYPTION_REGEX; }
|
|
51
47
|
});
|
|
52
48
|
Object.defineProperty(exports, "NODE_ALGORITHM", {
|
|
53
49
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkGAAPPJTK_cjs.NODE_ALGORITHM; }
|
|
55
51
|
});
|
|
56
52
|
Object.defineProperty(exports, "isInEncryptionFormat", {
|
|
57
53
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkGAAPPJTK_cjs.isInEncryptionFormat; }
|
|
59
55
|
});
|
|
60
56
|
Object.defineProperty(exports, "isInNodeEncryptionFormat", {
|
|
61
57
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkGAAPPJTK_cjs.isInNodeEncryptionFormat; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "isNodeKey", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkGAAPPJTK_cjs.isNodeKey; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "parseToObj", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkGAAPPJTK_cjs.parseToObj; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "stringifyObj", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkGAAPPJTK_cjs.stringifyObj; }
|
|
71
71
|
});
|
|
72
72
|
//# sourceMappingURL=node.cjs.map
|
|
73
73
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, p as parseToObj, s as stringifyObj } from './
|
|
1
|
+
import { g as EncodingFormat, R as Result, e as NodeKey } from './utils-Bryp07ny.cjs';
|
|
2
|
+
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, c as isNodeKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.cjs';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
|
-
import
|
|
4
|
+
import 'node:crypto';
|
|
5
5
|
|
|
6
6
|
declare function encode(data: string, format?: EncodingFormat): Result<{
|
|
7
7
|
bytes: Buffer;
|
|
@@ -9,7 +9,6 @@ declare function encode(data: string, format?: EncodingFormat): Result<{
|
|
|
9
9
|
declare function decode(data: Buffer, format?: EncodingFormat): Result<string>;
|
|
10
10
|
|
|
11
11
|
declare function generateUuid(): Result<string>;
|
|
12
|
-
declare function isNodeKey(key: unknown): key is nodeCrypto.KeyObject;
|
|
13
12
|
declare function hash(data: string): Result<string>;
|
|
14
13
|
declare function createSecretKey(key: string | NodeKey): Result<{
|
|
15
14
|
secretKey: NodeKey;
|
|
@@ -21,4 +20,4 @@ declare function decryptObj(encrypted: string, secretKey: NodeKey): Result<{
|
|
|
21
20
|
result: Record<string, unknown>;
|
|
22
21
|
}>;
|
|
23
22
|
|
|
24
|
-
export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash
|
|
23
|
+
export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, p as parseToObj, s as stringifyObj } from './
|
|
1
|
+
import { g as EncodingFormat, R as Result, e as NodeKey } from './utils-Bryp07ny.js';
|
|
2
|
+
export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, c as isNodeKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.js';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
|
-
import
|
|
4
|
+
import 'node:crypto';
|
|
5
5
|
|
|
6
6
|
declare function encode(data: string, format?: EncodingFormat): Result<{
|
|
7
7
|
bytes: Buffer;
|
|
@@ -9,7 +9,6 @@ declare function encode(data: string, format?: EncodingFormat): Result<{
|
|
|
9
9
|
declare function decode(data: Buffer, format?: EncodingFormat): Result<string>;
|
|
10
10
|
|
|
11
11
|
declare function generateUuid(): Result<string>;
|
|
12
|
-
declare function isNodeKey(key: unknown): key is nodeCrypto.KeyObject;
|
|
13
12
|
declare function hash(data: string): Result<string>;
|
|
14
13
|
declare function createSecretKey(key: string | NodeKey): Result<{
|
|
15
14
|
secretKey: NodeKey;
|
|
@@ -21,4 +20,4 @@ declare function decryptObj(encrypted: string, secretKey: NodeKey): Result<{
|
|
|
21
20
|
result: Record<string, unknown>;
|
|
22
21
|
}>;
|
|
23
22
|
|
|
24
|
-
export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash
|
|
23
|
+
export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash };
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash
|
|
2
|
-
export { ENCRYPTION_REGEX, NODE_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, parseToObj, stringifyObj } from './chunk-
|
|
1
|
+
export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './chunk-FVUCOHD7.js';
|
|
2
|
+
export { ENCRYPTION_REGEX, NODE_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, isNodeKey, parseToObj, stringifyObj } from './chunk-V7MXS2IX.js';
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
|
4
4
|
//# sourceMappingURL=node.js.map
|