Skip to content

Conversation

felipecsl
Copy link
Contributor

@felipecsl felipecsl commented Dec 4, 2024

Motivation and Context

Replace usage of Buffer with js-base64 polyfill for browser environment

Description

It looks like Base64.decode is able to parse both flavors of base64-encoded strings (regular and url-safe 'base64url' encoding), so this is a safe change. The docs also mention that explicitly https://github.com/dankogai/js-base64?tab=readme-ov-file#synopsis
image

How has this been tested?

Wrote another test

Related to Eppo-exp/js-client-sdk#115

@felipecsl felipecsl changed the title fix: Use base64 polyfill instead of Buffer fix: Use js-base64 polyfill instead of Buffer for browser env Dec 4, 2024
if (!encodedPayload) return null;

const decodedPayload = Buffer.from(encodedPayload, 'base64url').toString('utf-8');
const decodedPayload = Base64.decode(encodedPayload);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@felipecsl felipecsl merged commit dd0904d into main Dec 4, 2024
8 checks passed
@felipecsl felipecsl deleted the felipecsl--base64-polyfill branch December 4, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants