summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/decodeClientDataJSON.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-05-24 17:51:31 -0700
committerMatthew Miller <matthew@millerti.me>2020-05-24 17:51:31 -0700
commitb2d897ff93444b5e25b3e26892b627f2b771b5bf (patch)
treef769388a9ec389a3dad6e5b1a8b8cc82ee21621b /packages/server/src/helpers/decodeClientDataJSON.ts
parent494183f116660dbfbef50bc56cd2ec3cf7cc11a9 (diff)
Decode `challenge` when decoding client data
Diffstat (limited to 'packages/server/src/helpers/decodeClientDataJSON.ts')
-rw-r--r--packages/server/src/helpers/decodeClientDataJSON.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/server/src/helpers/decodeClientDataJSON.ts b/packages/server/src/helpers/decodeClientDataJSON.ts
index 1aeb9c9..0ff5dea 100644
--- a/packages/server/src/helpers/decodeClientDataJSON.ts
+++ b/packages/server/src/helpers/decodeClientDataJSON.ts
@@ -7,5 +7,11 @@ import asciiToBinary from './asciiToBinary';
*/
export default function decodeClientDataJSON(data: string): ClientDataJSON {
const toString = asciiToBinary(data);
- return JSON.parse(toString);
+ const clientData: ClientDataJSON = JSON.parse(toString);
+
+ // `challenge` will be Base64-encoded here. Decode it for easier comparisons with what is provided
+ // as the expected value
+ clientData.challenge = Buffer.from(clientData.challenge, 'base64').toString('ascii');
+
+ return clientData;
}