@digitaldefiance/node-ecies-lib 1.1.11 → 1.1.13

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.
Files changed (95) hide show
  1. package/README.md +9 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +44 -44
  4. package/dist/constants.js.map +1 -1
  5. package/dist/enumerations/index.js +17 -1
  6. package/dist/enumerations/index.js.map +1 -1
  7. package/dist/enumerations/pbkdf2-profile.js +5 -2
  8. package/dist/enumerations/pbkdf2-profile.js.map +1 -1
  9. package/dist/i18n/ecies-i18n-factory.js +27 -21
  10. package/dist/i18n/ecies-i18n-factory.js.map +1 -1
  11. package/dist/i18n/index.js +17 -1
  12. package/dist/i18n/index.js.map +1 -1
  13. package/dist/index.js +23 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/interfaces/authenticated-cipher.js +2 -1
  16. package/dist/interfaces/authenticated-decipher.js +2 -1
  17. package/dist/interfaces/checksum-config.js +2 -1
  18. package/dist/interfaces/checksum-consts.js +2 -1
  19. package/dist/interfaces/constants.js +2 -1
  20. package/dist/interfaces/ecies-consts.js +2 -1
  21. package/dist/interfaces/encryption-consts.js +2 -1
  22. package/dist/interfaces/index.js +33 -17
  23. package/dist/interfaces/index.js.map +1 -1
  24. package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.js +2 -1
  25. package/dist/interfaces/keyring-consts.js +2 -1
  26. package/dist/interfaces/member-operational.js +2 -1
  27. package/dist/interfaces/member-with-mnemonic.js +2 -1
  28. package/dist/interfaces/multi-encrypted-message.js +2 -1
  29. package/dist/interfaces/multi-encrypted-parsed-header.js +2 -1
  30. package/dist/interfaces/pbkdf-profiles.js +2 -1
  31. package/dist/interfaces/pbkdf2-result.js +2 -1
  32. package/dist/interfaces/signing-key-private-key-info.js +2 -1
  33. package/dist/interfaces/simple-keypair-buffer.js +2 -1
  34. package/dist/interfaces/simple-keypair.js +2 -1
  35. package/dist/interfaces/simple-public-key-only-buffer.js +2 -1
  36. package/dist/interfaces/simple-public-key-only.js +2 -1
  37. package/dist/interfaces/single-encrypted-parsed-header.js +2 -1
  38. package/dist/interfaces/wallet-seed.js +2 -1
  39. package/dist/interfaces/wrapped-key-consts.js +2 -1
  40. package/dist/member.js +35 -30
  41. package/dist/member.js.map +1 -1
  42. package/dist/services/aes-gcm.js +14 -10
  43. package/dist/services/aes-gcm.js.map +1 -1
  44. package/dist/services/ecies/crypto-core.js +29 -25
  45. package/dist/services/ecies/crypto-core.js.map +1 -1
  46. package/dist/services/ecies/file.js +39 -2
  47. package/dist/services/ecies/file.js.map +1 -1
  48. package/dist/services/ecies/index.js +23 -7
  49. package/dist/services/ecies/index.js.map +1 -1
  50. package/dist/services/ecies/multi-recipient.js +50 -46
  51. package/dist/services/ecies/multi-recipient.js.map +1 -1
  52. package/dist/services/ecies/service.js +25 -21
  53. package/dist/services/ecies/service.js.map +1 -1
  54. package/dist/services/ecies/signature.js +15 -11
  55. package/dist/services/ecies/signature.js.map +1 -1
  56. package/dist/services/ecies/single-recipient.js +60 -56
  57. package/dist/services/ecies/single-recipient.js.map +1 -1
  58. package/dist/services/ecies/utilities.js +17 -13
  59. package/dist/services/ecies/utilities.js.map +1 -1
  60. package/dist/services/index.js +19 -3
  61. package/dist/services/index.js.map +1 -1
  62. package/dist/services/pbkdf2.js +25 -20
  63. package/dist/services/pbkdf2.js.map +1 -1
  64. package/dist/types.js +2 -1
  65. package/dist/utils.js +26 -22
  66. package/dist/utils.js.map +1 -1
  67. package/package.json +3 -4
  68. package/dist/interfaces/fec-consts.d.ts +0 -5
  69. package/dist/interfaces/fec-consts.d.ts.map +0 -1
  70. package/dist/interfaces/fec-consts.js +0 -2
  71. package/dist/interfaces/fec-consts.js.map +0 -1
  72. package/dist/services/ecies/crypto-core.debug.d.ts +0 -13
  73. package/dist/services/ecies/crypto-core.debug.d.ts.map +0 -1
  74. package/dist/services/ecies/crypto-core.debug.js +0 -91
  75. package/dist/services/ecies/crypto-core.debug.js.map +0 -1
  76. package/dist/services/ecies/debug-aes-gcm.d.ts +0 -2
  77. package/dist/services/ecies/debug-aes-gcm.d.ts.map +0 -1
  78. package/dist/services/ecies/debug-aes-gcm.js +0 -106
  79. package/dist/services/ecies/debug-aes-gcm.js.map +0 -1
  80. package/dist/services/ecies/debug-ecdh.d.ts +0 -2
  81. package/dist/services/ecies/debug-ecdh.d.ts.map +0 -1
  82. package/dist/services/ecies/debug-ecdh.js +0 -123
  83. package/dist/services/ecies/debug-ecdh.js.map +0 -1
  84. package/dist/services/ecies/debug-ecies-burnbag.d.ts +0 -2
  85. package/dist/services/ecies/debug-ecies-burnbag.d.ts.map +0 -1
  86. package/dist/services/ecies/debug-ecies-burnbag.js +0 -134
  87. package/dist/services/ecies/debug-ecies-burnbag.js.map +0 -1
  88. package/dist/services/ecies/debug-ecies.d.ts +0 -2
  89. package/dist/services/ecies/debug-ecies.d.ts.map +0 -1
  90. package/dist/services/ecies/debug-ecies.js +0 -110
  91. package/dist/services/ecies/debug-ecies.js.map +0 -1
  92. package/dist/services/ecies/debug-test.d.ts +0 -2
  93. package/dist/services/ecies/debug-test.d.ts.map +0 -1
  94. package/dist/services/ecies/debug-test.js +0 -57
  95. package/dist/services/ecies/debug-test.js.map +0 -1
@@ -1,18 +1,34 @@
1
- export * from './authenticated-cipher';
2
- export * from './authenticated-decipher';
3
- export * from './checksum-config';
4
- export * from './checksum-consts';
5
- export * from './keypair-buffer-with-un-encrypted-private-key';
6
- export * from './keyring-consts';
7
- export * from './member-operational';
8
- export * from './pbkdf-profiles';
9
- export * from './pbkdf2-result';
10
- export * from './signing-key-private-key-info';
11
- export * from './simple-keypair';
12
- export * from './simple-keypair-buffer';
13
- export * from './simple-public-key-only';
14
- export * from './simple-public-key-only-buffer';
15
- export * from './single-encrypted-parsed-header';
16
- export * from './wallet-seed';
17
- export * from './wrapped-key-consts';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./authenticated-cipher"), exports);
18
+ __exportStar(require("./authenticated-decipher"), exports);
19
+ __exportStar(require("./checksum-config"), exports);
20
+ __exportStar(require("./checksum-consts"), exports);
21
+ __exportStar(require("./keypair-buffer-with-un-encrypted-private-key"), exports);
22
+ __exportStar(require("./keyring-consts"), exports);
23
+ __exportStar(require("./member-operational"), exports);
24
+ __exportStar(require("./pbkdf-profiles"), exports);
25
+ __exportStar(require("./pbkdf2-result"), exports);
26
+ __exportStar(require("./signing-key-private-key-info"), exports);
27
+ __exportStar(require("./simple-keypair"), exports);
28
+ __exportStar(require("./simple-keypair-buffer"), exports);
29
+ __exportStar(require("./simple-public-key-only"), exports);
30
+ __exportStar(require("./simple-public-key-only-buffer"), exports);
31
+ __exportStar(require("./single-encrypted-parsed-header"), exports);
32
+ __exportStar(require("./wallet-seed"), exports);
33
+ __exportStar(require("./wrapped-key-consts"), exports);
18
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,2DAAyC;AACzC,oDAAkC;AAClC,oDAAkC;AAClC,iFAA+D;AAC/D,mDAAiC;AACjC,uDAAqC;AACrC,mDAAiC;AACjC,kDAAgC;AAChC,iEAA+C;AAC/C,mDAAiC;AACjC,0DAAwC;AACxC,2DAAyC;AACzC,kEAAgD;AAChD,mEAAiD;AACjD,gDAA8B;AAC9B,uDAAqC"}
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=keypair-buffer-with-un-encrypted-private-key.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=keyring-consts.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=member-operational.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=member-with-mnemonic.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=multi-encrypted-message.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=multi-encrypted-parsed-header.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=pbkdf-profiles.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=pbkdf2-result.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=signing-key-private-key-info.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=simple-keypair-buffer.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=simple-keypair.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=simple-public-key-only-buffer.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=simple-public-key-only.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=single-encrypted-parsed-header.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=wallet-seed.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=wrapped-key-consts.js.map
package/dist/member.js CHANGED
@@ -1,9 +1,12 @@
1
- import { ECIES, EmailString, MemberErrorType, MemberType, SecureBuffer, } from '@digitaldefiance/ecies-lib';
2
- import { getNodeEciesTranslation, NodeEciesStringKey, } from './i18n/ecies-i18n-factory';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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");
3
6
  /**
4
7
  * Custom error classes that work with the plugin i18n system
5
8
  */
6
- export class NodeMemberError extends Error {
9
+ class NodeMemberError extends Error {
7
10
  type;
8
11
  constructor(message, type) {
9
12
  super(message);
@@ -11,8 +14,9 @@ export class NodeMemberError extends Error {
11
14
  this.name = 'NodeMemberError';
12
15
  }
13
16
  }
17
+ exports.NodeMemberError = NodeMemberError;
14
18
  // Removed: import { ServiceProvider } from './services/service.provider';
15
- import { ObjectId } from 'mongodb';
19
+ const mongodb_1 = require("mongodb");
16
20
  /**
17
21
  * A member of Brightchain.
18
22
  * In the Owner Free Filesystem (OFF), members are used to:
@@ -21,7 +25,7 @@ import { ObjectId } from 'mongodb';
21
25
  * 3. Participate in voting
22
26
  * 4. Establish ownership of data
23
27
  */
24
- export class Member {
28
+ class Member {
25
29
  _eciesService;
26
30
  _id;
27
31
  _type;
@@ -42,13 +46,13 @@ export class Member {
42
46
  this._eciesService = eciesService;
43
47
  // Assign original parameters
44
48
  this._type = type;
45
- this._id = id ?? new ObjectId();
49
+ this._id = id ?? new mongodb_1.ObjectId();
46
50
  this._name = name;
47
51
  if (!this._name || this._name.length == 0) {
48
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingMemberName), MemberErrorType.MissingMemberName);
52
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingMemberName), ecies_lib_1.MemberErrorType.MissingMemberName);
49
53
  }
50
54
  if (this._name.trim() != this._name) {
51
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), MemberErrorType.InvalidMemberNameWhitespace);
55
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), ecies_lib_1.MemberErrorType.InvalidMemberNameWhitespace);
52
56
  }
53
57
  this._email = email;
54
58
  this._publicKey = publicKey;
@@ -97,7 +101,7 @@ export class Member {
97
101
  }
98
102
  get wallet() {
99
103
  if (!this._wallet) {
100
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_NoWallet), MemberErrorType.NoWallet);
104
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_NoWallet), ecies_lib_1.MemberErrorType.NoWallet);
101
105
  }
102
106
  return this._wallet;
103
107
  }
@@ -119,20 +123,20 @@ export class Member {
119
123
  }
120
124
  loadWallet(mnemonic) {
121
125
  if (this._wallet) {
122
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_WalletAlreadyLoaded), MemberErrorType.WalletAlreadyLoaded);
126
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_WalletAlreadyLoaded), ecies_lib_1.MemberErrorType.WalletAlreadyLoaded);
123
127
  }
124
128
  const { wallet } = this._eciesService.walletAndSeedFromMnemonic(mnemonic);
125
129
  const privateKey = wallet.getPrivateKey();
126
130
  const publicKey = wallet.getPublicKey();
127
131
  const publicKeyWithPrefix = Buffer.concat([
128
- Buffer.from([ECIES.PUBLIC_KEY_MAGIC]),
132
+ Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
129
133
  publicKey,
130
134
  ]);
131
135
  if (publicKeyWithPrefix.toString('hex') !== this._publicKey.toString('hex')) {
132
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_InvalidMnemonic), MemberErrorType.InvalidMnemonic);
136
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMnemonic), ecies_lib_1.MemberErrorType.InvalidMnemonic);
133
137
  }
134
138
  this._wallet = wallet;
135
- this._privateKey = new SecureBuffer(privateKey);
139
+ this._privateKey = new ecies_lib_1.SecureBuffer(privateKey);
136
140
  }
137
141
  /**
138
142
  * Loads the private key and optionally the voting private key.
@@ -145,13 +149,13 @@ export class Member {
145
149
  }
146
150
  sign(data) {
147
151
  if (!this._privateKey) {
148
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingPrivateKey), MemberErrorType.MissingPrivateKey);
152
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
149
153
  }
150
154
  return this._eciesService.signMessage(Buffer.from(this._privateKey.value), data);
151
155
  }
152
156
  signData(data) {
153
157
  if (!this._privateKey) {
154
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingPrivateKey), MemberErrorType.MissingPrivateKey);
158
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
155
159
  }
156
160
  return this._eciesService.signMessage(Buffer.from(this._privateKey.value), data);
157
161
  }
@@ -166,14 +170,14 @@ export class Member {
166
170
  encryptData(data, recipientPublicKey) {
167
171
  // Validate input
168
172
  if (!data) {
169
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingEncryptionData), MemberErrorType.MissingEncryptionData);
173
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingEncryptionData), ecies_lib_1.MemberErrorType.MissingEncryptionData);
170
174
  }
171
175
  // Check size limit
172
176
  const dataSize = Buffer.isBuffer(data)
173
177
  ? data.length
174
178
  : Buffer.byteLength(data);
175
179
  if (dataSize > Member.MAX_ENCRYPTION_SIZE) {
176
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_EncryptionDataTooLarge), MemberErrorType.EncryptionDataTooLarge);
180
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_EncryptionDataTooLarge), ecies_lib_1.MemberErrorType.EncryptionDataTooLarge);
177
181
  }
178
182
  // Create buffer from data
179
183
  const bufferData = Buffer.isBuffer(data) ? data : Buffer.from(data);
@@ -183,7 +187,7 @@ export class Member {
183
187
  }
184
188
  decryptData(encryptedData) {
185
189
  if (!this._privateKey) {
186
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingPrivateKey), MemberErrorType.MissingPrivateKey);
190
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingPrivateKey), ecies_lib_1.MemberErrorType.MissingPrivateKey);
187
191
  }
188
192
  // decryptSingleWithHeader now returns the Buffer directly
189
193
  return this._eciesService.decryptSimpleOrSingleWithHeader(false, Buffer.from(this._privateKey.value), encryptedData);
@@ -214,19 +218,19 @@ export class Member {
214
218
  // Add injected services as parameters
215
219
  eciesService) {
216
220
  const storage = JSON.parse(json);
217
- const email = new EmailString(storage.email);
221
+ const email = new ecies_lib_1.EmailString(storage.email);
218
222
  // Pass injected services to constructor
219
223
  const dateCreated = new Date(storage.dateCreated);
220
- return new Member(eciesService, storage.type, storage.name, email, Buffer.from(storage.publicKey, 'base64'), undefined, undefined, new ObjectId(storage.id), dateCreated, new Date(storage.dateUpdated), new ObjectId(storage.creatorId));
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));
221
225
  }
222
- static fromMnemonic(mnemonic, eciesService, memberType = MemberType.User, name = 'Test User', email = new EmailString('test@example.com')) {
226
+ static fromMnemonic(mnemonic, eciesService, memberType = ecies_lib_1.MemberType.User, name = 'Test User', email = new ecies_lib_1.EmailString('test@example.com')) {
223
227
  const { wallet } = eciesService.walletAndSeedFromMnemonic(mnemonic);
224
228
  const privateKey = wallet.getPrivateKey();
225
229
  const publicKeyWithPrefix = Buffer.concat([
226
- Buffer.from([ECIES.PUBLIC_KEY_MAGIC]),
230
+ Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
227
231
  wallet.getPublicKey(),
228
232
  ]);
229
- return new Member(eciesService, memberType, name, email, publicKeyWithPrefix, new SecureBuffer(privateKey), wallet);
233
+ return new Member(eciesService, memberType, name, email, publicKeyWithPrefix, new ecies_lib_1.SecureBuffer(privateKey), wallet);
230
234
  }
231
235
  static newMember(
232
236
  // Add injected services as parameters
@@ -235,16 +239,16 @@ export class Member {
235
239
  type, name, email, forceMnemonic, createdBy) {
236
240
  // Validate inputs first
237
241
  if (!name || name.length == 0) {
238
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingMemberName), MemberErrorType.MissingMemberName);
242
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingMemberName), ecies_lib_1.MemberErrorType.MissingMemberName);
239
243
  }
240
244
  if (name.trim() != name) {
241
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), MemberErrorType.InvalidMemberNameWhitespace);
245
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidMemberNameWhitespace), ecies_lib_1.MemberErrorType.InvalidMemberNameWhitespace);
242
246
  }
243
247
  if (!email || email.toString().length == 0) {
244
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_MissingEmail), MemberErrorType.MissingEmail);
248
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_MissingEmail), ecies_lib_1.MemberErrorType.MissingEmail);
245
249
  }
246
250
  if (email.toString().trim() != email.toString()) {
247
- throw new NodeMemberError(getNodeEciesTranslation(NodeEciesStringKey.Error_Member_InvalidEmailWhitespace), MemberErrorType.InvalidEmailWhitespace);
251
+ throw new NodeMemberError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_Member_InvalidEmailWhitespace), ecies_lib_1.MemberErrorType.InvalidEmailWhitespace);
248
252
  }
249
253
  // Use injected services
250
254
  const mnemonic = forceMnemonic ?? eciesService.generateNewMnemonic();
@@ -253,16 +257,17 @@ export class Member {
253
257
  const privateKey = wallet.getPrivateKey();
254
258
  // Get public key with 0x04 prefix
255
259
  const publicKeyWithPrefix = Buffer.concat([
256
- Buffer.from([ECIES.PUBLIC_KEY_MAGIC]),
260
+ Buffer.from([ecies_lib_1.ECIES.PUBLIC_KEY_MAGIC]),
257
261
  wallet.getPublicKey(),
258
262
  ]);
259
- const newId = new ObjectId();
263
+ const newId = new mongodb_1.ObjectId();
260
264
  const dateCreated = new Date();
261
265
  return {
262
266
  // Pass injected services to constructor
263
- member: new Member(eciesService, type, name, email, publicKeyWithPrefix, new SecureBuffer(privateKey), wallet, newId, dateCreated, dateCreated, createdBy ?? newId),
267
+ member: new Member(eciesService, type, name, email, publicKeyWithPrefix, new ecies_lib_1.SecureBuffer(privateKey), wallet, newId, dateCreated, dateCreated, createdBy ?? newId),
264
268
  mnemonic,
265
269
  };
266
270
  }
267
271
  }
272
+ exports.Member = Member;
268
273
  //# sourceMappingURL=member.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"member.js","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,WAAW,EAEX,eAAe,EACf,UAAU,EACV,YAAY,GAEb,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,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;AAGD,0EAA0E;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC;;;;;;;GAOG;AACH,MAAM,OAAO,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,aAAa,GAAG,YAAY,CAAC;QAClC,6BAA6B;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI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EACX,WAAW,EACX,SAAS,IAAI,KAAK,CACnB;YACD,QAAQ;SACT,CAAC;IACJ,CAAC;;AAraH,wBAsaC"}
@@ -1,13 +1,16 @@
1
- import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
2
- import { getEciesPluginI18nEngine, NodeEciesComponentId, NodeEciesStringKey } from '../i18n';
3
- import { Constants } from '../constants';
4
- export class AESGCMService {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AESGCMService = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const i18n_1 = require("../i18n");
6
+ const constants_1 = require("../constants");
7
+ class AESGCMService {
5
8
  algorithmName;
6
9
  mode;
7
10
  keyBits;
8
11
  ivSize;
9
12
  keyringAlgorithmConfiguration;
10
- constructor(constants = Constants) {
13
+ constructor(constants = constants_1.Constants) {
11
14
  this.algorithmName = constants.KEYRING.ALGORITHM;
12
15
  this.mode = constants.KEYRING.MODE;
13
16
  this.keyBits = constants.KEYRING.KEY_BITS;
@@ -31,8 +34,8 @@ export class AESGCMService {
31
34
  * @returns Encrypted data with IV and optional separate auth tag
32
35
  */
33
36
  encrypt(data, key, authTag = false) {
34
- const iv = randomBytes(this.ivSize);
35
- const cipher = createCipheriv(this.keyringAlgorithmConfiguration, key, iv);
37
+ const iv = (0, crypto_1.randomBytes)(this.ivSize);
38
+ const cipher = (0, crypto_1.createCipheriv)(this.keyringAlgorithmConfiguration, key, iv);
36
39
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
37
40
  const tag = cipher.getAuthTag();
38
41
  if (!authTag) {
@@ -84,8 +87,8 @@ export class AESGCMService {
84
87
  const ivLength = this.ivSize;
85
88
  const minLength = ivLength + (hasAuthTag ? 16 : 0);
86
89
  if (combinedData.length < minLength) {
87
- const pluginEngine = getEciesPluginI18nEngine();
88
- throw new Error(pluginEngine.translate(NodeEciesComponentId, NodeEciesStringKey.Error_CombinedDataTooShort));
90
+ const pluginEngine = (0, i18n_1.getEciesPluginI18nEngine)();
91
+ throw new Error(pluginEngine.translate(i18n_1.NodeEciesComponentId, i18n_1.NodeEciesStringKey.Error_CombinedDataTooShort));
89
92
  }
90
93
  const iv = combinedData.subarray(0, ivLength);
91
94
  const encryptedDataWithTag = combinedData.subarray(ivLength);
@@ -100,7 +103,7 @@ export class AESGCMService {
100
103
  * @returns Decrypted data
101
104
  */
102
105
  decrypt(iv, encryptedData, key, authTag = false) {
103
- const decipher = createDecipheriv(this.keyringAlgorithmConfiguration, key, iv);
106
+ const decipher = (0, crypto_1.createDecipheriv)(this.keyringAlgorithmConfiguration, key, iv);
104
107
  const tagLength = 16;
105
108
  const tag = encryptedData.subarray(-tagLength);
106
109
  const ciphertext = encryptedData.subarray(0, -tagLength);
@@ -108,4 +111,5 @@ export class AESGCMService {
108
111
  return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
109
112
  }
110
113
  }
114
+ exports.AESGCMService = AESGCMService;
111
115
  //# sourceMappingURL=aes-gcm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aes-gcm.js","sourceRoot":"","sources":["../../src/services/aes-gcm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGvE,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,OAAO,aAAa;IACP,aAAa,CAAS;IACtB,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,6BAA6B,CAAiB;IAE/D,YAAY,YAAwB,SAAS;QAC3C,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,Q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ACxE,CAAC;CACF;AAzJD,sCAyJC"}
@@ -1,14 +1,17 @@
1
- import { ECIESError, ECIESErrorTypeEnum, SecureBuffer, SecureString, } from '@digitaldefiance/ecies-lib';
2
- import { hdkey } from '@ethereumjs/wallet';
3
- import { generateMnemonic, mnemonicToSeedSync, validateMnemonic } from 'bip39';
4
- import { secp256k1 } from 'ethereum-cryptography/secp256k1.js';
5
- import { createEciesTranslationEngine, getEciesPluginI18nEngine, NodeEciesComponentId, NodeEciesStringKey } from '../../i18n/ecies-i18n-factory';
6
- import { Constants } from '../../constants';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesCryptoCore = void 0;
4
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
+ const wallet_1 = require("@ethereumjs/wallet");
6
+ const bip39_1 = require("bip39");
7
+ const secp256k1_js_1 = require("ethereum-cryptography/secp256k1.js");
8
+ const ecies_i18n_factory_1 = require("../../i18n/ecies-i18n-factory");
9
+ const constants_1 = require("../../constants");
7
10
  /**
8
11
  * Core encryption and decryption functions for ECIES
9
12
  * Includes coverage for simple and single modes, does not cover multiple mode which is in a separate module
10
13
  */
11
- export class EciesCryptoCore {
14
+ class EciesCryptoCore {
12
15
  _config;
13
16
  _consts;
14
17
  get config() {
@@ -17,7 +20,7 @@ export class EciesCryptoCore {
17
20
  get consts() {
18
21
  return this._consts;
19
22
  }
20
- constructor(config, eciesParams = Constants.ECIES) {
23
+ constructor(config, eciesParams = constants_1.Constants.ECIES) {
21
24
  this._config = config;
22
25
  this._consts = eciesParams;
23
26
  }
@@ -28,10 +31,10 @@ export class EciesCryptoCore {
28
31
  */
29
32
  normalizePublicKey(publicKey) {
30
33
  if (!publicKey) {
31
- const engine = createEciesTranslationEngine();
32
- const pluginEngine = getEciesPluginI18nEngine();
33
- throw new ECIESError(ECIESErrorTypeEnum.InvalidEphemeralPublicKey, engine, undefined, undefined, {
34
- error: pluginEngine.translate(NodeEciesComponentId, NodeEciesStringKey.Error_InvalidPublicKey),
34
+ const engine = (0, ecies_i18n_factory_1.createEciesTranslationEngine)();
35
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
36
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey, engine, undefined, undefined, {
37
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_InvalidPublicKey),
35
38
  });
36
39
  }
37
40
  const keyLength = publicKey.length;
@@ -44,11 +47,11 @@ export class EciesCryptoCore {
44
47
  if (keyLength === this._consts.RAW_PUBLIC_KEY_LENGTH) {
45
48
  return Buffer.concat([Buffer.from([this._consts.PUBLIC_KEY_MAGIC]), publicKey]);
46
49
  }
47
- const engine = createEciesTranslationEngine();
48
- const pluginEngine = getEciesPluginI18nEngine();
50
+ const engine = (0, ecies_i18n_factory_1.createEciesTranslationEngine)();
51
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
49
52
  // Invalid format
50
- throw new ECIESError(ECIESErrorTypeEnum.InvalidEphemeralPublicKey, engine, undefined, undefined, {
51
- error: pluginEngine.translate(NodeEciesComponentId, NodeEciesStringKey.Error_InvalidPublicKeyFormat),
53
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey, engine, undefined, undefined, {
54
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_InvalidPublicKeyFormat),
52
55
  keyLength: String(keyLength),
53
56
  expectedLength64: String(this._consts.RAW_PUBLIC_KEY_LENGTH),
54
57
  expectedLength65: String(this._consts.PUBLIC_KEY_LENGTH),
@@ -61,7 +64,7 @@ export class EciesCryptoCore {
61
64
  * @returns {SecureString} The new mnemonic
62
65
  */
63
66
  generateNewMnemonic() {
64
- return new SecureString(generateMnemonic(this._config.mnemonicStrength));
67
+ return new ecies_lib_1.SecureString((0, bip39_1.generateMnemonic)(this._config.mnemonicStrength));
65
68
  }
66
69
  /**
67
70
  * Generate a new wallet from a seed
@@ -69,7 +72,7 @@ export class EciesCryptoCore {
69
72
  * @returns {Wallet} The new wallet
70
73
  */
71
74
  walletFromSeed(seed) {
72
- const hdWallet = hdkey.EthereumHDKey.fromMasterSeed(seed);
75
+ const hdWallet = wallet_1.hdkey.EthereumHDKey.fromMasterSeed(seed);
73
76
  return hdWallet
74
77
  .derivePath(this._config.primaryKeyDerivationPath)
75
78
  .getWallet();
@@ -80,13 +83,13 @@ export class EciesCryptoCore {
80
83
  * @returns {IWalletSeed} The new wallet and seed
81
84
  */
82
85
  walletAndSeedFromMnemonic(mnemonic) {
83
- if (!mnemonic.value || !validateMnemonic(mnemonic.value)) {
84
- throw new ECIESError(ECIESErrorTypeEnum.InvalidMnemonic, createEciesTranslationEngine());
86
+ if (!mnemonic.value || !(0, bip39_1.validateMnemonic)(mnemonic.value)) {
87
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidMnemonic, (0, ecies_i18n_factory_1.createEciesTranslationEngine)());
85
88
  }
86
- const seed = mnemonicToSeedSync(mnemonic.value);
89
+ const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic.value);
87
90
  const wallet = this.walletFromSeed(seed);
88
91
  return {
89
- seed: new SecureBuffer(seed),
92
+ seed: new ecies_lib_1.SecureBuffer(seed),
90
93
  wallet,
91
94
  };
92
95
  }
@@ -128,7 +131,7 @@ export class EciesCryptoCore {
128
131
  * @returns {Buffer} The new private key
129
132
  */
130
133
  generatePrivateKey() {
131
- return Buffer.from(secp256k1.utils.randomPrivateKey());
134
+ return Buffer.from(secp256k1_js_1.secp256k1.utils.randomPrivateKey());
132
135
  }
133
136
  /**
134
137
  * Get public key from private key
@@ -136,7 +139,7 @@ export class EciesCryptoCore {
136
139
  * @returns {Buffer} The public key
137
140
  */
138
141
  getPublicKey(privateKey) {
139
- const publicKey = secp256k1.getPublicKey(privateKey, false);
142
+ const publicKey = secp256k1_js_1.secp256k1.getPublicKey(privateKey, false);
140
143
  return Buffer.from(publicKey);
141
144
  }
142
145
  /**
@@ -155,8 +158,9 @@ export class EciesCryptoCore {
155
158
  * @returns {Buffer} The shared secret
156
159
  */
157
160
  computeSharedSecret(privateKey, publicKey) {
158
- const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey, true);
161
+ const sharedSecret = secp256k1_js_1.secp256k1.getSharedSecret(privateKey, publicKey, true);
159
162
  return Buffer.from(sharedSecret.slice(1)); // Remove the 0x02/0x03 prefix
160
163
  }
161
164
  }
165
+ exports.EciesCryptoCore = EciesCryptoCore;
162
166
  //# sourceMappingURL=crypto-core.js.map