Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@magic-sdk/provider
Advanced tools
<iframe>
is RenderedTo balance performance with flexibility, one <iframe>
is shared between all instances of MagicSDK
containing the same "signature" of parameters. All options given to the MagicSDK
constructor factor into this "signature," including the API key and (if present), custom Ethereum network configuration. This flexibility allows integrations to manage multiple instances of MagicSDK
, which is an important feature for Web3 projects in particular.
Note: the Magic
<iframe>
is lazy loaded upon the first JSON RPC method call, or ifMagicSDK.preload
is explicitly invoked.
There are numerous code paths that ./modules
can follow to interact with the Magic <iframe>
context. Notably, the code path changes depending on use-case (such as when Web3 enters the picture). This section contains a high-level summary of each possible case.
// `magic.auth` and `magic.user` methods follow this pattern.
magic.user.getMetadata();
BaseModule.request -> PayloadTransport.post -> Window.postMessage -> iframe
>=1.0.0-beta.38
using send
This represents the most current behavior of Web3:
web3.eth.sendTransaction(...);
RPCProviderModule.send -> BaseModule.request -> PayloadTransport.post -> Window.postMessage -> iframe
<=1.0.0-beta.37
using send
This is an edge case affecting a small subset of Web3 pre-1.x
beta versions:
web3.eth.sendTransaction(...);
RPCProviderModule.send -> RPCProviderModule.sendAsync -> PayloadTransport.post -> Window.postMessage -> iframe
sendAsync
This is the legacy behavior of Web3 providers, though it is still widely supported:
web3.eth.sendTransaction(...);
RPCProviderModule.sendAsync -> PayloadTransport.post -> Window.postMessage -> iframe
We support web and React Native implementations from the same SDK. This introduces a few notable gotchas:
Do not reference any React dependencies at the top-level! Only use these dependencies within a closure (such as the body of a class method or function), and assume they could be undefined
. We completely remove these dependencies from CJS and CDN bundles, so referencing these imports will raise a TypeError
.
You can use the IS_REACT_NATIVE
environment constant to gate browser-specific or React Native-specific APIs. Do not assume that all window
functionality is available in a React Native context! It may be helpful to familiarize yourself with the differences between React.js and React Native.
See ./noop-module.ts
? It's purposefully empty! Any dependencies that need removal from a specific environment's bundle is replaced with this module. Please don't change or remove this file!
FAQs
Core business logic for Magic SDK packages.
The npm package @magic-sdk/provider receives a total of 19,961 weekly downloads. As such, @magic-sdk/provider popularity was classified as popular.
We found that @magic-sdk/provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.