From 1791cb7c8216cb283f0480bd01d35abcb2145fb6 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Tue, 26 Jan 2021 10:18:52 +0100 Subject: [PATCH] auth: Fix base64url transformation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem was that replace only replaces the first occurrence of a string and not all as is needed for this function. tsconfig.json needed lib to be set to esnext or the replaceAll function won't be available… Signed-off-by: Philip Molares --- src/auth/auth.service.ts | 6 +++--- tsconfig.json | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 3d5751e89..9500cef57 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -70,9 +70,9 @@ export class AuthService { // base64url is quite easy buildable from base64 return text .toString('base64') - .replace('+', '-') - .replace('/', '_') - .replace(/=+$/, ''); + .replaceAll(/\+/g, '-') + .replaceAll(/\//g, '_') + .replaceAll(/=+$/g, ''); } async createTokenForUser( diff --git a/tsconfig.json b/tsconfig.json index bf10a2398..e129127e1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "sourceMap": true, "outDir": "./dist", "baseUrl": "./", - "incremental": true + "incremental": true, + "lib": ["esnext"] } }