From b9101de1cc238f554366a3d5a4f9d155042cdcc2 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 16 Nov 2019 20:48:40 -0500 Subject: [PATCH] Fix encoding issue --- src/api/Security.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/Security.ts b/src/api/Security.ts index 378afcb..b3962c3 100644 --- a/src/api/Security.ts +++ b/src/api/Security.ts @@ -19,13 +19,13 @@ export default class Security { public async createBearer(_id: string): Promise { const account = await this.client.db.Account.findOne({ _id }); if (!account) throw new Error(`Account [${_id}] cannot be found.`); - const bearer = crypto.randomBytes(12); + const bearer = crypto.randomBytes(12).toString('base64'); const sign = crypto.createSign('sha3-224'); sign.update(bearer); sign.end(); const signature = sign.sign(this.keyPair.privateKey, 'hex'); await account.updateOne({ bearerSignature: signature }); - return bearer.toString('base64'); + return bearer; } public async checkBearer(_id: string, bearer: string): Promise {