@digitaldefiance/ecies-lib 1.1.14 → 1.1.15

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 (150) hide show
  1. package/README.md +5 -0
  2. package/dist/constants.js +68 -57
  3. package/dist/constants.js.map +1 -1
  4. package/dist/email-string.js +16 -9
  5. package/dist/email-string.js.map +1 -1
  6. package/dist/enumerations/ecies-encryption-type.js +27 -20
  7. package/dist/enumerations/ecies-encryption-type.js.map +1 -1
  8. package/dist/enumerations/ecies-error-type.js +5 -2
  9. package/dist/enumerations/ecies-error-type.js.map +1 -1
  10. package/dist/enumerations/ecies-string-key.js +5 -2
  11. package/dist/enumerations/ecies-string-key.js.map +1 -1
  12. package/dist/enumerations/guid-brand-type.js +5 -2
  13. package/dist/enumerations/guid-brand-type.js.map +1 -1
  14. package/dist/enumerations/guid-error-type.js +5 -2
  15. package/dist/enumerations/guid-error-type.js.map +1 -1
  16. package/dist/enumerations/index.js +30 -14
  17. package/dist/enumerations/index.js.map +1 -1
  18. package/dist/enumerations/invalid-email-type.js +5 -2
  19. package/dist/enumerations/invalid-email-type.js.map +1 -1
  20. package/dist/enumerations/length-encoding-type.js +5 -2
  21. package/dist/enumerations/length-encoding-type.js.map +1 -1
  22. package/dist/enumerations/length-error-type.js +5 -2
  23. package/dist/enumerations/length-error-type.js.map +1 -1
  24. package/dist/enumerations/member-error-type.js +6 -3
  25. package/dist/enumerations/member-error-type.js.map +1 -1
  26. package/dist/enumerations/member-type.js +6 -3
  27. package/dist/enumerations/member-type.js.map +1 -1
  28. package/dist/enumerations/password-login-error-type.js +5 -2
  29. package/dist/enumerations/password-login-error-type.js.map +1 -1
  30. package/dist/enumerations/pbkdf2-error-type.js +5 -2
  31. package/dist/enumerations/pbkdf2-error-type.js.map +1 -1
  32. package/dist/enumerations/pbkdf2-profile.js +5 -2
  33. package/dist/enumerations/pbkdf2-profile.js.map +1 -1
  34. package/dist/enumerations/secure-storage-error-type.js +5 -2
  35. package/dist/enumerations/secure-storage-error-type.js.map +1 -1
  36. package/dist/errors/disposed.js +8 -4
  37. package/dist/errors/disposed.js.map +1 -1
  38. package/dist/errors/ecies.js +11 -7
  39. package/dist/errors/ecies.js.map +1 -1
  40. package/dist/errors/guid.js +9 -5
  41. package/dist/errors/guid.js.map +1 -1
  42. package/dist/errors/handleable.js +5 -1
  43. package/dist/errors/handleable.js.map +1 -1
  44. package/dist/errors/index.js +27 -11
  45. package/dist/errors/index.js.map +1 -1
  46. package/dist/errors/invalid-email.js +9 -5
  47. package/dist/errors/invalid-email.js.map +1 -1
  48. package/dist/errors/length.js +9 -5
  49. package/dist/errors/length.js.map +1 -1
  50. package/dist/errors/member.js +9 -5
  51. package/dist/errors/member.js.map +1 -1
  52. package/dist/errors/pbkdf2.js +9 -5
  53. package/dist/errors/pbkdf2.js.map +1 -1
  54. package/dist/errors/secure-storage.js +9 -5
  55. package/dist/errors/secure-storage.js.map +1 -1
  56. package/dist/errors/simple-ecies.js +9 -5
  57. package/dist/errors/simple-ecies.js.map +1 -1
  58. package/dist/errors/simple-test-error.js +5 -1
  59. package/dist/errors/simple-test-error.js.map +1 -1
  60. package/dist/errors/translatable.js +6 -2
  61. package/dist/errors/translatable.js.map +1 -1
  62. package/dist/errors/typed-handleable.js +9 -5
  63. package/dist/errors/typed-handleable.js.map +1 -1
  64. package/dist/guid.js +113 -76
  65. package/dist/guid.js.map +1 -1
  66. package/dist/i18n-setup.js +675 -665
  67. package/dist/i18n-setup.js.map +1 -1
  68. package/dist/index.js +30 -14
  69. package/dist/index.js.map +1 -1
  70. package/dist/interfaces/checksum-config.js +2 -1
  71. package/dist/interfaces/checksum-consts.js +2 -1
  72. package/dist/interfaces/constants.js +2 -1
  73. package/dist/interfaces/ecies-config.js +2 -1
  74. package/dist/interfaces/ecies-consts.js +2 -1
  75. package/dist/interfaces/ecies-file-service.js +2 -1
  76. package/dist/interfaces/guid.js +2 -1
  77. package/dist/interfaces/handleable-error-options.js +2 -1
  78. package/dist/interfaces/handleable.js +2 -1
  79. package/dist/interfaces/index.js +31 -15
  80. package/dist/interfaces/index.js.map +1 -1
  81. package/dist/interfaces/library-error.js +2 -1
  82. package/dist/interfaces/member-operational.js +2 -1
  83. package/dist/interfaces/member-storage.js +2 -1
  84. package/dist/interfaces/member-with-mnemonic.js +2 -1
  85. package/dist/interfaces/pbkdf2-config.js +2 -1
  86. package/dist/interfaces/pbkdf2-consts.js +2 -1
  87. package/dist/interfaces/pbkdf2-result.js +2 -1
  88. package/dist/member.js +44 -37
  89. package/dist/member.js.map +1 -1
  90. package/dist/pbkdf2-profiles.js +2 -1
  91. package/dist/regexes.js +5 -2
  92. package/dist/regexes.js.map +1 -1
  93. package/dist/secure-buffer.js +22 -18
  94. package/dist/secure-buffer.js.map +1 -1
  95. package/dist/secure-string.js +24 -20
  96. package/dist/secure-string.js.map +1 -1
  97. package/dist/services/aes-gcm.js +13 -9
  98. package/dist/services/aes-gcm.js.map +1 -1
  99. package/dist/services/ecies/crypto-core.js +35 -31
  100. package/dist/services/ecies/crypto-core.js.map +1 -1
  101. package/dist/services/ecies/example.js +44 -37
  102. package/dist/services/ecies/example.js.map +1 -1
  103. package/dist/services/ecies/file.js +5 -1
  104. package/dist/services/ecies/file.js.map +1 -1
  105. package/dist/services/ecies/index.js +28 -10
  106. package/dist/services/ecies/index.js.map +1 -1
  107. package/dist/services/ecies/integration.js +28 -23
  108. package/dist/services/ecies/integration.js.map +1 -1
  109. package/dist/services/ecies/interfaces.js +2 -1
  110. package/dist/services/ecies/interfaces.js.map +1 -1
  111. package/dist/services/ecies/manual-test.js +34 -26
  112. package/dist/services/ecies/manual-test.js.map +1 -1
  113. package/dist/services/ecies/multi-recipient.js +51 -47
  114. package/dist/services/ecies/multi-recipient.js.map +1 -1
  115. package/dist/services/ecies/service.js +20 -16
  116. package/dist/services/ecies/service.js.map +1 -1
  117. package/dist/services/ecies/signature.js +13 -9
  118. package/dist/services/ecies/signature.js.map +1 -1
  119. package/dist/services/ecies/single-recipient.js +32 -28
  120. package/dist/services/ecies/single-recipient.js.map +1 -1
  121. package/dist/services/index.js +21 -5
  122. package/dist/services/index.js.map +1 -1
  123. package/dist/services/password-login.js +37 -33
  124. package/dist/services/password-login.js.map +1 -1
  125. package/dist/services/pbkdf2.js +12 -8
  126. package/dist/services/pbkdf2.js.map +1 -1
  127. package/dist/services/xor.js +5 -1
  128. package/dist/services/xor.js.map +1 -1
  129. package/dist/types/deep-partial.js +2 -1
  130. package/dist/types.js +2 -1
  131. package/dist/utils.js +69 -51
  132. package/dist/utils.js.map +1 -1
  133. package/package.json +2 -2
  134. package/dist/defaults.d.ts +0 -37
  135. package/dist/defaults.d.ts.map +0 -1
  136. package/dist/defaults.js +0 -323
  137. package/dist/defaults.js.map +0 -1
  138. package/dist/errors/typed.d.ts +0 -14
  139. package/dist/errors/typed.d.ts.map +0 -1
  140. package/dist/errors/typed.js +0 -48
  141. package/dist/errors/typed.js.map +0 -1
  142. package/dist/i18n-config.d.ts +0 -77
  143. package/dist/i18n-config.d.ts.map +0 -1
  144. package/dist/i18n-config.js +0 -88
  145. package/dist/i18n-config.js.map +0 -1
  146. package/dist/interfaces/defaults.d.ts +0 -35
  147. package/dist/interfaces/defaults.d.ts.map +0 -1
  148. package/dist/interfaces/defaults.js +0 -2
  149. package/dist/interfaces/defaults.js.map +0 -1
  150. package/dist/package.json +0 -63
@@ -1,6 +1,22 @@
1
- export * from './aes-gcm';
2
- export * from './ecies';
3
- export * from './password-login';
4
- export * from './pbkdf2';
5
- export * from './xor';
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("./aes-gcm"), exports);
18
+ __exportStar(require("./ecies"), exports);
19
+ __exportStar(require("./password-login"), exports);
20
+ __exportStar(require("./pbkdf2"), exports);
21
+ __exportStar(require("./xor"), exports);
6
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB;AACxB,mDAAiC;AACjC,2CAAyB;AACzB,wCAAsB"}
@@ -1,14 +1,17 @@
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 { TranslatableError, TypedHandleableError } from '../errors';
8
- import { EciesStringKey, PasswordLoginErrorTypeEnum } from '../enumerations';
9
- import { buildReasonMap } from '@digitaldefiance/i18n-lib';
10
- import { Constants } from '../constants';
11
- export class PasswordLoginService {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PasswordLoginService = void 0;
4
+ const wallet_1 = require("@ethereumjs/wallet");
5
+ const ecies_encryption_type_1 = require("../enumerations/ecies-encryption-type");
6
+ const pbkdf2_profile_1 = require("../enumerations/pbkdf2-profile");
7
+ const secure_string_1 = require("../secure-string");
8
+ const utils_1 = require("../utils");
9
+ const aes_gcm_1 = require("./aes-gcm");
10
+ const errors_1 = require("../errors");
11
+ const enumerations_1 = require("../enumerations");
12
+ const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
13
+ const constants_1 = require("../constants");
14
+ class PasswordLoginService {
12
15
  eciesService;
13
16
  pbkdf2Service;
14
17
  engine;
@@ -17,24 +20,24 @@ export class PasswordLoginService {
17
20
  static saltStorageKey = 'passwordLoginSalt';
18
21
  static encryptedMnemonicStorageKey = 'encryptedMnemonic';
19
22
  static profileStorageKey = 'pbkdf2Profile';
20
- constructor(eciesService, pbkdf2Service, engine, eciesParams = Constants.ECIES) {
23
+ constructor(eciesService, pbkdf2Service, engine, eciesParams = constants_1.Constants.ECIES) {
21
24
  this.eciesService = eciesService;
22
25
  this.pbkdf2Service = pbkdf2Service;
23
26
  this.engine = engine;
24
27
  this.eciesConsts = eciesParams;
25
28
  }
26
- async createPasswordLoginBundle(mnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
29
+ async createPasswordLoginBundle(mnemonic, password, profile = pbkdf2_profile_1.Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
27
30
  const { wallet } = this.eciesService.walletAndSeedFromMnemonic(mnemonic);
28
31
  const derivedKey = await this.pbkdf2Service.deriveKeyFromPasswordWithProfileAsync(password.valueAsUint8Array, profile);
29
32
  // Encrypt private key with derived key
30
33
  const privateKeyBytes = wallet.getPrivateKey();
31
- const { encrypted, iv, tag } = await AESGCMService.encrypt(privateKeyBytes, derivedKey.hash, true);
34
+ const { encrypted, iv, tag } = await aes_gcm_1.AESGCMService.encrypt(privateKeyBytes, derivedKey.hash, true);
32
35
  if (!tag) {
33
- throw new TranslatableError(EciesStringKey.Error_Utils_EncryptionFailedNoAuthTag, this.engine);
36
+ throw new errors_1.TranslatableError(enumerations_1.EciesStringKey.Error_Utils_EncryptionFailedNoAuthTag, this.engine);
34
37
  }
35
- const encryptedPrivateKey = AESGCMService.combineIvTagAndEncryptedData(iv, encrypted, tag);
38
+ const encryptedPrivateKey = aes_gcm_1.AESGCMService.combineIvTagAndEncryptedData(iv, encrypted, tag);
36
39
  // now use the public key to encrypt the mnemonic and store it
37
- const encryptedMnemonic = await this.eciesService.encrypt(EciesEncryptionTypeEnum.Simple, [{ publicKey: wallet.getPublicKey() }], mnemonic.valueAsUint8Array);
40
+ const encryptedMnemonic = await this.eciesService.encrypt(ecies_encryption_type_1.EciesEncryptionTypeEnum.Simple, [{ publicKey: wallet.getPublicKey() }], mnemonic.valueAsUint8Array);
38
41
  return {
39
42
  salt: derivedKey.salt,
40
43
  encryptedPrivateKey: encryptedPrivateKey,
@@ -47,32 +50,32 @@ export class PasswordLoginService {
47
50
  * @param mnemonic The user's mnemonic
48
51
  * @param password The user's password
49
52
  */
50
- async setupPasswordLoginLocalStorageBundle(mnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
53
+ async setupPasswordLoginLocalStorageBundle(mnemonic, password, profile = pbkdf2_profile_1.Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
51
54
  const { salt, encryptedPrivateKey, encryptedMnemonic, wallet } = await this.createPasswordLoginBundle(mnemonic, password, profile);
52
55
  // store the salt and encrypted private key in local storage
53
56
  try {
54
- localStorage.setItem(PasswordLoginService.saltStorageKey, uint8ArrayToHex(salt));
55
- localStorage.setItem(PasswordLoginService.privateKeyStorageKey, uint8ArrayToHex(encryptedPrivateKey));
56
- localStorage.setItem(PasswordLoginService.encryptedMnemonicStorageKey, uint8ArrayToHex(encryptedMnemonic));
57
+ localStorage.setItem(PasswordLoginService.saltStorageKey, (0, utils_1.uint8ArrayToHex)(salt));
58
+ localStorage.setItem(PasswordLoginService.privateKeyStorageKey, (0, utils_1.uint8ArrayToHex)(encryptedPrivateKey));
59
+ localStorage.setItem(PasswordLoginService.encryptedMnemonicStorageKey, (0, utils_1.uint8ArrayToHex)(encryptedMnemonic));
57
60
  localStorage.setItem(PasswordLoginService.profileStorageKey, profile);
58
61
  }
59
62
  catch (error) {
60
- throw new TypedHandleableError(PasswordLoginErrorTypeEnum.FailedToStoreLoginData, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine, undefined, undefined, { cause: error instanceof Error ? error : undefined });
63
+ throw new errors_1.TypedHandleableError(enumerations_1.PasswordLoginErrorTypeEnum.FailedToStoreLoginData, (0, i18n_lib_1.buildReasonMap)(enumerations_1.PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine, undefined, undefined, { cause: error instanceof Error ? error : undefined });
61
64
  }
62
65
  return wallet;
63
66
  }
64
- async getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile = Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
67
+ async getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile = pbkdf2_profile_1.Pbkdf2ProfileEnum.BROWSER_PASSWORD) {
65
68
  if (!salt || !encryptedPrivateKey || !encryptedMnemonic) {
66
- throw new TypedHandleableError(PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine);
69
+ throw new errors_1.TypedHandleableError(enumerations_1.PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, (0, i18n_lib_1.buildReasonMap)(enumerations_1.PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine);
67
70
  }
68
71
  const derivedKey = await this.pbkdf2Service.deriveKeyFromPasswordWithProfileAsync(password.valueAsUint8Array, profile, salt);
69
72
  // Decrypt private key with derived key
70
- const { iv, encryptedDataWithTag } = AESGCMService.splitEncryptedData(encryptedPrivateKey, true, this.eciesConsts);
71
- const privateKeyBytes = await AESGCMService.decrypt(iv, encryptedDataWithTag, derivedKey.hash, true, this.eciesConsts);
72
- const wallet = Wallet.fromPrivateKey(privateKeyBytes);
73
+ const { iv, encryptedDataWithTag } = aes_gcm_1.AESGCMService.splitEncryptedData(encryptedPrivateKey, true, this.eciesConsts);
74
+ const privateKeyBytes = await aes_gcm_1.AESGCMService.decrypt(iv, encryptedDataWithTag, derivedKey.hash, true, this.eciesConsts);
75
+ const wallet = wallet_1.Wallet.fromPrivateKey(privateKeyBytes);
73
76
  // now decrypt the mnemonic
74
77
  const decryptedMnemonic = await this.eciesService.decryptSimpleOrSingleWithHeader(true, wallet.getPrivateKey(), encryptedMnemonic);
75
- return { wallet, mnemonic: new SecureString(decryptedMnemonic) };
78
+ return { wallet, mnemonic: new secure_string_1.SecureString(decryptedMnemonic) };
76
79
  }
77
80
  /**
78
81
  * Recover wallet and mnemonic from password
@@ -90,12 +93,12 @@ export class PasswordLoginService {
90
93
  saltHex === '' ||
91
94
  encryptedPrivateKeyHex === '' ||
92
95
  encryptedMnemonicHex === '') {
93
- throw new TypedHandleableError(PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, buildReasonMap(PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine);
96
+ throw new errors_1.TypedHandleableError(enumerations_1.PasswordLoginErrorTypeEnum.PasswordLoginNotSetUp, (0, i18n_lib_1.buildReasonMap)(enumerations_1.PasswordLoginErrorTypeEnum, ['Error', 'PasswordLoginError']), this.engine);
94
97
  }
95
- const salt = hexToUint8Array(saltHex);
96
- const encryptedPrivateKey = hexToUint8Array(encryptedPrivateKeyHex);
97
- const encryptedMnemonic = hexToUint8Array(encryptedMnemonicHex);
98
- const profile = profileStr || Pbkdf2ProfileEnum.BROWSER_PASSWORD;
98
+ const salt = (0, utils_1.hexToUint8Array)(saltHex);
99
+ const encryptedPrivateKey = (0, utils_1.hexToUint8Array)(encryptedPrivateKeyHex);
100
+ const encryptedMnemonic = (0, utils_1.hexToUint8Array)(encryptedMnemonicHex);
101
+ const profile = profileStr || pbkdf2_profile_1.Pbkdf2ProfileEnum.BROWSER_PASSWORD;
99
102
  return await this.getWalletAndMnemonicFromEncryptedPasswordBundle(salt, encryptedPrivateKey, encryptedMnemonic, password, profile);
100
103
  }
101
104
  /**
@@ -114,4 +117,5 @@ export class PasswordLoginService {
114
117
  encryptedMnemonicHex !== '');
115
118
  }
116
119
  }
120
+ exports.PasswordLoginService = PasswordLoginService;
117
121
  //# sourceMappingURL=password-login.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"password-login.js","sourceRoot":"","sources":["../../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,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAwB,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,OAAO,oBAAoB;IACZ,YAAY,CAAe;IAC3B,aAAa,CAAgB;IAC7B,MAAM,CAAiD;IACvD,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,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AAmB,GAAG,IAAA,uBAAe,EAAC,sBAAsB,CAAC,CAAC;QACpE,MAAM,iBAAiB,GAAG,IAAA,uBAAe,EAAC,oBAAoB,CAAC,CAAC;QAChE,MAAM,OAAO,GAAI,UAAgC,IAAI,kCAAiB,CAAC,gBAAgB,CAAC;QAExF,OAAO,MAAM,IAAI,CAAC,+CAA+C,CAC/D,IAAI,EACJ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAChC,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAC1E,MAAM,sBAAsB,GAAG,YAAY,CAAC,OAAO,CACjD,oBAAoB,CAAC,oBAAoB,CAC1C,CAAC;QACF,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,CAC/C,oBAAoB,CAAC,2BAA2B,CACjD,CAAC;QAEF,OAAO,CAAC,CAAC,CACP,OAAO;YACP,sBAAsB;YACtB,oBAAoB;YACpB,OAAO,KAAK,EAAE;YACd,sBAAsB,KAAK,EAAE;YAC7B,oBAAoB,KAAK,EAAE,CAC5B,CAAC;IACJ,CAAC;;AAnNH,oDAoNC"}
@@ -1,6 +1,9 @@
1
- import { Constants } from '../constants';
2
- import { Pbkdf2ErrorType } from '../enumerations/pbkdf2-error-type';
3
- import { Pbkdf2Error } from '../errors/pbkdf2';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pbkdf2Service = void 0;
4
+ const constants_1 = require("../constants");
5
+ const pbkdf2_error_type_1 = require("../enumerations/pbkdf2-error-type");
6
+ const pbkdf2_1 = require("../errors/pbkdf2");
4
7
  /**
5
8
  * Service for handling PBKDF2 (Password-Based Key Derivation Function 2) operations.
6
9
  * This service provides functionality for:
@@ -9,12 +12,12 @@ import { Pbkdf2Error } from '../errors/pbkdf2';
9
12
  * - Managing salt and iteration parameters
10
13
  * - Both synchronous and asynchronous key derivation
11
14
  */
12
- export class Pbkdf2Service {
15
+ class Pbkdf2Service {
13
16
  engine;
14
17
  profiles;
15
18
  eciesConsts;
16
19
  pbkdf2Consts;
17
- constructor(engine, profiles = Constants.PBKDF2_PROFILES, eciesParams = Constants.ECIES, pbkdf2Params = Constants.PBKDF2) {
20
+ constructor(engine, profiles = constants_1.Constants.PBKDF2_PROFILES, eciesParams = constants_1.Constants.ECIES, pbkdf2Params = constants_1.Constants.PBKDF2) {
18
21
  this.engine = engine;
19
22
  this.profiles = profiles;
20
23
  this.eciesConsts = eciesParams;
@@ -28,7 +31,7 @@ export class Pbkdf2Service {
28
31
  getProfileConfig(profile) {
29
32
  const profileConfig = this.profiles[profile];
30
33
  if (!profileConfig) {
31
- throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidProfile, this.engine);
34
+ throw new pbkdf2_1.Pbkdf2Error(pbkdf2_error_type_1.Pbkdf2ErrorType.InvalidProfile, this.engine);
32
35
  }
33
36
  return {
34
37
  hashBytes: profileConfig.hashBytes,
@@ -76,7 +79,7 @@ export class Pbkdf2Service {
76
79
  const config = this.getConfig(iterations, saltBytes, keySize, algorithm);
77
80
  const saltBytes_ = salt ?? crypto.getRandomValues(new Uint8Array(config.saltBytes));
78
81
  if (saltBytes_.length !== config.saltBytes) {
79
- throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidSaltLength, this.engine);
82
+ throw new pbkdf2_1.Pbkdf2Error(pbkdf2_error_type_1.Pbkdf2ErrorType.InvalidSaltLength, this.engine);
80
83
  }
81
84
  const keyMaterial = await crypto.subtle.importKey('raw', new Uint8Array(password), 'PBKDF2', false, ['deriveBits']);
82
85
  const keyArray = await crypto.subtle.deriveBits({
@@ -87,7 +90,7 @@ export class Pbkdf2Service {
87
90
  }, keyMaterial, config.hashBytes * 8);
88
91
  const keyBytes = new Uint8Array(keyArray);
89
92
  if (keyBytes.length !== config.hashBytes) {
90
- throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidHashLength, this.engine);
93
+ throw new pbkdf2_1.Pbkdf2Error(pbkdf2_error_type_1.Pbkdf2ErrorType.InvalidHashLength, this.engine);
91
94
  }
92
95
  return {
93
96
  salt: saltBytes_,
@@ -107,4 +110,5 @@ export class Pbkdf2Service {
107
110
  return await this.deriveKeyFromPasswordAsync(password, salt, config.iterations, config.saltBytes, config.hashBytes, config.algorithm);
108
111
  }
109
112
  }
113
+ exports.Pbkdf2Service = Pbkdf2Service;
110
114
  //# sourceMappingURL=pbkdf2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["../../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;AAO/C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACL,MAAM,CAAiD;IACvD,QAAQ,CAAgC;IACxC,WAAW,CAAkB;IAC7B,YAAY,CAAgB;IAE/C,YACE,MAAsD,EACtD,WAA0C,SAAS,CAAC,eAAe,EACnE,cAA+B,SAAS,CAAC,KAAK,EAC9C,eAA8B,SAAS,CAAC,MAAM;QAE9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CACrB,OAAe;QAEf,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC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IAAI,CAAC,MAAM,CAAC,CAAC;QACxE,CAAC;QAED,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC;IACJ,CAAC;IAED;;;;;;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;AAzJD,sCAyJC"}
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XorService = void 0;
1
4
  /**
2
5
  * A simple and fast XOR cipher for obfuscating data in memory for browser environments.
3
6
  * This is not a substitute for strong cryptography but provides a lightweight way
4
7
  * to prevent sensitive data from being stored in plaintext in memory.
5
8
  */
6
- export class XorService {
9
+ class XorService {
7
10
  /**
8
11
  * Encrypts or decrypts data using a simple XOR cipher.
9
12
  * The key is XORed with the data. The same function is used for
@@ -60,4 +63,5 @@ export class XorService {
60
63
  return decoder.decode(bytes);
61
64
  }
62
65
  }
66
+ exports.XorService = XorService;
63
67
  //# sourceMappingURL=xor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xor.js","sourceRoot":"","sources":["../../src/services/xor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACrB;;;;;;;;OAQG;IACI,MAAM,CAAC,GAAG,CAAC,IAAgB,EAAE,GAAe;QACjD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,KAAK,IAAI,CAAC,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 -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=deep-partial.js.map
package/dist/types.js CHANGED
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=types.js.map
package/dist/utils.js CHANGED
@@ -1,82 +1,100 @@
1
- import { LengthEncodingType } from './enumerations/length-encoding-type';
2
- import { LengthErrorType } from './enumerations/length-error-type';
3
- import { LengthError } from './errors';
4
- import { getCompatibleEciesEngine } from './i18n-setup';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lengthEncodeData = lengthEncodeData;
4
+ exports.decodeLengthEncodedData = decodeLengthEncodedData;
5
+ exports.uint8ArrayToBase64 = uint8ArrayToBase64;
6
+ exports.base64ToUint8Array = base64ToUint8Array;
7
+ exports.uint8ArrayToHex = uint8ArrayToHex;
8
+ exports.hexToUint8Array = hexToUint8Array;
9
+ exports.crc16 = crc16;
10
+ exports.stringToUint8Array = stringToUint8Array;
11
+ exports.uint8ArrayToString = uint8ArrayToString;
12
+ exports.randomBytes = randomBytes;
13
+ exports.arraysEqual = arraysEqual;
14
+ exports.concatUint8Arrays = concatUint8Arrays;
15
+ exports.getLengthEncodingTypeForLength = getLengthEncodingTypeForLength;
16
+ exports.getLengthEncodingTypeFromValue = getLengthEncodingTypeFromValue;
17
+ exports.safeBigIntToNumber = safeBigIntToNumber;
18
+ exports.getLengthForLengthType = getLengthForLengthType;
19
+ const length_encoding_type_1 = require("./enumerations/length-encoding-type");
20
+ const length_error_type_1 = require("./enumerations/length-error-type");
21
+ const errors_1 = require("./errors");
22
+ const i18n_setup_1 = require("./i18n-setup");
5
23
  /**
6
24
  * Encodes the length of the data in the buffer
7
25
  * @param buffer The buffer to encode
8
26
  * @returns The encoded buffer
9
27
  */
10
- export function lengthEncodeData(buffer) {
28
+ function lengthEncodeData(buffer) {
11
29
  const lengthType = getLengthEncodingTypeForLength(buffer.length);
12
30
  const lengthTypeSize = getLengthForLengthType(lengthType);
13
31
  const result = new Uint8Array(1 + lengthTypeSize + buffer.length);
14
32
  const view = new DataView(result.buffer);
15
33
  view.setUint8(0, lengthType);
16
34
  switch (lengthType) {
17
- case LengthEncodingType.UInt8:
35
+ case length_encoding_type_1.LengthEncodingType.UInt8:
18
36
  view.setUint8(1, buffer.length);
19
37
  break;
20
- case LengthEncodingType.UInt16:
38
+ case length_encoding_type_1.LengthEncodingType.UInt16:
21
39
  view.setUint16(1, buffer.length, false); // big-endian
22
40
  break;
23
- case LengthEncodingType.UInt32:
41
+ case length_encoding_type_1.LengthEncodingType.UInt32:
24
42
  view.setUint32(1, buffer.length, false); // big-endian
25
43
  break;
26
- case LengthEncodingType.UInt64:
44
+ case length_encoding_type_1.LengthEncodingType.UInt64:
27
45
  view.setBigUint64(1, BigInt(buffer.length), false); // big-endian
28
46
  break;
29
47
  }
30
48
  result.set(buffer, 1 + lengthTypeSize);
31
49
  return result;
32
50
  }
33
- export function decodeLengthEncodedData(buffer) {
51
+ function decodeLengthEncodedData(buffer) {
34
52
  if (buffer.length < 1) {
35
- throw new LengthError(LengthErrorType.LengthIsTooShort, getCompatibleEciesEngine());
53
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooShort, (0, i18n_setup_1.getCompatibleEciesEngine)());
36
54
  }
37
55
  const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
38
56
  const lengthType = getLengthEncodingTypeFromValue(view.getUint8(0));
39
57
  const lengthTypeSize = getLengthForLengthType(lengthType);
40
58
  if (buffer.length < 1 + lengthTypeSize) {
41
- throw new LengthError(LengthErrorType.LengthIsTooShort, getCompatibleEciesEngine());
59
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooShort, (0, i18n_setup_1.getCompatibleEciesEngine)());
42
60
  }
43
61
  let length;
44
62
  switch (lengthType) {
45
- case LengthEncodingType.UInt8:
63
+ case length_encoding_type_1.LengthEncodingType.UInt8:
46
64
  length = view.getUint8(1);
47
65
  break;
48
- case LengthEncodingType.UInt16:
66
+ case length_encoding_type_1.LengthEncodingType.UInt16:
49
67
  length = view.getUint16(1, false); // big-endian
50
68
  break;
51
- case LengthEncodingType.UInt32:
69
+ case length_encoding_type_1.LengthEncodingType.UInt32:
52
70
  length = view.getUint32(1, false); // big-endian
53
71
  break;
54
- case LengthEncodingType.UInt64:
72
+ case length_encoding_type_1.LengthEncodingType.UInt64:
55
73
  length = view.getBigUint64(1, false); // big-endian
56
74
  if (length.valueOf() > BigInt(Number.MAX_SAFE_INTEGER)) {
57
- throw new LengthError(LengthErrorType.LengthIsTooLong, getCompatibleEciesEngine());
75
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooLong, (0, i18n_setup_1.getCompatibleEciesEngine)());
58
76
  }
59
77
  break;
60
78
  default:
61
- throw new LengthError(LengthErrorType.LengthIsInvalidType, getCompatibleEciesEngine());
79
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsInvalidType, (0, i18n_setup_1.getCompatibleEciesEngine)());
62
80
  }
63
81
  const totalLength = 1 + lengthTypeSize + Number(length);
64
82
  if (totalLength > buffer.length) {
65
- throw new LengthError(LengthErrorType.LengthIsTooShort, getCompatibleEciesEngine());
83
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooShort, (0, i18n_setup_1.getCompatibleEciesEngine)());
66
84
  }
67
85
  return {
68
86
  data: buffer.subarray(1 + lengthTypeSize, totalLength),
69
87
  totalLength,
70
88
  };
71
89
  }
72
- export function uint8ArrayToBase64(uint8Array) {
90
+ function uint8ArrayToBase64(uint8Array) {
73
91
  let binaryString = '';
74
92
  for (let i = 0; i < uint8Array.length; i++) {
75
93
  binaryString += String.fromCharCode(uint8Array[i]);
76
94
  }
77
95
  return btoa(binaryString);
78
96
  }
79
- export function base64ToUint8Array(base64String) {
97
+ function base64ToUint8Array(base64String) {
80
98
  const binaryString = atob(base64String);
81
99
  const len = binaryString.length;
82
100
  const bytes = new Uint8Array(len);
@@ -85,12 +103,12 @@ export function base64ToUint8Array(base64String) {
85
103
  }
86
104
  return bytes;
87
105
  }
88
- export function uint8ArrayToHex(uint8Array) {
106
+ function uint8ArrayToHex(uint8Array) {
89
107
  return Array.from(uint8Array)
90
108
  .map((byte) => byte.toString(16).padStart(2, '0'))
91
109
  .join('');
92
110
  }
93
- export function hexToUint8Array(hexString) {
111
+ function hexToUint8Array(hexString) {
94
112
  if (!hexString || typeof hexString !== 'string') {
95
113
  throw new Error('Invalid hex string');
96
114
  }
@@ -114,7 +132,7 @@ export function hexToUint8Array(hexString) {
114
132
  * CRC16-CCITT implementation for data integrity checking
115
133
  * Uses CRC16-CCITT-FALSE variant (init 0xFFFF)
116
134
  */
117
- export function crc16(data) {
135
+ function crc16(data) {
118
136
  let crc = 0xffff; // Initial value for CRC16-CCITT-FALSE
119
137
  const polynomial = 0x1021; // CRC16-CCITT polynomial
120
138
  for (let i = 0; i < data.length; i++) {
@@ -137,25 +155,25 @@ export function crc16(data) {
137
155
  /**
138
156
  * Convert string to Uint8Array (UTF-8 encoding)
139
157
  */
140
- export function stringToUint8Array(str) {
158
+ function stringToUint8Array(str) {
141
159
  return new TextEncoder().encode(str);
142
160
  }
143
161
  /**
144
162
  * Convert Uint8Array to string (UTF-8 decoding)
145
163
  */
146
- export function uint8ArrayToString(array) {
164
+ function uint8ArrayToString(array) {
147
165
  return new TextDecoder().decode(array);
148
166
  }
149
167
  /**
150
168
  * Secure random bytes generation
151
169
  */
152
- export function randomBytes(length) {
170
+ function randomBytes(length) {
153
171
  return crypto.getRandomValues(new Uint8Array(length));
154
172
  }
155
173
  /**
156
174
  * Compare two Uint8Arrays for equality
157
175
  */
158
- export function arraysEqual(a, b) {
176
+ function arraysEqual(a, b) {
159
177
  if (a.length !== b.length)
160
178
  return false;
161
179
  let result = 0;
@@ -167,7 +185,7 @@ export function arraysEqual(a, b) {
167
185
  /**
168
186
  * Concatenate multiple Uint8Arrays
169
187
  */
170
- export function concatUint8Arrays(...arrays) {
188
+ function concatUint8Arrays(...arrays) {
171
189
  const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
172
190
  const result = new Uint8Array(totalLength);
173
191
  let offset = 0;
@@ -182,43 +200,43 @@ export function concatUint8Arrays(...arrays) {
182
200
  * @param length The length to evaluate
183
201
  * @returns The corresponding LengthEncodingType
184
202
  */
185
- export function getLengthEncodingTypeForLength(length) {
203
+ function getLengthEncodingTypeForLength(length) {
186
204
  if (typeof length === 'number') {
187
205
  if (length < 256) {
188
- return LengthEncodingType.UInt8;
206
+ return length_encoding_type_1.LengthEncodingType.UInt8;
189
207
  }
190
208
  else if (length < 65536) {
191
- return LengthEncodingType.UInt16;
209
+ return length_encoding_type_1.LengthEncodingType.UInt16;
192
210
  }
193
211
  else if (length < 4294967296) {
194
- return LengthEncodingType.UInt32;
212
+ return length_encoding_type_1.LengthEncodingType.UInt32;
195
213
  }
196
214
  else if (length < Number.MAX_SAFE_INTEGER) {
197
- return LengthEncodingType.UInt64;
215
+ return length_encoding_type_1.LengthEncodingType.UInt64;
198
216
  }
199
217
  else {
200
- throw new LengthError(LengthErrorType.LengthIsTooLong, getCompatibleEciesEngine());
218
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooLong, (0, i18n_setup_1.getCompatibleEciesEngine)());
201
219
  }
202
220
  }
203
221
  else if (typeof length === 'bigint') {
204
222
  if (length < 256n) {
205
- return LengthEncodingType.UInt8;
223
+ return length_encoding_type_1.LengthEncodingType.UInt8;
206
224
  }
207
225
  else if (length < 65536n) {
208
- return LengthEncodingType.UInt16;
226
+ return length_encoding_type_1.LengthEncodingType.UInt16;
209
227
  }
210
228
  else if (length < 4294967296n) {
211
- return LengthEncodingType.UInt32;
229
+ return length_encoding_type_1.LengthEncodingType.UInt32;
212
230
  }
213
231
  else if (length < 18446744073709551616n) {
214
- return LengthEncodingType.UInt64;
232
+ return length_encoding_type_1.LengthEncodingType.UInt64;
215
233
  }
216
234
  else {
217
- throw new LengthError(LengthErrorType.LengthIsTooLong, getCompatibleEciesEngine());
235
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsTooLong, (0, i18n_setup_1.getCompatibleEciesEngine)());
218
236
  }
219
237
  }
220
238
  else {
221
- throw new LengthError(LengthErrorType.LengthIsInvalidType, getCompatibleEciesEngine());
239
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsInvalidType, (0, i18n_setup_1.getCompatibleEciesEngine)());
222
240
  }
223
241
  }
224
242
  /**
@@ -226,20 +244,20 @@ export function getLengthEncodingTypeForLength(length) {
226
244
  * @param value The value to evaluate
227
245
  * @returns The corresponding LengthEncodingType
228
246
  */
229
- export function getLengthEncodingTypeFromValue(value) {
230
- for (const length of Object.values(LengthEncodingType)) {
247
+ function getLengthEncodingTypeFromValue(value) {
248
+ for (const length of Object.values(length_encoding_type_1.LengthEncodingType)) {
231
249
  if (length === value) {
232
250
  return length;
233
251
  }
234
252
  }
235
- throw new LengthError(LengthErrorType.LengthIsInvalidType, getCompatibleEciesEngine());
253
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsInvalidType, (0, i18n_setup_1.getCompatibleEciesEngine)());
236
254
  }
237
255
  /**
238
256
  * Safely converts BigInt to Number, throwing if value exceeds safe integer range
239
257
  * @param value The BigInt value to convert
240
258
  * @returns The number value
241
259
  */
242
- export function safeBigIntToNumber(value) {
260
+ function safeBigIntToNumber(value) {
243
261
  if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
244
262
  throw new Error('Value exceeds safe integer range');
245
263
  }
@@ -253,18 +271,18 @@ export function safeBigIntToNumber(value) {
253
271
  * @param type The LengthEncodingType to evaluate
254
272
  * @returns The length in bytes
255
273
  */
256
- export function getLengthForLengthType(type) {
274
+ function getLengthForLengthType(type) {
257
275
  switch (type) {
258
- case LengthEncodingType.UInt8:
276
+ case length_encoding_type_1.LengthEncodingType.UInt8:
259
277
  return 1;
260
- case LengthEncodingType.UInt16:
278
+ case length_encoding_type_1.LengthEncodingType.UInt16:
261
279
  return 2;
262
- case LengthEncodingType.UInt32:
280
+ case length_encoding_type_1.LengthEncodingType.UInt32:
263
281
  return 4;
264
- case LengthEncodingType.UInt64:
282
+ case length_encoding_type_1.LengthEncodingType.UInt64:
265
283
  return 8;
266
284
  default:
267
- throw new LengthError(LengthErrorType.LengthIsInvalidType, getCompatibleEciesEngine());
285
+ throw new errors_1.LengthError(length_error_type_1.LengthErrorType.LengthIsInvalidType, (0, i18n_setup_1.getCompatibleEciesEngine)());
268
286
  }
269
287
  }
270
288
  //# sourceMappingURL=utils.js.map