@talismn/crypto 0.1.4 → 0.2.0

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.
@@ -2,3 +2,4 @@ export * from "./encoding";
2
2
  export * from "./addressFromPublicKey";
3
3
  export * from "./normalizeAddress";
4
4
  export * from "./isAddressEqual";
5
+ export * from "./isValidAddress";
@@ -0,0 +1 @@
1
+ export declare const isValidAddress: (address: string) => boolean;
@@ -2,7 +2,7 @@ export declare const blake3: {
2
2
  (msg: import("@noble/hashes/utils").Input, opts?: Object | undefined): Uint8Array;
3
3
  outputLen: number;
4
4
  blockLen: number;
5
- create(opts: Object): import("@noble/hashes/utils").HashXOF<import("@noble/hashes/utils").HashXOF<import("@noble/hashes/utils").HashXOF<any>>>;
5
+ create(opts?: Object | undefined): import("@noble/hashes/utils").HashXOF<import("@noble/hashes/utils").HashXOF<import("@noble/hashes/utils").HashXOF<any>>>;
6
6
  };
7
7
  export declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
8
8
  export declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
@@ -401,6 +401,15 @@ const isAddressEqual = (address1, address2) => {
401
401
  }
402
402
  };
403
403
 
404
+ const isValidAddress = address => {
405
+ try {
406
+ normalizeAddress(address);
407
+ return true;
408
+ } catch {
409
+ return false;
410
+ }
411
+ };
412
+
404
413
  // Inspired from MIT licensed @polkadot-labs/hdkd helpers
405
414
  // https://github.com/polkadot-labs/hdkd/blob/3ef6e02827212d934b59a4e566d8aa61d3ba7b27/packages/hdkd-helpers/src/parseDerivations.ts#L1
406
415
 
@@ -735,6 +744,7 @@ exports.isBech32mAddress = isBech32mAddress;
735
744
  exports.isBitcoinAddress = isBitcoinAddress;
736
745
  exports.isEthereumAddress = isEthereumAddress;
737
746
  exports.isSs58Address = isSs58Address;
747
+ exports.isValidAddress = isValidAddress;
738
748
  exports.isValidDerivationPath = isValidDerivationPath;
739
749
  exports.isValidMnemonic = isValidMnemonic;
740
750
  exports.mnemonicToEntropy = mnemonicToEntropy;
@@ -401,6 +401,15 @@ const isAddressEqual = (address1, address2) => {
401
401
  }
402
402
  };
403
403
 
404
+ const isValidAddress = address => {
405
+ try {
406
+ normalizeAddress(address);
407
+ return true;
408
+ } catch {
409
+ return false;
410
+ }
411
+ };
412
+
404
413
  // Inspired from MIT licensed @polkadot-labs/hdkd helpers
405
414
  // https://github.com/polkadot-labs/hdkd/blob/3ef6e02827212d934b59a4e566d8aa61d3ba7b27/packages/hdkd-helpers/src/parseDerivations.ts#L1
406
415
 
@@ -735,6 +744,7 @@ exports.isBech32mAddress = isBech32mAddress;
735
744
  exports.isBitcoinAddress = isBitcoinAddress;
736
745
  exports.isEthereumAddress = isEthereumAddress;
737
746
  exports.isSs58Address = isSs58Address;
747
+ exports.isValidAddress = isValidAddress;
738
748
  exports.isValidDerivationPath = isValidDerivationPath;
739
749
  exports.isValidMnemonic = isValidMnemonic;
740
750
  exports.mnemonicToEntropy = mnemonicToEntropy;
@@ -396,6 +396,15 @@ const isAddressEqual = (address1, address2) => {
396
396
  }
397
397
  };
398
398
 
399
+ const isValidAddress = address => {
400
+ try {
401
+ normalizeAddress(address);
402
+ return true;
403
+ } catch {
404
+ return false;
405
+ }
406
+ };
407
+
399
408
  // Inspired from MIT licensed @polkadot-labs/hdkd helpers
400
409
  // https://github.com/polkadot-labs/hdkd/blob/3ef6e02827212d934b59a4e566d8aa61d3ba7b27/packages/hdkd-helpers/src/parseDerivations.ts#L1
401
410
 
@@ -690,4 +699,4 @@ const platformFromAddress = address => {
690
699
  return platformFromEncoding(encoding);
691
700
  };
692
701
 
693
- export { DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, addressEncodingFromCurve, addressFromPublicKey, addressFromSuri, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, deriveKeypair, detectAddressEncoding, encodeAddressBase58, encodeAddressEthereum, encodeAddressSs58, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getDevSeed, getPublicKeyFromSecret, getSafeHash, isAddressEqual, isBase58Address, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isSs58Address, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, parseSuri, pbkdf2, platformFromAddress, platformFromCurve, platformFromEncoding, removeHexPrefix };
702
+ export { DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, addressEncodingFromCurve, addressFromPublicKey, addressFromSuri, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, deriveKeypair, detectAddressEncoding, encodeAddressBase58, encodeAddressEthereum, encodeAddressSs58, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getDevSeed, getPublicKeyFromSecret, getSafeHash, isAddressEqual, isBase58Address, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isSs58Address, isValidAddress, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, parseSuri, pbkdf2, platformFromAddress, platformFromCurve, platformFromEncoding, removeHexPrefix };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/crypto",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -22,10 +22,10 @@
22
22
  "node": ">=18"
23
23
  },
24
24
  "dependencies": {
25
- "@noble/curves": "1.8.1",
26
- "@noble/hashes": "1.7.1",
27
- "@scure/base": "1.2.4",
28
- "@scure/bip32": "1.6.2",
25
+ "@noble/curves": "1.9.2",
26
+ "@noble/hashes": "1.8.0",
27
+ "@scure/base": "1.2.6",
28
+ "@scure/bip32": "1.7.0",
29
29
  "@scure/bip39": "1.5.4",
30
30
  "bech32": "2.0.0",
31
31
  "bs58check": "4.0.0",
@@ -53,7 +53,7 @@
53
53
  ]
54
54
  },
55
55
  "scripts": {
56
- "test": "jest",
56
+ "test": "jest --detectOpenHandles",
57
57
  "lint": "eslint src --max-warnings 0",
58
58
  "clean": "rm -rf dist plugins/dist .turbo node_modules"
59
59
  }