Update crypto imports to support React Native #76
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.
@mme I am trying to run the typescript-sdk in a React Native / Expo environment using the Metro bundler, I got a build error due to the package's reliance on crypto:
The package at "apps/dojo-rn/node_modules/@ag-ui/langgraph/dist/index.js" attempted to import the Node standard library module "crypto".
It failed because the native React runtime does not include the Node standard library.
I am currently employing a polyfill using expo-standard-web-crypto combined with a package patch to resolve this issue, here is a sample of the patch I am currently using @ag-ui+langgraph+0.0.1-alpha.0.patch
It basically replaces the ot=require("crypto") with ot={randomUUID:()=>global.crypto.randomUUID()} that is supplied via a polyfill.
This PR basically replaces the direct crypto imports and function calls with UUID v11 which is already an existing dependency, this can then be combined with expo-standard-web-crypto in React Native / Expo projects to provide the required polyfill without additional patches https://github.com/expo/expo/tree/main/packages/expo-standard-web-crypto.
Fixes #79.