@digitaldefiance/ecies-lib 3.0.8 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +4 -3
- package/src/builders/ecies-builder.js +5 -9
- package/src/builders/ecies-builder.js.map +1 -1
- package/src/builders/index.js +2 -5
- package/src/builders/index.js.map +1 -1
- package/src/builders/member-builder.js +12 -16
- package/src/builders/member-builder.js.map +1 -1
- package/src/constants.d.ts +14 -0
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +150 -74
- package/src/constants.js.map +1 -1
- package/src/core/errors/crypto-error.js +10 -14
- package/src/core/errors/crypto-error.js.map +1 -1
- package/src/core/index.js +2 -5
- package/src/core/index.js.map +1 -1
- package/src/core/types/result.js +1 -5
- package/src/core/types/result.js.map +1 -1
- package/src/email-string.js +8 -13
- package/src/email-string.js.map +1 -1
- package/src/enumerations/disposed-error-type.d.ts +12 -0
- package/src/enumerations/disposed-error-type.d.ts.map +1 -0
- package/src/enumerations/disposed-error-type.js +13 -0
- package/src/enumerations/disposed-error-type.js.map +1 -0
- package/src/enumerations/ecies-encryption-type.js +20 -27
- package/src/enumerations/ecies-encryption-type.js.map +1 -1
- package/src/enumerations/ecies-error-type.js +2 -5
- package/src/enumerations/ecies-error-type.js.map +1 -1
- package/src/enumerations/ecies-string-key.d.ts +19 -1
- package/src/enumerations/ecies-string-key.d.ts.map +1 -1
- package/src/enumerations/ecies-string-key.js +21 -5
- package/src/enumerations/ecies-string-key.js.map +1 -1
- package/src/enumerations/guid-brand-type.d.ts +27 -0
- package/src/enumerations/guid-brand-type.d.ts.map +1 -0
- package/src/enumerations/guid-brand-type.js +28 -0
- package/src/enumerations/guid-brand-type.js.map +1 -0
- package/src/enumerations/guid-error-type.d.ts +7 -0
- package/src/enumerations/guid-error-type.d.ts.map +1 -0
- package/src/enumerations/guid-error-type.js +8 -0
- package/src/enumerations/guid-error-type.js.map +1 -0
- package/src/enumerations/id-provider-error-type.d.ts +43 -0
- package/src/enumerations/id-provider-error-type.d.ts.map +1 -0
- package/src/enumerations/id-provider-error-type.js +44 -0
- package/src/enumerations/id-provider-error-type.js.map +1 -0
- package/src/enumerations/index.d.ts +3 -0
- package/src/enumerations/index.d.ts.map +1 -1
- package/src/enumerations/index.js +15 -15
- package/src/enumerations/index.js.map +1 -1
- package/src/enumerations/invalid-email-type.js +2 -5
- package/src/enumerations/invalid-email-type.js.map +1 -1
- package/src/enumerations/length-encoding-type.js +2 -5
- package/src/enumerations/length-encoding-type.js.map +1 -1
- package/src/enumerations/length-error-type.js +2 -5
- package/src/enumerations/length-error-type.js.map +1 -1
- package/src/enumerations/member-error-type.js +3 -6
- package/src/enumerations/member-error-type.js.map +1 -1
- package/src/enumerations/member-type.js +3 -6
- package/src/enumerations/member-type.js.map +1 -1
- package/src/enumerations/password-login-error-type.js +2 -5
- package/src/enumerations/password-login-error-type.js.map +1 -1
- package/src/enumerations/pbkdf2-error-type.js +2 -5
- package/src/enumerations/pbkdf2-error-type.js.map +1 -1
- package/src/enumerations/pbkdf2-profile.js +2 -5
- package/src/enumerations/pbkdf2-profile.js.map +1 -1
- package/src/enumerations/secure-storage-error-type.js +2 -5
- package/src/enumerations/secure-storage-error-type.js.map +1 -1
- package/src/errors/disposed.d.ts +20 -2
- package/src/errors/disposed.d.ts.map +1 -1
- package/src/errors/disposed.js +24 -17
- package/src/errors/disposed.js.map +1 -1
- package/src/errors/ecies.d.ts +46 -1
- package/src/errors/ecies.d.ts.map +1 -1
- package/src/errors/ecies.js +65 -10
- package/src/errors/ecies.js.map +1 -1
- package/src/errors/guid.d.ts +44 -0
- package/src/errors/guid.d.ts.map +1 -0
- package/src/errors/guid.js +81 -0
- package/src/errors/guid.js.map +1 -0
- package/src/errors/id-provider.d.ts +23 -0
- package/src/errors/id-provider.d.ts.map +1 -0
- package/src/errors/id-provider.js +29 -0
- package/src/errors/id-provider.js.map +1 -0
- package/src/errors/index.d.ts +3 -0
- package/src/errors/index.d.ts.map +1 -1
- package/src/errors/index.js +9 -10
- package/src/errors/index.js.map +1 -1
- package/src/errors/invalid-email.js +5 -9
- package/src/errors/invalid-email.js.map +1 -1
- package/src/errors/length.js +5 -9
- package/src/errors/length.js.map +1 -1
- package/src/errors/member.js +5 -9
- package/src/errors/member.js.map +1 -1
- package/src/errors/pbkdf2.js +5 -9
- package/src/errors/pbkdf2.js.map +1 -1
- package/src/errors/secure-storage.js +6 -10
- package/src/errors/secure-storage.js.map +1 -1
- package/src/errors/simple-ecies.js +6 -10
- package/src/errors/simple-ecies.js.map +1 -1
- package/src/errors/simple-test-error.js +1 -5
- package/src/errors/simple-test-error.js.map +1 -1
- package/src/i18n-setup.js +29 -37
- package/src/i18n-setup.js.map +1 -1
- package/src/index.d.ts +10 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +44 -57
- package/src/index.js.map +1 -1
- package/src/interfaces/checksum-config.js +1 -2
- package/src/interfaces/checksum-consts.js +1 -2
- package/src/interfaces/configuration-provenance.d.ts +51 -0
- package/src/interfaces/configuration-provenance.d.ts.map +1 -0
- package/src/interfaces/configuration-provenance.js +23 -0
- package/src/interfaces/configuration-provenance.js.map +1 -0
- package/src/interfaces/constants.d.ts +27 -1
- package/src/interfaces/constants.d.ts.map +1 -1
- package/src/interfaces/constants.js +1 -2
- package/src/interfaces/ecies-config.js +1 -2
- package/src/interfaces/ecies-consts.js +1 -2
- package/src/interfaces/ecies-file-service.js +1 -2
- package/src/interfaces/encrypted-chunk.js +1 -4
- package/src/interfaces/encrypted-chunk.js.map +1 -1
- package/src/interfaces/encryption-state.js +1 -4
- package/src/interfaces/encryption-state.js.map +1 -1
- package/src/interfaces/frontend-member-operational.js +1 -2
- package/src/interfaces/guid.d.ts +78 -0
- package/src/interfaces/guid.d.ts.map +1 -0
- package/src/interfaces/guid.js +2 -0
- package/src/interfaces/guid.js.map +1 -0
- package/src/interfaces/id-provider.d.ts +83 -0
- package/src/interfaces/id-provider.d.ts.map +1 -0
- package/src/interfaces/id-provider.js +35 -0
- package/src/interfaces/id-provider.js.map +1 -0
- package/src/interfaces/index.d.ts +1 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +13 -15
- package/src/interfaces/index.js.map +1 -1
- package/src/interfaces/invariant.d.ts +46 -0
- package/src/interfaces/invariant.d.ts.map +1 -0
- package/src/interfaces/invariant.js +18 -0
- package/src/interfaces/invariant.js.map +1 -0
- package/src/interfaces/library-error.js +1 -2
- package/src/interfaces/member-storage.js +1 -2
- package/src/interfaces/member-with-mnemonic.js +1 -2
- package/src/interfaces/multi-recipient-chunk.d.ts +36 -12
- package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -1
- package/src/interfaces/multi-recipient-chunk.js +36 -14
- package/src/interfaces/multi-recipient-chunk.js.map +1 -1
- package/src/interfaces/pbkdf2-config.js +1 -2
- package/src/interfaces/pbkdf2-consts.js +1 -2
- package/src/interfaces/pbkdf2-result.js +1 -2
- package/src/interfaces/stream-config.js +1 -4
- package/src/interfaces/stream-config.js.map +1 -1
- package/src/interfaces/stream-header.js +1 -4
- package/src/interfaces/stream-header.js.map +1 -1
- package/src/interfaces/stream-progress.js +1 -2
- package/src/lib/crypto-container.js +9 -13
- package/src/lib/crypto-container.js.map +1 -1
- package/src/lib/guid.d.ts +344 -0
- package/src/lib/guid.d.ts.map +1 -0
- package/src/lib/guid.js +914 -0
- package/src/lib/guid.js.map +1 -0
- package/src/lib/id-providers/custom-provider.d.ts +69 -0
- package/src/lib/id-providers/custom-provider.d.ts.map +1 -0
- package/src/lib/id-providers/custom-provider.js +128 -0
- package/src/lib/id-providers/custom-provider.js.map +1 -0
- package/src/lib/id-providers/guidv4-provider.d.ts +46 -0
- package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -0
- package/src/lib/id-providers/guidv4-provider.js +105 -0
- package/src/lib/id-providers/guidv4-provider.js.map +1 -0
- package/src/lib/id-providers/index.d.ts +30 -0
- package/src/lib/id-providers/index.d.ts.map +1 -0
- package/src/lib/id-providers/index.js +29 -0
- package/src/lib/id-providers/index.js.map +1 -0
- package/src/lib/id-providers/objectid-provider.d.ts +33 -0
- package/src/lib/id-providers/objectid-provider.d.ts.map +1 -0
- package/src/lib/id-providers/objectid-provider.js +79 -0
- package/src/lib/id-providers/objectid-provider.js.map +1 -0
- package/src/lib/id-providers/uuid-provider.d.ts +42 -0
- package/src/lib/id-providers/uuid-provider.d.ts.map +1 -0
- package/src/lib/id-providers/uuid-provider.js +96 -0
- package/src/lib/id-providers/uuid-provider.js.map +1 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/index.d.ts.map +1 -1
- package/src/lib/index.js +2 -4
- package/src/lib/index.js.map +1 -1
- package/src/lib/invariant-validator.d.ts +59 -0
- package/src/lib/invariant-validator.d.ts.map +1 -0
- package/src/lib/invariant-validator.js +97 -0
- package/src/lib/invariant-validator.js.map +1 -0
- package/src/lib/invariants/encryption-algorithm-consistency.d.ts +17 -0
- package/src/lib/invariants/encryption-algorithm-consistency.d.ts.map +1 -0
- package/src/lib/invariants/encryption-algorithm-consistency.js +49 -0
- package/src/lib/invariants/encryption-algorithm-consistency.js.map +1 -0
- package/src/lib/invariants/index.d.ts +4 -0
- package/src/lib/invariants/index.d.ts.map +1 -0
- package/src/lib/invariants/index.js +4 -0
- package/src/lib/invariants/index.js.map +1 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.d.ts +16 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.d.ts.map +1 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.js +58 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.js.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts +18 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.js +31 -0
- package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
- package/src/member.js +43 -48
- package/src/member.js.map +1 -1
- package/src/pbkdf2-profiles.js +1 -2
- package/src/phone-number.js +7 -11
- package/src/phone-number.js.map +1 -1
- package/src/regexes.js +3 -6
- package/src/regexes.js.map +1 -1
- package/src/secure-buffer.d.ts +17 -1
- package/src/secure-buffer.d.ts.map +1 -1
- package/src/secure-buffer.js +40 -22
- package/src/secure-buffer.js.map +1 -1
- package/src/secure-string.js +20 -24
- package/src/secure-string.js.map +1 -1
- package/src/services/aes-gcm.js +21 -25
- package/src/services/aes-gcm.js.map +1 -1
- package/src/services/chunk-processor.js +32 -36
- package/src/services/chunk-processor.js.map +1 -1
- package/src/services/ecies/crypto-core.js +33 -37
- package/src/services/ecies/crypto-core.js.map +1 -1
- package/src/services/ecies/example.js +37 -44
- package/src/services/ecies/example.js.map +1 -1
- package/src/services/ecies/file.js +1 -5
- package/src/services/ecies/file.js.map +1 -1
- package/src/services/ecies/index.js +10 -15
- package/src/services/ecies/index.js.map +1 -1
- package/src/services/ecies/integration.js +23 -28
- package/src/services/ecies/integration.js.map +1 -1
- package/src/services/ecies/interfaces.js +1 -2
- package/src/services/ecies/interfaces.js.map +1 -1
- package/src/services/ecies/manual-test.js +26 -34
- package/src/services/ecies/manual-test.js.map +1 -1
- package/src/services/ecies/multi-recipient.js +47 -51
- package/src/services/ecies/multi-recipient.js.map +1 -1
- package/src/services/ecies/service.js +27 -31
- package/src/services/ecies/service.js.map +1 -1
- package/src/services/ecies/signature.js +9 -13
- package/src/services/ecies/signature.js.map +1 -1
- package/src/services/ecies/single-recipient.js +42 -46
- package/src/services/ecies/single-recipient.js.map +1 -1
- package/src/services/encryption-stream.d.ts +3 -1
- package/src/services/encryption-stream.d.ts.map +1 -1
- package/src/services/encryption-stream.js +46 -48
- package/src/services/encryption-stream.js.map +1 -1
- package/src/services/index.js +5 -8
- package/src/services/index.js.map +1 -1
- package/src/services/multi-recipient-processor.d.ts +12 -2
- package/src/services/multi-recipient-processor.d.ts.map +1 -1
- package/src/services/multi-recipient-processor.js +65 -56
- package/src/services/multi-recipient-processor.js.map +1 -1
- package/src/services/password-login.js +33 -37
- package/src/services/password-login.js.map +1 -1
- package/src/services/pbkdf2.js +8 -12
- package/src/services/pbkdf2.js.map +1 -1
- package/src/services/progress-tracker.js +5 -9
- package/src/services/progress-tracker.js.map +1 -1
- package/src/services/resumable-encryption.js +24 -28
- package/src/services/resumable-encryption.js.map +1 -1
- package/src/services/xor.js +1 -5
- package/src/services/xor.js.map +1 -1
- package/src/test-mocks/index.js +1 -4
- package/src/test-mocks/index.js.map +1 -1
- package/src/test-mocks/mock-frontend-member.js +20 -24
- package/src/test-mocks/mock-frontend-member.js.map +1 -1
- package/src/testing.js +1 -4
- package/src/testing.js.map +1 -1
- package/src/translations/de.d.ts +2 -1
- package/src/translations/de.d.ts.map +1 -1
- package/src/translations/de.js +190 -170
- package/src/translations/de.js.map +1 -1
- package/src/translations/en-US.d.ts +2 -1
- package/src/translations/en-US.d.ts.map +1 -1
- package/src/translations/en-US.js +190 -170
- package/src/translations/en-US.js.map +1 -1
- package/src/translations/es.d.ts +2 -1
- package/src/translations/es.d.ts.map +1 -1
- package/src/translations/es.js +190 -170
- package/src/translations/es.js.map +1 -1
- package/src/translations/fr.d.ts +2 -1
- package/src/translations/fr.d.ts.map +1 -1
- package/src/translations/fr.js +190 -170
- package/src/translations/fr.js.map +1 -1
- package/src/translations/ja.d.ts +2 -1
- package/src/translations/ja.d.ts.map +1 -1
- package/src/translations/ja.js +189 -170
- package/src/translations/ja.js.map +1 -1
- package/src/translations/uk.d.ts +2 -1
- package/src/translations/uk.d.ts.map +1 -1
- package/src/translations/uk.js +192 -170
- package/src/translations/uk.js.map +1 -1
- package/src/translations/zh-cn.d.ts +2 -1
- package/src/translations/zh-cn.d.ts.map +1 -1
- package/src/translations/zh-cn.js +189 -170
- package/src/translations/zh-cn.js.map +1 -1
- package/src/types/deep-partial.js +1 -2
- package/src/types.d.ts +31 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.js +1 -2
- package/src/utils.js +59 -77
- package/src/utils.js.map +1 -1
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const i18n_setup_1 = require("../i18n-setup");
|
|
7
|
-
const enumerations_1 = require("../enumerations");
|
|
1
|
+
import { getMultiRecipientConstants, } from '../interfaces/multi-recipient-chunk';
|
|
2
|
+
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
|
|
3
|
+
import { EciesComponentId, getEciesI18nEngine } from '../i18n-setup';
|
|
4
|
+
import { EciesStringKey } from '../enumerations';
|
|
5
|
+
import { Constants } from '../constants';
|
|
8
6
|
/**
|
|
9
|
-
* Processes multi-recipient chunks using symmetric encryption
|
|
7
|
+
* Processes multi-recipient chunks using symmetric encryption.
|
|
8
|
+
* Supports dynamic recipient ID sizes based on the configured ID provider.
|
|
10
9
|
*/
|
|
11
|
-
class MultiRecipientProcessor {
|
|
10
|
+
export class MultiRecipientProcessor {
|
|
12
11
|
ecies;
|
|
13
|
-
|
|
12
|
+
config;
|
|
13
|
+
recipientIdSize;
|
|
14
|
+
constants;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new multi-recipient processor.
|
|
17
|
+
* @param ecies - ECIES service for key encryption
|
|
18
|
+
* @param config - Configuration containing ID provider (defaults to global Constants)
|
|
19
|
+
*/
|
|
20
|
+
constructor(ecies, config = Constants) {
|
|
14
21
|
this.ecies = ecies;
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.recipientIdSize = config.idProvider.byteLength;
|
|
24
|
+
this.constants = getMultiRecipientConstants(this.recipientIdSize);
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
27
|
* Encrypt chunk for multiple recipients
|
|
18
28
|
*/
|
|
19
29
|
async encryptChunk(data, recipients, chunkIndex, isLast, symmetricKey) {
|
|
20
30
|
// Validate inputs
|
|
21
|
-
const engine =
|
|
22
|
-
if (recipients.length === 0 || recipients.length >
|
|
23
|
-
throw new Error(engine.translate(
|
|
31
|
+
const engine = getEciesI18nEngine();
|
|
32
|
+
if (recipients.length === 0 || recipients.length > this.constants.MAX_RECIPIENTS) {
|
|
33
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_InvalidRecipientCountTemplate, { count: recipients.length }));
|
|
24
34
|
}
|
|
25
35
|
if (symmetricKey.length !== 32) {
|
|
26
|
-
throw new Error(engine.translate(
|
|
36
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_SymmetricKeyMust32Bytes));
|
|
27
37
|
}
|
|
28
38
|
if (chunkIndex < 0 || chunkIndex > 0xFFFFFFFF) {
|
|
29
|
-
throw new Error(engine.translate(
|
|
39
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_InvalidChunkIndexTemplate, { index: chunkIndex }));
|
|
30
40
|
}
|
|
31
41
|
if (data.length > 0x7FFFFFFF) {
|
|
32
|
-
throw new Error(engine.translate(
|
|
42
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_DataSizeExceedsMaximumTemplate, { size: data.length }));
|
|
33
43
|
}
|
|
34
44
|
// Check for duplicate recipient IDs
|
|
35
45
|
const seenIds = new Set();
|
|
36
46
|
for (const recipient of recipients) {
|
|
37
47
|
const idStr = Buffer.from(recipient.id).toString('hex');
|
|
38
48
|
if (seenIds.has(idStr)) {
|
|
39
|
-
throw new Error(engine.translate(
|
|
49
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_DuplicateRecipientId));
|
|
40
50
|
}
|
|
41
51
|
seenIds.add(idStr);
|
|
42
52
|
}
|
|
43
53
|
// Encrypt data with AES-256-GCM
|
|
44
|
-
const iv =
|
|
45
|
-
const cipher =
|
|
54
|
+
const iv = randomBytes(12);
|
|
55
|
+
const cipher = createCipheriv('aes-256-gcm', symmetricKey, iv);
|
|
46
56
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
47
57
|
const authTag = cipher.getAuthTag();
|
|
48
58
|
// Build recipient headers
|
|
49
59
|
const recipientHeaders = [];
|
|
50
60
|
for (const recipient of recipients) {
|
|
51
|
-
if (recipient.id.length !==
|
|
52
|
-
throw new Error(
|
|
61
|
+
if (recipient.id.length !== this.recipientIdSize) {
|
|
62
|
+
throw new Error(`Recipient ID must be ${this.recipientIdSize} bytes (configured by ID provider), got ${recipient.id.length} bytes`);
|
|
53
63
|
}
|
|
54
64
|
const encryptedKey = await this.ecies.encryptSimpleOrSingle(false, recipient.publicKey, symmetricKey);
|
|
55
65
|
recipientHeaders.push({
|
|
@@ -61,30 +71,30 @@ class MultiRecipientProcessor {
|
|
|
61
71
|
// Calculate sizes with overflow check
|
|
62
72
|
let recipientHeadersSize = 0;
|
|
63
73
|
for (const h of recipientHeaders) {
|
|
64
|
-
const headerSize =
|
|
65
|
-
|
|
74
|
+
const headerSize = this.recipientIdSize +
|
|
75
|
+
this.constants.KEY_SIZE_BYTES + h.keySize;
|
|
66
76
|
if (recipientHeadersSize + headerSize < recipientHeadersSize) {
|
|
67
|
-
throw new Error(engine.translate(
|
|
77
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_RecipientHeadersSizeOverflow));
|
|
68
78
|
}
|
|
69
79
|
recipientHeadersSize += headerSize;
|
|
70
80
|
}
|
|
71
|
-
const totalSize =
|
|
81
|
+
const totalSize = this.constants.HEADER_SIZE +
|
|
72
82
|
recipientHeadersSize +
|
|
73
83
|
12 + // IV
|
|
74
84
|
encrypted.length +
|
|
75
85
|
16; // Auth tag
|
|
76
86
|
// Check for integer overflow (max safe: 2^31 - 1 for Uint8Array)
|
|
77
87
|
if (totalSize > 0x7FFFFFFF || totalSize < 0) {
|
|
78
|
-
throw new Error(engine.translate(
|
|
88
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkSizeOverflow));
|
|
79
89
|
}
|
|
80
90
|
// Build chunk
|
|
81
91
|
const chunk = new Uint8Array(totalSize);
|
|
82
92
|
const view = new DataView(chunk.buffer);
|
|
83
93
|
let offset = 0;
|
|
84
94
|
// Write header
|
|
85
|
-
view.setUint32(offset,
|
|
95
|
+
view.setUint32(offset, this.constants.MAGIC, false);
|
|
86
96
|
offset += 4;
|
|
87
|
-
view.setUint16(offset,
|
|
97
|
+
view.setUint16(offset, this.constants.VERSION, false);
|
|
88
98
|
offset += 2;
|
|
89
99
|
view.setUint16(offset, recipients.length, false);
|
|
90
100
|
offset += 2;
|
|
@@ -94,16 +104,16 @@ class MultiRecipientProcessor {
|
|
|
94
104
|
offset += 4;
|
|
95
105
|
view.setUint32(offset, encrypted.length, false);
|
|
96
106
|
offset += 4;
|
|
97
|
-
view.setUint8(offset, isLast ?
|
|
107
|
+
view.setUint8(offset, isLast ? this.constants.FLAG_IS_LAST : 0);
|
|
98
108
|
offset += 1;
|
|
99
109
|
// Padding to 32 bytes
|
|
100
|
-
offset =
|
|
110
|
+
offset = this.constants.HEADER_SIZE;
|
|
101
111
|
// Write recipient headers
|
|
102
112
|
for (const header of recipientHeaders) {
|
|
103
113
|
chunk.set(header.id, offset);
|
|
104
|
-
offset +=
|
|
114
|
+
offset += this.recipientIdSize;
|
|
105
115
|
view.setUint16(offset, header.keySize, false);
|
|
106
|
-
offset +=
|
|
116
|
+
offset += this.constants.KEY_SIZE_BYTES;
|
|
107
117
|
chunk.set(header.encryptedKey, offset);
|
|
108
118
|
offset += header.keySize;
|
|
109
119
|
}
|
|
@@ -126,27 +136,27 @@ class MultiRecipientProcessor {
|
|
|
126
136
|
* Decrypt chunk for specific recipient
|
|
127
137
|
*/
|
|
128
138
|
async decryptChunk(chunkData, recipientId, privateKey) {
|
|
129
|
-
const engine =
|
|
130
|
-
if (chunkData.length <
|
|
131
|
-
throw new Error(engine.translate(
|
|
139
|
+
const engine = getEciesI18nEngine();
|
|
140
|
+
if (chunkData.length < this.constants.HEADER_SIZE) {
|
|
141
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkTooSmall));
|
|
132
142
|
}
|
|
133
143
|
const view = new DataView(chunkData.buffer, chunkData.byteOffset);
|
|
134
144
|
let offset = 0;
|
|
135
145
|
// Parse header
|
|
136
146
|
const magic = view.getUint32(offset, false);
|
|
137
147
|
offset += 4;
|
|
138
|
-
if (magic !==
|
|
139
|
-
throw new Error(engine.translate(
|
|
148
|
+
if (magic !== this.constants.MAGIC) {
|
|
149
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_InvalidChunkMagic));
|
|
140
150
|
}
|
|
141
151
|
const version = view.getUint16(offset, false);
|
|
142
152
|
offset += 2;
|
|
143
|
-
if (version !==
|
|
144
|
-
throw new Error(engine.translate(
|
|
153
|
+
if (version !== this.constants.VERSION) {
|
|
154
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_UnsupportedVersionTemplate, { version }));
|
|
145
155
|
}
|
|
146
156
|
const recipientCount = view.getUint16(offset, false);
|
|
147
157
|
offset += 2;
|
|
148
|
-
if (recipientCount === 0 || recipientCount >
|
|
149
|
-
throw new Error(engine.translate(
|
|
158
|
+
if (recipientCount === 0 || recipientCount > this.constants.MAX_RECIPIENTS) {
|
|
159
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_InvalidRecipientCountTemplate, { count: recipientCount }));
|
|
150
160
|
}
|
|
151
161
|
const chunkIndex = view.getUint32(offset, false);
|
|
152
162
|
offset += 4;
|
|
@@ -155,35 +165,35 @@ class MultiRecipientProcessor {
|
|
|
155
165
|
const encryptedSize = view.getUint32(offset, false);
|
|
156
166
|
offset += 4;
|
|
157
167
|
const flags = view.getUint8(offset);
|
|
158
|
-
offset =
|
|
168
|
+
offset = this.constants.HEADER_SIZE;
|
|
159
169
|
// Validate encryptedSize against chunk size
|
|
160
|
-
const minChunkSize =
|
|
170
|
+
const minChunkSize = this.constants.HEADER_SIZE + 12 + encryptedSize + 16;
|
|
161
171
|
if (chunkData.length < minChunkSize) {
|
|
162
|
-
throw new Error(engine.translate(
|
|
172
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkTooSmallForEncryptedSize));
|
|
163
173
|
}
|
|
164
174
|
// Find recipient header and decrypt symmetric key
|
|
165
175
|
let symmetricKey = null;
|
|
166
176
|
let tempOffset = offset;
|
|
167
177
|
for (let i = 0; i < recipientCount; i++) {
|
|
168
178
|
// Check if we have enough data for recipient ID
|
|
169
|
-
if (tempOffset +
|
|
170
|
-
throw new Error(engine.translate(
|
|
179
|
+
if (tempOffset + this.recipientIdSize > chunkData.length) {
|
|
180
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkTruncatedRecipientId));
|
|
171
181
|
}
|
|
172
|
-
const id = chunkData.slice(tempOffset, tempOffset +
|
|
173
|
-
tempOffset +=
|
|
182
|
+
const id = chunkData.slice(tempOffset, tempOffset + this.recipientIdSize);
|
|
183
|
+
tempOffset += this.recipientIdSize;
|
|
174
184
|
// Check if we have enough data for keySize field
|
|
175
|
-
if (tempOffset +
|
|
176
|
-
throw new Error(engine.translate(
|
|
185
|
+
if (tempOffset + this.constants.KEY_SIZE_BYTES > chunkData.length) {
|
|
186
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkTruncatedKeySize));
|
|
177
187
|
}
|
|
178
188
|
const keySize = view.getUint16(tempOffset, false);
|
|
179
|
-
tempOffset +=
|
|
189
|
+
tempOffset += this.constants.KEY_SIZE_BYTES;
|
|
180
190
|
// Validate keySize (typical ECIES: 100-400 bytes)
|
|
181
191
|
if (keySize === 0 || keySize > 1000) {
|
|
182
|
-
throw new Error(engine.translate(
|
|
192
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_InvalidKeySizeTemplate, { size: keySize }));
|
|
183
193
|
}
|
|
184
194
|
// Check if we have enough data for the encrypted key
|
|
185
195
|
if (tempOffset + keySize > chunkData.length) {
|
|
186
|
-
throw new Error(engine.translate(
|
|
196
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_ChunkTruncatedEncryptedKey));
|
|
187
197
|
}
|
|
188
198
|
const encryptedKey = chunkData.slice(tempOffset, tempOffset + keySize);
|
|
189
199
|
tempOffset += keySize;
|
|
@@ -194,7 +204,7 @@ class MultiRecipientProcessor {
|
|
|
194
204
|
}
|
|
195
205
|
}
|
|
196
206
|
if (!symmetricKey) {
|
|
197
|
-
throw new Error(engine.translate(
|
|
207
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_MultiRecipient_RecipientNotFoundInChunk));
|
|
198
208
|
}
|
|
199
209
|
// Update offset to after all recipient headers
|
|
200
210
|
offset = tempOffset;
|
|
@@ -207,7 +217,7 @@ class MultiRecipientProcessor {
|
|
|
207
217
|
// Read auth tag
|
|
208
218
|
const authTag = chunkData.slice(offset, offset + 16);
|
|
209
219
|
// Decrypt
|
|
210
|
-
const decipher =
|
|
220
|
+
const decipher = createDecipheriv('aes-256-gcm', symmetricKey, iv);
|
|
211
221
|
decipher.setAuthTag(authTag);
|
|
212
222
|
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
213
223
|
return {
|
|
@@ -234,5 +244,4 @@ class MultiRecipientProcessor {
|
|
|
234
244
|
return diff === 0;
|
|
235
245
|
}
|
|
236
246
|
}
|
|
237
|
-
exports.MultiRecipientProcessor = MultiRecipientProcessor;
|
|
238
247
|
//# sourceMappingURL=multi-recipient-processor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-recipient-processor.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/multi-recipient-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multi-recipient-processor.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/multi-recipient-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cA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CAAC;CACF"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
const i18n_setup_1 = require("../i18n-setup");
|
|
14
|
-
class PasswordLoginService {
|
|
1
|
+
import { Wallet } from '@ethereumjs/wallet';
|
|
2
|
+
import { EciesEncryptionTypeEnum } from '../enumerations/ecies-encryption-type';
|
|
3
|
+
import { Pbkdf2ProfileEnum } from '../enumerations/pbkdf2-profile';
|
|
4
|
+
import { SecureString } from '../secure-string';
|
|
5
|
+
import { hexToUint8Array, uint8ArrayToHex } from '../utils';
|
|
6
|
+
import { AESGCMService } from './aes-gcm';
|
|
7
|
+
import { EciesStringKey, PasswordLoginErrorTypeEnum } from '../enumerations';
|
|
8
|
+
import { buildReasonMap, TranslatableGenericError, TypedHandleableError } from '@digitaldefiance/i18n-lib';
|
|
9
|
+
import { Constants } from '../constants';
|
|
10
|
+
import { EciesComponentId } from '../i18n-setup';
|
|
11
|
+
export class PasswordLoginService {
|
|
15
12
|
eciesService;
|
|
16
13
|
pbkdf2Service;
|
|
17
14
|
eciesConsts;
|
|
@@ -19,23 +16,23 @@ class PasswordLoginService {
|
|
|
19
16
|
static saltStorageKey = 'passwordLoginSalt';
|
|
20
17
|
static encryptedMnemonicStorageKey = 'encryptedMnemonic';
|
|
21
18
|
static profileStorageKey = 'pbkdf2Profile';
|
|
22
|
-
constructor(eciesService, pbkdf2Service, eciesParams =
|
|
19
|
+
constructor(eciesService, pbkdf2Service, eciesParams = Constants.ECIES) {
|
|
23
20
|
this.eciesService = eciesService;
|
|
24
21
|
this.pbkdf2Service = pbkdf2Service;
|
|
25
22
|
this.eciesConsts = eciesParams;
|
|
26
23
|
}
|
|
27
|
-
async createPasswordLoginBundle(mnemonic, password, profile =
|
|
24
|
+
async createPasswordLoginBundle(mnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
|
|
28
25
|
const { wallet } = this.eciesService.walletAndSeedFromMnemonic(mnemonic);
|
|
29
26
|
const derivedKey = await this.pbkdf2Service.deriveKeyFromPasswordWithProfileAsync(password.valueAsUint8Array, profile);
|
|
30
27
|
// Encrypt private key with derived key
|
|
31
28
|
const privateKeyBytes = wallet.getPrivateKey();
|
|
32
|
-
const { encrypted, iv, tag } = await
|
|
29
|
+
const { encrypted, iv, tag } = await AESGCMService.encrypt(privateKeyBytes, derivedKey.hash, true);
|
|
33
30
|
if (!tag) {
|
|
34
|
-
throw new
|
|
31
|
+
throw new TranslatableGenericError(EciesComponentId, EciesStringKey.Error_Utils_EncryptionFailedNoAuthTag);
|
|
35
32
|
}
|
|
36
|
-
const encryptedPrivateKey =
|
|
33
|
+
const encryptedPrivateKey = AESGCMService.combineIvTagAndEncryptedData(iv, encrypted, tag);
|
|
37
34
|
// now use the public key to encrypt the mnemonic and store it
|
|
38
|
-
const encryptedMnemonic = await this.eciesService.encrypt(
|
|
35
|
+
const encryptedMnemonic = await this.eciesService.encrypt(EciesEncryptionTypeEnum.Simple, wallet.getPublicKey(), mnemonic.valueAsUint8Array);
|
|
39
36
|
return {
|
|
40
37
|
salt: derivedKey.salt,
|
|
41
38
|
encryptedPrivateKey: encryptedPrivateKey,
|
|
@@ -48,32 +45,32 @@ class PasswordLoginService {
|
|
|
48
45
|
* @param mnemonic The user's mnemonic
|
|
49
46
|
* @param password The user's password
|
|
50
47
|
*/
|
|
51
|
-
async setupPasswordLoginLocalStorageBundle(mnemonic, password, profile =
|
|
48
|
+
async setupPasswordLoginLocalStorageBundle(mnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
|
|
52
49
|
const { salt, encryptedPrivateKey, encryptedMnemonic, wallet } = await this.createPasswordLoginBundle(mnemonic, password, profile);
|
|
53
50
|
// store the salt and encrypted private key in local storage
|
|
54
51
|
try {
|
|
55
|
-
localStorage.setItem(PasswordLoginService.saltStorageKey,
|
|
56
|
-
localStorage.setItem(PasswordLoginService.privateKeyStorageKey,
|
|
57
|
-
localStorage.setItem(PasswordLoginService.encryptedMnemonicStorageKey,
|
|
52
|
+
localStorage.setItem(PasswordLoginService.saltStorageKey, uint8ArrayToHex(salt));
|
|
53
|
+
localStorage.setItem(PasswordLoginService.privateKeyStorageKey, uint8ArrayToHex(encryptedPrivateKey));
|
|
54
|
+
localStorage.setItem(PasswordLoginService.encryptedMnemonicStorageKey, uint8ArrayToHex(encryptedMnemonic));
|
|
58
55
|
localStorage.setItem(PasswordLoginService.profileStorageKey, profile);
|
|
59
56
|
}
|
|
60
57
|
catch (error) {
|
|
61
|
-
throw new
|
|
58
|
+
throw new TypedHandleableError(EciesComponentId, PasswordLoginErrorTypeEnum.FailedToStoreLoginData, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), new Error(), { cause: error instanceof Error ? error : undefined });
|
|
62
59
|
}
|
|
63
60
|
return wallet;
|
|
64
61
|
}
|
|
65
|
-
async getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile =
|
|
62
|
+
async getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
|
|
66
63
|
if (!salt || !encryptedPrivateKey || !encryptedMnemonic) {
|
|
67
|
-
throw new
|
|
64
|
+
throw new TypedHandleableError(EciesComponentId, PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), new Error());
|
|
68
65
|
}
|
|
69
66
|
const derivedKey = await this.pbkdf2Service.deriveKeyFromPasswordWithProfileAsync(password.valueAsUint8Array, profile, salt);
|
|
70
67
|
// Decrypt private key with derived key
|
|
71
|
-
const { iv, encryptedDataWithTag } =
|
|
72
|
-
const privateKeyBytes = await
|
|
73
|
-
const wallet =
|
|
68
|
+
const { iv, encryptedDataWithTag } = AESGCMService.splitEncryptedData(encryptedPrivateKey, true, this.eciesConsts);
|
|
69
|
+
const privateKeyBytes = await AESGCMService.decrypt(iv, encryptedDataWithTag, derivedKey.hash, true, this.eciesConsts);
|
|
70
|
+
const wallet = Wallet.fromPrivateKey(privateKeyBytes);
|
|
74
71
|
// now decrypt the mnemonic
|
|
75
72
|
const decryptedMnemonic = await this.eciesService.decryptSimpleOrSingleWithHeader(true, wallet.getPrivateKey(), encryptedMnemonic);
|
|
76
|
-
return { wallet, mnemonic: new
|
|
73
|
+
return { wallet, mnemonic: new SecureString(decryptedMnemonic) };
|
|
77
74
|
}
|
|
78
75
|
/**
|
|
79
76
|
* Recover wallet and mnemonic from password
|
|
@@ -91,12 +88,12 @@ class PasswordLoginService {
|
|
|
91
88
|
saltHex === '' ||
|
|
92
89
|
encryptedPrivateKeyHex === '' ||
|
|
93
90
|
encryptedMnemonicHex === '') {
|
|
94
|
-
throw new
|
|
91
|
+
throw new TypedHandleableError(EciesComponentId, PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), new Error());
|
|
95
92
|
}
|
|
96
|
-
const salt =
|
|
97
|
-
const encryptedPrivateKey =
|
|
98
|
-
const encryptedMnemonic =
|
|
99
|
-
const profile = profileStr ||
|
|
93
|
+
const salt = hexToUint8Array(saltHex);
|
|
94
|
+
const encryptedPrivateKey = hexToUint8Array(encryptedPrivateKeyHex);
|
|
95
|
+
const encryptedMnemonic = hexToUint8Array(encryptedMnemonicHex);
|
|
96
|
+
const profile = profileStr || Pbkdf2ProfileEnum.BROWSER_PASSWORD;
|
|
100
97
|
return await this.getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile);
|
|
101
98
|
}
|
|
102
99
|
/**
|
|
@@ -115,5 +112,4 @@ class PasswordLoginService {
|
|
|
115
112
|
encryptedMnemonicHex !== '');
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
|
-
exports.PasswordLoginService = PasswordLoginService;
|
|
119
115
|
//# sourceMappingURL=password-login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-login.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/password-login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-login.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/password-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE3G,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,OAAO,oBAAoB;IACZ,YAAY,CAAe;IAC3B,aAAa,CAAgB;IAC7B,WAAW,CAAkB;IACzC,MAAM,CAAU,oBAAoB,GAAG,qBAAqB,CAAC;IAC7D,MAAM,CAAU,cAAc,GAAG,mBAAmB,CAAC;IACrD,MAAM,CAAU,2BAA2B,GAAG,mBAAmB,CAAC;IAClE,MAAM,CAAU,iBAAiB,GAAG,eAAe,CAAC;IAE3D,YAAY,YAA0B,EAAE,aAA4B,EAAE,c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
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const pbkdf2_error_type_1 = require("../enumerations/pbkdf2-error-type");
|
|
6
|
-
const pbkdf2_1 = require("../errors/pbkdf2");
|
|
1
|
+
import { Constants } from '../constants';
|
|
2
|
+
import { Pbkdf2ErrorType } from '../enumerations/pbkdf2-error-type';
|
|
3
|
+
import { Pbkdf2Error } from '../errors/pbkdf2';
|
|
7
4
|
/**
|
|
8
5
|
* Service for handling PBKDF2 (Password-Based Key Derivation Function 2) operations.
|
|
9
6
|
* This service provides functionality for:
|
|
@@ -12,11 +9,11 @@ const pbkdf2_1 = require("../errors/pbkdf2");
|
|
|
12
9
|
* - Managing salt and iteration parameters
|
|
13
10
|
* - Both synchronous and asynchronous key derivation
|
|
14
11
|
*/
|
|
15
|
-
class Pbkdf2Service {
|
|
12
|
+
export class Pbkdf2Service {
|
|
16
13
|
profiles;
|
|
17
14
|
eciesConsts;
|
|
18
15
|
pbkdf2Consts;
|
|
19
|
-
constructor(profiles =
|
|
16
|
+
constructor(profiles = Constants.PBKDF2_PROFILES, eciesParams = Constants.ECIES, pbkdf2Params = Constants.PBKDF2) {
|
|
20
17
|
this.profiles = profiles;
|
|
21
18
|
this.eciesConsts = eciesParams;
|
|
22
19
|
this.pbkdf2Consts = pbkdf2Params;
|
|
@@ -29,7 +26,7 @@ class Pbkdf2Service {
|
|
|
29
26
|
getProfileConfig(profile) {
|
|
30
27
|
const profileConfig = this.profiles[profile];
|
|
31
28
|
if (!profileConfig) {
|
|
32
|
-
throw new
|
|
29
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidProfile);
|
|
33
30
|
}
|
|
34
31
|
return {
|
|
35
32
|
hashBytes: profileConfig.hashBytes,
|
|
@@ -77,7 +74,7 @@ class Pbkdf2Service {
|
|
|
77
74
|
const config = this.getConfig(iterations, saltBytes, keySize, algorithm);
|
|
78
75
|
const saltBytes_ = salt ?? crypto.getRandomValues(new Uint8Array(config.saltBytes));
|
|
79
76
|
if (saltBytes_.length !== config.saltBytes) {
|
|
80
|
-
throw new
|
|
77
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidSaltLength);
|
|
81
78
|
}
|
|
82
79
|
const keyMaterial = await crypto.subtle.importKey('raw', new Uint8Array(password), 'PBKDF2', false, ['deriveBits']);
|
|
83
80
|
const keyArray = await crypto.subtle.deriveBits({
|
|
@@ -88,7 +85,7 @@ class Pbkdf2Service {
|
|
|
88
85
|
}, keyMaterial, config.hashBytes * 8);
|
|
89
86
|
const keyBytes = new Uint8Array(keyArray);
|
|
90
87
|
if (keyBytes.length !== config.hashBytes) {
|
|
91
|
-
throw new
|
|
88
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidHashLength);
|
|
92
89
|
}
|
|
93
90
|
return {
|
|
94
91
|
salt: saltBytes_,
|
|
@@ -108,5 +105,4 @@ class Pbkdf2Service {
|
|
|
108
105
|
return await this.deriveKeyFromPasswordAsync(password, salt, config.iterations, config.saltBytes, config.hashBytes, config.algorithm);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
exports.Pbkdf2Service = Pbkdf2Service;
|
|
112
108
|
//# sourceMappingURL=pbkdf2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/pbkdf2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/pbkdf2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C;;;;;;;GAOG;AACH,MAAM,OAA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;;;;;OAMG;IACI,KAAK,CAAC,qCAAqC,CAChD,QAAoB,EACpB,OAA0B,EAC1B,IAAiB;QAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,MAAM,IAAI,CAAC,0BAA0B,CAC1C,QAAQ,EACR,IAAI,EACJ,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,SAAS,CACjB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ProgressTracker = void 0;
|
|
4
|
-
const i18n_setup_1 = require("../i18n-setup");
|
|
5
|
-
const ecies_string_key_1 = require("../enumerations/ecies-string-key");
|
|
1
|
+
import { getEciesI18nEngine, EciesComponentId } from '../i18n-setup';
|
|
2
|
+
import { EciesStringKey } from '../enumerations/ecies-string-key';
|
|
6
3
|
/**
|
|
7
4
|
* Tracks progress for streaming operations
|
|
8
5
|
*/
|
|
9
|
-
class ProgressTracker {
|
|
6
|
+
export class ProgressTracker {
|
|
10
7
|
totalBytes;
|
|
11
8
|
startTime;
|
|
12
9
|
lastUpdateTime;
|
|
@@ -25,8 +22,8 @@ class ProgressTracker {
|
|
|
25
22
|
update(chunkBytes) {
|
|
26
23
|
// Validate input
|
|
27
24
|
if (chunkBytes < 0) {
|
|
28
|
-
const engine =
|
|
29
|
-
throw new Error(engine.translate(
|
|
25
|
+
const engine = getEciesI18nEngine();
|
|
26
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Progress_ChunkBytesCannotBeNegative));
|
|
30
27
|
}
|
|
31
28
|
this.bytesProcessed += chunkBytes;
|
|
32
29
|
this.chunksProcessed++;
|
|
@@ -94,5 +91,4 @@ class ProgressTracker {
|
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
|
-
exports.ProgressTracker = ProgressTracker;
|
|
98
94
|
//# sourceMappingURL=progress-tracker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-tracker.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/progress-tracker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"progress-tracker.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/services/progress-tracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,eAAe;IAQG;IAPrB,SAAS,CAAS;IAClB,cAAc,CAAS;IACvB,cAAc,GAAW,CAAC,CAAC;IAC3B,eAAe,GAAW,CAAC,CAAC;IAC5B,iBAAiB,GAAa,EAAE,CAAC;IACxB,oBAAoB,GAAG,CAAC,CAAC;IAE1C,YAA6B,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;QAC9C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAkB;QACvB,iBAAiB;QACjB,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,EAAE,cAAc,CAAC,yCAAyC,CAAC,CAAC,CAAC;QAChH,CAAC;QAED,IAAI,CAAC,cAAc,IAAI,UAAU,CAAC;QAClC,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,G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