/** * Extract checkout token from a URL path * * @param url - The URL to extract the token from * @returns The checkout token if found, null otherwise * * @example * ```typescript * // These will all return "0cb592d75aae75e337b7b784f6624dbf" * extractCheckoutToken("https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf") * extractCheckoutToken("/checkout/0cb592d75aae75e337b7b784f6624dbf") * extractCheckoutToken("/some/path/0cb592d75aae75e337b7b784f6624dbf/other/path") * extractCheckoutToken("0cb592d75aae75e337b7b784f6624dbf") * * // These will return null * extractCheckoutToken("https://example.com/checkout") * extractCheckoutToken("invalid-token") * ``` */ export declare function extractCheckoutToken(url: string): string | null; /** * Extract checkout token from current browser URL * * @returns The checkout token if found in current URL, null otherwise * * @example * ```typescript * // If current URL is "https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf" * const token = extractCheckoutTokenFromCurrentUrl(); * // Returns: "0cb592d75aae75e337b7b784f6624dbf" * ``` */ export declare function extractCheckoutTokenFromCurrentUrl(): string | null; /** * Extract checkout token from URL pathname only * * @param pathname - The pathname to extract the token from * @returns The checkout token if found, null otherwise * * @example * ```typescript * // These will all return "0cb592d75aae75e337b7b784f6624dbf" * extractCheckoutTokenFromPath("/checkout/0cb592d75aae75e337b7b784f6624dbf") * extractCheckoutTokenFromPath("/some/path/0cb592d75aae75e337b7b784f6624dbf/other/path") * extractCheckoutTokenFromPath("0cb592d75aae75e337b7b784f6624dbf") * ``` */ export declare function extractCheckoutTokenFromPath(pathname: string): string | null; /** * Validate if a string is a valid checkout token format * * @param token - The token to validate * @returns True if the token is valid, false otherwise * * @example * ```typescript * isValidCheckoutToken("0cb592d75aae75e337b7b784f6624dbf") // true * isValidCheckoutToken("invalid-token") // false * isValidCheckoutToken("1234567890abcdef1234567890abcdef") // true * isValidCheckoutToken("") // false * ``` */ export declare function isValidCheckoutToken(token: string): boolean; /** * Extract checkout token from various URL formats and validate it * * @param url - The URL to extract and validate the token from * @returns The validated checkout token if found and valid, null otherwise * * @example * ```typescript * // These will all return "0cb592d75aae75e337b7b784f6624dbf" * extractAndValidateCheckoutToken("https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf") * extractAndValidateCheckoutToken("/checkout/0cb592d75aae75e337b7b784f6624dbf") * * // These will return null * extractAndValidateCheckoutToken("https://example.com/checkout/invalid-token") * extractAndValidateCheckoutToken("https://example.com/checkout") * ``` */ export declare function extractAndValidateCheckoutToken(url: string): string | null; /** * Extract checkout token from URL query parameters * * @param searchParams - URLSearchParams object or search string * @returns The checkout token if found in query params, null otherwise * * @example * ```typescript * // From URLSearchParams * const params = new URLSearchParams('?token=0cb592d75aae75e337b7b784f6624dbf'); * const token = extractCheckoutTokenFromQuery(params); * * // From search string * const token = extractCheckoutTokenFromQuery('?checkoutToken=0cb592d75aae75e337b7b784f6624dbf'); * ``` */ export declare function extractCheckoutTokenFromQuery(searchParams: URLSearchParams | string): string | null; /** * Extract checkout token from current browser URL query parameters * * @returns The checkout token if found in current URL query params, null otherwise * * @example * ```typescript * // If current URL is "https://example.com/checkout?token=0cb592d75aae75e337b7b784f6624dbf" * const token = extractCheckoutTokenFromCurrentUrlQuery(); * // Returns: "0cb592d75aae75e337b7b784f6624dbf" * ``` */ export declare function extractCheckoutTokenFromCurrentUrlQuery(): string | null; /** * Get checkout token from multiple possible sources * * @param options - Options for token extraction * @returns The checkout token if found, null otherwise * * @example * ```typescript * // Try to get token from current URL (both query params and path), then from a specific URL, then from a fallback * const token = getCheckoutToken({ * currentUrl: true, * specificUrl: "https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf", * fallbackToken: "0cb592d75aae75e337b7b784f6624dbf" * }); * * // Works with both query parameters and path parameters: * // /checkout?token=0cb592d75aae75e337b7b784f6624dbf * // /checkout?checkoutToken=0cb592d75aae75e337b7b784f6624dbf * // /checkout/0cb592d75aae75e337b7b784f6624dbf * ``` */ export declare function getCheckoutToken(options?: { currentUrl?: boolean; specificUrl?: string; fallbackToken?: string; }): string | null; /** * Build a checkout URL with a token * * @param baseUrl - The base URL for the checkout * @param token - The checkout token * @returns The complete checkout URL * * @example * ```typescript * buildCheckoutUrl("https://example.com/checkout", "0cb592d75aae75e337b7b784f6624dbf") * // Returns: "https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf" * ``` */ export declare function buildCheckoutUrl(baseUrl: string, token: string): string; /** * Check if a URL contains a checkout token (in path or query parameters) * * @param url - The URL to check * @returns True if the URL contains a valid checkout token, false otherwise * * @example * ```typescript * hasCheckoutToken("https://example.com/checkout/0cb592d75aae75e337b7b784f6624dbf") // true * hasCheckoutToken("https://example.com/checkout?token=0cb592d75aae75e337b7b784f6624dbf") // true * hasCheckoutToken("https://example.com/checkout?checkoutToken=0cb592d75aae75e337b7b784f6624dbf") // true * hasCheckoutToken("https://example.com/checkout") // false * hasCheckoutToken("https://example.com/checkout/invalid-token") // false * ``` */ export declare function hasCheckoutToken(url: string): boolean; /** * Extract checkout initialization data from URL search parameters * * @param searchParams - URLSearchParams object or search string * @returns Checkout initialization data if found, null otherwise * * @example * ```typescript * // From URLSearchParams * const params = new URLSearchParams('?items=[{"id":"1","quantity":2}]&cartToken=abc&storeId=123'); * const data = extractCheckoutInitData(params); * * // From search string * const data = extractCheckoutInitData('?items=[{"id":"1","quantity":2}]&cartToken=abc&storeId=123'); * * // From base64 encoded data * const data = extractCheckoutInitData('?data=eyJpdGVtcyI6W3siaWQiOiIxIiwicXVhbnRpdHkiOjJ9XX0='); * ``` */ export declare function extractCheckoutInitData(searchParams: URLSearchParams | string): { cartToken?: string; lineItems: { id: string; quantity: number; price?: number; }[]; customer?: { currency?: string; locale?: string; }; returnUrl?: string; storeId?: string; } | null; /** * Extract checkout initialization data from current browser URL * * @returns Checkout initialization data if found, null otherwise * * @example * ```typescript * // If current URL is "https://example.com/checkout?items=[...]&cartToken=abc" * const data = extractCheckoutInitDataFromCurrentUrl(); * ``` */ export declare function extractCheckoutInitDataFromCurrentUrl(): ReturnType; /** * Check if URL contains checkout initialization data * * @param searchParams - URLSearchParams object or search string * @returns True if URL contains checkout init data, false otherwise * * @example * ```typescript * hasCheckoutInitData('?items=[{"id":"1","quantity":2}]') // true * hasCheckoutInitData('?other=param') // false * ``` */ export declare function hasCheckoutInitData(searchParams: URLSearchParams | string): boolean; /** * Check if current URL contains checkout initialization data * * @returns True if current URL contains checkout init data, false otherwise * * @example * ```typescript * // If current URL has checkout data * if (hasCheckoutInitDataInCurrentUrl()) { * // Auto-initialize checkout * } * ``` */ export declare function hasCheckoutInitDataInCurrentUrl(): boolean;