@digitaldefiance/node-ecies-lib 1.1.21 → 1.1.22
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 +14 -35
- package/src/constants.ts +182 -0
- package/src/enumerations/index.ts +1 -0
- package/src/enumerations/pbkdf2-profile.ts +8 -0
- package/src/i18n/ecies-i18n-factory.ts +435 -0
- package/{dist/i18n/index.d.ts → src/i18n/index.ts} +0 -1
- package/{dist/index.d.ts → src/index.ts} +0 -1
- package/src/interfaces/authenticated-cipher.ts +9 -0
- package/src/interfaces/authenticated-decipher.ts +8 -0
- package/src/interfaces/checksum-config.ts +4 -0
- package/src/interfaces/checksum-consts.ts +13 -0
- package/src/interfaces/constants.ts +43 -0
- package/src/interfaces/ecies-consts.ts +99 -0
- package/src/interfaces/encryption-consts.ts +10 -0
- package/{dist/interfaces/index.d.ts → src/interfaces/index.ts} +0 -1
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +7 -0
- package/src/interfaces/keyring-consts.ts +5 -0
- package/src/interfaces/member-operational.ts +52 -0
- package/{dist/interfaces/member-with-mnemonic.d.ts → src/interfaces/member-with-mnemonic.ts} +3 -3
- package/{dist/interfaces/multi-encrypted-message.d.ts → src/interfaces/multi-encrypted-message.ts} +5 -5
- package/src/interfaces/multi-encrypted-parsed-header.ts +24 -0
- package/{dist/interfaces/pbkdf-profiles.d.ts → src/interfaces/pbkdf-profiles.ts} +2 -2
- package/src/interfaces/pbkdf2-result.ts +5 -0
- package/src/interfaces/signing-key-private-key-info.ts +12 -0
- package/{dist/interfaces/simple-keypair-buffer.d.ts → src/interfaces/simple-keypair-buffer.ts} +3 -3
- package/{dist/interfaces/simple-keypair.d.ts → src/interfaces/simple-keypair.ts} +3 -3
- package/src/interfaces/simple-public-key-only-buffer.ts +3 -0
- package/src/interfaces/simple-public-key-only.ts +3 -0
- package/src/interfaces/single-encrypted-parsed-header.ts +35 -0
- package/{dist/interfaces/wallet-seed.d.ts → src/interfaces/wallet-seed.ts} +3 -3
- package/src/interfaces/wrapped-key-consts.ts +6 -0
- package/src/member.ts +463 -0
- package/src/services/aes-gcm.ts +160 -0
- package/src/services/ecies/crypto-core.ts +213 -0
- package/src/services/ecies/file.ts +174 -0
- package/{dist/services/ecies/index.d.ts → src/services/ecies/index.ts} +0 -1
- package/src/services/ecies/multi-recipient.ts +583 -0
- package/src/services/ecies/service.ts +351 -0
- package/src/services/ecies/signature.ts +91 -0
- package/src/services/ecies/single-recipient.ts +676 -0
- package/src/services/ecies/utilities.ts +111 -0
- package/src/services/index.ts +3 -0
- package/src/services/pbkdf2.ts +307 -0
- package/{dist/types.d.ts → src/types.ts} +26 -9
- package/src/utils.ts +104 -0
- package/dist/constants.d.ts +0 -32
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -137
- package/dist/constants.js.map +0 -1
- package/dist/enumerations/index.d.ts +0 -2
- package/dist/enumerations/index.d.ts.map +0 -1
- package/dist/enumerations/index.js +0 -18
- package/dist/enumerations/index.js.map +0 -1
- package/dist/enumerations/pbkdf2-profile.d.ts +0 -9
- package/dist/enumerations/pbkdf2-profile.d.ts.map +0 -1
- package/dist/enumerations/pbkdf2-profile.js +0 -13
- package/dist/enumerations/pbkdf2-profile.js.map +0 -1
- package/dist/i18n/ecies-i18n-factory.d.ts +0 -54
- package/dist/i18n/ecies-i18n-factory.d.ts.map +0 -1
- package/dist/i18n/ecies-i18n-factory.js +0 -333
- package/dist/i18n/ecies-i18n-factory.js.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/index.js +0 -18
- package/dist/i18n/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/interfaces/authenticated-cipher.d.ts +0 -10
- package/dist/interfaces/authenticated-cipher.d.ts.map +0 -1
- package/dist/interfaces/authenticated-cipher.js +0 -3
- package/dist/interfaces/authenticated-cipher.js.map +0 -1
- package/dist/interfaces/authenticated-decipher.d.ts +0 -9
- package/dist/interfaces/authenticated-decipher.d.ts.map +0 -1
- package/dist/interfaces/authenticated-decipher.js +0 -3
- package/dist/interfaces/authenticated-decipher.js.map +0 -1
- package/dist/interfaces/checksum-config.d.ts +0 -5
- package/dist/interfaces/checksum-config.d.ts.map +0 -1
- package/dist/interfaces/checksum-config.js +0 -3
- package/dist/interfaces/checksum-config.js.map +0 -1
- package/dist/interfaces/checksum-consts.d.ts +0 -11
- package/dist/interfaces/checksum-consts.d.ts.map +0 -1
- package/dist/interfaces/checksum-consts.js +0 -3
- package/dist/interfaces/checksum-consts.js.map +0 -1
- package/dist/interfaces/constants.d.ts +0 -43
- package/dist/interfaces/constants.d.ts.map +0 -1
- package/dist/interfaces/constants.js +0 -3
- package/dist/interfaces/constants.js.map +0 -1
- package/dist/interfaces/ecies-consts.d.ts +0 -88
- package/dist/interfaces/ecies-consts.d.ts.map +0 -1
- package/dist/interfaces/ecies-consts.js +0 -3
- package/dist/interfaces/ecies-consts.js.map +0 -1
- package/dist/interfaces/encryption-consts.d.ts +0 -11
- package/dist/interfaces/encryption-consts.d.ts.map +0 -1
- package/dist/interfaces/encryption-consts.js +0 -3
- package/dist/interfaces/encryption-consts.js.map +0 -1
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -34
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +0 -6
- package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +0 -1
- package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.js +0 -3
- package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +0 -1
- package/dist/interfaces/keyring-consts.d.ts +0 -6
- package/dist/interfaces/keyring-consts.d.ts.map +0 -1
- package/dist/interfaces/keyring-consts.js +0 -3
- package/dist/interfaces/keyring-consts.js.map +0 -1
- package/dist/interfaces/member-operational.d.ts +0 -36
- package/dist/interfaces/member-operational.d.ts.map +0 -1
- package/dist/interfaces/member-operational.js +0 -3
- package/dist/interfaces/member-operational.js.map +0 -1
- package/dist/interfaces/member-with-mnemonic.d.ts.map +0 -1
- package/dist/interfaces/member-with-mnemonic.js +0 -3
- package/dist/interfaces/member-with-mnemonic.js.map +0 -1
- package/dist/interfaces/multi-encrypted-message.d.ts.map +0 -1
- package/dist/interfaces/multi-encrypted-message.js +0 -3
- package/dist/interfaces/multi-encrypted-message.js.map +0 -1
- package/dist/interfaces/multi-encrypted-parsed-header.d.ts +0 -24
- package/dist/interfaces/multi-encrypted-parsed-header.d.ts.map +0 -1
- package/dist/interfaces/multi-encrypted-parsed-header.js +0 -3
- package/dist/interfaces/multi-encrypted-parsed-header.js.map +0 -1
- package/dist/interfaces/pbkdf-profiles.d.ts.map +0 -1
- package/dist/interfaces/pbkdf-profiles.js +0 -3
- package/dist/interfaces/pbkdf-profiles.js.map +0 -1
- package/dist/interfaces/pbkdf2-result.d.ts +0 -6
- package/dist/interfaces/pbkdf2-result.d.ts.map +0 -1
- package/dist/interfaces/pbkdf2-result.js +0 -3
- package/dist/interfaces/pbkdf2-result.js.map +0 -1
- package/dist/interfaces/signing-key-private-key-info.d.ts +0 -11
- package/dist/interfaces/signing-key-private-key-info.d.ts.map +0 -1
- package/dist/interfaces/signing-key-private-key-info.js +0 -3
- package/dist/interfaces/signing-key-private-key-info.js.map +0 -1
- package/dist/interfaces/simple-keypair-buffer.d.ts.map +0 -1
- package/dist/interfaces/simple-keypair-buffer.js +0 -3
- package/dist/interfaces/simple-keypair-buffer.js.map +0 -1
- package/dist/interfaces/simple-keypair.d.ts.map +0 -1
- package/dist/interfaces/simple-keypair.js +0 -3
- package/dist/interfaces/simple-keypair.js.map +0 -1
- package/dist/interfaces/simple-public-key-only-buffer.d.ts +0 -4
- package/dist/interfaces/simple-public-key-only-buffer.d.ts.map +0 -1
- package/dist/interfaces/simple-public-key-only-buffer.js +0 -3
- package/dist/interfaces/simple-public-key-only-buffer.js.map +0 -1
- package/dist/interfaces/simple-public-key-only.d.ts +0 -4
- package/dist/interfaces/simple-public-key-only.d.ts.map +0 -1
- package/dist/interfaces/simple-public-key-only.js +0 -3
- package/dist/interfaces/simple-public-key-only.js.map +0 -1
- package/dist/interfaces/single-encrypted-parsed-header.d.ts +0 -35
- package/dist/interfaces/single-encrypted-parsed-header.d.ts.map +0 -1
- package/dist/interfaces/single-encrypted-parsed-header.js +0 -3
- package/dist/interfaces/single-encrypted-parsed-header.js.map +0 -1
- package/dist/interfaces/wallet-seed.d.ts.map +0 -1
- package/dist/interfaces/wallet-seed.js +0 -3
- package/dist/interfaces/wallet-seed.js.map +0 -1
- package/dist/interfaces/wrapped-key-consts.d.ts +0 -7
- package/dist/interfaces/wrapped-key-consts.d.ts.map +0 -1
- package/dist/interfaces/wrapped-key-consts.js +0 -3
- package/dist/interfaces/wrapped-key-consts.js.map +0 -1
- package/dist/member.d.ts +0 -74
- package/dist/member.d.ts.map +0 -1
- package/dist/member.js +0 -273
- package/dist/member.js.map +0 -1
- package/dist/services/aes-gcm.d.ts +0 -66
- package/dist/services/aes-gcm.d.ts.map +0 -1
- package/dist/services/aes-gcm.js +0 -115
- package/dist/services/aes-gcm.js.map +0 -1
- package/dist/services/ecies/crypto-core.d.ts +0 -83
- package/dist/services/ecies/crypto-core.d.ts.map +0 -1
- package/dist/services/ecies/crypto-core.js +0 -166
- package/dist/services/ecies/crypto-core.js.map +0 -1
- package/dist/services/ecies/file.d.ts +0 -30
- package/dist/services/ecies/file.d.ts.map +0 -1
- package/dist/services/ecies/file.js +0 -144
- package/dist/services/ecies/file.js.map +0 -1
- package/dist/services/ecies/index.d.ts.map +0 -1
- package/dist/services/ecies/index.js +0 -24
- package/dist/services/ecies/index.js.map +0 -1
- package/dist/services/ecies/multi-recipient.d.ts +0 -82
- package/dist/services/ecies/multi-recipient.d.ts.map +0 -1
- package/dist/services/ecies/multi-recipient.js +0 -360
- package/dist/services/ecies/multi-recipient.js.map +0 -1
- package/dist/services/ecies/service.d.ts +0 -70
- package/dist/services/ecies/service.d.ts.map +0 -1
- package/dist/services/ecies/service.js +0 -167
- package/dist/services/ecies/service.js.map +0 -1
- package/dist/services/ecies/signature.d.ts +0 -38
- package/dist/services/ecies/signature.d.ts.map +0 -1
- package/dist/services/ecies/signature.js +0 -69
- package/dist/services/ecies/signature.js.map +0 -1
- package/dist/services/ecies/single-recipient.d.ts +0 -85
- package/dist/services/ecies/single-recipient.d.ts.map +0 -1
- package/dist/services/ecies/single-recipient.js +0 -399
- package/dist/services/ecies/single-recipient.js.map +0 -1
- package/dist/services/ecies/utilities.d.ts +0 -22
- package/dist/services/ecies/utilities.d.ts.map +0 -1
- package/dist/services/ecies/utilities.js +0 -75
- package/dist/services/ecies/utilities.js.map +0 -1
- package/dist/services/index.d.ts +0 -4
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -20
- package/dist/services/index.js.map +0 -1
- package/dist/services/pbkdf2.d.ts +0 -106
- package/dist/services/pbkdf2.d.ts.map +0 -1
- package/dist/services/pbkdf2.js +0 -195
- package/dist/services/pbkdf2.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -11
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -82
- package/dist/utils.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signing-key-private-key-info.d.ts","sourceRoot":"","sources":["../../src/interfaces/signing-key-private-key-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,uCAAuC,EAAE,MAAM,gDAAgD,CAAC;AAEzG,MAAM,WAAW,yBACf,SAAQ,uCAAuC;IAC/C,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signing-key-private-key-info.js","sourceRoot":"","sources":["../../src/interfaces/signing-key-private-key-info.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-keypair-buffer.d.ts","sourceRoot":"","sources":["../../src/interfaces/simple-keypair-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,WAAW,oBAAqB,SAAQ,0BAA0B;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-keypair-buffer.js","sourceRoot":"","sources":["../../src/interfaces/simple-keypair-buffer.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-keypair.d.ts","sourceRoot":"","sources":["../../src/interfaces/simple-keypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,cAAe,SAAQ,oBAAoB;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-keypair.js","sourceRoot":"","sources":["../../src/interfaces/simple-keypair.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-public-key-only-buffer.d.ts","sourceRoot":"","sources":["../../src/interfaces/simple-public-key-only-buffer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-public-key-only-buffer.js","sourceRoot":"","sources":["../../src/interfaces/simple-public-key-only-buffer.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-public-key-only.d.ts","sourceRoot":"","sources":["../../src/interfaces/simple-public-key-only.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-public-key-only.js","sourceRoot":"","sources":["../../src/interfaces/simple-public-key-only.ts"],"names":[],"mappings":""}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { EciesEncryptionTypeEnum } from '@digitaldefiance/ecies-lib';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for encrypted messages
|
|
4
|
-
*/
|
|
5
|
-
export interface ISingleEncryptedParsedHeader {
|
|
6
|
-
/**
|
|
7
|
-
* The optional preamble, if specified/relevant
|
|
8
|
-
*/
|
|
9
|
-
readonly preamble?: Buffer;
|
|
10
|
-
/**
|
|
11
|
-
* The encryption type used to encrypt the data
|
|
12
|
-
*/
|
|
13
|
-
readonly encryptionType: EciesEncryptionTypeEnum;
|
|
14
|
-
/**
|
|
15
|
-
* The ephemeral public key used to encrypt the data
|
|
16
|
-
*/
|
|
17
|
-
readonly ephemeralPublicKey: Buffer;
|
|
18
|
-
/**
|
|
19
|
-
* The initialization vector used to encrypt the data
|
|
20
|
-
*/
|
|
21
|
-
readonly iv: Buffer;
|
|
22
|
-
/**
|
|
23
|
-
* The authentication tag used to encrypt the data
|
|
24
|
-
*/
|
|
25
|
-
readonly authTag: Buffer;
|
|
26
|
-
/**
|
|
27
|
-
* The length of the encrypted data
|
|
28
|
-
*/
|
|
29
|
-
readonly dataLength: number;
|
|
30
|
-
/**
|
|
31
|
-
* The size of the encrypted data header
|
|
32
|
-
*/
|
|
33
|
-
readonly headerSize: number;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=single-encrypted-parsed-header.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"single-encrypted-parsed-header.d.ts","sourceRoot":"","sources":["../../src/interfaces/single-encrypted-parsed-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,uBAAuB,CAAC;IACjD;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"single-encrypted-parsed-header.js","sourceRoot":"","sources":["../../src/interfaces/single-encrypted-parsed-header.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-seed.d.ts","sourceRoot":"","sources":["../../src/interfaces/wallet-seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-seed.js","sourceRoot":"","sources":["../../src/interfaces/wallet-seed.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapped-key-consts.d.ts","sourceRoot":"","sources":["../../src/interfaces/wrapped-key-consts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapped-key-consts.js","sourceRoot":"","sources":["../../src/interfaces/wrapped-key-consts.ts"],"names":[],"mappings":""}
|
package/dist/member.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { EmailString, MemberErrorType, MemberType, SecureBuffer, SecureString } from '@digitaldefiance/ecies-lib';
|
|
2
|
-
import { Wallet } from '@ethereumjs/wallet';
|
|
3
|
-
/**
|
|
4
|
-
* Custom error classes that work with the plugin i18n system
|
|
5
|
-
*/
|
|
6
|
-
export declare class NodeMemberError extends Error {
|
|
7
|
-
readonly type: MemberErrorType;
|
|
8
|
-
constructor(message: string, type: MemberErrorType);
|
|
9
|
-
}
|
|
10
|
-
import { ECIESService } from './services/ecies/service';
|
|
11
|
-
import { Types } from 'mongoose';
|
|
12
|
-
import { IMemberOperational } from './interfaces/member-operational';
|
|
13
|
-
import { SignatureBuffer } from './types';
|
|
14
|
-
/**
|
|
15
|
-
* A member of Brightchain.
|
|
16
|
-
* In the Owner Free Filesystem (OFF), members are used to:
|
|
17
|
-
* 1. Sign and verify data
|
|
18
|
-
* 2. Encrypt and decrypt data
|
|
19
|
-
* 3. Participate in voting
|
|
20
|
-
* 4. Establish ownership of data
|
|
21
|
-
*/
|
|
22
|
-
export declare class Member implements IMemberOperational<Types.ObjectId> {
|
|
23
|
-
private readonly _eciesService;
|
|
24
|
-
private readonly _id;
|
|
25
|
-
private readonly _type;
|
|
26
|
-
private readonly _name;
|
|
27
|
-
private readonly _email;
|
|
28
|
-
private readonly _publicKey;
|
|
29
|
-
private readonly _creatorId;
|
|
30
|
-
private readonly _dateCreated;
|
|
31
|
-
private readonly _dateUpdated;
|
|
32
|
-
private _privateKey?;
|
|
33
|
-
private _wallet?;
|
|
34
|
-
constructor(eciesService: ECIESService, type: MemberType, name: string, email: EmailString, publicKey: Buffer, privateKey?: SecureBuffer, wallet?: Wallet, id?: Types.ObjectId, dateCreated?: Date, dateUpdated?: Date, creatorId?: Types.ObjectId);
|
|
35
|
-
get id(): Types.ObjectId;
|
|
36
|
-
get type(): MemberType;
|
|
37
|
-
get name(): string;
|
|
38
|
-
get email(): EmailString;
|
|
39
|
-
get publicKey(): Buffer;
|
|
40
|
-
get creatorId(): Types.ObjectId;
|
|
41
|
-
get dateCreated(): Date;
|
|
42
|
-
get dateUpdated(): Date;
|
|
43
|
-
get privateKey(): SecureBuffer | undefined;
|
|
44
|
-
get wallet(): Wallet;
|
|
45
|
-
get hasPrivateKey(): boolean;
|
|
46
|
-
unloadPrivateKey(): void;
|
|
47
|
-
unloadWallet(): void;
|
|
48
|
-
unloadWalletAndPrivateKey(): void;
|
|
49
|
-
loadWallet(mnemonic: SecureString): void;
|
|
50
|
-
/**
|
|
51
|
-
* Loads the private key and optionally the voting private key.
|
|
52
|
-
*
|
|
53
|
-
* @param privateKey The private key to load.
|
|
54
|
-
* @param votingPrivateKey The voting private key to load.
|
|
55
|
-
*/
|
|
56
|
-
loadPrivateKey(privateKey: SecureBuffer): void;
|
|
57
|
-
sign(data: Buffer): SignatureBuffer;
|
|
58
|
-
signData(data: Buffer): SignatureBuffer;
|
|
59
|
-
verify(signature: SignatureBuffer, data: Buffer): boolean;
|
|
60
|
-
verifySignature(data: Buffer, signature: Buffer, publicKey: Buffer): boolean;
|
|
61
|
-
private static readonly MAX_ENCRYPTION_SIZE;
|
|
62
|
-
private static readonly VALID_STRING_REGEX;
|
|
63
|
-
encryptData(data: string | Buffer, recipientPublicKey?: Buffer): Buffer;
|
|
64
|
-
decryptData(encryptedData: Buffer): Buffer;
|
|
65
|
-
toJson(): string;
|
|
66
|
-
dispose(): void;
|
|
67
|
-
static fromJson(json: string, eciesService: ECIESService): Member;
|
|
68
|
-
static fromMnemonic(mnemonic: SecureString, eciesService: ECIESService, memberType?: MemberType, name?: string, email?: EmailString): Member;
|
|
69
|
-
static newMember(eciesService: ECIESService, type: MemberType, name: string, email: EmailString, forceMnemonic?: SecureString, createdBy?: Types.ObjectId): {
|
|
70
|
-
member: Member;
|
|
71
|
-
mnemonic: SecureString;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=member.d.ts.map
|
package/dist/member.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAEX,eAAe,EACf,UAAU,EACV,YAAY,EACZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM5C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aACK,IAAI,EAAE,eAAe;gBAAtD,OAAO,EAAE,MAAM,EAAkB,IAAI,EAAE,eAAe;CAInE;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;GAOG;AACH,qBAAa,MAAO,YAAW,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAiB;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAC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|
3
|
-
exports.Member = exports.NodeMemberError = void 0;
|
|
4
|
-
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
5
|
-
const ecies_i18n_factory_1 = require("./i18n/ecies-i18n-factory");
|
|
6
|
-
/**
|
|
7
|
-
* Custom error classes that work with the plugin i18n system
|
|
8
|
-
*/
|
|
9
|
-
class NodeMemberError extends Error {
|
|
10
|
-
type;
|
|
11
|
-
constructor(message, type) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.type = type;
|
|
14
|
-
this.name = 'NodeMemberError';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.NodeMemberError = NodeMemberError;
|
|
18
|
-
// Removed: import { ServiceProvider } from './services/service.provider';
|
|
19
|
-
const mongodb_1 = require("mongodb");
|
|
20
|
-
/**
|
|
21
|
-
* A member of Brightchain.
|
|
22
|
-
* In the Owner Free Filesystem (OFF), members are used to:
|
|
23
|
-
* 1. Sign and verify data
|
|
24
|
-
* 2. Encrypt and decrypt data
|
|
25
|
-
* 3. Participate in voting
|
|
26
|
-
* 4. Establish ownership of data
|
|
27
|
-
*/
|
|
28
|
-
class Member {
|
|
29
|
-
_eciesService;
|
|
30
|
-
_id;
|
|
31
|
-
_type;
|
|
32
|
-
_name;
|
|
33
|
-
_email;
|
|
34
|
-
_publicKey;
|
|
35
|
-
_creatorId;
|
|
36
|
-
_dateCreated;
|
|
37
|
-
_dateUpdated;
|
|
38
|
-
_privateKey;
|
|
39
|
-
_wallet;
|
|
40
|
-
constructor(
|
|
41
|
-
// Add injected services as parameters
|
|
42
|
-
eciesService,
|
|
43
|
-
// Original parameters
|
|
44
|
-
type, name, email, publicKey, privateKey, wallet, id, dateCreated, dateUpdated, creatorId) {
|
|
45
|
-
// Assign injected services
|
|
46
|
-
this._eciesService = eciesService;
|
|
47
|
-
// Assign original parameters
|
|
48
|
-
this._type = type;
|
|
49
|
-
this._id = id ?? new mongodb_1.ObjectId();
|
|
50
|
-
this._name = name;
|
|
51
|
-
if (!this._name || this._name.length == 0) {
|
|
52
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingMemberName), ecies_lib_1.MemberErrorType.MissingMemberName);
|
|
53
|
-
}
|
|
54
|
-
if (this._name.trim() != this._name) {
|
|
55
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), ecies_lib_1.MemberErrorType.InvalidMemberNameWhitespace);
|
|
56
|
-
}
|
|
57
|
-
this._email = email;
|
|
58
|
-
this._publicKey = publicKey;
|
|
59
|
-
this._privateKey = privateKey;
|
|
60
|
-
this._wallet = wallet;
|
|
61
|
-
// don't create a new date object with nearly identical values to the existing one
|
|
62
|
-
let _now = null;
|
|
63
|
-
const now = function () {
|
|
64
|
-
if (!_now) {
|
|
65
|
-
_now = new Date();
|
|
66
|
-
}
|
|
67
|
-
return _now;
|
|
68
|
-
};
|
|
69
|
-
this._dateCreated = dateCreated ?? now();
|
|
70
|
-
this._dateUpdated = dateUpdated ?? now();
|
|
71
|
-
this._creatorId = creatorId ?? this._id;
|
|
72
|
-
}
|
|
73
|
-
// Required getters
|
|
74
|
-
get id() {
|
|
75
|
-
return this._id;
|
|
76
|
-
}
|
|
77
|
-
get type() {
|
|
78
|
-
return this._type;
|
|
79
|
-
}
|
|
80
|
-
get name() {
|
|
81
|
-
return this._name;
|
|
82
|
-
}
|
|
83
|
-
get email() {
|
|
84
|
-
return this._email;
|
|
85
|
-
}
|
|
86
|
-
get publicKey() {
|
|
87
|
-
return this._publicKey;
|
|
88
|
-
}
|
|
89
|
-
get creatorId() {
|
|
90
|
-
return this._creatorId;
|
|
91
|
-
}
|
|
92
|
-
get dateCreated() {
|
|
93
|
-
return this._dateCreated;
|
|
94
|
-
}
|
|
95
|
-
get dateUpdated() {
|
|
96
|
-
return this._dateUpdated;
|
|
97
|
-
}
|
|
98
|
-
// Optional private data getters
|
|
99
|
-
get privateKey() {
|
|
100
|
-
return this._privateKey;
|
|
101
|
-
}
|
|
102
|
-
get wallet() {
|
|
103
|
-
if (!this._wallet) {
|
|
104
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_NoWallet), ecies_lib_1.MemberErrorType.NoWallet);
|
|
105
|
-
}
|
|
106
|
-
return this._wallet;
|
|
107
|
-
}
|
|
108
|
-
// State getters
|
|
109
|
-
get hasPrivateKey() {
|
|
110
|
-
return this._privateKey !== undefined;
|
|
111
|
-
}
|
|
112
|
-
unloadPrivateKey() {
|
|
113
|
-
// Do not dispose here; tests expect the same SecureBuffer instance to remain usable
|
|
114
|
-
// when reloaded into another member in the same process.
|
|
115
|
-
this._privateKey = undefined;
|
|
116
|
-
}
|
|
117
|
-
unloadWallet() {
|
|
118
|
-
this._wallet = undefined;
|
|
119
|
-
}
|
|
120
|
-
unloadWalletAndPrivateKey() {
|
|
121
|
-
this.unloadWallet();
|
|
122
|
-
this.unloadPrivateKey();
|
|
123
|
-
}
|
|
124
|
-
loadWallet(mnemonic) {
|
|
125
|
-
if (this._wallet) {
|
|
126
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_WalletAlreadyLoaded), ecies_lib_1.MemberErrorType.WalletAlreadyLoaded);
|
|
127
|
-
}
|
|
128
|
-
const { wallet } = this._eciesService.walletAndSeedFromMnemonic(mnemonic);
|
|
129
|
-
const privateKey = wallet.getPrivateKey();
|
|
130
|
-
const publicKey = wallet.getPublicKey();
|
|
131
|
-
const publicKeyWithPrefix = Buffer.concat([
|
|
132
|
-
Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
|
|
133
|
-
publicKey,
|
|
134
|
-
]);
|
|
135
|
-
if (publicKeyWithPrefix.toString('hex') !== this._publicKey.toString('hex')) {
|
|
136
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMnemonic), ecies_lib_1.MemberErrorType.InvalidMnemonic);
|
|
137
|
-
}
|
|
138
|
-
this._wallet = wallet;
|
|
139
|
-
this._privateKey = new ecies_lib_1.SecureBuffer(privateKey);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Loads the private key and optionally the voting private key.
|
|
143
|
-
*
|
|
144
|
-
* @param privateKey The private key to load.
|
|
145
|
-
* @param votingPrivateKey The voting private key to load.
|
|
146
|
-
*/
|
|
147
|
-
loadPrivateKey(privateKey) {
|
|
148
|
-
this._privateKey = privateKey;
|
|
149
|
-
}
|
|
150
|
-
sign(data) {
|
|
151
|
-
if (!this._privateKey) {
|
|
152
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
|
|
153
|
-
}
|
|
154
|
-
return this._eciesService.signMessage(Buffer.from(this._privateKey.value), data);
|
|
155
|
-
}
|
|
156
|
-
signData(data) {
|
|
157
|
-
if (!this._privateKey) {
|
|
158
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
|
|
159
|
-
}
|
|
160
|
-
return this._eciesService.signMessage(Buffer.from(this._privateKey.value), data);
|
|
161
|
-
}
|
|
162
|
-
verify(signature, data) {
|
|
163
|
-
return this._eciesService.verifyMessage(this._publicKey, data, signature);
|
|
164
|
-
}
|
|
165
|
-
verifySignature(data, signature, publicKey) {
|
|
166
|
-
return this._eciesService.verifyMessage(publicKey, data, signature);
|
|
167
|
-
}
|
|
168
|
-
static MAX_ENCRYPTION_SIZE = 1024 * 1024 * 10; // 10MB limit
|
|
169
|
-
static VALID_STRING_REGEX = /^[\x20-\x7E\n\r\t]*$/; // Printable ASCII + common whitespace
|
|
170
|
-
encryptData(data, recipientPublicKey) {
|
|
171
|
-
// Validate input
|
|
172
|
-
if (!data) {
|
|
173
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingEncryptionData), ecies_lib_1.MemberErrorType.MissingEncryptionData);
|
|
174
|
-
}
|
|
175
|
-
// Check size limit
|
|
176
|
-
const dataSize = Buffer.isBuffer(data)
|
|
177
|
-
? data.length
|
|
178
|
-
: Buffer.byteLength(data);
|
|
179
|
-
if (dataSize > Member.MAX_ENCRYPTION_SIZE) {
|
|
180
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_EncryptionDataTooLarge), ecies_lib_1.MemberErrorType.EncryptionDataTooLarge);
|
|
181
|
-
}
|
|
182
|
-
// Create buffer from data
|
|
183
|
-
const bufferData = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
184
|
-
// Use recipient public key or self public key
|
|
185
|
-
const targetPublicKey = recipientPublicKey || this._publicKey;
|
|
186
|
-
return this._eciesService.encryptSimpleOrSingle(false, targetPublicKey, bufferData);
|
|
187
|
-
}
|
|
188
|
-
decryptData(encryptedData) {
|
|
189
|
-
if (!this._privateKey) {
|
|
190
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
|
|
191
|
-
}
|
|
192
|
-
// decryptSingleWithHeader now returns the Buffer directly
|
|
193
|
-
return this._eciesService.decryptSimpleOrSingleWithHeader(false, Buffer.from(this._privateKey.value), encryptedData);
|
|
194
|
-
}
|
|
195
|
-
toJson() {
|
|
196
|
-
const storage = {
|
|
197
|
-
id: this._id.toString(),
|
|
198
|
-
type: this._type,
|
|
199
|
-
name: this._name,
|
|
200
|
-
email: this._email.toString(),
|
|
201
|
-
publicKey: this._publicKey.toString('base64'),
|
|
202
|
-
creatorId: this._creatorId.toString(),
|
|
203
|
-
dateCreated: this._dateCreated.toISOString(),
|
|
204
|
-
dateUpdated: this._dateUpdated.toISOString(),
|
|
205
|
-
};
|
|
206
|
-
return JSON.stringify(storage);
|
|
207
|
-
}
|
|
208
|
-
dispose() {
|
|
209
|
-
// Ensure secret material is zeroized when disposing
|
|
210
|
-
try {
|
|
211
|
-
this._privateKey?.dispose();
|
|
212
|
-
}
|
|
213
|
-
finally {
|
|
214
|
-
this.unloadWalletAndPrivateKey();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
static fromJson(json,
|
|
218
|
-
// Add injected services as parameters
|
|
219
|
-
eciesService) {
|
|
220
|
-
const storage = JSON.parse(json);
|
|
221
|
-
const email = new ecies_lib_1.EmailString(storage.email);
|
|
222
|
-
// Pass injected services to constructor
|
|
223
|
-
const dateCreated = new Date(storage.dateCreated);
|
|
224
|
-
return new Member(eciesService, storage.type, storage.name, email, Buffer.from(storage.publicKey, 'base64'), undefined, undefined, new mongodb_1.ObjectId(storage.id), dateCreated, new Date(storage.dateUpdated), new mongodb_1.ObjectId(storage.creatorId));
|
|
225
|
-
}
|
|
226
|
-
static fromMnemonic(mnemonic, eciesService, memberType = ecies_lib_1.MemberType.User, name = 'Test User', email = new ecies_lib_1.EmailString('test@example.com')) {
|
|
227
|
-
const { wallet } = eciesService.walletAndSeedFromMnemonic(mnemonic);
|
|
228
|
-
const privateKey = wallet.getPrivateKey();
|
|
229
|
-
const publicKeyWithPrefix = Buffer.concat([
|
|
230
|
-
Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
|
|
231
|
-
wallet.getPublicKey(),
|
|
232
|
-
]);
|
|
233
|
-
return new Member(eciesService, memberType, name, email, publicKeyWithPrefix, new ecies_lib_1.SecureBuffer(privateKey), wallet);
|
|
234
|
-
}
|
|
235
|
-
static newMember(
|
|
236
|
-
// Add injected services as parameters
|
|
237
|
-
eciesService,
|
|
238
|
-
// Original parameters
|
|
239
|
-
type, name, email, forceMnemonic, createdBy) {
|
|
240
|
-
// Validate inputs first
|
|
241
|
-
if (!name || name.length == 0) {
|
|
242
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingMemberName), ecies_lib_1.MemberErrorType.MissingMemberName);
|
|
243
|
-
}
|
|
244
|
-
if (name.trim() != name) {
|
|
245
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), ecies_lib_1.MemberErrorType.InvalidMemberNameWhitespace);
|
|
246
|
-
}
|
|
247
|
-
if (!email || email.toString().length == 0) {
|
|
248
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingEmail), ecies_lib_1.MemberErrorType.MissingEmail);
|
|
249
|
-
}
|
|
250
|
-
if (email.toString().trim() != email.toString()) {
|
|
251
|
-
throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidEmailWhitespace), ecies_lib_1.MemberErrorType.InvalidEmailWhitespace);
|
|
252
|
-
}
|
|
253
|
-
// Use injected services
|
|
254
|
-
const mnemonic = forceMnemonic ?? eciesService.generateNewMnemonic();
|
|
255
|
-
const { wallet } = eciesService.walletAndSeedFromMnemonic(mnemonic);
|
|
256
|
-
// Get private key from wallet
|
|
257
|
-
const privateKey = wallet.getPrivateKey();
|
|
258
|
-
// Get public key with 0x04 prefix
|
|
259
|
-
const publicKeyWithPrefix = Buffer.concat([
|
|
260
|
-
Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
|
|
261
|
-
wallet.getPublicKey(),
|
|
262
|
-
]);
|
|
263
|
-
const newId = new mongodb_1.ObjectId();
|
|
264
|
-
const dateCreated = new Date();
|
|
265
|
-
return {
|
|
266
|
-
// Pass injected services to constructor
|
|
267
|
-
member: new Member(eciesService, type, name, email, publicKeyWithPrefix, new ecies_lib_1.SecureBuffer(privateKey), wallet, newId, dateCreated, dateCreated, createdBy ?? newId),
|
|
268
|
-
mnemonic,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
exports.Member = Member;
|
|
273
|
-
//# sourceMappingURL=member.js.map
|
package/dist/member.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"member.js","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":";;;AAAA,0DAQoC;AAEpC,kEAGmC;AAEnC;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACK;IAA7C,YAAY,OAAe,EAAkB,IAAqB;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,SAAI,GAAJ,IAAI,CAAiB;QAEhE,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAGD,0EAA0E;AAC1E,qCAAmC;AAKnC;;;;;;;GAOG;AACH,MAAa,MAAM;IACA,aAAa,CAAe;IAC5B,GAAG,CAAiB;IACpB,KAAK,CAAa;IAClB,KAAK,CAAS;IACd,MAAM,CAAc;IACpB,UAAU,CAAS;IACnB,UAAU,CAAiB;IAC3B,YAAY,CAAO;IACnB,YAAY,CAAO;IAC5B,WAAW,CAAgB;IAC3B,OAAO,CAAU;IAEzB;IACE,sCAAsC;IACtC,YAA0B;IAC1B,sBAAsB;IACtB,IAAgB,EAChB,IAAY,EACZ,KAAkB,EAClB,SAAiB,EACjB,UAAyB,EACzB,MAAe,EACf,EAAmB,EACnB,WAAkB,EAClB,WAAkB,EAClB,SAA0B;QAE1B,2BAA2B;QAC3B,IAAI,CAAC,aA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AC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,eAAe,CACvB,IAAA,4CAAuB,EACrB,uCAAkB,CAAC,mCAAmC,CACvD,EACD,2BAAe,CAAC,sBAAsB,CACvC,CAAC;QACJ,CAAC;QAED,wBAAwB;QACxB,MAAM,QAAQ,GAAG,aAAa,IAAI,YAAY,CAAC,mBAAmB,EAAE,CAAC;QACrE,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;QAEpE,8BAA8B;QAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1C,kCAAkC;QAClC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAK,CAAC,gBAAgB,CAAC,CAAC;YACrC,MAAM,CAAC,YAAY,EAAE;SACtB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,kBAAQ,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAO;YACL,wCAAwC;YACxC,MAAM,EAAE,IAAI,MAAM,CAChB,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,mBAAmB,EACnB,IAAI,wBAAY,CAAC,UAAU,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,EACX,SAAS,IAAI,KAAK,CACnB;YACD,QAAQ;SACT,CAAC;IACJ,CAAC;;AAraH,wBAsaC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { IConstants } from '../interfaces/constants';
|
|
2
|
-
export declare class AESGCMService {
|
|
3
|
-
private readonly algorithmName;
|
|
4
|
-
private readonly mode;
|
|
5
|
-
private readonly keyBits;
|
|
6
|
-
private readonly ivSize;
|
|
7
|
-
private readonly keyringAlgorithmConfiguration;
|
|
8
|
-
constructor(constants?: IConstants);
|
|
9
|
-
get ALGORITHM_NAME(): string;
|
|
10
|
-
get MODE(): string;
|
|
11
|
-
get KEY_BITS(): number;
|
|
12
|
-
/**
|
|
13
|
-
* Encrypt data using AES-GCM
|
|
14
|
-
* @param data Data to encrypt
|
|
15
|
-
* @param key Key to use for encryption (must be 16, 24 or 32 bytes for AES)
|
|
16
|
-
* @param authTag Whether to return separate auth tag
|
|
17
|
-
* @returns Encrypted data with IV and optional separate auth tag
|
|
18
|
-
*/
|
|
19
|
-
encrypt(data: Buffer, key: Buffer, authTag?: boolean): {
|
|
20
|
-
encrypted: Buffer;
|
|
21
|
-
iv: Buffer;
|
|
22
|
-
tag?: Buffer;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Combine encrypted data and auth tag into a single Buffer
|
|
26
|
-
* @param encryptedData The encrypted data
|
|
27
|
-
* @param authTag The authentication tag
|
|
28
|
-
* @returns The combined Buffer
|
|
29
|
-
*/
|
|
30
|
-
combineEncryptedDataAndTag(encryptedData: Buffer, authTag: Buffer): Buffer;
|
|
31
|
-
/**
|
|
32
|
-
* Combine IV and encrypted data (with optional auth tag) into a single Buffer
|
|
33
|
-
* @param iv The initialization vector
|
|
34
|
-
* @param encryptedDataWithTag The encrypted data with auth tag already appended (if applicable)
|
|
35
|
-
* @returns The combined Buffer
|
|
36
|
-
*/
|
|
37
|
-
combineIvAndEncryptedData(iv: Buffer, encryptedDataWithTag: Buffer): Buffer;
|
|
38
|
-
/**
|
|
39
|
-
* Combine IV, encrypted data and auth tag into a single Buffer
|
|
40
|
-
* @param iv The initialization vector
|
|
41
|
-
* @param encryptedData The encrypted data
|
|
42
|
-
* @param authTag The authentication tag
|
|
43
|
-
* @returns The combined Buffer
|
|
44
|
-
*/
|
|
45
|
-
combineIvTagAndEncryptedData(iv: Buffer, encryptedData: Buffer, authTag: Buffer): Buffer;
|
|
46
|
-
/**
|
|
47
|
-
* Split combined encrypted data back into its components
|
|
48
|
-
* @param combinedData The combined data containing IV, encrypted data, and optionally auth tag
|
|
49
|
-
* @param hasAuthTag Whether the combined data includes an authentication tag
|
|
50
|
-
* @returns Object containing the split components
|
|
51
|
-
*/
|
|
52
|
-
splitEncryptedData(combinedData: Buffer, hasAuthTag?: boolean): {
|
|
53
|
-
iv: Buffer;
|
|
54
|
-
encryptedDataWithTag: Buffer;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Decrypt data using AES-GCM
|
|
58
|
-
* @param iv The initialization vector
|
|
59
|
-
* @param encryptedData Data to decrypt (with auth tag appended)
|
|
60
|
-
* @param key Key to use for decryption (must be 16, 24 or 32 bytes for AES)
|
|
61
|
-
* @param authTag Whether the encrypted data includes an authentication tag
|
|
62
|
-
* @returns Decrypted data
|
|
63
|
-
*/
|
|
64
|
-
decrypt(iv: Buffer, encryptedData: Buffer, key: Buffer, authTag?: boolean): Buffer;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=aes-gcm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-gcm.d.ts","sourceRoot":"","sources":["../../src/services/aes-gcm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAiB;gBAEnD,SAAS,GAAE,UAAsB;IAQ7C,IAAW,cAAc,IAAI,MAAM,CAElC;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;;;;OAMG;IACI,OAAO,CACZ,IAA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