cipher-kit 1.0.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -1
- package/dist/chunk-4IOWANDJ.cjs +376 -0
- package/dist/chunk-4IOWANDJ.cjs.map +1 -0
- package/dist/chunk-D656BYPA.cjs +133 -0
- package/dist/chunk-D656BYPA.cjs.map +1 -0
- package/dist/chunk-IYMK2O3K.cjs +473 -0
- package/dist/chunk-IYMK2O3K.cjs.map +1 -0
- package/dist/chunk-J5YHHXDC.js +108 -0
- package/dist/chunk-J5YHHXDC.js.map +1 -0
- package/dist/chunk-M7V4HSRH.js +347 -0
- package/dist/chunk-M7V4HSRH.js.map +1 -0
- package/dist/chunk-N2ZI2CIT.js +448 -0
- package/dist/chunk-N2ZI2CIT.js.map +1 -0
- package/dist/export-Bh49U7Yf.d.ts +254 -0
- package/dist/export-CrT_Y2Cy.d.cts +254 -0
- package/dist/export-VUQLKGvM.d.ts +255 -0
- package/dist/export-VtQvdOuA.d.cts +255 -0
- package/dist/index.cjs +86 -38
- package/dist/index.d.cts +3 -22
- package/dist/index.d.ts +3 -22
- package/dist/index.js +3 -3
- package/dist/node.cjs +84 -28
- package/dist/node.d.cts +3 -22
- package/dist/node.d.ts +3 -22
- package/dist/node.js +2 -2
- package/dist/validate-CPWPEEAt.d.cts +86 -0
- package/dist/validate-CPWPEEAt.d.ts +86 -0
- package/dist/web-api.cjs +84 -28
- package/dist/web-api.d.cts +2 -21
- package/dist/web-api.d.ts +2 -21
- package/dist/web-api.js +2 -2
- package/package.json +9 -5
- package/dist/chunk-A7EF2XVZ.js +0 -141
- package/dist/chunk-A7EF2XVZ.js.map +0 -1
- package/dist/chunk-BQTBKP4M.js +0 -214
- package/dist/chunk-BQTBKP4M.js.map +0 -1
- package/dist/chunk-PDLO733W.cjs +0 -225
- package/dist/chunk-PDLO733W.cjs.map +0 -1
- package/dist/chunk-QGYPW6G5.cjs +0 -156
- package/dist/chunk-QGYPW6G5.cjs.map +0 -1
- package/dist/chunk-SBXDW4MY.cjs +0 -99
- package/dist/chunk-SBXDW4MY.cjs.map +0 -1
- package/dist/chunk-THMEBIZB.js +0 -79
- package/dist/chunk-THMEBIZB.js.map +0 -1
- package/dist/utils-Bryp07ny.d.cts +0 -48
- package/dist/utils-Bryp07ny.d.ts +0 -48
package/dist/chunk-THMEBIZB.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import nodeCrypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __export = (target, all) => {
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// src/error.ts
|
|
10
|
-
function $ok(result) {
|
|
11
|
-
if ($isObj(result)) return { success: true, ...result };
|
|
12
|
-
return { success: true, result };
|
|
13
|
-
}
|
|
14
|
-
function $err(err) {
|
|
15
|
-
return {
|
|
16
|
-
success: false,
|
|
17
|
-
error: {
|
|
18
|
-
message: "msg" in err ? err.msg : err.message,
|
|
19
|
-
description: "desc" in err ? err.desc : err.description
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function $stringifyError(error) {
|
|
24
|
-
if (error instanceof Error) return error.message;
|
|
25
|
-
if (typeof error === "string") return error;
|
|
26
|
-
return String(error);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/utils.ts
|
|
30
|
-
var NODE_ALGORITHM = "aes-256-gcm";
|
|
31
|
-
var WEB_API_ALGORITHM = "AES-GCM";
|
|
32
|
-
var ENCRYPTION_REGEX = Object.freeze({
|
|
33
|
-
GENERAL: /^(?:[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?\.)$/,
|
|
34
|
-
NODE: /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)\.$/,
|
|
35
|
-
WEB_API: /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)\.$/
|
|
36
|
-
});
|
|
37
|
-
function isInEncryptionFormat(data) {
|
|
38
|
-
return typeof data === "string" && ENCRYPTION_REGEX.GENERAL.test(data);
|
|
39
|
-
}
|
|
40
|
-
function isInNodeEncryptionFormat(data) {
|
|
41
|
-
return typeof data === "string" && ENCRYPTION_REGEX.NODE.test(data);
|
|
42
|
-
}
|
|
43
|
-
function isInWebApiEncryptionFormat(data) {
|
|
44
|
-
return typeof data === "string" && ENCRYPTION_REGEX.WEB_API.test(data);
|
|
45
|
-
}
|
|
46
|
-
function $isStr(value, min = 1) {
|
|
47
|
-
return value !== null && value !== void 0 && typeof value === "string" && value.trim().length >= min;
|
|
48
|
-
}
|
|
49
|
-
function $isObj(value) {
|
|
50
|
-
return typeof value === "object" && value !== null && value !== void 0 && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
51
|
-
}
|
|
52
|
-
function isWebApiKey(key) {
|
|
53
|
-
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");
|
|
54
|
-
}
|
|
55
|
-
function isNodeKey(key) {
|
|
56
|
-
return key instanceof nodeCrypto.KeyObject;
|
|
57
|
-
}
|
|
58
|
-
function stringifyObj(obj) {
|
|
59
|
-
try {
|
|
60
|
-
if (!$isObj(obj)) return $err({ msg: "Invalid object", desc: "Input is not a plain object" });
|
|
61
|
-
return $ok(JSON.stringify(obj));
|
|
62
|
-
} catch (error) {
|
|
63
|
-
return $err({ msg: "Stringify error", desc: $stringifyError(error) });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function parseToObj(str) {
|
|
67
|
-
try {
|
|
68
|
-
if (!$isStr(str)) return $err({ msg: "Invalid input", desc: "Input is not a valid string" });
|
|
69
|
-
const obj = JSON.parse(str);
|
|
70
|
-
if (!$isObj(obj)) return $err({ msg: "Invalid object format", desc: "Parsed data is not a plain object" });
|
|
71
|
-
return $ok({ result: obj });
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return $err({ msg: "Invalid format", desc: $stringifyError(error) });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { $err, $isStr, $ok, $stringifyError, ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, __export, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, isNodeKey, isWebApiKey, parseToObj, stringifyObj };
|
|
78
|
-
//# sourceMappingURL=chunk-THMEBIZB.js.map
|
|
79
|
-
//# sourceMappingURL=chunk-THMEBIZB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,GAAA,EAA0E;AAC7F,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,KAAA;AAAA,IACT,KAAA,EAAO;AAAA,MACL,OAAA,EAAS,KAAA,IAAS,GAAA,GAAM,GAAA,CAAI,MAAM,GAAA,CAAI,OAAA;AAAA,MACtC,WAAA,EAAa,MAAA,IAAU,GAAA,GAAM,GAAA,CAAI,OAAO,GAAA,CAAI;AAAA;AAC9C,GACF;AACF;AAEO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAA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EAAQ,GAAA,EAAK,CAAA;AAAA,EAC5B,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,gBAAA,EAAkB,MAAM,eAAA,CAAgB,KAAK,GAAG,CAAA;AAAA,EACrE;AACF","file":"chunk-THMEBIZB.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(err: { msg: string; desc: string }): Result<never, ResultErr>;\r\nexport function $err(err: ResultErr): Result<never, ResultErr>;\r\nexport function $err(err: { msg: string; desc: string } | ResultErr): Result<never, ResultErr> {\r\n return {\r\n success: false,\r\n error: {\r\n message: 'msg' in err ? err.msg : err.message,\r\n description: 'desc' in err ? err.desc : err.description,\r\n },\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 = 1): 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 try {\r\n if (!$isObj(obj)) return $err({ msg: 'Invalid object', desc: 'Input is not a plain object' });\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 try {\r\n if (!$isStr(str)) return $err({ msg: 'Invalid input', desc: 'Input is not a valid string' });\r\n const obj = JSON.parse(str);\r\n if (!$isObj(obj)) return $err({ msg: 'Invalid object format', desc: 'Parsed data is not a plain object' });\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"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import nodeCrypto, { webcrypto } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
type WebApiKey = webcrypto.CryptoKey;
|
|
4
|
-
type NodeKey = nodeCrypto.KeyObject;
|
|
5
|
-
type EncodingFormat = 'base64' | 'base64url' | 'hex' | 'utf8';
|
|
6
|
-
|
|
7
|
-
interface ResultErr {
|
|
8
|
-
readonly message: string;
|
|
9
|
-
readonly description: string;
|
|
10
|
-
}
|
|
11
|
-
type Result<T, E = ResultErr> = T extends object ? ({
|
|
12
|
-
readonly [K in keyof T]: T[K];
|
|
13
|
-
} & {
|
|
14
|
-
readonly success: true;
|
|
15
|
-
readonly error?: undefined;
|
|
16
|
-
}) | ({
|
|
17
|
-
readonly [K in keyof T]?: undefined;
|
|
18
|
-
} & {
|
|
19
|
-
readonly success: false;
|
|
20
|
-
readonly error: E;
|
|
21
|
-
}) : {
|
|
22
|
-
readonly success: true;
|
|
23
|
-
readonly result: T;
|
|
24
|
-
readonly error?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
readonly success: false;
|
|
27
|
-
readonly error: E;
|
|
28
|
-
readonly result?: undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
declare const NODE_ALGORITHM = "aes-256-gcm";
|
|
32
|
-
declare const WEB_API_ALGORITHM = "AES-GCM";
|
|
33
|
-
declare const ENCRYPTION_REGEX: Readonly<{
|
|
34
|
-
GENERAL: RegExp;
|
|
35
|
-
NODE: RegExp;
|
|
36
|
-
WEB_API: RegExp;
|
|
37
|
-
}>;
|
|
38
|
-
declare function isInEncryptionFormat(data: string): boolean;
|
|
39
|
-
declare function isInNodeEncryptionFormat(data: string): boolean;
|
|
40
|
-
declare function isInWebApiEncryptionFormat(data: string): boolean;
|
|
41
|
-
declare function isWebApiKey(key: unknown): key is WebApiKey;
|
|
42
|
-
declare function isNodeKey(key: unknown): key is nodeCrypto.KeyObject;
|
|
43
|
-
declare function stringifyObj(obj: Record<string, unknown>): Result<string>;
|
|
44
|
-
declare function parseToObj(str: string): Result<{
|
|
45
|
-
result: Record<string, unknown>;
|
|
46
|
-
}>;
|
|
47
|
-
|
|
48
|
-
export { ENCRYPTION_REGEX as E, NODE_ALGORITHM as N, type Result as R, WEB_API_ALGORITHM as W, isInNodeEncryptionFormat as a, isInWebApiEncryptionFormat as b, isNodeKey as c, isWebApiKey as d, type NodeKey as e, type WebApiKey as f, type EncodingFormat as g, isInEncryptionFormat as i, parseToObj as p, stringifyObj as s };
|
package/dist/utils-Bryp07ny.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import nodeCrypto, { webcrypto } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
type WebApiKey = webcrypto.CryptoKey;
|
|
4
|
-
type NodeKey = nodeCrypto.KeyObject;
|
|
5
|
-
type EncodingFormat = 'base64' | 'base64url' | 'hex' | 'utf8';
|
|
6
|
-
|
|
7
|
-
interface ResultErr {
|
|
8
|
-
readonly message: string;
|
|
9
|
-
readonly description: string;
|
|
10
|
-
}
|
|
11
|
-
type Result<T, E = ResultErr> = T extends object ? ({
|
|
12
|
-
readonly [K in keyof T]: T[K];
|
|
13
|
-
} & {
|
|
14
|
-
readonly success: true;
|
|
15
|
-
readonly error?: undefined;
|
|
16
|
-
}) | ({
|
|
17
|
-
readonly [K in keyof T]?: undefined;
|
|
18
|
-
} & {
|
|
19
|
-
readonly success: false;
|
|
20
|
-
readonly error: E;
|
|
21
|
-
}) : {
|
|
22
|
-
readonly success: true;
|
|
23
|
-
readonly result: T;
|
|
24
|
-
readonly error?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
readonly success: false;
|
|
27
|
-
readonly error: E;
|
|
28
|
-
readonly result?: undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
declare const NODE_ALGORITHM = "aes-256-gcm";
|
|
32
|
-
declare const WEB_API_ALGORITHM = "AES-GCM";
|
|
33
|
-
declare const ENCRYPTION_REGEX: Readonly<{
|
|
34
|
-
GENERAL: RegExp;
|
|
35
|
-
NODE: RegExp;
|
|
36
|
-
WEB_API: RegExp;
|
|
37
|
-
}>;
|
|
38
|
-
declare function isInEncryptionFormat(data: string): boolean;
|
|
39
|
-
declare function isInNodeEncryptionFormat(data: string): boolean;
|
|
40
|
-
declare function isInWebApiEncryptionFormat(data: string): boolean;
|
|
41
|
-
declare function isWebApiKey(key: unknown): key is WebApiKey;
|
|
42
|
-
declare function isNodeKey(key: unknown): key is nodeCrypto.KeyObject;
|
|
43
|
-
declare function stringifyObj(obj: Record<string, unknown>): Result<string>;
|
|
44
|
-
declare function parseToObj(str: string): Result<{
|
|
45
|
-
result: Record<string, unknown>;
|
|
46
|
-
}>;
|
|
47
|
-
|
|
48
|
-
export { ENCRYPTION_REGEX as E, NODE_ALGORITHM as N, type Result as R, WEB_API_ALGORITHM as W, isInNodeEncryptionFormat as a, isInWebApiEncryptionFormat as b, isNodeKey as c, isWebApiKey as d, type NodeKey as e, type WebApiKey as f, type EncodingFormat as g, isInEncryptionFormat as i, parseToObj as p, stringifyObj as s };
|