@near-js/crypto
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -35,7 +35,10 @@ "use strict"; | ||
const parts = encodedKey.split(':'); | ||
let publicKey; | ||
let keyType = constants_1.KeyType.ED25519; | ||
if (parts.length === 1) { | ||
return new PublicKey({ keyType: constants_1.KeyType.ED25519, data: (0, borsh_1.baseDecode)(parts[0]) }); | ||
publicKey = parts[0]; | ||
} | ||
else if (parts.length === 2) { | ||
return new PublicKey({ keyType: str_to_key_type(parts[0]), data: (0, borsh_1.baseDecode)(parts[1]) }); | ||
publicKey = parts[1]; | ||
keyType = str_to_key_type(parts[0]); | ||
} | ||
@@ -45,2 +48,7 @@ else { | ||
} | ||
const decodedPublicKey = (0, borsh_1.baseDecode)(publicKey); | ||
if (decodedPublicKey.length !== tweetnacl_1.default.box.publicKeyLength) { | ||
throw new Error(`Invalid public key size (${decodedPublicKey.length}), must be ${tweetnacl_1.default.box.publicKeyLength}`); | ||
} | ||
return new PublicKey({ keyType, data: decodedPublicKey }); | ||
} | ||
@@ -47,0 +55,0 @@ toString() { |
{ | ||
"name": "@near-js/crypto", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Abstractions around NEAR-compatible elliptical curves and cryptographic keys", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12281
250