diff --git a/.changeset/plenty-comics-matter.md b/.changeset/plenty-comics-matter.md new file mode 100644 index 00000000000..77d26075a25 --- /dev/null +++ b/.changeset/plenty-comics-matter.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-expo': patch +--- + +Use a polyfill for the `atob` function to prevent errors when using the Hermes JS engine, since the engine's `atob` implementation is stricter than it should be. diff --git a/packages/expo/src/polyfills/base64Polyfill.ts b/packages/expo/src/polyfills/base64Polyfill.ts index 960046fa0da..b36d38f63f2 100644 --- a/packages/expo/src/polyfills/base64Polyfill.ts +++ b/packages/expo/src/polyfills/base64Polyfill.ts @@ -1,9 +1,14 @@ import { decode, encode } from 'base-64'; -if (!global.btoa) { +//@ts-expect-error HermesInternal is added by the Hermes JS Engine +const isHermes = !!global.HermesInternal; + +// See Default Expo 51 engine Hermes' issue: https://github.com/facebook/hermes/issues/1379 +if (!global.btoa || isHermes) { global.btoa = encode; } -if (!global.atob) { +// See Default Expo 51 engine Hermes' issue: https://github.com/facebook/hermes/issues/1379 +if (!global.atob || isHermes) { global.atob = decode; }