@yuno-payments/sdk-web
v4.2.0
Published
Wrapper to install sdk-web and types
Maintainers
Keywords
Readme
SDK Web (v1.5)
This package provides a wrapper to easily load and use the Yuno SDK in your web applications.
Installation
npm install @yuno-payments/sdk-webBasic Usage
import { loadScript } from '@yuno-payments/sdk-web'
// Load the SDK with default settings (production environment)
const yuno = await loadScript()
// Initialize with your public API key
yuno.initialize('your-public-api-key')Note: The SDK version loaded by this package is v1.5.
Advanced Usage
The loadScript function accepts optional configuration props, primarily for testing and development purposes:
import { loadScript } from '@yuno-payments/sdk-web'
// Load SDK from a specific environment
const yuno = await loadScript({
env: 'sandbox' // Options: 'dev', 'staging', 'sandbox', 'prod'
})
yuno.initialize('your-public-api-key')Subresource Integrity (SRI)
You can enable SRI to ensure the SDK script has not been tampered with. When sri is set to true, the script tag will include an integrity attribute and crossorigin="anonymous". SRI is supported for sandbox and prod environments.
import { loadScript } from '@yuno-payments/sdk-web'
const yuno = await loadScript({
env: 'prod',
sri: true
})Note: When
sriis enabled, the SDK is loaded from a static bundle URL. SRI is only available forsandboxandprodenvironments. Fordevandstaging, thesrioption is ignored and the regular URL is used.
Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| env | 'dev' \| 'staging' \| 'sandbox' \| 'prod' | 'prod' | Environment to load the SDK from. Use different environments for testing. |
| sri | boolean | false | Enable Subresource Integrity. Only supported for sandbox and prod. |
TypeScript Support
This package includes TypeScript definitions. The loadScript function returns a Promise that resolves to the Yuno SDK instance with full type support.
import { loadScript, LoadScript } from '@yuno-payments/sdk-web'
const yuno: Yuno = await loadScript({ env: 'sandbox' })