@vaultsandbox/client 0.5.1 → 0.6.1
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 +3 -1
- package/dist/client.d.ts +41 -12
- package/dist/client.js +97 -34
- package/dist/client.js.map +1 -1
- package/dist/crypto/constants.d.ts +52 -3
- package/dist/crypto/constants.js +56 -3
- package/dist/crypto/constants.js.map +1 -1
- package/dist/crypto/decrypt.d.ts +1 -0
- package/dist/crypto/decrypt.js +65 -6
- package/dist/crypto/decrypt.js.map +1 -1
- package/dist/crypto/keypair.d.ts +2 -7
- package/dist/crypto/keypair.js +9 -11
- package/dist/crypto/keypair.js.map +1 -1
- package/dist/crypto/signature.js +5 -3
- package/dist/crypto/signature.js.map +1 -1
- package/dist/crypto/utils.d.ts +1 -0
- package/dist/crypto/utils.js +7 -1
- package/dist/crypto/utils.js.map +1 -1
- package/dist/email.js +1 -0
- package/dist/email.js.map +1 -1
- package/dist/http/api-client.d.ts +2 -1
- package/dist/http/api-client.js +7 -2
- package/dist/http/api-client.js.map +1 -1
- package/dist/inbox.d.ts +71 -3
- package/dist/inbox.js +127 -7
- package/dist/inbox.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/strategies/delivery-strategy.d.ts +4 -2
- package/dist/strategies/polling-strategy.d.ts +2 -2
- package/dist/strategies/polling-strategy.js +39 -18
- package/dist/strategies/polling-strategy.js.map +1 -1
- package/dist/strategies/sse-strategy.d.ts +7 -2
- package/dist/strategies/sse-strategy.js +108 -21
- package/dist/strategies/sse-strategy.js.map +1 -1
- package/dist/sync/inbox-sync.d.ts +31 -0
- package/dist/sync/inbox-sync.js +52 -0
- package/dist/sync/inbox-sync.js.map +1 -0
- package/dist/types/index.d.ts +21 -11
- package/dist/types/index.js.map +1 -1
- package/dist/utils/email-utils.d.ts +1 -1
- package/dist/utils/email-utils.js +9 -8
- package/dist/utils/email-utils.js.map +1 -1
- package/dist/utils/hash.d.ts +15 -0
- package/dist/utils/hash.js +31 -0
- package/dist/utils/hash.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
<img alt="VaultSandbox" src="./assets/logo-dark.svg">
|
|
5
5
|
</picture>
|
|
6
6
|
|
|
7
|
+
> **VaultSandbox is in Public Beta.** Join the journey to 1.0. Share feedback on [GitHub](https://github.com/vaultsandbox/gateway/discussions).
|
|
8
|
+
|
|
7
9
|
# @vaultsandbox/client
|
|
8
10
|
|
|
9
11
|
[](https://www.npmjs.com/package/@vaultsandbox/client)
|
|
@@ -288,7 +290,7 @@ new VaultSandboxClient(config: ClientConfig)
|
|
|
288
290
|
|
|
289
291
|
- `url: string` - Gateway URL
|
|
290
292
|
- `apiKey: string` - Your API key
|
|
291
|
-
- `strategy?: 'sse' | 'polling'
|
|
293
|
+
- `strategy?: 'sse' | 'polling'` - Delivery strategy (default: 'sse')
|
|
292
294
|
- `pollingInterval?: number` - Polling interval in ms (default: 2000)
|
|
293
295
|
- `maxRetries?: number` - Max retry attempts for HTTP requests (default: 3)
|
|
294
296
|
- `retryDelay?: number` - Delay in ms between retry attempts (default: 1000)
|
package/dist/client.d.ts
CHANGED
|
@@ -83,6 +83,13 @@ export declare class VaultSandboxClient {
|
|
|
83
83
|
* @returns A promise that resolves to the number of inboxes deleted.
|
|
84
84
|
*/
|
|
85
85
|
deleteAllInboxes(): Promise<number>;
|
|
86
|
+
/**
|
|
87
|
+
* Deletes a specific inbox by its email address.
|
|
88
|
+
*
|
|
89
|
+
* @param emailAddress - The email address of the inbox to delete.
|
|
90
|
+
* @returns A promise that resolves when the inbox is deleted.
|
|
91
|
+
*/
|
|
92
|
+
deleteInbox(emailAddress: string): Promise<void>;
|
|
86
93
|
/**
|
|
87
94
|
* Retrieves information about the VaultSandbox server.
|
|
88
95
|
*
|
|
@@ -116,6 +123,7 @@ export declare class VaultSandboxClient {
|
|
|
116
123
|
exportInbox(inboxOrEmail: Inbox | string): ExportedInboxData;
|
|
117
124
|
/**
|
|
118
125
|
* Imports an inbox from exported data.
|
|
126
|
+
* See vaultsandbox-spec.md Section 10: Inbox Import Process
|
|
119
127
|
*
|
|
120
128
|
* @param data - The exported inbox data
|
|
121
129
|
* @returns A promise that resolves to the imported Inbox instance
|
|
@@ -125,21 +133,41 @@ export declare class VaultSandboxClient {
|
|
|
125
133
|
* const importedInbox = await client.importInbox(exportedData);
|
|
126
134
|
*/
|
|
127
135
|
importInbox(data: ExportedInboxData): Promise<Inbox>;
|
|
136
|
+
/**
|
|
137
|
+
* Validates the export format version.
|
|
138
|
+
* @private
|
|
139
|
+
* @param data - The exported inbox data to validate
|
|
140
|
+
* @throws {InvalidImportDataError} If version is not supported
|
|
141
|
+
*/
|
|
142
|
+
private validateVersion;
|
|
128
143
|
/**
|
|
129
144
|
* Validates that all required fields are present and non-empty in the exported inbox data.
|
|
130
145
|
* @private
|
|
131
146
|
* @param data - The exported inbox data to validate
|
|
132
|
-
* @throws {InvalidImportDataError} If any required field is missing
|
|
147
|
+
* @throws {InvalidImportDataError} If any required field is missing or empty
|
|
133
148
|
*/
|
|
134
149
|
private validateRequiredFields;
|
|
135
150
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
151
|
+
* Validates that the email address contains exactly one @ character.
|
|
152
|
+
* @private
|
|
153
|
+
* @param emailAddress - The email address to validate
|
|
154
|
+
* @throws {InvalidImportDataError} If email format is invalid
|
|
155
|
+
*/
|
|
156
|
+
private validateEmailAddress;
|
|
157
|
+
/**
|
|
158
|
+
* Validates that the inbox hash is non-empty.
|
|
159
|
+
* @private
|
|
160
|
+
* @param inboxHash - The inbox hash to validate
|
|
161
|
+
* @throws {InvalidImportDataError} If inbox hash is empty
|
|
162
|
+
*/
|
|
163
|
+
private validateInboxHash;
|
|
164
|
+
/**
|
|
165
|
+
* Validates that the server signature public key has the correct size.
|
|
138
166
|
* @private
|
|
139
|
-
* @param
|
|
140
|
-
* @throws {InvalidImportDataError} If
|
|
167
|
+
* @param serverSigPk - The server public key (base64url encoded)
|
|
168
|
+
* @throws {InvalidImportDataError} If server public key has invalid size
|
|
141
169
|
*/
|
|
142
|
-
private
|
|
170
|
+
private validateServerSigPkSize;
|
|
143
171
|
/**
|
|
144
172
|
* Validates that the timestamp fields contain valid ISO 8601 date strings.
|
|
145
173
|
* @private
|
|
@@ -163,22 +191,23 @@ export declare class VaultSandboxClient {
|
|
|
163
191
|
*/
|
|
164
192
|
private validateServerPublicKey;
|
|
165
193
|
/**
|
|
166
|
-
* Decodes the cryptographic keys from
|
|
194
|
+
* Decodes the cryptographic keys from base64url and validates their lengths.
|
|
195
|
+
* Public key is derived from secret key per spec Section 10.2.
|
|
167
196
|
* @private
|
|
168
|
-
* @param data - The exported inbox data containing
|
|
197
|
+
* @param data - The exported inbox data containing base64url-encoded keys
|
|
169
198
|
* @returns A keypair object with decoded keys and base64url-encoded public key
|
|
170
199
|
* @throws {InvalidImportDataError} If keys cannot be decoded or have invalid lengths
|
|
171
200
|
*/
|
|
172
201
|
private decodeAndValidateKeys;
|
|
173
202
|
/**
|
|
174
|
-
* Decodes a
|
|
203
|
+
* Decodes a base64url-encoded cryptographic key to a byte array.
|
|
175
204
|
* @private
|
|
176
|
-
* @param
|
|
205
|
+
* @param keyB64Url - The base64url-encoded key string
|
|
177
206
|
* @param keyType - The type of key (e.g., 'public', 'secret') for error messages
|
|
178
207
|
* @returns The decoded key as a Uint8Array
|
|
179
|
-
* @throws {InvalidImportDataError} If the
|
|
208
|
+
* @throws {InvalidImportDataError} If the base64url string is malformed
|
|
180
209
|
*/
|
|
181
|
-
private
|
|
210
|
+
private decodeBase64UrlKey;
|
|
182
211
|
/**
|
|
183
212
|
* Validates that a cryptographic key has the expected byte length.
|
|
184
213
|
* @private
|
package/dist/client.js
CHANGED
|
@@ -6,8 +6,9 @@ import { readFile, writeFile } from 'fs/promises';
|
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
import { ApiClient } from './http/api-client.js';
|
|
8
8
|
import { Inbox } from './inbox.js';
|
|
9
|
-
import { generateKeypair,
|
|
10
|
-
import { toBase64Url,
|
|
9
|
+
import { generateKeypair, SECRET_KEY_SIZE, derivePublicKeyFromSecret } from './crypto/keypair.js';
|
|
10
|
+
import { toBase64Url, fromBase64Url } from './crypto/utils.js';
|
|
11
|
+
import { EXPORT_VERSION, MLDSA_PUBLIC_KEY_SIZE } from './crypto/constants.js';
|
|
11
12
|
import { SSEStrategy } from './strategies/sse-strategy.js';
|
|
12
13
|
import { PollingStrategy } from './strategies/polling-strategy.js';
|
|
13
14
|
import { InboxNotFoundError, InboxAlreadyExistsError, InvalidImportDataError, StrategyError } from './types/index.js';
|
|
@@ -93,9 +94,9 @@ export class VaultSandboxClient {
|
|
|
93
94
|
* @private
|
|
94
95
|
*/
|
|
95
96
|
createStrategy() {
|
|
96
|
-
const strategyType = this.config.strategy ?? '
|
|
97
|
-
// SSE strategy (default
|
|
98
|
-
if (strategyType === 'sse'
|
|
97
|
+
const strategyType = this.config.strategy ?? 'sse';
|
|
98
|
+
// SSE strategy (default)
|
|
99
|
+
if (strategyType === 'sse') {
|
|
99
100
|
debug('Using SSE strategy for real-time delivery');
|
|
100
101
|
return new SSEStrategy(this.apiClient, {
|
|
101
102
|
url: this.config.url,
|
|
@@ -134,6 +135,7 @@ export class VaultSandboxClient {
|
|
|
134
135
|
// Create Inbox instance (use serverSigPk from response)
|
|
135
136
|
const inbox = new Inbox(inboxData, keypair, this.apiClient, inboxData.serverSigPk);
|
|
136
137
|
// Set delivery strategy
|
|
138
|
+
/* istanbul ignore else - strategy always exists after ensureInitialized */
|
|
137
139
|
if (this.strategy) {
|
|
138
140
|
inbox.setStrategy(this.strategy);
|
|
139
141
|
}
|
|
@@ -146,11 +148,22 @@ export class VaultSandboxClient {
|
|
|
146
148
|
*
|
|
147
149
|
* @returns A promise that resolves to the number of inboxes deleted.
|
|
148
150
|
*/
|
|
151
|
+
/* istanbul ignore next 5 - destructive operation, not safe to test against real server */
|
|
149
152
|
async deleteAllInboxes() {
|
|
150
153
|
const result = await this.apiClient.deleteAllInboxes();
|
|
151
154
|
this.inboxes.clear();
|
|
152
155
|
return result.deleted;
|
|
153
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Deletes a specific inbox by its email address.
|
|
159
|
+
*
|
|
160
|
+
* @param emailAddress - The email address of the inbox to delete.
|
|
161
|
+
* @returns A promise that resolves when the inbox is deleted.
|
|
162
|
+
*/
|
|
163
|
+
async deleteInbox(emailAddress) {
|
|
164
|
+
await this.apiClient.deleteInbox(emailAddress);
|
|
165
|
+
this.inboxes.delete(emailAddress);
|
|
166
|
+
}
|
|
154
167
|
/**
|
|
155
168
|
* Retrieves information about the VaultSandbox server.
|
|
156
169
|
*
|
|
@@ -209,6 +222,7 @@ export class VaultSandboxClient {
|
|
|
209
222
|
}
|
|
210
223
|
/**
|
|
211
224
|
* Imports an inbox from exported data.
|
|
225
|
+
* See vaultsandbox-spec.md Section 10: Inbox Import Process
|
|
212
226
|
*
|
|
213
227
|
* @param data - The exported inbox data
|
|
214
228
|
* @returns A promise that resolves to the imported Inbox instance
|
|
@@ -218,56 +232,102 @@ export class VaultSandboxClient {
|
|
|
218
232
|
* const importedInbox = await client.importInbox(exportedData);
|
|
219
233
|
*/
|
|
220
234
|
async importInbox(data) {
|
|
235
|
+
// Step 2: Validate version
|
|
236
|
+
this.validateVersion(data);
|
|
237
|
+
// Step 3: Validate required fields
|
|
221
238
|
this.validateRequiredFields(data);
|
|
222
|
-
|
|
239
|
+
// Step 4: Validate emailAddress
|
|
240
|
+
this.validateEmailAddress(data.emailAddress);
|
|
241
|
+
// Step 5: Validate inboxHash
|
|
242
|
+
this.validateInboxHash(data.inboxHash);
|
|
243
|
+
// Step 8: Validate timestamps
|
|
223
244
|
this.validateTimestamps(data);
|
|
245
|
+
// Check for duplicates
|
|
224
246
|
this.checkInboxDoesNotExist(data.emailAddress);
|
|
225
247
|
await this.ensureInitialized();
|
|
248
|
+
// Step 7: Validate and decode serverSigPk
|
|
249
|
+
this.validateServerSigPkSize(data.serverSigPk);
|
|
226
250
|
this.validateServerPublicKey(data.serverSigPk);
|
|
251
|
+
// Step 6: Validate and decode secretKey
|
|
227
252
|
const keypair = this.decodeAndValidateKeys(data);
|
|
228
253
|
const inboxData = this.buildInboxData(data);
|
|
229
254
|
return this.createAndTrackInbox(inboxData, keypair);
|
|
230
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Validates the export format version.
|
|
258
|
+
* @private
|
|
259
|
+
* @param data - The exported inbox data to validate
|
|
260
|
+
* @throws {InvalidImportDataError} If version is not supported
|
|
261
|
+
*/
|
|
262
|
+
validateVersion(data) {
|
|
263
|
+
if (data.version !== EXPORT_VERSION) {
|
|
264
|
+
throw new InvalidImportDataError(`Unsupported version: ${data.version}, expected ${EXPORT_VERSION}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
231
267
|
/**
|
|
232
268
|
* Validates that all required fields are present and non-empty in the exported inbox data.
|
|
233
269
|
* @private
|
|
234
270
|
* @param data - The exported inbox data to validate
|
|
235
|
-
* @throws {InvalidImportDataError} If any required field is missing
|
|
271
|
+
* @throws {InvalidImportDataError} If any required field is missing or empty
|
|
236
272
|
*/
|
|
237
273
|
validateRequiredFields(data) {
|
|
238
|
-
const
|
|
274
|
+
const requiredStringFields = [
|
|
239
275
|
'emailAddress',
|
|
240
276
|
'expiresAt',
|
|
241
277
|
'inboxHash',
|
|
242
278
|
'serverSigPk',
|
|
243
|
-
'
|
|
279
|
+
'secretKey',
|
|
244
280
|
'exportedAt',
|
|
245
281
|
];
|
|
246
|
-
for (const field of
|
|
247
|
-
|
|
282
|
+
for (const field of requiredStringFields) {
|
|
283
|
+
const value = data[field];
|
|
284
|
+
if (value === undefined || value === null || (typeof value === 'string' && value.trim() === '')) {
|
|
248
285
|
throw new InvalidImportDataError(`Missing or invalid field: ${field}`);
|
|
249
286
|
}
|
|
250
287
|
}
|
|
251
288
|
}
|
|
252
289
|
/**
|
|
253
|
-
*
|
|
254
|
-
* In ML-KEM (Kyber), the public key is embedded in the secret key, so we can extract it if missing.
|
|
290
|
+
* Validates that the email address contains exactly one @ character.
|
|
255
291
|
* @private
|
|
256
|
-
* @param
|
|
257
|
-
* @throws {InvalidImportDataError} If
|
|
292
|
+
* @param emailAddress - The email address to validate
|
|
293
|
+
* @throws {InvalidImportDataError} If email format is invalid
|
|
258
294
|
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
295
|
+
validateEmailAddress(emailAddress) {
|
|
296
|
+
const atCount = (emailAddress.match(/@/g) || []).length;
|
|
297
|
+
if (atCount !== 1) {
|
|
298
|
+
throw new InvalidImportDataError('Invalid email address: must contain exactly one @ character');
|
|
262
299
|
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Validates that the inbox hash is non-empty.
|
|
303
|
+
* @private
|
|
304
|
+
* @param inboxHash - The inbox hash to validate
|
|
305
|
+
* @throws {InvalidImportDataError} If inbox hash is empty
|
|
306
|
+
*/
|
|
307
|
+
validateInboxHash(inboxHash) {
|
|
308
|
+
/* istanbul ignore next 3 - defensive check, already validated by validateRequiredFields */
|
|
309
|
+
if (!inboxHash || inboxHash.trim() === '') {
|
|
310
|
+
throw new InvalidImportDataError('Invalid inbox hash: must be non-empty');
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Validates that the server signature public key has the correct size.
|
|
315
|
+
* @private
|
|
316
|
+
* @param serverSigPk - The server public key (base64url encoded)
|
|
317
|
+
* @throws {InvalidImportDataError} If server public key has invalid size
|
|
318
|
+
*/
|
|
319
|
+
validateServerSigPkSize(serverSigPk) {
|
|
263
320
|
try {
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
321
|
+
const decoded = fromBase64Url(serverSigPk);
|
|
322
|
+
if (decoded.length !== MLDSA_PUBLIC_KEY_SIZE) {
|
|
323
|
+
throw new InvalidImportDataError(`Invalid server public key size: expected ${MLDSA_PUBLIC_KEY_SIZE}, got ${decoded.length}`);
|
|
324
|
+
}
|
|
267
325
|
}
|
|
268
326
|
catch (error) {
|
|
269
|
-
|
|
270
|
-
|
|
327
|
+
if (error instanceof InvalidImportDataError)
|
|
328
|
+
throw error;
|
|
329
|
+
const errorMsg = error instanceof Error ? error.message : /* istanbul ignore next */ String(error);
|
|
330
|
+
throw new InvalidImportDataError(`Invalid server public key encoding: ${errorMsg}`);
|
|
271
331
|
}
|
|
272
332
|
}
|
|
273
333
|
/**
|
|
@@ -309,17 +369,19 @@ export class VaultSandboxClient {
|
|
|
309
369
|
}
|
|
310
370
|
}
|
|
311
371
|
/**
|
|
312
|
-
* Decodes the cryptographic keys from
|
|
372
|
+
* Decodes the cryptographic keys from base64url and validates their lengths.
|
|
373
|
+
* Public key is derived from secret key per spec Section 10.2.
|
|
313
374
|
* @private
|
|
314
|
-
* @param data - The exported inbox data containing
|
|
375
|
+
* @param data - The exported inbox data containing base64url-encoded keys
|
|
315
376
|
* @returns A keypair object with decoded keys and base64url-encoded public key
|
|
316
377
|
* @throws {InvalidImportDataError} If keys cannot be decoded or have invalid lengths
|
|
317
378
|
*/
|
|
318
379
|
decodeAndValidateKeys(data) {
|
|
319
|
-
|
|
320
|
-
const secretKey = this.
|
|
321
|
-
this.validateKeyLength(publicKey, PUBLIC_KEY_SIZE, 'public');
|
|
380
|
+
// Decode and validate secret key
|
|
381
|
+
const secretKey = this.decodeBase64UrlKey(data.secretKey, 'secret');
|
|
322
382
|
this.validateKeyLength(secretKey, SECRET_KEY_SIZE, 'secret');
|
|
383
|
+
// Derive public key from secret key per spec Section 10.2
|
|
384
|
+
const publicKey = derivePublicKeyFromSecret(secretKey);
|
|
323
385
|
return {
|
|
324
386
|
publicKey,
|
|
325
387
|
secretKey,
|
|
@@ -327,19 +389,19 @@ export class VaultSandboxClient {
|
|
|
327
389
|
};
|
|
328
390
|
}
|
|
329
391
|
/**
|
|
330
|
-
* Decodes a
|
|
392
|
+
* Decodes a base64url-encoded cryptographic key to a byte array.
|
|
331
393
|
* @private
|
|
332
|
-
* @param
|
|
394
|
+
* @param keyB64Url - The base64url-encoded key string
|
|
333
395
|
* @param keyType - The type of key (e.g., 'public', 'secret') for error messages
|
|
334
396
|
* @returns The decoded key as a Uint8Array
|
|
335
|
-
* @throws {InvalidImportDataError} If the
|
|
397
|
+
* @throws {InvalidImportDataError} If the base64url string is malformed
|
|
336
398
|
*/
|
|
337
|
-
|
|
399
|
+
decodeBase64UrlKey(keyB64Url, keyType) {
|
|
338
400
|
try {
|
|
339
|
-
return
|
|
401
|
+
return fromBase64Url(keyB64Url);
|
|
340
402
|
}
|
|
341
403
|
catch {
|
|
342
|
-
throw new InvalidImportDataError(`Invalid
|
|
404
|
+
throw new InvalidImportDataError(`Invalid base64url encoding in ${keyType} key`);
|
|
343
405
|
}
|
|
344
406
|
}
|
|
345
407
|
/**
|
|
@@ -378,6 +440,7 @@ export class VaultSandboxClient {
|
|
|
378
440
|
*/
|
|
379
441
|
createAndTrackInbox(inboxData, keypair) {
|
|
380
442
|
const inbox = new Inbox(inboxData, keypair, this.apiClient, inboxData.serverSigPk);
|
|
443
|
+
/* istanbul ignore else - strategy always exists after ensureInitialized */
|
|
381
444
|
if (this.strategy) {
|
|
382
445
|
inbox.setStrategy(this.strategy);
|
|
383
446
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,WAAW,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,
|
|
1
|
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@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized cryptographic constants for the VaultSandbox client
|
|
3
|
+
* See vaultsandbox-spec.md Appendix B: Size Constants
|
|
3
4
|
*/
|
|
4
5
|
/**
|
|
5
6
|
* HKDF context string used for key derivation
|
|
@@ -7,7 +8,55 @@
|
|
|
7
8
|
*/
|
|
8
9
|
export declare const HKDF_CONTEXT = "vaultsandbox:email:v1";
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
* This is the standard size for ML-DSA-65 public keys
|
|
11
|
+
* Algorithm suite identifier string
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const ALGORITHM_SUITE = "ML-KEM-768:ML-DSA-65:AES-256-GCM:HKDF-SHA-512";
|
|
14
|
+
/**
|
|
15
|
+
* ML-KEM-768 public key size in bytes
|
|
16
|
+
*/
|
|
17
|
+
export declare const MLKEM_PUBLIC_KEY_SIZE = 1184;
|
|
18
|
+
/**
|
|
19
|
+
* ML-KEM-768 secret key size in bytes
|
|
20
|
+
*/
|
|
21
|
+
export declare const MLKEM_SECRET_KEY_SIZE = 2400;
|
|
22
|
+
/**
|
|
23
|
+
* ML-KEM-768 ciphertext size in bytes
|
|
24
|
+
*/
|
|
25
|
+
export declare const MLKEM_CIPHERTEXT_SIZE = 1088;
|
|
26
|
+
/**
|
|
27
|
+
* ML-KEM-768 shared secret size in bytes
|
|
28
|
+
*/
|
|
29
|
+
export declare const MLKEM_SHARED_SECRET_SIZE = 32;
|
|
30
|
+
/**
|
|
31
|
+
* Offset of public key within secret key in bytes
|
|
32
|
+
* The public key is embedded in the secret key at this offset
|
|
33
|
+
*/
|
|
34
|
+
export declare const MLKEM_PUBLIC_KEY_OFFSET = 1152;
|
|
35
|
+
/**
|
|
36
|
+
* ML-DSA-65 public key size in bytes
|
|
37
|
+
*/
|
|
38
|
+
export declare const MLDSA_PUBLIC_KEY_SIZE = 1952;
|
|
39
|
+
/**
|
|
40
|
+
* ML-DSA-65 signature size in bytes
|
|
41
|
+
*/
|
|
42
|
+
export declare const MLDSA_SIGNATURE_SIZE = 3309;
|
|
43
|
+
/**
|
|
44
|
+
* AES-256 key size in bytes
|
|
45
|
+
*/
|
|
46
|
+
export declare const AES_KEY_SIZE = 32;
|
|
47
|
+
/**
|
|
48
|
+
* AES-GCM nonce size in bytes
|
|
49
|
+
*/
|
|
50
|
+
export declare const AES_NONCE_SIZE = 12;
|
|
51
|
+
/**
|
|
52
|
+
* AES-GCM authentication tag size in bytes
|
|
53
|
+
*/
|
|
54
|
+
export declare const AES_TAG_SIZE = 16;
|
|
55
|
+
/**
|
|
56
|
+
* Current export format version
|
|
57
|
+
*/
|
|
58
|
+
export declare const EXPORT_VERSION = 1;
|
|
59
|
+
/**
|
|
60
|
+
* Current protocol version
|
|
61
|
+
*/
|
|
62
|
+
export declare const PROTOCOL_VERSION = 1;
|
package/dist/crypto/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized cryptographic constants for the VaultSandbox client
|
|
3
|
+
* See vaultsandbox-spec.md Appendix B: Size Constants
|
|
3
4
|
*/
|
|
4
5
|
/**
|
|
5
6
|
* HKDF context string used for key derivation
|
|
@@ -7,8 +8,60 @@
|
|
|
7
8
|
*/
|
|
8
9
|
export const HKDF_CONTEXT = 'vaultsandbox:email:v1';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
* This is the standard size for ML-DSA-65 public keys
|
|
11
|
+
* Algorithm suite identifier string
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const ALGORITHM_SUITE = 'ML-KEM-768:ML-DSA-65:AES-256-GCM:HKDF-SHA-512';
|
|
14
|
+
// ===== ML-KEM-768 Constants =====
|
|
15
|
+
/**
|
|
16
|
+
* ML-KEM-768 public key size in bytes
|
|
17
|
+
*/
|
|
18
|
+
export const MLKEM_PUBLIC_KEY_SIZE = 1184;
|
|
19
|
+
/**
|
|
20
|
+
* ML-KEM-768 secret key size in bytes
|
|
21
|
+
*/
|
|
22
|
+
export const MLKEM_SECRET_KEY_SIZE = 2400;
|
|
23
|
+
/**
|
|
24
|
+
* ML-KEM-768 ciphertext size in bytes
|
|
25
|
+
*/
|
|
26
|
+
export const MLKEM_CIPHERTEXT_SIZE = 1088;
|
|
27
|
+
/**
|
|
28
|
+
* ML-KEM-768 shared secret size in bytes
|
|
29
|
+
*/
|
|
30
|
+
export const MLKEM_SHARED_SECRET_SIZE = 32;
|
|
31
|
+
/**
|
|
32
|
+
* Offset of public key within secret key in bytes
|
|
33
|
+
* The public key is embedded in the secret key at this offset
|
|
34
|
+
*/
|
|
35
|
+
export const MLKEM_PUBLIC_KEY_OFFSET = 1152;
|
|
36
|
+
// ===== ML-DSA-65 Constants =====
|
|
37
|
+
/**
|
|
38
|
+
* ML-DSA-65 public key size in bytes
|
|
39
|
+
*/
|
|
40
|
+
export const MLDSA_PUBLIC_KEY_SIZE = 1952;
|
|
41
|
+
/**
|
|
42
|
+
* ML-DSA-65 signature size in bytes
|
|
43
|
+
*/
|
|
44
|
+
export const MLDSA_SIGNATURE_SIZE = 3309;
|
|
45
|
+
// ===== AES-256-GCM Constants =====
|
|
46
|
+
/**
|
|
47
|
+
* AES-256 key size in bytes
|
|
48
|
+
*/
|
|
49
|
+
export const AES_KEY_SIZE = 32;
|
|
50
|
+
/**
|
|
51
|
+
* AES-GCM nonce size in bytes
|
|
52
|
+
*/
|
|
53
|
+
export const AES_NONCE_SIZE = 12;
|
|
54
|
+
/**
|
|
55
|
+
* AES-GCM authentication tag size in bytes
|
|
56
|
+
*/
|
|
57
|
+
export const AES_TAG_SIZE = 16;
|
|
58
|
+
// ===== Export Format Constants =====
|
|
59
|
+
/**
|
|
60
|
+
* Current export format version
|
|
61
|
+
*/
|
|
62
|
+
export const EXPORT_VERSION = 1;
|
|
63
|
+
/**
|
|
64
|
+
* Current protocol version
|
|
65
|
+
*/
|
|
66
|
+
export const PROTOCOL_VERSION = 1;
|
|
14
67
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/crypto/constants.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/crypto/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAE/E,mCAAmC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC,oCAAoC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,sCAAsC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC"}
|
package/dist/crypto/decrypt.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { Keypair, EncryptedData } from '../types/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Decrypts an encrypted payload using the complete reference implementation flow
|
|
8
|
+
* See vaultsandbox-spec.md Section 8: Decryption Process
|
|
8
9
|
*
|
|
9
10
|
* @param encryptedData - The encrypted data from the server
|
|
10
11
|
* @param keypair - The recipient's keypair
|