UNPKG

@tyrads.com/tyrads-sdk-iframe

Version:

Official TyrAds SDK for NodeJS

59 lines (58 loc) 3.33 kB
import { Config } from "./config"; import { AuthenticationRequest } from "./contract/authentication-request"; import { AuthenticationSign } from "./contract/authentication-sign"; import { HttpClient } from "./http-client"; export declare class TyradsSDK { protected httpClient: HttpClient; protected config: Config; /** * Creates an instance of TyradsSDK. * @param {Config} config - The configuration object for the SDK. */ constructor(config: Config); /** * Creates an instance of TyradsSDK. * @param apiKey - The API key for authentication. * @param apiSecret - The API secret for authentication. * @param language - The language for the SDK (default is 'en'). * @returns An instance of TyradsSDK. */ static make(apiKey?: string, apiSecret?: string, language?: string): TyradsSDK; /** * Authenticates a user with the Tyrads SDK. * @param {AuthenticationRequest} request - The authentication request containing user details. * @returns {Promise<AuthenticationSign | null>} A promise that resolves to an AuthenticationSign object if authentication is successful, or null if it fails. * @throws {Error} * @description This method validates the authentication request, sends it to the Tyrads API, * and returns an AuthenticationSign object containing the authentication token, publisher user ID, age, * and gender. */ authenticate(request: AuthenticationRequest): Promise<AuthenticationSign | null>; /** * Generates an iframe URL for the Tyrads SDK. * @param {AuthenticationSign | string} authSignOrToken - An instance of AuthenticationSign or a string token. * @param {string | null} deeplinkTo - Optional deeplink to redirect after authentication. * @returns {string} The generated iframe URL. * @throws {Error} If the arguments are invalid. * @throws {Error} If the deeplinkTo argument is not a string or null. * @description This method constructs a URL for the Tyrads iframe, including the authentication token * and an optional deeplink parameter. The token can be provided as an instance of AuthenticationSign or as a string. * If the deeplinkTo parameter is provided, it will be included in the URL as a query parameter. */ iframeUrl(authSignOrToken: AuthenticationSign | string, deeplinkTo?: string | null): string; /** * Generates a URL for the premium widget iframe. * * @param authSignOrToken - Authentication token or AuthenticationSign instance for authorization * @param name - Optional name parameter to be included in the URL * @returns A fully constructed URL string for the iframe widget * * @throws {Error} If authSignOrToken is neither a string nor an AuthenticationSign instance * @throws {Error} If name is provided but is not a string * * @description This method constructs a URL for the Tyrads premium widget iframe, including the authentication token * and an optional name parameter. The token can be provided as an instance of AuthenticationSign or as a string. * If the name parameter is provided, it will be included in the URL as a query parameter. */ iframePremiumWidget(authSignOrToken: AuthenticationSign | string, name?: string | null): string; }