How to use the js-sha256.array function in js-sha256

To help you get started, we’ve selected a few js-sha256 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nearprotocol / near-wallet / src / utils / wallet.js View on Github external
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') })