@yuno-payments/sdk-web
v7.12.2
Published
Wrapper to install sdk-web and types
Downloads
15,103
Maintainers
Keywords
Readme
SDK Web (v1.9)
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 sdkPayments = await loadScript()
// Initialize with your public API key
sdkPayments.initialize('your-public-api-key')Note: The SDK version loaded by this package is v1.9. When SRI is enabled, the version used is v1.9.19.
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 sdkPayments = await loadScript({
env: 'sandbox' // Options: 'dev', 'staging', 'sandbox', 'prod'
})
sdkPayments.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, default to prod.
import { loadScript } from '@yuno-payments/sdk-web'
const sdkPayments = await loadScript({
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.
Custom Base URL
You can override the domain (and optionally a base path) the SDK script is loaded from with the baseUrl option. The version path is appended to it, and env no longer affects the host:
import { loadScript } from '@yuno-payments/sdk-web'
// Loads https://some.domain/v1.9/main.js
const sdkPayments = await loadScript({ baseUrl: 'https://some.domain' })
// Loads https://some.domain/any/path/v1.9/main.js
const sdkPayments = await loadScript({ baseUrl: 'https://some.domain/any/path' })Note:
baseUrlalso applies whensriis enabled — the static bundle path (/sdk-static-bundles-ms/sdk-web/v1.9.19/main.js) is appended to your base URL. Since the integrity hash is pinned, the file served from your domain must be byte-identical to the official bundle.
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. |
| baseUrl | string | — | Custom origin (and optional base path) to load the SDK from, e.g. https://some.domain/any/path. Overrides the host derived from env. |
TypeScript Support
This package includes TypeScript definitions. The loadScript function returns a Promise that resolves to the SDK instance (typed as SdkPayments) with full type support.
import { loadScript } from '@yuno-payments/sdk-web'
const sdkPayments = await loadScript({ env: 'sandbox' })Types come from @yuno-payments/sdk-web-types. The public surface uses the whitelabel-neutral names (SdkPayments, SdkPaymentsInstance, SdkPaymentsConfig). At runtime loadScript reads the window.SdkPayments global (requires SDK v1.9.0+).
