We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There's a bunch of Buffer.from(newSecret, 'hex') code that is preventing this library from working in Expo specifically the one in
Buffer.from(newSecret, 'hex')
function hotpDigestToToken(hexDigest, digits) { const digest = Buffer.from(hexDigest, 'hex'); ... }
Which I can't find a way to override.
Also In my attempt, I used Uint8Array which I think may be a better choice than passing hex strings.
This is my workaround for now
const hexToUint8Array = (hexString) => { const length = hexString.length; const uint8Array = new Uint8Array(length / 2); for (let i = 0, j = 0; i < length; i += 2, j++) { uint8Array[j] = parseInt(hexString.substring(i, i + 2), 16); } return uint8Array; } function hotpDigestToToken(hexDigest, digits) { const digest = hexToUint8Array(hexDigest); const offset = digest[digest.length - 1] & 0xf; const binary = (digest[offset] & 0x7f) << 24 | (digest[offset + 1] & 0xff) << 16 | (digest[offset + 2] & 0xff) << 8 | digest[offset + 3] & 0xff; const token = binary % Math.pow(10, digits); return padStart(String(token), digits, '0'); }
The text was updated successfully, but these errors were encountered:
Also to avoid having to modify the code I just added a simplistic polyfill for this one scenario
if (!global.Buffer) { global.Buffer = {} as typeof global.Buffer; global.Buffer.from = (...args: any[]): any => { const hexString = args[0] as string; const length = hexString.length; const uint8Array = new Uint8Array(length / 2); for (let i = 0, j = 0; i < length; i += 2, j++) { uint8Array[j] = parseInt(hexString.substring(i, i + 2), 16); } return uint8Array; }; }
Sorry, something went wrong.
No branches or pull requests
There's a bunch of
Buffer.from(newSecret, 'hex')
code that is preventing this library from working in Expo specifically the one inWhich I can't find a way to override.
Also In my attempt, I used Uint8Array which I think may be a better choice than passing hex strings.
This is my workaround for now
The text was updated successfully, but these errors were encountered: