import { AdminSession } from '../../public/node/session.js'; /** * A scope supported by the Shopify Admin API. */ export type AdminAPIScope = 'graphql' | 'themes' | 'collaborator'; /** * It represents the options to authenticate against the Shopify Admin API. */ interface AdminAPIOAuthOptions { /** Store to request permissions for. */ storeFqdn: string; /** List of scopes to request permissions for. */ scopes: AdminAPIScope[]; } /** * A scope supported by the Partners API. */ export type PartnersAPIScope = 'cli'; interface PartnersAPIOAuthOptions { /** List of scopes to request permissions for. */ scopes: PartnersAPIScope[]; } /** * A scope supported by the Developer Platform API. */ export type AppManagementAPIScope = 'https://api.shopify.com/auth/organization.apps.manage'; interface AppManagementAPIOauthOptions { /** List of scopes to request permissions for. */ scopes: AppManagementAPIScope[]; } /** * A scope supported by the Storefront Renderer API. */ export type StorefrontRendererScope = 'devtools' | 'graphql'; interface StorefrontRendererAPIOAuthOptions { /** List of scopes to request permissions for. */ scopes: StorefrontRendererScope[]; } export type BusinessPlatformScope = 'destinations'; interface BusinessPlatformAPIOAuthOptions { /** List of scopes to request permissions for. */ scopes: BusinessPlatformScope[]; } /** * It represents the authentication requirements and * is the input necessary to trigger the authentication * flow. */ export interface OAuthApplications { adminApi?: AdminAPIOAuthOptions; storefrontRendererApi?: StorefrontRendererAPIOAuthOptions; partnersApi?: PartnersAPIOAuthOptions; businessPlatformApi?: BusinessPlatformAPIOAuthOptions; appManagementApi?: AppManagementAPIOauthOptions; } export interface OAuthSession { admin?: AdminSession; partners?: string; storefront?: string; businessPlatform?: string; appManagement?: string; userId: string; } type AuthMethod = 'partners_token' | 'device_auth' | 'theme_access_token' | 'custom_app_token' | 'none'; /** * Retrieves a stable user identifier for analytics, or `'unknown'` if none applies. * * Evaluation order: * 1. If an app automation token or theme token is used, returns a deterministic UUID * derived from that secret. * 2. Otherwise, if `setLastSeenUserIdAfterAuth` was called (e.g. after OAuth), returns that value. * 3. Otherwise, if a persisted CLI session id is available, returns it. * 4. Otherwise returns `'unknown'`. * * @returns A Promise that resolves to the user ID as a string. */ export declare function getLastSeenUserIdAfterAuth(): Promise; export declare function setLastSeenUserIdAfterAuth(id: string): void; /** * Retrieves the last seen authentication method used in the current session. * * This function checks for the authentication method in the following order: * 1. Returns the cached auth method if it's not 'none'. * 2. Checks for a cached session, which implies 'device_auth' was used. * 3. Checks for a partners token in the environment. * 4. Checks for a theme password in the environment. * 5. If none of the above are true, returns 'none'. * * @returns A Promise that resolves to the last seen authentication method as an AuthMethod type. */ export declare function getLastSeenAuthMethod(): Promise; export declare function setLastSeenAuthMethod(method: AuthMethod): void; export declare function setCommandSessionId(sessionId: string | undefined): void; export interface EnsureAuthenticatedAdditionalOptions { noPrompt?: boolean; forceRefresh?: boolean; forceNewSession?: boolean; } /** * This method ensures that we have a valid session to authenticate against the given applications using the provided scopes. * * @param applications - An object containing the applications we need to be authenticated with. * @param _env - Optional environment variables to use. * @param options - Optional extra options to use. * @returns An instance with the access tokens organized by application. */ export declare function ensureAuthenticated(applications: OAuthApplications, _env?: NodeJS.ProcessEnv, { forceRefresh, noPrompt, forceNewSession }?: EnsureAuthenticatedAdditionalOptions): Promise; export {};