/** * @license * Copyright 2025 Boxo pte. ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export interface RequestIdProp { request_id?: number | string; } export interface ErrorDataClientError { error_code: number; error_reason: string; error_description?: string; } export interface ErrorDataAPIError { error_code: number; error_msg: string; request_params: string[]; } export interface ErrorDataAuthError { error_code: number; error_reason: string; error_description?: string[]; } export type ErrorData = { error_type: "client_error"; error_data: ErrorDataClientError; request_id?: number | string; } | { error_type: "api_error"; error_data: ErrorDataAPIError; request_id?: number | string; } | { error_type: "auth_error"; error_data: ErrorDataAuthError; request_id?: number | string; }; export interface LoginRequest { confirmModalText: string; } export interface PaymentRequest { amount: number; miniappOrderId: string; transactionToken: string; currency: string; extraParams?: any; } export interface InitDataRequest { app_id: string; client_id: string; payload: string; data?: { [key: string]: any; }; } export interface LoginResponse { token: string; refresh_token?: string; } /** * Payment status type * Possible values: 'success' | 'failed' | 'cancelled' */ export type PaymentStatus = 'success' | 'failed' | 'cancelled'; /** * Payment response type * Must include all PaymentData fields plus hostappOrderId and status * According to js-sdk: PaymentData & { hostappOrderId: string; status: string } */ export interface PaymentResponse extends PaymentRequest { status: PaymentStatus; hostappOrderId: string; transactionId?: string; error?: string; } export interface InitDataResponse { app_id: string; client_id: string; payload: string; data: { [key: string]: any; handlers?: string[]; capabilities?: string[]; }; token?: string; refresh_token?: string; sandbox_mode?: boolean; } export interface MiniappEvent { handler: string; params: any; type: 'appboxo-js-sdk'; sdkVersion: string; request_id?: number | string; } export interface HostAppResponse { type: 'appboxo-host-response'; handler: string; data: any; request_id?: number | string; } export interface SDKConfig { clientId: string; appId: string; userId?: string; baseUrl?: string; sandboxMode?: boolean; debug?: boolean; /** * Locale/language code (e.g., 'en', 'en-US', 'ru', 'zh-CN') * This will be passed to the miniapp via InitData */ locale?: string; /** * Theme/color scheme preference ('dark' | 'light' | 'system') * This will be passed to the miniapp via InitData * - 'dark': Force dark mode * - 'light': Force light mode * - 'system': Use system preference (default) */ theme?: 'dark' | 'light' | 'system'; /** * Callback to get auth_code from Desktop App backend * This should connect to Desktop App's backend to get the auth_code for current user session */ onGetAuthCode?: () => Promise; /** * Callback to get auth tokens for miniapp (Boxo Connect Direct - alternative) * Desktop App backend should call Boxo Dashboard connect endpoint to request miniapp tokens * Returns miniapp tokens that will be provided to the miniapp */ onGetAuthTokens?: () => Promise; /** * Callback to handle payment requests from miniapp * Desktop App should process the payment and return the result */ onPaymentRequest?: (params: PaymentRequest) => Promise; /** * Allowed origins for security validation (miniapp iframe origins, NOT desktop app origin) * * **Important**: This should be the miniapp's origin (where the iframe loads from), * NOT the desktop app's `window.location.origin`. * * Behavior: * - If not provided or empty array: All origins are allowed (flexible, default) * - If provided with origins: Only events from these origins will be accepted (more secure) * * Example: If your miniapp is deployed at `https://miniapp.example.com`, use: * ```typescript * allowedOrigins: ['https://miniapp.example.com'] * ``` * * Do NOT use `window.location.origin` - that's the desktop app's origin, not the miniapp's. */ allowedOrigins?: string[]; /** * Disable origin validation (NOT RECOMMENDED for production) * When true, all origins will be accepted. Use only for development/testing. * WARNING: This may expose your app to security risks from malicious websites. */ disableOriginValidation?: boolean; /** * Desktop mode flag * When true, API calls will include is_desktop=true parameter */ isDesktop?: boolean; } export type LoginEventHandler = (params: LoginRequest) => Promise; export type PaymentEventHandler = (params: PaymentRequest) => Promise; export type InitDataEventHandler = (params: InitDataRequest) => Promise; export type CustomEventHandler = (type: string, payload: any) => Promise; export type LifecycleEventHandler = (success: boolean, data?: any) => void; export interface PromiseController { resolve: (value: any) => void; reject: (reason: any) => void; } export interface FinomLoginCredentials { username: string; password: string; payload: string; } export interface FinomAuthTokens { access_token: string; refresh_token: string; expires_in: number; } export interface MiniappSettings { miniapp: { url: string; [key: string]: any; }; [key: string]: any; } //# sourceMappingURL=types.d.ts.map