@happyvertical/encryption 0.111.5 → 0.111.7
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/AGENT.md +9 -0
- package/README.md +73 -0
- package/dist/chunks/base-COUQhj5x.js +100 -0
- package/dist/chunks/base-COUQhj5x.js.map +1 -0
- package/dist/chunks/errors-Q_wX_NMz.js +143 -0
- package/dist/chunks/errors-Q_wX_NMz.js.map +1 -0
- package/dist/chunks/{nacl-BElkPprm.js → nacl-Ct71p1KK.js} +3 -2
- package/dist/chunks/{nacl-BElkPprm.js.map → nacl-Ct71p1KK.js.map} +1 -1
- package/dist/chunks/{node-Bg7R5Icq.js → node-9IJG40yb.js} +3 -2
- package/dist/chunks/{node-Bg7R5Icq.js.map → node-9IJG40yb.js.map} +1 -1
- package/dist/chunks/{pgp-rwlJTWLC.js → pgp-Dss_W-gt.js} +3 -2
- package/dist/chunks/{pgp-rwlJTWLC.js.map → pgp-Dss_W-gt.js.map} +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/vault-snapshot.d.ts +23 -0
- package/dist/vault-snapshot.d.ts.map +1 -0
- package/dist/vault-snapshot.js +97 -0
- package/dist/vault-snapshot.js.map +1 -0
- package/package.json +8 -3
- package/vault-snapshot-v1-vectors.json +23 -0
- package/dist/chunks/base-qiu-WiZ0.js +0 -239
- package/dist/chunks/base-qiu-WiZ0.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-snapshot.js","names":[],"sources":["../src/vault-snapshot.ts"],"sourcesContent":["import { randomBytes, timingSafeEqual } from 'node:crypto';\nimport { deflateSync, type Inflate, inflateSync } from 'node:zlib';\nimport nacl from 'tweetnacl';\nimport {\n DecryptError,\n FormatError,\n InvalidKeyError,\n KeyNotFoundError,\n} from './shared/errors.js';\n\nconst MAGIC = Buffer.from('HVSE');\nconst VERSION = 1;\nconst ALGORITHM = 1; // XSalsa20-Poly1305 secretbox\nconst KEY_ID_OFFSET = 7;\nconst NONCE_OFFSET = KEY_ID_OFFSET + 16;\nconst HEADER_BYTES = NONCE_OFFSET + nacl.secretbox.nonceLength;\nconst MAX_ID_BYTES = 255;\nconst MIN_CONTEXT_BYTES = 12; // two length bytes, two nonempty IDs, uint64 sequence\nconst MAX_CONTEXT_BYTES = 2 + 2 * MAX_ID_BYTES + 8;\nconst MAX_SNAPSHOT_BYTES = 8 * 1024 * 1024;\nconst MAX_ENCODED_BYTES = MAX_SNAPSHOT_BYTES + 64 * 1024;\nconst MAX_ENVELOPE_BYTES =\n 2 * HEADER_BYTES +\n nacl.secretbox.overheadLength +\n MAX_CONTEXT_BYTES +\n MAX_ENCODED_BYTES;\nconst MAX_SEQUENCE = (1n << 64n) - 1n;\n\nexport interface VaultSnapshotContext {\n accountId: string;\n deviceId: string;\n sequence: bigint;\n}\n\nexport interface SealVaultSnapshotOptions {\n key: Uint8Array;\n /** Opaque 16-byte identifier represented by 32 lowercase hex digits. */\n keyId: string;\n context: VaultSnapshotContext;\n compression?: 'none' | 'zlib';\n}\n\nexport interface OpenVaultSnapshotOptions {\n /** Trusted restore context, supplied independently of the envelope. */\n context: VaultSnapshotContext;\n /** Called once with the untrusted key ID, scoped by the caller to this account. */\n resolveKey: (keyId: string) => Uint8Array | undefined;\n}\n\nfunction encodeId(id: string): Buffer {\n if (typeof id !== 'string' || id.length === 0 || id.length > MAX_ID_BYTES) {\n throw new FormatError('Invalid vault snapshot context ID');\n }\n const bytes = Buffer.from(id, 'utf8');\n if (bytes.length > MAX_ID_BYTES || bytes.toString('utf8') !== id) {\n throw new FormatError('Invalid vault snapshot context ID');\n }\n return bytes;\n}\n\nfunction encodeContext(context: VaultSnapshotContext): Buffer {\n const { accountId, deviceId, sequence } = context;\n const account = encodeId(accountId);\n const device = encodeId(deviceId);\n if (\n typeof sequence !== 'bigint' ||\n sequence < 0n ||\n sequence > MAX_SEQUENCE\n ) {\n throw new FormatError('Invalid vault snapshot sequence');\n }\n const counter = Buffer.alloc(8);\n counter.writeBigUInt64BE(sequence);\n return Buffer.concat([\n Buffer.of(account.length),\n account,\n Buffer.of(device.length),\n device,\n counter,\n ]);\n}\n\nfunction checkKey(key: Uint8Array): void {\n if (!(key instanceof Uint8Array) || key.length !== nacl.secretbox.keyLength) {\n throw new InvalidKeyError('Vault snapshot key must be 32 bytes');\n }\n}\n\n/** Seal a bounded snapshot with a fresh cryptographically random nonce. */\nexport function sealVaultSnapshot(\n snapshot: Uint8Array,\n options: SealVaultSnapshotOptions,\n): Uint8Array {\n const { key, keyId, context, compression = 'none' } = options;\n checkKey(key);\n if (\n !(snapshot instanceof Uint8Array) ||\n snapshot.length > MAX_SNAPSHOT_BYTES\n ) {\n throw new FormatError('Invalid vault snapshot size');\n }\n if (\n typeof keyId !== 'string' ||\n keyId.length !== 32 ||\n /[^0-9a-f]/.test(keyId)\n ) {\n throw new FormatError('Invalid vault snapshot key ID');\n }\n if (compression !== 'none' && compression !== 'zlib') {\n throw new FormatError('Unsupported vault snapshot compression');\n }\n const contextBytes = encodeContext(context);\n const nonce = randomBytes(nacl.secretbox.nonceLength);\n const header = Buffer.concat([\n MAGIC,\n Buffer.of(VERSION, ALGORITHM, compression === 'zlib' ? 1 : 0),\n Buffer.from(keyId, 'hex'),\n nonce,\n ]);\n const payload =\n compression === 'zlib'\n ? deflateSync(snapshot, { maxOutputLength: MAX_ENCODED_BYTES })\n : snapshot;\n // Secretbox has no AAD. Its authenticated plaintext starts with an exact\n // copy of the wire header followed by the private context.\n const message = Buffer.concat([header, contextBytes, payload]);\n return Buffer.concat([header, nacl.secretbox(message, nonce, key)]);\n}\n\n/** Authenticate the header and context before decoding any snapshot bytes. */\nexport function openVaultSnapshot(\n envelope: Uint8Array,\n { context, resolveKey }: OpenVaultSnapshotOptions,\n): Uint8Array {\n const minBytes =\n 2 * HEADER_BYTES + MIN_CONTEXT_BYTES + nacl.secretbox.overheadLength;\n if (\n !(envelope instanceof Uint8Array) ||\n envelope.length < minBytes ||\n envelope.length > MAX_ENVELOPE_BYTES\n ) {\n throw new FormatError('Invalid vault snapshot envelope size');\n }\n // Keep the same bytes across the caller's lookup, even if it mutates the input.\n const bytes = Buffer.from(envelope);\n if (\n !bytes.subarray(0, MAGIC.length).equals(MAGIC) ||\n bytes[4] !== VERSION ||\n bytes[5] !== ALGORITHM ||\n (bytes[6] !== 0 && bytes[6] !== 1)\n ) {\n throw new FormatError('Unsupported vault snapshot header');\n }\n\n const prefix = Buffer.concat([\n bytes.subarray(0, HEADER_BYTES),\n encodeContext(context),\n ]);\n const payloadLength =\n bytes.length - HEADER_BYTES - nacl.secretbox.overheadLength - prefix.length;\n const compressed = bytes[6] === 1;\n if (\n payloadLength < 0 ||\n payloadLength > (compressed ? MAX_ENCODED_BYTES : MAX_SNAPSHOT_BYTES)\n ) {\n throw new FormatError('Invalid vault snapshot payload size');\n }\n\n const keyId = bytes.toString('hex', KEY_ID_OFFSET, NONCE_OFFSET);\n const key = resolveKey(keyId);\n if (key === undefined) {\n throw new KeyNotFoundError('Vault snapshot key not found', keyId);\n }\n checkKey(key);\n const nonce = bytes.subarray(NONCE_OFFSET, HEADER_BYTES);\n const message = nacl.secretbox.open(bytes.subarray(HEADER_BYTES), nonce, key);\n if (\n !message ||\n !timingSafeEqual(prefix, message.subarray(0, prefix.length))\n ) {\n throw new DecryptError('Vault snapshot authentication failed');\n }\n\n const payload = message.subarray(prefix.length);\n if (!compressed) {\n return payload.slice();\n }\n try {\n // Node returns the engine when info is true, but its types omit that overload.\n const result = inflateSync(payload, {\n info: true,\n maxOutputLength: MAX_SNAPSHOT_BYTES,\n }) as unknown as { buffer: Buffer; engine: Inflate };\n if (result.engine.bytesWritten === payload.length) {\n return result.buffer;\n }\n } catch {\n // Treat all zlib failures, including the output cap, as invalid payloads.\n }\n throw new DecryptError('Invalid vault snapshot compression payload');\n}\n"],"mappings":";;;;;AAUA,IAAM,QAAQ,OAAO,KAAK,MAAM;AAChC,IAAM,UAAU;AAChB,IAAM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AChB,iBAAiB,aAAa,oBAAoB,qBAElD,MAAM,IAAI,YAAY,qCAAqC;CAG7D,MAAM,QAAQ,MAAM,SAAS,OAAO,eAAe,YAAY;CAC/D,MAAM,MAAM,WAAW,KAAK;CAC5B,IAAI,QAAQ,KAAA,GACV,MAAM,IAAI,iBAAiB,gCAAgC,KAAK;CAElE,SAAS,GAAG;CACZ,MAAM,QAAQ,MAAM,SAAS,cAAc,YAAY;CACvD,MAAM,UAAU,KAAK,UAAU,KAAK,MAAM,SAAS,YAAY,GAAG,OAAO,GAAG;CAC5E,IACE,CAAC,WACD,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,GAAG,OAAO,MAAM,CAAC,GAE3D,MAAM,IAAI,aAAa,sCAAsC;CAG/D,MAAM,UAAU,QAAQ,SAAS,OAAO,MAAM;CAC9C,IAAI,CAAC,YACH,OAAO,QAAQ,MAAM;CAEvB,IAAI;EAEF,MAAM,SAAS,YAAY,SAAS;GAClC,MAAM;GACN,iBAAiB;EACnB,CAAC;EACD,IAAI,OAAO,OAAO,iBAAiB,QAAQ,QACzC,OAAO,OAAO;CAElB,QAAQ,CAER;CACA,MAAM,IAAI,aAAa,4CAA4C;AACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/encryption",
|
|
3
|
-
"version": "0.111.
|
|
3
|
+
"version": "0.111.7",
|
|
4
4
|
"description": "Unified encryption and cryptography operations with adapter-based architecture",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./vault-snapshot": {
|
|
15
|
+
"types": "./dist/vault-snapshot.d.ts",
|
|
16
|
+
"import": "./dist/vault-snapshot.js"
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
"bin": {
|
|
@@ -18,6 +22,7 @@
|
|
|
18
22
|
"files": [
|
|
19
23
|
"dist",
|
|
20
24
|
"README.md",
|
|
25
|
+
"vault-snapshot-v1-vectors.json",
|
|
21
26
|
"LICENSE",
|
|
22
27
|
"AGENT.md",
|
|
23
28
|
"metadata.json"
|
|
@@ -27,8 +32,8 @@
|
|
|
27
32
|
"access": "public"
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@happyvertical/logger": "0.111.
|
|
31
|
-
"@happyvertical/utils": "0.111.
|
|
35
|
+
"@happyvertical/logger": "0.111.7",
|
|
36
|
+
"@happyvertical/utils": "0.111.7",
|
|
32
37
|
"@openpgp/web-stream-tools": "^0.3.1",
|
|
33
38
|
"openpgp": "^6.3.0",
|
|
34
39
|
"tweetnacl": "^1.0.3",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keyHex": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
|
3
|
+
"keyIdHex": "101112131415161718191a1b1c1d1e1f",
|
|
4
|
+
"accountId": "acct-雪",
|
|
5
|
+
"deviceId": "dev-🦊",
|
|
6
|
+
"sequenceHex": "fedcba9876543210",
|
|
7
|
+
"contextHex": "08616363742de99baa086465762df09fa68afedcba9876543210",
|
|
8
|
+
"snapshotHex": "7661756c7420736e617073686f74007661756c7420736e617073686f74ff",
|
|
9
|
+
"vectors": [
|
|
10
|
+
{
|
|
11
|
+
"compression": "none",
|
|
12
|
+
"nonceHex": "202122232425262728292a2b2c2d2e2f3031323334353637",
|
|
13
|
+
"payloadHex": "7661756c7420736e617073686f74007661756c7420736e617073686f74ff",
|
|
14
|
+
"envelopeHex": "48565345010100101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f30313233343536375b3ad7d1fb2c53611f8d45a9ab0bbe8db90f1ee04c265a861827467a195ea0eca0a8a697ec073c549d5410b6e73d8bd59e21fbefd68756ff925c60bfc0eb495ad2b5c9bd25df6f55a13f1aedb4e9d3a722b1c37bcee4a0140be2060e6da001ce2aeb33c8f7f724439d090c7ba9fac657b41d368052e45b"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"compression": "zlib",
|
|
18
|
+
"nonceHex": "38393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f",
|
|
19
|
+
"payloadHex": "789c2b4b2ccd295128ce4b2c28cec82f612843e1fe0700b7b70c78",
|
|
20
|
+
"envelopeHex": "48565345010101101112131415161718191a1b1c1d1e1f38393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f953c50fbe98c0ecda057cb6574e636529889eb9bfd52165c0298992e4d1fb15ddbac4618ce2af7df0a1b2ecc5c76ae6b2aaf5e404d54412cec1b219180fa30b01aef204d2e8edcd37a9044d8f7b937a1860baaa65bcbf834dd4024dc03e87d8e402455397053cae304681f596d870d1c2642b4b3"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
//#region src/shared/errors.ts
|
|
3
|
-
/**
|
|
4
|
-
* Base error class for all encryption errors
|
|
5
|
-
*/
|
|
6
|
-
var EncryptionError = class extends Error {
|
|
7
|
-
code;
|
|
8
|
-
adapter;
|
|
9
|
-
cause;
|
|
10
|
-
timestamp;
|
|
11
|
-
constructor(message, code, adapter, cause) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = "EncryptionError";
|
|
14
|
-
this.code = code;
|
|
15
|
-
this.adapter = adapter;
|
|
16
|
-
this.cause = cause;
|
|
17
|
-
this.timestamp = /* @__PURE__ */ new Date();
|
|
18
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Convert error to JSON for logging/serialization
|
|
22
|
-
*/
|
|
23
|
-
toJSON() {
|
|
24
|
-
return {
|
|
25
|
-
name: this.name,
|
|
26
|
-
message: this.message,
|
|
27
|
-
code: this.code,
|
|
28
|
-
adapter: this.adapter,
|
|
29
|
-
timestamp: this.timestamp.toISOString(),
|
|
30
|
-
stack: this.stack,
|
|
31
|
-
cause: this.cause
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Key-related errors
|
|
37
|
-
*/
|
|
38
|
-
var KeyError = class extends EncryptionError {
|
|
39
|
-
constructor(message, adapter, cause) {
|
|
40
|
-
super(message, "KEY_ERROR", adapter, cause);
|
|
41
|
-
this.name = "KeyError";
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Invalid key format or content
|
|
46
|
-
*/
|
|
47
|
-
var InvalidKeyError = class extends EncryptionError {
|
|
48
|
-
constructor(message, adapter, cause) {
|
|
49
|
-
super(message, "INVALID_KEY", adapter, cause);
|
|
50
|
-
this.name = "InvalidKeyError";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Key not found error
|
|
55
|
-
*/
|
|
56
|
-
var KeyNotFoundError = class extends EncryptionError {
|
|
57
|
-
keyId;
|
|
58
|
-
constructor(message, keyId, adapter) {
|
|
59
|
-
super(message, "KEY_NOT_FOUND", adapter);
|
|
60
|
-
this.name = "KeyNotFoundError";
|
|
61
|
-
this.keyId = keyId;
|
|
62
|
-
}
|
|
63
|
-
toJSON() {
|
|
64
|
-
return {
|
|
65
|
-
...super.toJSON(),
|
|
66
|
-
keyId: this.keyId
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Passphrase-related errors
|
|
72
|
-
*/
|
|
73
|
-
var PassphraseError = class extends EncryptionError {
|
|
74
|
-
constructor(message, adapter, cause) {
|
|
75
|
-
super(message, "PASSPHRASE_ERROR", adapter, cause);
|
|
76
|
-
this.name = "PassphraseError";
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Encryption operation errors
|
|
81
|
-
*/
|
|
82
|
-
var EncryptError = class extends EncryptionError {
|
|
83
|
-
constructor(message, adapter, cause) {
|
|
84
|
-
super(message, "ENCRYPT_ERROR", adapter, cause);
|
|
85
|
-
this.name = "EncryptError";
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Decryption operation errors
|
|
90
|
-
*/
|
|
91
|
-
var DecryptError = class extends EncryptionError {
|
|
92
|
-
constructor(message, adapter, cause) {
|
|
93
|
-
super(message, "DECRYPT_ERROR", adapter, cause);
|
|
94
|
-
this.name = "DecryptError";
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Signature operation errors
|
|
99
|
-
*/
|
|
100
|
-
var SignatureError = class extends EncryptionError {
|
|
101
|
-
constructor(message, adapter, cause) {
|
|
102
|
-
super(message, "SIGNATURE_ERROR", adapter, cause);
|
|
103
|
-
this.name = "SignatureError";
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Verification operation errors
|
|
108
|
-
*/
|
|
109
|
-
var VerificationError = class extends EncryptionError {
|
|
110
|
-
constructor(message, adapter, cause) {
|
|
111
|
-
super(message, "VERIFICATION_ERROR", adapter, cause);
|
|
112
|
-
this.name = "VerificationError";
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Format-related errors
|
|
117
|
-
*/
|
|
118
|
-
var FormatError = class extends EncryptionError {
|
|
119
|
-
constructor(message, adapter, cause) {
|
|
120
|
-
super(message, "FORMAT_ERROR", adapter, cause);
|
|
121
|
-
this.name = "FormatError";
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Algorithm-related errors
|
|
126
|
-
*/
|
|
127
|
-
var AlgorithmError = class extends EncryptionError {
|
|
128
|
-
algorithm;
|
|
129
|
-
constructor(message, algorithm, adapter) {
|
|
130
|
-
super(message, "ALGORITHM_ERROR", adapter);
|
|
131
|
-
this.name = "AlgorithmError";
|
|
132
|
-
this.algorithm = algorithm;
|
|
133
|
-
}
|
|
134
|
-
toJSON() {
|
|
135
|
-
return {
|
|
136
|
-
...super.toJSON(),
|
|
137
|
-
algorithm: this.algorithm
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/shared/base.ts
|
|
143
|
-
/**
|
|
144
|
-
* Base adapter class that provides common functionality for all encryption adapters
|
|
145
|
-
*/
|
|
146
|
-
var BaseEncryption = class {
|
|
147
|
-
adapterType;
|
|
148
|
-
debug;
|
|
149
|
-
constructor(adapterType, debug = false) {
|
|
150
|
-
this.adapterType = adapterType;
|
|
151
|
-
this.debug = debug;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get the adapter type
|
|
155
|
-
*/
|
|
156
|
-
getAdapter() {
|
|
157
|
-
return this.adapterType;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Log debug messages if debug mode is enabled
|
|
161
|
-
*/
|
|
162
|
-
log(message, ...args) {
|
|
163
|
-
if (this.debug) console.log(`[${this.adapterType}] ${message}`, ...args);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Validate that a key is provided
|
|
167
|
-
*/
|
|
168
|
-
validateKey(key, keyType) {
|
|
169
|
-
if (!key) throw new KeyError(`${keyType} key is required but was not provided`, this.adapterType);
|
|
170
|
-
if (typeof key === "string" && key.trim().length === 0) throw new InvalidKeyError(`${keyType} key cannot be empty`, this.adapterType);
|
|
171
|
-
if (Buffer.isBuffer(key) && key.length === 0) throw new InvalidKeyError(`${keyType} key cannot be empty`, this.adapterType);
|
|
172
|
-
if (key instanceof Uint8Array && key.length === 0) throw new InvalidKeyError(`${keyType} key cannot be empty`, this.adapterType);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Validate encryption options
|
|
176
|
-
*/
|
|
177
|
-
validateEncryptOptions(options) {
|
|
178
|
-
if (!options) return;
|
|
179
|
-
if (options.encoding && ![
|
|
180
|
-
"base64",
|
|
181
|
-
"hex",
|
|
182
|
-
"utf8"
|
|
183
|
-
].includes(options.encoding)) throw new Error(`Invalid encoding: ${options.encoding}. Must be 'base64', 'hex', or 'utf8'`);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Validate decryption options
|
|
187
|
-
*/
|
|
188
|
-
validateDecryptOptions(options) {
|
|
189
|
-
if (!options) return;
|
|
190
|
-
if (options.encoding && ![
|
|
191
|
-
"base64",
|
|
192
|
-
"hex",
|
|
193
|
-
"utf8"
|
|
194
|
-
].includes(options.encoding)) throw new Error(`Invalid encoding: ${options.encoding}. Must be 'base64', 'hex', or 'utf8'`);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Convert Buffer to string based on encoding
|
|
198
|
-
*/
|
|
199
|
-
bufferToString(buffer, encoding = "base64") {
|
|
200
|
-
return buffer.toString(encoding);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Convert string to Buffer based on encoding
|
|
204
|
-
*/
|
|
205
|
-
stringToBuffer(str, encoding = "base64") {
|
|
206
|
-
return Buffer.from(str, encoding);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Wrap errors with adapter context
|
|
210
|
-
*/
|
|
211
|
-
wrapError(error, operation) {
|
|
212
|
-
if (error instanceof Error) return error;
|
|
213
|
-
return /* @__PURE__ */ new Error(`${operation} failed in ${this.adapterType} adapter: ${String(error)}`);
|
|
214
|
-
}
|
|
215
|
-
async encryptFile(inputPath, outputPath, options) {
|
|
216
|
-
try {
|
|
217
|
-
this.log(`Encrypting file: ${inputPath} -> ${outputPath}`);
|
|
218
|
-
const input = await readFile(inputPath);
|
|
219
|
-
await writeFile(outputPath, await this.encryptBuffer(input, options));
|
|
220
|
-
this.log(`File encrypted successfully: ${outputPath}`);
|
|
221
|
-
} catch (error) {
|
|
222
|
-
throw new EncryptError(`Failed to encrypt file: ${error.message}`, this.adapterType, error);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
async decryptFile(inputPath, outputPath, options) {
|
|
226
|
-
try {
|
|
227
|
-
this.log(`Decrypting file: ${inputPath} -> ${outputPath}`);
|
|
228
|
-
const input = await readFile(inputPath);
|
|
229
|
-
await writeFile(outputPath, await this.decryptBuffer(input, options));
|
|
230
|
-
this.log(`File decrypted successfully: ${outputPath}`);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
throw new DecryptError(`Failed to decrypt file: ${error.message}`, this.adapterType, error);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
//#endregion
|
|
237
|
-
export { EncryptionError as a, KeyError as c, SignatureError as d, VerificationError as f, EncryptError as i, KeyNotFoundError as l, AlgorithmError as n, FormatError as o, DecryptError as r, InvalidKeyError as s, BaseEncryption as t, PassphraseError as u };
|
|
238
|
-
|
|
239
|
-
//# sourceMappingURL=base-qiu-WiZ0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-qiu-WiZ0.js","names":[],"sources":["../../src/shared/errors.ts","../../src/shared/base.ts"],"sourcesContent":["/**\n * Base error class for all encryption errors\n */\nexport class EncryptionError extends Error {\n public readonly code: string;\n public readonly adapter?: string;\n public readonly cause?: unknown;\n public readonly timestamp: Date;\n\n constructor(\n message: string,\n code: string,\n adapter?: string,\n cause?: unknown,\n ) {\n super(message);\n this.name = 'EncryptionError';\n this.code = code;\n this.adapter = adapter;\n this.cause = cause;\n this.timestamp = new Date();\n\n // Maintains proper stack trace for where error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n /**\n * Convert error to JSON for logging/serialization\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n adapter: this.adapter,\n timestamp: this.timestamp.toISOString(),\n stack: this.stack,\n cause: this.cause,\n };\n }\n}\n\n/**\n * Key-related errors\n */\nexport class KeyError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'KEY_ERROR', adapter, cause);\n this.name = 'KeyError';\n }\n}\n\n/**\n * Invalid key format or content\n */\nexport class InvalidKeyError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'INVALID_KEY', adapter, cause);\n this.name = 'InvalidKeyError';\n }\n}\n\n/**\n * Key not found error\n */\nexport class KeyNotFoundError extends EncryptionError {\n public readonly keyId?: string;\n\n constructor(message: string, keyId?: string, adapter?: string) {\n super(message, 'KEY_NOT_FOUND', adapter);\n this.name = 'KeyNotFoundError';\n this.keyId = keyId;\n }\n\n override toJSON(): Record<string, unknown> {\n return {\n ...super.toJSON(),\n keyId: this.keyId,\n };\n }\n}\n\n/**\n * Passphrase-related errors\n */\nexport class PassphraseError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'PASSPHRASE_ERROR', adapter, cause);\n this.name = 'PassphraseError';\n }\n}\n\n/**\n * Encryption operation errors\n */\nexport class EncryptError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'ENCRYPT_ERROR', adapter, cause);\n this.name = 'EncryptError';\n }\n}\n\n/**\n * Decryption operation errors\n */\nexport class DecryptError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'DECRYPT_ERROR', adapter, cause);\n this.name = 'DecryptError';\n }\n}\n\n/**\n * Signature operation errors\n */\nexport class SignatureError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'SIGNATURE_ERROR', adapter, cause);\n this.name = 'SignatureError';\n }\n}\n\n/**\n * Verification operation errors\n */\nexport class VerificationError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'VERIFICATION_ERROR', adapter, cause);\n this.name = 'VerificationError';\n }\n}\n\n/**\n * Format-related errors\n */\nexport class FormatError extends EncryptionError {\n constructor(message: string, adapter?: string, cause?: unknown) {\n super(message, 'FORMAT_ERROR', adapter, cause);\n this.name = 'FormatError';\n }\n}\n\n/**\n * Algorithm-related errors\n */\nexport class AlgorithmError extends EncryptionError {\n public readonly algorithm?: string;\n\n constructor(message: string, algorithm?: string, adapter?: string) {\n super(message, 'ALGORITHM_ERROR', adapter);\n this.name = 'AlgorithmError';\n this.algorithm = algorithm;\n }\n\n override toJSON(): Record<string, unknown> {\n return {\n ...super.toJSON(),\n algorithm: this.algorithm,\n };\n }\n}\n","import { readFile, writeFile } from 'node:fs/promises';\nimport type { Transform } from 'node:stream';\nimport {\n DecryptError,\n EncryptError,\n InvalidKeyError,\n KeyError,\n} from './errors.js';\nimport type {\n AdapterType,\n DecryptEmailOptions,\n DecryptedEmail,\n DecryptOptions,\n EmailMessage,\n EncryptEmailOptions,\n Encryption,\n EncryptionCapabilities,\n EncryptOptions,\n ExportKeyOptions,\n ImportKeyOptions,\n Key,\n KeyPair,\n KeyPairOptions,\n SignEmailOptions,\n SignOptions,\n VerificationResult,\n VerifyEmailOptions,\n VerifyOptions,\n} from './types.js';\n\n/**\n * Base adapter class that provides common functionality for all encryption adapters\n */\nexport abstract class BaseEncryption implements Encryption {\n protected readonly adapterType: AdapterType;\n protected readonly debug: boolean;\n\n constructor(adapterType: AdapterType, debug = false) {\n this.adapterType = adapterType;\n this.debug = debug;\n }\n\n /**\n * Get the adapter type\n */\n getAdapter(): AdapterType {\n return this.adapterType;\n }\n\n /**\n * Log debug messages if debug mode is enabled\n */\n protected log(message: string, ...args: unknown[]): void {\n if (this.debug) {\n console.log(`[${this.adapterType}] ${message}`, ...args);\n }\n }\n\n /**\n * Validate that a key is provided\n */\n protected validateKey(\n key: string | Buffer | Uint8Array | undefined,\n keyType: 'public' | 'private',\n ): void {\n if (!key) {\n throw new KeyError(\n `${keyType} key is required but was not provided`,\n this.adapterType,\n );\n }\n\n if (typeof key === 'string' && key.trim().length === 0) {\n throw new InvalidKeyError(\n `${keyType} key cannot be empty`,\n this.adapterType,\n );\n }\n\n if (Buffer.isBuffer(key) && key.length === 0) {\n throw new InvalidKeyError(\n `${keyType} key cannot be empty`,\n this.adapterType,\n );\n }\n\n if (key instanceof Uint8Array && key.length === 0) {\n throw new InvalidKeyError(\n `${keyType} key cannot be empty`,\n this.adapterType,\n );\n }\n }\n\n /**\n * Validate encryption options\n */\n protected validateEncryptOptions(options?: EncryptOptions): void {\n // Base validation - adapters can override\n if (!options) return;\n\n // Validate encoding if provided\n if (\n options.encoding &&\n !['base64', 'hex', 'utf8'].includes(options.encoding)\n ) {\n throw new Error(\n `Invalid encoding: ${options.encoding}. Must be 'base64', 'hex', or 'utf8'`,\n );\n }\n }\n\n /**\n * Validate decryption options\n */\n protected validateDecryptOptions(options?: DecryptOptions): void {\n // Base validation - adapters can override\n if (!options) return;\n\n // Validate encoding if provided\n if (\n options.encoding &&\n !['base64', 'hex', 'utf8'].includes(options.encoding)\n ) {\n throw new Error(\n `Invalid encoding: ${options.encoding}. Must be 'base64', 'hex', or 'utf8'`,\n );\n }\n }\n\n /**\n * Convert Buffer to string based on encoding\n */\n protected bufferToString(\n buffer: Buffer,\n encoding: 'base64' | 'hex' | 'utf8' = 'base64',\n ): string {\n return buffer.toString(encoding);\n }\n\n /**\n * Convert string to Buffer based on encoding\n */\n protected stringToBuffer(\n str: string,\n encoding: 'base64' | 'hex' | 'utf8' = 'base64',\n ): Buffer {\n return Buffer.from(str, encoding);\n }\n\n /**\n * Wrap errors with adapter context\n */\n protected wrapError(error: unknown, operation: string): Error {\n if (error instanceof Error) {\n return error;\n }\n return new Error(\n `${operation} failed in ${this.adapterType} adapter: ${String(error)}`,\n );\n }\n\n // =============================================================================\n // Text operations (must be implemented by adapters)\n // =============================================================================\n\n abstract encryptText(text: string, options?: EncryptOptions): Promise<string>;\n\n abstract decryptText(\n encrypted: string,\n options?: DecryptOptions,\n ): Promise<string>;\n\n // =============================================================================\n // File operations (default implementation using text/buffer methods)\n // =============================================================================\n\n async encryptFile(\n inputPath: string,\n outputPath: string,\n options?: EncryptOptions,\n ): Promise<void> {\n try {\n this.log(`Encrypting file: ${inputPath} -> ${outputPath}`);\n\n // Read input file\n const input = await readFile(inputPath);\n\n // Encrypt buffer\n const encrypted = await this.encryptBuffer(input, options);\n\n // Write output file\n await writeFile(outputPath, encrypted);\n\n this.log(`File encrypted successfully: ${outputPath}`);\n } catch (error) {\n throw new EncryptError(\n `Failed to encrypt file: ${(error as Error).message}`,\n this.adapterType,\n error,\n );\n }\n }\n\n async decryptFile(\n inputPath: string,\n outputPath: string,\n options?: DecryptOptions,\n ): Promise<void> {\n try {\n this.log(`Decrypting file: ${inputPath} -> ${outputPath}`);\n\n // Read input file\n const input = await readFile(inputPath);\n\n // Decrypt buffer\n const decrypted = await this.decryptBuffer(input, options);\n\n // Write output file\n await writeFile(outputPath, decrypted);\n\n this.log(`File decrypted successfully: ${outputPath}`);\n } catch (error) {\n throw new DecryptError(\n `Failed to decrypt file: ${(error as Error).message}`,\n this.adapterType,\n error,\n );\n }\n }\n\n // =============================================================================\n // Buffer operations (must be implemented by adapters)\n // =============================================================================\n\n abstract encryptBuffer(\n buffer: Buffer,\n options?: EncryptOptions,\n ): Promise<Buffer>;\n\n abstract decryptBuffer(\n buffer: Buffer,\n options?: DecryptOptions,\n ): Promise<Buffer>;\n\n // =============================================================================\n // Stream operations (optional - not implemented by default)\n // =============================================================================\n\n encryptStream?(options?: EncryptOptions): Transform;\n\n decryptStream?(options?: DecryptOptions): Transform;\n\n // =============================================================================\n // Email operations (optional - mainly PGP)\n // =============================================================================\n\n encryptEmail?(\n message: EmailMessage,\n options?: EncryptEmailOptions,\n ): Promise<EmailMessage>;\n\n decryptEmail?(\n message: EmailMessage,\n options?: DecryptEmailOptions,\n ): Promise<DecryptedEmail>;\n\n signEmail?(\n message: EmailMessage,\n options?: SignEmailOptions,\n ): Promise<EmailMessage>;\n\n verifyEmail?(\n message: EmailMessage,\n options?: VerifyEmailOptions,\n ): Promise<VerificationResult>;\n\n // =============================================================================\n // Signing operations (optional - mainly PGP)\n // =============================================================================\n\n sign?(data: string | Buffer, options?: SignOptions): Promise<string | Buffer>;\n\n verify?(\n data: string | Buffer,\n signature: string | Buffer,\n options?: VerifyOptions,\n ): Promise<boolean>;\n\n // =============================================================================\n // Key management (must be implemented by adapters)\n // =============================================================================\n\n abstract generateKeyPair(options?: KeyPairOptions): Promise<KeyPair>;\n\n abstract importKey(\n key: string | Buffer,\n options?: ImportKeyOptions,\n ): Promise<Key>;\n\n abstract exportKey(\n key: Key,\n options?: ExportKeyOptions,\n ): Promise<string | Buffer>;\n\n // =============================================================================\n // Adapter capabilities (must be implemented by adapters)\n // =============================================================================\n\n abstract getCapabilities(): Promise<EncryptionCapabilities>;\n}\n"],"mappings":";;;;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CACA;CACA;CAEA,YACE,SACA,MACA,SACA,OACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,KAAK,QAAQ;EACb,KAAK,4BAAY,IAAI,KAAK;EAG1B,IAAI,MAAM,mBACR,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAElD;;;;CAKA,SAAkC;EAChC,OAAO;GACL,MAAM,KAAK;GACX,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;GACd,WAAW,KAAK,UAAU,YAAY;GACtC,OAAO,KAAK;GACZ,OAAO,KAAK;EACd;CACF;AACF;;;;AAKA,IAAa,WAAb,cAA8B,gBAAgB;CAC5C,YAAY,SAAiB,SAAkB,OAAiB;EAC9D,MAAM,SAAS,aAAa,SAAS,KAAK;EAC1C,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,kBAAb,cAAqC,gBAAgB;CACnD,YAAY,SAAiB,SAAkB,OAAiB;EAC9D,MAAM,SAAS,eAAe,SAAS,KAAK;EAC5C,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,mBAAb,cAAsC,gBAAgB;CACpD;CAEA,YAAY,SAAiB,OAAgB,SAAkB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