summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-06-02 11:52:12 -0700
committerMatthew Miller <matthew@millerti.me>2020-06-02 11:52:12 -0700
commit451ae557b51875f6b0eedb055d5561f22ad4456f (patch)
tree7684e4b64ccbace18fca5df60190dd451af8a25e /packages/browser/src/helpers
parentcac818173050ec1e18d73d0f880c826901cf4abd (diff)
Refactor to incorporate new helper
Diffstat (limited to 'packages/browser/src/helpers')
-rw-r--r--packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts b/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts
index c37fed0..8fad78b 100644
--- a/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts
+++ b/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts
@@ -1,16 +1,14 @@
-import base64js from 'base64-js';
import type { PublicKeyCredentialDescriptorJSON } from '@simplewebauthn/typescript-types';
+import base64URLStringToBuffer from './base64URLStringToBuffer';
+
export default function toPublicKeyCredentialDescriptor(
descriptor: PublicKeyCredentialDescriptorJSON,
): PublicKeyCredentialDescriptor {
- // Make sure the Base64'd credential ID length is a multiple of 4 or else toByteArray will throw
const { id } = descriptor;
- const padLength = 4 - (id.length % 4);
- const paddedId = id.padEnd(id.length + padLength, '=');
return {
...descriptor,
- id: base64js.toByteArray(paddedId),
+ id: base64URLStringToBuffer(id),
};
}