/** * (c) Copyright Ascensio System SIA 2026 * * 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. * * @license */ import type { TFrameConfig } from "../types"; /** * Reads the expiry of a JWT access token from its `exp` claim. * * Best effort: the token is not verified, only its payload segment is decoded. Used by the * proactive refresh in OAuth mode when {@link TFrameConfig.tokenExpiresAt} is not set. * * @param token - The access token as returned by {@link TFrameConfig.getToken}. * @returns The expiry as epoch milliseconds, or `undefined` when the token is not a JWT or carries no `exp`. * * @example * ```typescript * getJwtExpiry("eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MDAwMDAwMDB9.sig"); * // → 1700000000000 * ``` * * @internal */ export declare const getJwtExpiry: (token: string) => number | undefined; /** * Converts a record of primitive values into a URL query string. * Strips `null` and `undefined` entries before serialization. * * Used internally by {@link getFramePath} to build iframe `src` query parameters. * * @param data - Key-value pairs to serialize. `null`/`undefined` values are removed. * @returns A URL-encoded query string (without the leading `?`), or `""` if `data` is falsy. * * @example * ```typescript * customUrlSearchParams({ theme: "Dark", locale: null, page: 1 }); * // → "theme=Dark&page=1" * ``` * * @internal */ export declare const customUrlSearchParams: (data: Record) => string; /** * Checks whether the current host domain is in the ONLYOFFICE Apps CSP allowlist. * * Fetches `{targetSrc}{@link CSPApiUrl}` and compares `window.location.host` (host name * and port, lower-cased) with the host of every entry of the `domains` array in the JSON * response; the scheme is ignored and an entry with a path never matches. If the host is * not listed, throws an error with {@link cspErrorText}. * * Skipped when `window.location.origin` equals the origin of `targetSrc` * (same-origin embedding). * * Called by `SDKInstance.initFrame` when {@link TFrameConfig.checkCSP} is `true`. * * @param targetSrc - The ONLYOFFICE Apps portal URL (e.g. `"https://portal.example.com"`). * @returns Resolves on success; rejects with an `Error` on failure. * * @throws `Error` — if the CSP response cannot be parsed as JSON. * @throws `Error` — with {@link cspErrorText} if the current host is not in the allowlist. * * @internal */ export declare const validateCSP: (targetSrc: string) => Promise; /** * Returns an HTML string for the CSP error page displayed inside the iframe * via `srcdoc` when {@link validateCSP} fails. * * The page shows the ONLYOFFICE Apps logo, an error illustration, {@link cspErrorText}, * and a link to the Developer Tools section where the domain can be added. * * @param src - The ONLYOFFICE Apps portal URL used to resolve static image assets and the Developer Tools link. * @returns A complete `` HTML string ready for iframe `srcdoc`. * * @internal */ export declare const getCSPErrorBody: (src: string) => string; /** * Returns a CSS string for the spinning loader animation injected into the * iframe container while ONLYOFFICE Apps is loading. * * Features: * - Dark/light mode via `prefers-color-scheme`. * - Reduced motion support via `prefers-reduced-motion` (slows animation to 1.5 s). * * The loader is created by `SDKInstance.initFrame` when {@link TFrameConfig.noLoader} is `false` * and removed by `SDKInstance.setIsLoaded`. * * @param className - The CSS class name applied to the loader `
`. Used to scope the styles. * @returns A `