export type SessionDataInputV20231219 = {clientIpAddress?: string | undefined, countryCode: string, destinationCurrencyCode: string, institutionId?: string | undefined, kycInfo?: ({kycProvider?: 'SUMSUB' | undefined, kycShareToken?: string | undefined}) | undefined, lockFields?: (Array<'cryptoCurrency' | 'destinationCurrencyCode' | 'sourceCurrencyCode' | 'walletAddress' | 'sourceAmount' | 'paymentMethodType'>) | undefined, paymentMethodType?: string | undefined, redirectUrl?: string | undefined, refundWalletAddress?: string | undefined, serviceProvider: 'ALCHEMYPAY' | 'BANXA' | 'BILIRA' | 'BINANCECONNECT' | 'BINANCEPAY' | 'BLOCKCHAINDOTCOM' | 'BOOMFI' | 'BTCDIRECT' | 'COINBASEPAY' | 'FONBNK' | 'GUARDARIAN' | 'KOYWE' | 'KRYPTONIM' | 'MERCURYO' | 'MESH' | 'MESO' | 'ONMETA' | 'ONRAMPMONEY' | 'PAYBIS' | 'PAYPAL' | 'RAMP' | 'REVOLUT' | 'ROBINHOOD' | 'SARDINE' | 'SHIFT4' | 'SIMPLEX' | 'SKRILLCRYPTO' | 'STRIPE' | 'SWAPPED' | 'TOPPER' | 'TRANSAK' | 'TRANSFI' | 'UNLIMIT' | 'YELLOWCARD', sourceAmount: string, sourceCurrencyCode: string, walletAddress: string, walletTag?: string | undefined} | {clientIpAddress?: string | undefined, countryCode: string, destinationCurrencyCode: string, kycInfo?: ({kycProvider?: 'SUMSUB' | undefined, kycShareToken?: string | undefined}) | undefined, lockFields?: (Array<'cryptoCurrency' | 'destinationCurrencyCode' | 'sourceCurrencyCode' | 'walletAddress' | 'sourceAmount' | 'paymentMethodType'>) | undefined, paymentMethodType?: string | undefined, redirectFlow?: boolean | undefined, redirectUrl?: string | undefined, refundWalletAddress?: string | undefined, serviceProvider: 'ALCHEMYPAY' | 'BANXA' | 'BILIRA' | 'BINANCECONNECT' | 'BINANCEPAY' | 'BLOCKCHAINDOTCOM' | 'BOOMFI' | 'BTCDIRECT' | 'COINBASEPAY' | 'FONBNK' | 'GUARDARIAN' | 'KOYWE' | 'KRYPTONIM' | 'MERCURYO' | 'MESH' | 'MESO' | 'ONMETA' | 'ONRAMPMONEY' | 'PAYBIS' | 'PAYPAL' | 'RAMP' | 'REVOLUT' | 'ROBINHOOD' | 'SARDINE' | 'SHIFT4' | 'SIMPLEX' | 'SKRILLCRYPTO' | 'STRIPE' | 'SWAPPED' | 'TOPPER' | 'TRANSAK' | 'TRANSFI' | 'UNLIMIT' | 'YELLOWCARD', sourceAmount: string, sourceCurrencyCode: string, walletAddress?: string | undefined, walletTag?: string | undefined} | {clientIpAddress?: string | undefined, countryCode: string, institutionId?: string | undefined, kycInfo?: ({kycProvider?: 'SUMSUB' | undefined, kycShareToken?: string | undefined}) | undefined, lockFields?: (Array<'cryptoCurrency' | 'destinationCurrencyCode' | 'sourceCurrencyCode' | 'walletAddress' | 'sourceAmount' | 'paymentMethodType'>) | undefined, redirectUrl?: string | undefined, serviceProvider: 'ALCHEMYPAY' | 'BANXA' | 'BILIRA' | 'BINANCECONNECT' | 'BINANCEPAY' | 'BLOCKCHAINDOTCOM' | 'BOOMFI' | 'BTCDIRECT' | 'COINBASEPAY' | 'FONBNK' | 'GUARDARIAN' | 'KOYWE' | 'KRYPTONIM' | 'MERCURYO' | 'MESH' | 'MESO' | 'ONMETA' | 'ONRAMPMONEY' | 'PAYBIS' | 'PAYPAL' | 'RAMP' | 'REVOLUT' | 'ROBINHOOD' | 'SARDINE' | 'SHIFT4' | 'SIMPLEX' | 'SKRILLCRYPTO' | 'STRIPE' | 'SWAPPED' | 'TOPPER' | 'TRANSAK' | 'TRANSFI' | 'UNLIMIT' | 'YELLOWCARD', sourceAmount?: string | undefined, sourceCurrencyCodes: Array, walletAddress?: string | undefined, walletTag?: string | undefined}; export type SessionTokenForWidgetRequestV20231219 = {bypassKyc?: boolean | undefined, customerId?: string | undefined, externalCustomerId?: string | undefined, externalSessionId?: string | undefined, externalSubaccountCustomerId?: string | undefined, sessionData: SessionDataInputV20231219, sessionType: 'BUY' | 'SELL' | 'TRANSFER', subaccountCustomerId?: string | undefined}; export type CreateApiCryptoSessionWidgetArgs = {body: SessionTokenForWidgetRequestV20231219}; export type CreateApiCryptoSessionWidgetOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a crypto widget * * POST /crypto/session/widget */ export const createApiCryptoSessionWidget = async (args: CreateApiCryptoSessionWidgetArgs, options?: CreateApiCryptoSessionWidgetOptions) => { const {baseUrl = "https://api-sb.meld.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/crypto/session/widget${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };