From a6dbc3a511229d1df0cce765412b79500048035c Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sun, 24 Jan 2021 13:47:56 +0300 Subject: [PATCH] Get rid of Buffer.from polyfill requirement IE10+ browsers support btoa function. Do we really need 50kb Buffer polyfill in the browser? --- packages/sdk-auth/src/auth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sdk-auth/src/auth.js b/packages/sdk-auth/src/auth.js index 9446fc103..4024e5a01 100644 --- a/packages/sdk-auth/src/auth.js +++ b/packages/sdk-auth/src/auth.js @@ -87,7 +87,8 @@ export default class SdkAuth { clientId, clientSecret, }: ClientAuthOptions): string { - return Buffer.from(`${clientId}:${clientSecret}`).toString('base64') + const targetStr = `${clientId}:${clientSecret}`; + return typeof Buffer === 'undefined' ? btoa(targetStr) : Buffer.from(targetStr).toString('base64'); } static _getScopes(scopes: ?Array, projectKey: ?string): string {