fix: add TextDecoder/TextEncoder polyfill for React Native#1578
Draft
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Draft
fix: add TextDecoder/TextEncoder polyfill for React Native#1578devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
Add fast-text-encoding polyfill to @crossmint/client-sdk-rn-window, mirroring the existing react-native-get-random-values pattern. Fixes ReferenceError: Property 'TextDecoder' doesn't exist on bare React Native apps (Android) using CrossmintEmbeddedCheckout.
🦋 Changeset detectedLatest commit: 7bf1479 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
Original prompt from GuilleAlso uses const keyDataBytes = new TextEncoder().encode(keyData);b) HPKE Encryption (
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes
ReferenceError: Property 'TextDecoder' doesn't existreported by a client usingCrossmintEmbeddedCheckoutin a bare React Native 0.76.5 app on Android (Pylon ticket).React Native's JS engines (Hermes/JSC) don't include
TextDecoder/TextEncoderby default. The SDK uses these in API key validation (validateAPIKey.ts:53,76) and HPKE encryption (hpke.ts:78,82), causing an immediate crash on Android.This adds
fast-text-encodingas a polyfill to@crossmint/client-sdk-rn-window, following the same pattern established forcrypto.getRandomValuesviareact-native-get-random-values.polyfills.ts → RNWebViewTransport.ts. IfTextDecoderis needed before the transport is initialized (e.g. early API key validation), it may still fail. This matches the existingreact-native-get-random-valuespattern, but worth considering whether polyfills should be re-exported from the package entry point instead.Link to Devin run | Requested by @xmint-guille
Test plan
pnpm lint)pnpm test:vitest, 11/11 suites)pnpm build:libssucceedsTextDecoderis already available natively.Package updates
fast-text-encoding@^1.0.6to@crossmint/client-sdk-rn-windowdependencies@crossmint/client-sdk-rn-window