UNPKG

@shopify/cli-kit

Version:

A set of utilities, interfaces, and models that are common across all the platform features

69 lines (68 loc) 3.03 kB
import { ApplicationToken, IdentityToken } from './schema.js'; import { API } from '../api.js'; import { Result } from '../../../public/node/result.js'; import { ExtendableError } from '../../../public/node/error.js'; export declare class InvalidGrantError extends ExtendableError { } export declare class InvalidRequestError extends ExtendableError { } export interface ExchangeScopes { admin: string[]; partners: string[]; storefront: string[]; businessPlatform: string[]; appManagement: string[]; } /** * Given an identity token, request an application token. * @param identityToken - access token obtained in a previous step * @param store - the store to use, only needed for admin API * @returns An array with the application access tokens. */ export declare function exchangeAccessForApplicationTokens(identityToken: IdentityToken, scopes: ExchangeScopes, store?: string): Promise<{ [x: string]: ApplicationToken; }>; /** * Given an expired access token, refresh it to get a new one. */ export declare function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken>; /** * Given a custom CLI token passed as ENV variable, request a valid Partners API token * This token does not accept extra scopes, just the cli one. * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN` * @returns An instance with the application access tokens. */ export declare function exchangeCustomPartnerToken(token: string): Promise<{ accessToken: string; userId: string; }>; /** * Given a custom CLI token passed as ENV variable, request a valid App Management API token * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN` * @returns An instance with the application access tokens. */ export declare function exchangeCliTokenForAppManagementAccessToken(token: string): Promise<{ accessToken: string; userId: string; }>; /** * Given a custom CLI token passed as ENV variable, request a valid Business Platform API token * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN` * @returns An instance with the application access tokens. */ export declare function exchangeCliTokenForBusinessPlatformAccessToken(token: string): Promise<{ accessToken: string; userId: string; }>; type IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure'; /** * Given a deviceCode obtained after starting a device identity flow, request an identity token. * @param deviceCode - The device code obtained after starting a device identity flow * @param scopes - The scopes to request * @returns An instance with the identity access tokens. */ export declare function exchangeDeviceCodeForAccessToken(deviceCode: string): Promise<Result<IdentityToken, IdentityDeviceError>>; export declare function requestAppToken(api: API, token: string, scopes?: string[], store?: string): Promise<{ [x: string]: ApplicationToken; }>; export {};