@layerswap/widget-react and @layerswap/widget-js are small loaders. They fetch the Widget at runtime from a signed Layerswap CDN channel instead of adding its implementation and wallet SDKs to your application bundle.
Loading and verification
On mount, the loader:- Fetches the channel’s
manifest.jsonfrom the fixed URL baked into the package. Props, environment variables, and page globals cannot change this origin. - Verifies a detached ECDSA P-256 signature against the public key baked into the npm package. The signed manifest has a 30-day validity window and the loader allows five minutes of clock skew.
- Registers the manifest’s SHA-384 integrity values. Remote chunks that are missing from the signed map or fail their integrity check are blocked.
- Loads the remote through Module Federation and renders it. React hosts share only
reactandreact-domas singletons; the JavaScript loader’s remote supplies its own React runtime.
Trust model
Trust is rooted in the signing public key inside the npm package, not in the CDN. The CDN hosts bytes but cannot create a manifest that passes signature verification. Rotating the signing key requires publishing a new loader package.Recommended Content Security Policy
Allow the production Widget origin in bothscript-src and connect-src:
https://cdn.layerswap.iois needed for the manifest fetch, remote entry, and chunks.https://layerswap.iocovers feature-flag and supported relay requests.- Runtime style injection requires
'unsafe-inline'instyle-src. - WalletConnect v2 needs its relay origins.
- Add the RPC origins used by any host-provided wagmi transports and enabled networks.
Two error channels
Manifest failure modes
ManifestError.reason has exactly five values:
Manifest freshness is checked only for new mounts. A page that has already loaded the code continues running. Re-signing and republishing the channel restores new mounts.