Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async setupAccountRecovery(phoneNumber, accountId, securityCode) {
const account = this.getAccount(accountId)
const accountKeys = await account.getAccessKeys();
if (!accountKeys.some(it => it.public_key.endsWith(HELPER_KEY))) {
await account.addKey(HELPER_KEY);
}
const hash = Uint8Array.from(sha256.array(Buffer.from(securityCode)));
const { signature } = await this.connection.signer.signHash(hash, accountId, NETWORK_ID)
await this.validateCode(phoneNumber, accountId, { securityCode, signature: Buffer.from(signature).toString('base64') })
}