dcl-crypto
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -7,2 +7,3 @@ import { EthereumProvider } from 'web3x/providers'; | ||
static validateSignature(expectedFinalAuthority: string, authChain: AuthChain, provider: EthereumProvider, dateToValidateExpirationInMillis?: number): Promise<ValidationResult>; | ||
static isValidAuthChain(authChain: AuthChain): boolean; | ||
static createEthereumMessageHash(msg: string): string; | ||
@@ -9,0 +10,0 @@ static createEIP1271MessageHash(msg: string): string; |
@@ -19,2 +19,8 @@ "use strict"; | ||
let currentAuthority = ''; | ||
if (!Authenticator.isValidAuthChain(authChain)) { | ||
return { | ||
ok: false, | ||
message: 'ERROR: Malformed authChain' | ||
}; | ||
} | ||
for (let authLink of authChain) { | ||
@@ -44,2 +50,15 @@ const validator = getValidatorByType(authLink.type); | ||
} | ||
static isValidAuthChain(authChain) { | ||
for (const [index, authLink] of authChain.entries()) { | ||
// SIGNER should be the first one | ||
if (index === 0 && authLink.type !== types_1.AuthLinkType.SIGNER) { | ||
return false; | ||
} | ||
// SIGNER should be unique | ||
if (authLink.type === types_1.AuthLinkType.SIGNER && index !== 0) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
static createEthereumMessageHash(msg) { | ||
@@ -46,0 +65,0 @@ let msgWithPrefix = `\x19Ethereum Signed Message:\n${msg.length}${msg}`; |
{ | ||
"name": "dcl-crypto", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Crypto auth for Decentraland", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
46193
644