From ea080e895f6c96db0d7c50393378bc5d5a408ef6 Mon Sep 17 00:00:00 2001 From: driverjb Date: Fri, 8 Mar 2024 10:18:20 -0500 Subject: [PATCH] the replace function will only replace the first instance of the + and / characters resulting in some strings that still contain those characters. Altering the string format to base64url will handle everything for url safety automatically. https://github.com/duosecurity/duo_universal_nodejs/issues/28 --- src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.ts b/src/util.ts index 4a498f7..5c6baad 100644 --- a/src/util.ts +++ b/src/util.ts @@ -6,7 +6,7 @@ import { randomBytes } from 'crypto'; function bytesToBase64url(s: Buffer): string { - return s.toString('base64').replace('+', '-').replace('/', '_'); + return s.toString('base64url'); } export const generateRandomString = (length: number): string => {