import { Address } from "viem"; import { ChecksType } from "../common/checks"; import { Scope } from "../common/scope"; import { Includes } from "../common/type-utils"; /** * Options for authorizing a client. */ export type BaseAuthorizeOpts = { /** * Client ID are used to identify your application for this integration. * You can find it in Developer Portal under Ronin Waypoint Service settings. */ clientId: string; /** * Ronin Waypoint environment - for testing only. * DO NOT override this value in production. */ waypointOrigin?: string; /** * Scopes are used by an application during authentication to authorize access to a user's details. * openid (required; to indicate that the application intends to use OIDC to verify the user's identity) * profile (so you can personalize the email with the user's name) * email (so you know where to send the welcome email) * wallet (so you can request signing & sending transaction from the user's wallet) */ scopes?: Scope[]; /** * Contains parameters you have to match against the request to make sure it is valid. */ checks?: ChecksType[]; /** * The URI of your application that users will be redirected to after authentication */ redirectUrl?: string; /** * The theme of the popup. */ theme?: "light" | "dark"; }; export type PopupAuthorizeOpts = BaseAuthorizeOpts & { /** * Authorize the user via a popup. */ mode: "popup"; }; export type RedirectAuthorizeOpts = BaseAuthorizeOpts & { /** * Redirect the user to the authorization page. */ mode: "redirect"; /** * The unique state to identify the request & response. */ state?: string; }; export type PopupAuthorizeData = { token: string; address: Address | undefined; secondaryAddress: Address | undefined; }; export type PKCEPopupAuthorizeData = { authorizationCode: string; codeVerifier: string; }; export type PKCERedirectAuthorizeData = { codeVerifier: string; }; export type AuthorizeData = T extends PopupAuthorizeOpts ? Includes extends true ? PKCEPopupAuthorizeData : PopupAuthorizeData : T extends RedirectAuthorizeOpts ? Includes extends true ? PKCERedirectAuthorizeData : undefined : never; /** * Authorize a user via Ronin Waypoint, returning an token and user address. * * @param opts Options for authorization. * @returns Authorization result including token and user addresses, or undefined in case of redirect. * * @example * import { authorize } from "@sky-mavis/waypoint" * * const { token, address } = await authorize({ * mode: "popup", * clientId: "YOUR_CLIENT_ID", * }) */ export declare const authorize: (opts: T) => Promise>; /** * Parse the redirect URL after authorization. * This function should be called in the redirect URL page. * * @returns Parsed data from the redirect URL. * * @example * const { state, token, address } = parseRedirectUrl() */ export declare const parseRedirectUrl: () => { state: string | null; authorizationCode: string | null; token: string | null; address: `0x${string}` | undefined; secondaryAddress: `0x${string}` | undefined; };