@shopify/cli-kit 3.92.1 → 3.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/api/graphql/admin/generated/find_development_theme_by_name.d.ts +16 -0
- package/dist/cli/api/graphql/admin/generated/find_development_theme_by_name.js +60 -0
- package/dist/cli/api/graphql/admin/generated/find_development_theme_by_name.js.map +1 -0
- package/dist/private/node/api/graphql.d.ts +10 -0
- package/dist/private/node/api/graphql.js +67 -5
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +13 -0
- package/dist/private/node/conf-store.js +17 -3
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/constants.d.ts +3 -0
- package/dist/private/node/constants.js +3 -0
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/session/exchange.d.ts +22 -8
- package/dist/private/node/session/exchange.js +37 -14
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/schema.d.ts +62 -62
- package/dist/private/node/session/scopes.js +3 -2
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session/store.d.ts +7 -0
- package/dist/private/node/session/store.js +17 -0
- package/dist/private/node/session/store.js.map +1 -1
- package/dist/private/node/session/validate.d.ts +5 -4
- package/dist/private/node/session/validate.js +34 -7
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/session.d.ts +1 -1
- package/dist/private/node/session.js +77 -32
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/testing/ui.js +6 -4
- package/dist/private/node/testing/ui.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +5 -5
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +5 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +2 -2
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +10 -10
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/Table.js +2 -2
- package/dist/private/node/ui/components/Table/Table.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +6 -6
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.test.js +1 -1
- package/dist/private/node/ui/components/TextAnimation.test.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.test.js +4 -4
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.js +1 -0
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/hooks/use-select-state.js +1 -3
- package/dist/private/node/ui/hooks/use-select-state.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/analytics.js +4 -4
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.js +1 -3
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/rest-api-throttler.d.ts +14 -0
- package/dist/public/node/api/rest-api-throttler.js +14 -87
- package/dist/public/node/api/rest-api-throttler.js.map +1 -1
- package/dist/public/node/archiver.js +6 -7
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/cli-launcher.d.ts +1 -1
- package/dist/public/node/cli-launcher.js +9 -9
- package/dist/public/node/cli-launcher.js.map +1 -1
- package/dist/public/node/cli.js +4 -1
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/fqdn.js +1 -0
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/context/local.d.ts +7 -0
- package/dist/public/node/context/local.js +9 -0
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/dot-env.js +1 -1
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/environment.d.ts +4 -9
- package/dist/public/node/environment.js +6 -12
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/environments.js +4 -3
- package/dist/public/node/environments.js.map +1 -1
- package/dist/public/node/error-handler.js +1 -1
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.js +1 -0
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.d.ts +9 -1
- package/dist/public/node/fs.js +16 -4
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.d.ts +10 -4
- package/dist/public/node/git.js +101 -80
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/global-context.js +1 -3
- package/dist/public/node/global-context.js.map +1 -1
- package/dist/public/node/hooks/postrun.d.ts +7 -0
- package/dist/public/node/hooks/postrun.js +61 -1
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.d.ts +3 -2
- package/dist/public/node/hooks/prerun.js +9 -22
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/http.js +1 -1
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/import-extractor.d.ts +17 -0
- package/dist/public/node/import-extractor.js +84 -23
- package/dist/public/node/import-extractor.js.map +1 -1
- package/dist/public/node/is-global.d.ts +9 -1
- package/dist/public/node/is-global.js +55 -12
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/mimes.js +1 -1
- package/dist/public/node/mimes.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +1 -1
- package/dist/public/node/node-package-manager.js +4 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/os.js +1 -0
- package/dist/public/node/os.js.map +1 -1
- package/dist/public/node/output.js +3 -2
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.d.ts +11 -0
- package/dist/public/node/path.js +30 -1
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/result.js +1 -0
- package/dist/public/node/result.js.map +1 -1
- package/dist/public/node/serial-batch-processor.js +1 -3
- package/dist/public/node/serial-batch-processor.js.map +1 -1
- package/dist/public/node/session-prompt.js +10 -2
- package/dist/public/node/session-prompt.js.map +1 -1
- package/dist/public/node/session.js +6 -6
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +1 -0
- package/dist/public/node/themes/api.js +26 -0
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/conf.js +3 -5
- package/dist/public/node/themes/conf.js.map +1 -1
- package/dist/public/node/themes/factories.js +1 -0
- package/dist/public/node/themes/factories.js.map +1 -1
- package/dist/public/node/themes/theme-manager.d.ts +2 -2
- package/dist/public/node/themes/theme-manager.js +13 -8
- package/dist/public/node/themes/theme-manager.js.map +1 -1
- package/dist/public/node/{toml.d.ts → toml/codec.d.ts} +1 -1
- package/dist/public/node/{toml.js → toml/codec.js} +1 -1
- package/dist/public/node/toml/codec.js.map +1 -0
- package/dist/public/node/toml/index.d.ts +1 -0
- package/dist/public/node/toml/index.js +2 -0
- package/dist/public/node/toml/index.js.map +1 -0
- package/dist/public/node/toml/toml-file.d.ts +88 -0
- package/dist/public/node/toml/toml-file.js +159 -0
- package/dist/public/node/toml/toml-file.js.map +1 -0
- package/dist/public/node/tree-kill.js +1 -1
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +1 -0
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade.d.ts +28 -1
- package/dist/public/node/upgrade.js +184 -16
- package/dist/public/node/upgrade.js.map +1 -1
- package/dist/public/node/version.d.ts +9 -0
- package/dist/public/node/version.js +16 -1
- package/dist/public/node/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/dist/public/node/custom-oclif-loader.d.ts +0 -6
- package/dist/public/node/custom-oclif-loader.js +0 -79
- package/dist/public/node/custom-oclif-loader.js.map +0 -1
- package/dist/public/node/toml.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.js","sourceRoot":"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GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC/B,MAAM;QACN,KAAK,EAAE,aAAa;KACrB,CAAA;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA0B;IACvD,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {ApplicationToken, IdentityToken} from './schema.js'\nimport {applicationId, clientId as getIdentityClientId} from './identity.js'\nimport {tokenExchangeScopes} from './scopes.js'\nimport {API} from '../api.js'\nimport {identityFqdn} from '../../../public/node/context/fqdn.js'\nimport {shopifyFetch} from '../../../public/node/http.js'\nimport {err, ok, Result} from '../../../public/node/result.js'\nimport {AbortError, BugError, ExtendableError} from '../../../public/node/error.js'\nimport {setLastSeenAuthMethod, setLastSeenUserIdAfterAuth} from '../session.js'\nimport {nonRandomUUID} from '../../../public/node/crypto.js'\n\nimport * as jose from 'jose'\n\nexport class InvalidGrantError extends ExtendableError {}\nexport class InvalidRequestError extends ExtendableError {}\nclass InvalidTargetError extends AbortError {}\n\n/**\n * Given an expired access token, refresh it to get a new one.\n */\nexport async function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken> {\n const clientId = getIdentityClientId()\n const params = {\n grant_type: 'refresh_token',\n access_token: currentToken.accessToken,\n refresh_token: currentToken.refreshToken,\n client_id: clientId,\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n return buildIdentityToken(value, currentToken.userId, currentToken.alias)\n}\n\n/**\n * Given a custom CLI token passed as ENV variable request a valid API access token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @param apiName - The API to exchange for the access token\n * @param scopes - The scopes to request with the access token\n * @returns An instance with the application access tokens.\n */\nasync function exchangeCliTokenForAccessToken(\n apiName: API,\n token: string,\n scopes: string[],\n): Promise<{accessToken: string; userId: string}> {\n const appId = applicationId(apiName)\n try {\n const newToken = await requestAppToken(apiName, token, scopes)\n\n const accessToken = newToken[appId]!.accessToken\n const userId = nonRandomUUID(token)\n setLastSeenUserIdAfterAuth(userId)\n setLastSeenAuthMethod('partners_token')\n return {accessToken, userId}\n } catch (error) {\n const prettyName = apiName.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n throw new AbortError(\n `The custom token provided can't be used for the ${prettyName} API.`,\n 'Ensure the token is correct and not expired.',\n )\n }\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid Partners API token\n * This token does not accept extra scopes, just the cli one.\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCustomPartnerToken(token: string): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('partners', token, tokenExchangeScopes('partners'))\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid App Management API token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCliTokenForAppManagementAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('app-management', token, tokenExchangeScopes('app-management'))\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid Business Platform API token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCliTokenForBusinessPlatformAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('business-platform', token, tokenExchangeScopes('business-platform'))\n}\n\ntype IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure'\n\n/**\n * Given a deviceCode obtained after starting a device identity flow, request an identity token.\n * @param deviceCode - The device code obtained after starting a device identity flow\n * @param scopes - The scopes to request\n * @returns An instance with the identity access tokens.\n */\nexport async function exchangeDeviceCodeForAccessToken(\n deviceCode: string,\n): Promise<Result<IdentityToken, IdentityDeviceError>> {\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:device_code',\n device_code: deviceCode,\n client_id: clientId,\n }\n\n const tokenResult = await tokenRequest(params)\n if (tokenResult.isErr()) {\n return err(tokenResult.error.error as IdentityDeviceError)\n }\n const identityToken = buildIdentityToken(tokenResult.value)\n return ok(identityToken)\n}\n\nexport async function requestAppToken(\n api: API,\n token: string,\n scopes: string[] = [],\n store?: string,\n): Promise<Record<string, ApplicationToken>> {\n const appId = applicationId(api)\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',\n requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n subject_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n client_id: clientId,\n audience: appId,\n scope: scopes.join(' '),\n subject_token: token,\n ...(api === 'admin' && {destination: `https://${store}/admin`, store}),\n }\n\n let identifier = appId\n if (api === 'admin' && store) {\n identifier = `${store}-${appId}`\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n const appToken = buildApplicationToken(value)\n return {[identifier]: appToken}\n}\n\ninterface TokenRequestResult {\n access_token: string\n expires_in: number\n refresh_token: string\n scope: string\n id_token?: string\n}\n\nfunction tokenRequestErrorHandler({error, store}: {error: string; store?: string}) {\n const invalidTargetErrorMessage = `You are not authorized to use the CLI to develop in the provided store${\n store ? `: ${store}` : '.'\n }`\n\n if (error === 'invalid_grant') {\n // There's an scenario when Identity returns \"invalid_grant\" when trying to refresh the token\n // using a valid refresh token. When that happens, we take the user through the authentication flow.\n return new InvalidGrantError()\n }\n if (error === 'invalid_request') {\n // There's an scenario when Identity returns \"invalid_request\" when exchanging an identity token.\n // This means the token is invalid. We clear the session and throw an error to let the caller know.\n return new InvalidRequestError()\n }\n if (error === 'invalid_target') {\n return new InvalidTargetError(invalidTargetErrorMessage, '', [\n 'Ensure you have logged in to the store using the Shopify admin at least once.',\n 'Ensure you are the store owner, or have a staff account if you are attempting to log in to a dev store.',\n 'Ensure you are using the permanent store domain, not a vanity domain.',\n ])\n }\n // eslint-disable-next-line @shopify/cli/no-error-factory-functions\n return new AbortError(error)\n}\n\nasync function tokenRequest(\n params: Record<string, string>,\n): Promise<Result<TokenRequestResult, {error: string; store?: string}>> {\n const fqdn = await identityFqdn()\n const url = new URL(`https://${fqdn}/oauth/token`)\n url.search = new URLSearchParams(Object.entries(params)).toString()\n\n const res = await shopifyFetch(url.href, {method: 'POST'})\n try {\n const responseText = await res.text()\n\n const payload = JSON.parse(responseText)\n if (res.ok) return ok(payload)\n\n return err({error: payload.error, store: params.store})\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new AbortError(\n `Received invalid response from authentication service (HTTP ${res.status}).`,\n 'The response could not be parsed as JSON. The service may be temporarily unavailable. Please try again.',\n )\n }\n throw error\n }\n}\n\nfunction buildIdentityToken(\n result: TokenRequestResult,\n existingUserId?: string,\n existingAlias?: string,\n): IdentityToken {\n const userId = existingUserId ?? (result.id_token ? jose.decodeJwt(result.id_token).sub! : undefined)\n\n if (!userId) {\n throw new BugError('Error setting userId for session. No id_token or pre-existing user ID provided.')\n }\n\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n userId,\n alias: existingAlias,\n }\n}\n\nfunction buildApplicationToken(result: TokenRequestResult): ApplicationToken {\n return {\n accessToken: result.access_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes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,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {ApplicationToken, IdentityToken} from './schema.js'\nimport {applicationId, clientId as getIdentityClientId} from './identity.js'\nimport {tokenExchangeScopes} from './scopes.js'\nimport {API} from '../api.js'\nimport {identityFqdn} from '../../../public/node/context/fqdn.js'\nimport {shopifyFetch} from '../../../public/node/http.js'\nimport {err, ok, Result} from '../../../public/node/result.js'\nimport {AbortError, BugError, ExtendableError} from '../../../public/node/error.js'\nimport {setLastSeenAuthMethod, setLastSeenUserIdAfterAuth} from '../session.js'\nimport {nonRandomUUID} from '../../../public/node/crypto.js'\n\nimport * as jose from 'jose'\n\nexport class InvalidGrantError extends ExtendableError {}\nexport class InvalidRequestError extends ExtendableError {}\nclass InvalidTargetError extends AbortError {}\n\nexport interface ExchangeScopes {\n admin: string[]\n partners: string[]\n storefront: string[]\n businessPlatform: string[]\n appManagement: string[]\n}\n\n/**\n * Given an identity token, request an application token.\n * @param identityToken - access token obtained in a previous step\n * @param store - the store to use, only needed for admin API\n * @returns An array with the application access tokens.\n */\nexport async function exchangeAccessForApplicationTokens(\n identityToken: IdentityToken,\n scopes: ExchangeScopes,\n store?: string,\n): Promise<Record<string, ApplicationToken>> {\n const token = identityToken.accessToken\n\n const [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([\n requestAppToken('partners', token, scopes.partners),\n requestAppToken('storefront-renderer', token, scopes.storefront),\n requestAppToken('business-platform', token, scopes.businessPlatform),\n store ? requestAppToken('admin', token, scopes.admin, store) : {},\n requestAppToken('app-management', token, scopes.appManagement),\n ])\n\n return {\n ...partners,\n ...storefront,\n ...businessPlatform,\n ...admin,\n ...appManagement,\n }\n}\n\n/**\n * Given an expired access token, refresh it to get a new one.\n */\nexport async function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken> {\n const clientId = getIdentityClientId()\n const params = {\n grant_type: 'refresh_token',\n access_token: currentToken.accessToken,\n refresh_token: currentToken.refreshToken,\n client_id: clientId,\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n return buildIdentityToken(value, currentToken.userId, currentToken.alias)\n}\n\n/**\n * Given a custom app automation token passed as ENV variable, request a valid API access token.\n * @param apiName - The API to exchange for the access token\n * @param token - The app automation token passed as ENV variable `SHOPIFY_APP_AUTOMATION_TOKEN`\n * @param scopes - The scopes to request with the access token\n * @returns An instance with the application access tokens.\n */\nasync function exchangeAppAutomationTokenForAccessToken(\n apiName: API,\n token: string,\n scopes: string[],\n): Promise<{accessToken: string; userId: string}> {\n const appId = applicationId(apiName)\n try {\n const newToken = await requestAppToken(apiName, token, scopes)\n\n const accessToken = newToken[appId]!.accessToken\n const userId = nonRandomUUID(token)\n setLastSeenUserIdAfterAuth(userId)\n setLastSeenAuthMethod('partners_token')\n return {accessToken, userId}\n } catch (error) {\n const prettyName = apiName.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n throw new AbortError(\n `The custom token provided can't be used for the ${prettyName} API.`,\n 'Ensure the token is correct and not expired.',\n )\n }\n}\n\n/**\n * Given a custom app automation token passed as ENV variable, request a valid Partners API token.\n * This token does not accept extra scopes, just the cli one.\n * @param token - The app automation token passed as ENV variable `SHOPIFY_APP_AUTOMATION_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCustomPartnerToken(token: string): Promise<{accessToken: string; userId: string}> {\n return exchangeAppAutomationTokenForAccessToken('partners', token, tokenExchangeScopes('partners'))\n}\n\n/**\n * Given a custom app automation token passed as ENV variable, request a valid App Management API token.\n * @param token - The app automation token passed as ENV variable `SHOPIFY_APP_AUTOMATION_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeAppAutomationTokenForAppManagementAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeAppAutomationTokenForAccessToken('app-management', token, tokenExchangeScopes('app-management'))\n}\n\n/**\n * Given a custom app automation token passed as ENV variable, request a valid Business Platform API token.\n * @param token - The app automation token passed as ENV variable `SHOPIFY_APP_AUTOMATION_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeAppAutomationTokenForBusinessPlatformAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeAppAutomationTokenForAccessToken('business-platform', token, tokenExchangeScopes('business-platform'))\n}\n\ntype IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure'\n\n/**\n * Given a deviceCode obtained after starting a device identity flow, request an identity token.\n * @param deviceCode - The device code obtained after starting a device identity flow\n * @param scopes - The scopes to request\n * @returns An instance with the identity access tokens.\n */\nexport async function exchangeDeviceCodeForAccessToken(\n deviceCode: string,\n): Promise<Result<IdentityToken, IdentityDeviceError>> {\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:device_code',\n device_code: deviceCode,\n client_id: clientId,\n }\n\n const tokenResult = await tokenRequest(params)\n if (tokenResult.isErr()) {\n return err(tokenResult.error.error as IdentityDeviceError)\n }\n const identityToken = buildIdentityToken(tokenResult.value)\n return ok(identityToken)\n}\n\nexport async function requestAppToken(\n api: API,\n token: string,\n scopes: string[] = [],\n store?: string,\n): Promise<Record<string, ApplicationToken>> {\n const appId = applicationId(api)\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',\n requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n subject_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n client_id: clientId,\n audience: appId,\n scope: scopes.join(' '),\n subject_token: token,\n ...(api === 'admin' && {destination: `https://${store}/admin`, store}),\n }\n\n let identifier = appId\n if (api === 'admin' && store) {\n identifier = `${store}-${appId}`\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n const appToken = buildApplicationToken(value)\n return {[identifier]: appToken}\n}\n\ninterface TokenRequestResult {\n access_token: string\n expires_in: number\n refresh_token: string\n scope: string\n id_token?: string\n}\n\nfunction tokenRequestErrorHandler({error, store}: {error: string; store?: string}) {\n const invalidTargetErrorMessage = `You are not authorized to use the CLI to develop in the provided store${\n store ? `: ${store}` : '.'\n }`\n\n if (error === 'invalid_grant') {\n // There's an scenario when Identity returns \"invalid_grant\" when trying to refresh the token\n // using a valid refresh token. When that happens, we take the user through the authentication flow.\n return new InvalidGrantError()\n }\n if (error === 'invalid_request') {\n // There's an scenario when Identity returns \"invalid_request\" when exchanging an identity token.\n // This means the token is invalid. We clear the session and throw an error to let the caller know.\n return new InvalidRequestError()\n }\n if (error === 'invalid_target') {\n return new InvalidTargetError(invalidTargetErrorMessage, '', [\n 'Ensure you have logged in to the store using the Shopify admin at least once.',\n 'Ensure you are the store owner, or have a staff account if you are attempting to log in to a dev store.',\n 'Ensure you are using the permanent store domain, not a vanity domain.',\n ])\n }\n // eslint-disable-next-line @shopify/cli/no-error-factory-functions\n return new AbortError(error)\n}\n\nasync function tokenRequest(\n params: Record<string, string>,\n): Promise<Result<TokenRequestResult, {error: string; store?: string}>> {\n const fqdn = await identityFqdn()\n const url = new URL(`https://${fqdn}/oauth/token`)\n url.search = new URLSearchParams(Object.entries(params)).toString()\n\n const res = await shopifyFetch(url.href, {method: 'POST'})\n try {\n const responseText = await res.text()\n\n const payload = JSON.parse(responseText)\n if (res.ok) return ok(payload)\n\n return err({error: payload.error, store: params.store})\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new AbortError(\n `Received invalid response from authentication service (HTTP ${res.status}).`,\n 'The response could not be parsed as JSON. The service may be temporarily unavailable. Please try again.',\n )\n }\n throw error\n }\n}\n\nfunction buildIdentityToken(\n result: TokenRequestResult,\n existingUserId?: string,\n existingAlias?: string,\n): IdentityToken {\n const userId = existingUserId ?? (result.id_token ? jose.decodeJwt(result.id_token).sub! : undefined)\n\n if (!userId) {\n throw new BugError('Error setting userId for session. No id_token or pre-existing user ID provided.')\n }\n\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n userId,\n alias: existingAlias,\n }\n}\n\nfunction buildApplicationToken(result: TokenRequestResult): ApplicationToken {\n return {\n accessToken: result.access_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n }\n}\n"]}
|
|
@@ -12,8 +12,8 @@ declare const IdentityTokenSchema: zod.ZodObject<{
|
|
|
12
12
|
}, "strip", zod.ZodTypeAny, {
|
|
13
13
|
accessToken: string;
|
|
14
14
|
refreshToken: string;
|
|
15
|
-
expiresAt: Date;
|
|
16
15
|
scopes: string[];
|
|
16
|
+
expiresAt: Date;
|
|
17
17
|
userId: string;
|
|
18
18
|
alias?: string | undefined;
|
|
19
19
|
}, {
|
|
@@ -34,8 +34,8 @@ declare const ApplicationTokenSchema: zod.ZodObject<{
|
|
|
34
34
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
35
35
|
}, "strip", zod.ZodTypeAny, {
|
|
36
36
|
accessToken: string;
|
|
37
|
-
expiresAt: Date;
|
|
38
37
|
scopes: string[];
|
|
38
|
+
expiresAt: Date;
|
|
39
39
|
storeFqdn?: string | undefined;
|
|
40
40
|
}, {
|
|
41
41
|
accessToken: string;
|
|
@@ -54,8 +54,8 @@ declare const SessionSchema: zod.ZodObject<{
|
|
|
54
54
|
}, "strip", zod.ZodTypeAny, {
|
|
55
55
|
accessToken: string;
|
|
56
56
|
refreshToken: string;
|
|
57
|
-
expiresAt: Date;
|
|
58
57
|
scopes: string[];
|
|
58
|
+
expiresAt: Date;
|
|
59
59
|
userId: string;
|
|
60
60
|
alias?: string | undefined;
|
|
61
61
|
}, {
|
|
@@ -73,8 +73,8 @@ declare const SessionSchema: zod.ZodObject<{
|
|
|
73
73
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
74
74
|
}, "strip", zod.ZodTypeAny, {
|
|
75
75
|
accessToken: string;
|
|
76
|
-
expiresAt: Date;
|
|
77
76
|
scopes: string[];
|
|
77
|
+
expiresAt: Date;
|
|
78
78
|
storeFqdn?: string | undefined;
|
|
79
79
|
}, {
|
|
80
80
|
accessToken: string;
|
|
@@ -88,8 +88,8 @@ declare const SessionSchema: zod.ZodObject<{
|
|
|
88
88
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
89
89
|
}, "strip", zod.ZodTypeAny, {
|
|
90
90
|
accessToken: string;
|
|
91
|
-
expiresAt: Date;
|
|
92
91
|
scopes: string[];
|
|
92
|
+
expiresAt: Date;
|
|
93
93
|
storeFqdn?: string | undefined;
|
|
94
94
|
}, {
|
|
95
95
|
accessToken: string;
|
|
@@ -103,8 +103,8 @@ declare const SessionSchema: zod.ZodObject<{
|
|
|
103
103
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
104
104
|
}, "strip", zod.ZodTypeAny, {
|
|
105
105
|
accessToken: string;
|
|
106
|
-
expiresAt: Date;
|
|
107
106
|
scopes: string[];
|
|
107
|
+
expiresAt: Date;
|
|
108
108
|
storeFqdn?: string | undefined;
|
|
109
109
|
}, {
|
|
110
110
|
accessToken: string;
|
|
@@ -116,16 +116,16 @@ declare const SessionSchema: zod.ZodObject<{
|
|
|
116
116
|
identity: {
|
|
117
117
|
accessToken: string;
|
|
118
118
|
refreshToken: string;
|
|
119
|
-
expiresAt: Date;
|
|
120
119
|
scopes: string[];
|
|
120
|
+
expiresAt: Date;
|
|
121
121
|
userId: string;
|
|
122
122
|
alias?: string | undefined;
|
|
123
123
|
};
|
|
124
124
|
applications: {} & {
|
|
125
125
|
[k: string]: {
|
|
126
126
|
accessToken: string;
|
|
127
|
-
expiresAt: Date;
|
|
128
127
|
scopes: string[];
|
|
128
|
+
expiresAt: Date;
|
|
129
129
|
storeFqdn?: string | undefined;
|
|
130
130
|
};
|
|
131
131
|
};
|
|
@@ -186,8 +186,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
186
186
|
}, "strip", zod.ZodTypeAny, {
|
|
187
187
|
accessToken: string;
|
|
188
188
|
refreshToken: string;
|
|
189
|
-
expiresAt: Date;
|
|
190
189
|
scopes: string[];
|
|
190
|
+
expiresAt: Date;
|
|
191
191
|
userId: string;
|
|
192
192
|
alias?: string | undefined;
|
|
193
193
|
}, {
|
|
@@ -205,8 +205,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
205
205
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
206
206
|
}, "strip", zod.ZodTypeAny, {
|
|
207
207
|
accessToken: string;
|
|
208
|
-
expiresAt: Date;
|
|
209
208
|
scopes: string[];
|
|
209
|
+
expiresAt: Date;
|
|
210
210
|
storeFqdn?: string | undefined;
|
|
211
211
|
}, {
|
|
212
212
|
accessToken: string;
|
|
@@ -220,8 +220,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
220
220
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
221
221
|
}, "strip", zod.ZodTypeAny, {
|
|
222
222
|
accessToken: string;
|
|
223
|
-
expiresAt: Date;
|
|
224
223
|
scopes: string[];
|
|
224
|
+
expiresAt: Date;
|
|
225
225
|
storeFqdn?: string | undefined;
|
|
226
226
|
}, {
|
|
227
227
|
accessToken: string;
|
|
@@ -235,8 +235,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
235
235
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
236
236
|
}, "strip", zod.ZodTypeAny, {
|
|
237
237
|
accessToken: string;
|
|
238
|
-
expiresAt: Date;
|
|
239
238
|
scopes: string[];
|
|
239
|
+
expiresAt: Date;
|
|
240
240
|
storeFqdn?: string | undefined;
|
|
241
241
|
}, {
|
|
242
242
|
accessToken: string;
|
|
@@ -248,16 +248,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
248
248
|
identity: {
|
|
249
249
|
accessToken: string;
|
|
250
250
|
refreshToken: string;
|
|
251
|
-
expiresAt: Date;
|
|
252
251
|
scopes: string[];
|
|
252
|
+
expiresAt: Date;
|
|
253
253
|
userId: string;
|
|
254
254
|
alias?: string | undefined;
|
|
255
255
|
};
|
|
256
256
|
applications: {} & {
|
|
257
257
|
[k: string]: {
|
|
258
258
|
accessToken: string;
|
|
259
|
-
expiresAt: Date;
|
|
260
259
|
scopes: string[];
|
|
260
|
+
expiresAt: Date;
|
|
261
261
|
storeFqdn?: string | undefined;
|
|
262
262
|
};
|
|
263
263
|
};
|
|
@@ -289,8 +289,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
289
289
|
}, "strip", zod.ZodTypeAny, {
|
|
290
290
|
accessToken: string;
|
|
291
291
|
refreshToken: string;
|
|
292
|
-
expiresAt: Date;
|
|
293
292
|
scopes: string[];
|
|
293
|
+
expiresAt: Date;
|
|
294
294
|
userId: string;
|
|
295
295
|
alias?: string | undefined;
|
|
296
296
|
}, {
|
|
@@ -308,8 +308,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
308
308
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
309
309
|
}, "strip", zod.ZodTypeAny, {
|
|
310
310
|
accessToken: string;
|
|
311
|
-
expiresAt: Date;
|
|
312
311
|
scopes: string[];
|
|
312
|
+
expiresAt: Date;
|
|
313
313
|
storeFqdn?: string | undefined;
|
|
314
314
|
}, {
|
|
315
315
|
accessToken: string;
|
|
@@ -323,8 +323,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
323
323
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
324
324
|
}, "strip", zod.ZodTypeAny, {
|
|
325
325
|
accessToken: string;
|
|
326
|
-
expiresAt: Date;
|
|
327
326
|
scopes: string[];
|
|
327
|
+
expiresAt: Date;
|
|
328
328
|
storeFqdn?: string | undefined;
|
|
329
329
|
}, {
|
|
330
330
|
accessToken: string;
|
|
@@ -338,8 +338,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
338
338
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
339
339
|
}, "strip", zod.ZodTypeAny, {
|
|
340
340
|
accessToken: string;
|
|
341
|
-
expiresAt: Date;
|
|
342
341
|
scopes: string[];
|
|
342
|
+
expiresAt: Date;
|
|
343
343
|
storeFqdn?: string | undefined;
|
|
344
344
|
}, {
|
|
345
345
|
accessToken: string;
|
|
@@ -351,16 +351,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
351
351
|
identity: {
|
|
352
352
|
accessToken: string;
|
|
353
353
|
refreshToken: string;
|
|
354
|
-
expiresAt: Date;
|
|
355
354
|
scopes: string[];
|
|
355
|
+
expiresAt: Date;
|
|
356
356
|
userId: string;
|
|
357
357
|
alias?: string | undefined;
|
|
358
358
|
};
|
|
359
359
|
applications: {} & {
|
|
360
360
|
[k: string]: {
|
|
361
361
|
accessToken: string;
|
|
362
|
-
expiresAt: Date;
|
|
363
362
|
scopes: string[];
|
|
363
|
+
expiresAt: Date;
|
|
364
364
|
storeFqdn?: string | undefined;
|
|
365
365
|
};
|
|
366
366
|
};
|
|
@@ -392,8 +392,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
392
392
|
}, "strip", zod.ZodTypeAny, {
|
|
393
393
|
accessToken: string;
|
|
394
394
|
refreshToken: string;
|
|
395
|
-
expiresAt: Date;
|
|
396
395
|
scopes: string[];
|
|
396
|
+
expiresAt: Date;
|
|
397
397
|
userId: string;
|
|
398
398
|
alias?: string | undefined;
|
|
399
399
|
}, {
|
|
@@ -411,8 +411,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
411
411
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
412
412
|
}, "strip", zod.ZodTypeAny, {
|
|
413
413
|
accessToken: string;
|
|
414
|
-
expiresAt: Date;
|
|
415
414
|
scopes: string[];
|
|
415
|
+
expiresAt: Date;
|
|
416
416
|
storeFqdn?: string | undefined;
|
|
417
417
|
}, {
|
|
418
418
|
accessToken: string;
|
|
@@ -426,8 +426,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
426
426
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
427
427
|
}, "strip", zod.ZodTypeAny, {
|
|
428
428
|
accessToken: string;
|
|
429
|
-
expiresAt: Date;
|
|
430
429
|
scopes: string[];
|
|
430
|
+
expiresAt: Date;
|
|
431
431
|
storeFqdn?: string | undefined;
|
|
432
432
|
}, {
|
|
433
433
|
accessToken: string;
|
|
@@ -441,8 +441,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
441
441
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
442
442
|
}, "strip", zod.ZodTypeAny, {
|
|
443
443
|
accessToken: string;
|
|
444
|
-
expiresAt: Date;
|
|
445
444
|
scopes: string[];
|
|
445
|
+
expiresAt: Date;
|
|
446
446
|
storeFqdn?: string | undefined;
|
|
447
447
|
}, {
|
|
448
448
|
accessToken: string;
|
|
@@ -454,16 +454,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
454
454
|
identity: {
|
|
455
455
|
accessToken: string;
|
|
456
456
|
refreshToken: string;
|
|
457
|
-
expiresAt: Date;
|
|
458
457
|
scopes: string[];
|
|
458
|
+
expiresAt: Date;
|
|
459
459
|
userId: string;
|
|
460
460
|
alias?: string | undefined;
|
|
461
461
|
};
|
|
462
462
|
applications: {} & {
|
|
463
463
|
[k: string]: {
|
|
464
464
|
accessToken: string;
|
|
465
|
-
expiresAt: Date;
|
|
466
465
|
scopes: string[];
|
|
466
|
+
expiresAt: Date;
|
|
467
467
|
storeFqdn?: string | undefined;
|
|
468
468
|
};
|
|
469
469
|
};
|
|
@@ -495,8 +495,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
495
495
|
}, "strip", zod.ZodTypeAny, {
|
|
496
496
|
accessToken: string;
|
|
497
497
|
refreshToken: string;
|
|
498
|
-
expiresAt: Date;
|
|
499
498
|
scopes: string[];
|
|
499
|
+
expiresAt: Date;
|
|
500
500
|
userId: string;
|
|
501
501
|
alias?: string | undefined;
|
|
502
502
|
}, {
|
|
@@ -514,8 +514,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
514
514
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
515
515
|
}, "strip", zod.ZodTypeAny, {
|
|
516
516
|
accessToken: string;
|
|
517
|
-
expiresAt: Date;
|
|
518
517
|
scopes: string[];
|
|
518
|
+
expiresAt: Date;
|
|
519
519
|
storeFqdn?: string | undefined;
|
|
520
520
|
}, {
|
|
521
521
|
accessToken: string;
|
|
@@ -529,8 +529,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
529
529
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
530
530
|
}, "strip", zod.ZodTypeAny, {
|
|
531
531
|
accessToken: string;
|
|
532
|
-
expiresAt: Date;
|
|
533
532
|
scopes: string[];
|
|
533
|
+
expiresAt: Date;
|
|
534
534
|
storeFqdn?: string | undefined;
|
|
535
535
|
}, {
|
|
536
536
|
accessToken: string;
|
|
@@ -544,8 +544,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
544
544
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
545
545
|
}, "strip", zod.ZodTypeAny, {
|
|
546
546
|
accessToken: string;
|
|
547
|
-
expiresAt: Date;
|
|
548
547
|
scopes: string[];
|
|
548
|
+
expiresAt: Date;
|
|
549
549
|
storeFqdn?: string | undefined;
|
|
550
550
|
}, {
|
|
551
551
|
accessToken: string;
|
|
@@ -557,16 +557,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
557
557
|
identity: {
|
|
558
558
|
accessToken: string;
|
|
559
559
|
refreshToken: string;
|
|
560
|
-
expiresAt: Date;
|
|
561
560
|
scopes: string[];
|
|
561
|
+
expiresAt: Date;
|
|
562
562
|
userId: string;
|
|
563
563
|
alias?: string | undefined;
|
|
564
564
|
};
|
|
565
565
|
applications: {} & {
|
|
566
566
|
[k: string]: {
|
|
567
567
|
accessToken: string;
|
|
568
|
-
expiresAt: Date;
|
|
569
568
|
scopes: string[];
|
|
569
|
+
expiresAt: Date;
|
|
570
570
|
storeFqdn?: string | undefined;
|
|
571
571
|
};
|
|
572
572
|
};
|
|
@@ -598,8 +598,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
598
598
|
}, "strip", zod.ZodTypeAny, {
|
|
599
599
|
accessToken: string;
|
|
600
600
|
refreshToken: string;
|
|
601
|
-
expiresAt: Date;
|
|
602
601
|
scopes: string[];
|
|
602
|
+
expiresAt: Date;
|
|
603
603
|
userId: string;
|
|
604
604
|
alias?: string | undefined;
|
|
605
605
|
}, {
|
|
@@ -617,8 +617,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
617
617
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
618
618
|
}, "strip", zod.ZodTypeAny, {
|
|
619
619
|
accessToken: string;
|
|
620
|
-
expiresAt: Date;
|
|
621
620
|
scopes: string[];
|
|
621
|
+
expiresAt: Date;
|
|
622
622
|
storeFqdn?: string | undefined;
|
|
623
623
|
}, {
|
|
624
624
|
accessToken: string;
|
|
@@ -632,8 +632,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
632
632
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
633
633
|
}, "strip", zod.ZodTypeAny, {
|
|
634
634
|
accessToken: string;
|
|
635
|
-
expiresAt: Date;
|
|
636
635
|
scopes: string[];
|
|
636
|
+
expiresAt: Date;
|
|
637
637
|
storeFqdn?: string | undefined;
|
|
638
638
|
}, {
|
|
639
639
|
accessToken: string;
|
|
@@ -647,8 +647,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
647
647
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
648
648
|
}, "strip", zod.ZodTypeAny, {
|
|
649
649
|
accessToken: string;
|
|
650
|
-
expiresAt: Date;
|
|
651
650
|
scopes: string[];
|
|
651
|
+
expiresAt: Date;
|
|
652
652
|
storeFqdn?: string | undefined;
|
|
653
653
|
}, {
|
|
654
654
|
accessToken: string;
|
|
@@ -660,16 +660,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
660
660
|
identity: {
|
|
661
661
|
accessToken: string;
|
|
662
662
|
refreshToken: string;
|
|
663
|
-
expiresAt: Date;
|
|
664
663
|
scopes: string[];
|
|
664
|
+
expiresAt: Date;
|
|
665
665
|
userId: string;
|
|
666
666
|
alias?: string | undefined;
|
|
667
667
|
};
|
|
668
668
|
applications: {} & {
|
|
669
669
|
[k: string]: {
|
|
670
670
|
accessToken: string;
|
|
671
|
-
expiresAt: Date;
|
|
672
671
|
scopes: string[];
|
|
672
|
+
expiresAt: Date;
|
|
673
673
|
storeFqdn?: string | undefined;
|
|
674
674
|
};
|
|
675
675
|
};
|
|
@@ -701,8 +701,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
701
701
|
}, "strip", zod.ZodTypeAny, {
|
|
702
702
|
accessToken: string;
|
|
703
703
|
refreshToken: string;
|
|
704
|
-
expiresAt: Date;
|
|
705
704
|
scopes: string[];
|
|
705
|
+
expiresAt: Date;
|
|
706
706
|
userId: string;
|
|
707
707
|
alias?: string | undefined;
|
|
708
708
|
}, {
|
|
@@ -720,8 +720,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
720
720
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
721
721
|
}, "strip", zod.ZodTypeAny, {
|
|
722
722
|
accessToken: string;
|
|
723
|
-
expiresAt: Date;
|
|
724
723
|
scopes: string[];
|
|
724
|
+
expiresAt: Date;
|
|
725
725
|
storeFqdn?: string | undefined;
|
|
726
726
|
}, {
|
|
727
727
|
accessToken: string;
|
|
@@ -735,8 +735,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
735
735
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
736
736
|
}, "strip", zod.ZodTypeAny, {
|
|
737
737
|
accessToken: string;
|
|
738
|
-
expiresAt: Date;
|
|
739
738
|
scopes: string[];
|
|
739
|
+
expiresAt: Date;
|
|
740
740
|
storeFqdn?: string | undefined;
|
|
741
741
|
}, {
|
|
742
742
|
accessToken: string;
|
|
@@ -750,8 +750,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
750
750
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
751
751
|
}, "strip", zod.ZodTypeAny, {
|
|
752
752
|
accessToken: string;
|
|
753
|
-
expiresAt: Date;
|
|
754
753
|
scopes: string[];
|
|
754
|
+
expiresAt: Date;
|
|
755
755
|
storeFqdn?: string | undefined;
|
|
756
756
|
}, {
|
|
757
757
|
accessToken: string;
|
|
@@ -763,16 +763,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
763
763
|
identity: {
|
|
764
764
|
accessToken: string;
|
|
765
765
|
refreshToken: string;
|
|
766
|
-
expiresAt: Date;
|
|
767
766
|
scopes: string[];
|
|
767
|
+
expiresAt: Date;
|
|
768
768
|
userId: string;
|
|
769
769
|
alias?: string | undefined;
|
|
770
770
|
};
|
|
771
771
|
applications: {} & {
|
|
772
772
|
[k: string]: {
|
|
773
773
|
accessToken: string;
|
|
774
|
-
expiresAt: Date;
|
|
775
774
|
scopes: string[];
|
|
775
|
+
expiresAt: Date;
|
|
776
776
|
storeFqdn?: string | undefined;
|
|
777
777
|
};
|
|
778
778
|
};
|
|
@@ -804,8 +804,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
804
804
|
}, "strip", zod.ZodTypeAny, {
|
|
805
805
|
accessToken: string;
|
|
806
806
|
refreshToken: string;
|
|
807
|
-
expiresAt: Date;
|
|
808
807
|
scopes: string[];
|
|
808
|
+
expiresAt: Date;
|
|
809
809
|
userId: string;
|
|
810
810
|
alias?: string | undefined;
|
|
811
811
|
}, {
|
|
@@ -823,8 +823,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
823
823
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
824
824
|
}, "strip", zod.ZodTypeAny, {
|
|
825
825
|
accessToken: string;
|
|
826
|
-
expiresAt: Date;
|
|
827
826
|
scopes: string[];
|
|
827
|
+
expiresAt: Date;
|
|
828
828
|
storeFqdn?: string | undefined;
|
|
829
829
|
}, {
|
|
830
830
|
accessToken: string;
|
|
@@ -838,8 +838,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
838
838
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
839
839
|
}, "strip", zod.ZodTypeAny, {
|
|
840
840
|
accessToken: string;
|
|
841
|
-
expiresAt: Date;
|
|
842
841
|
scopes: string[];
|
|
842
|
+
expiresAt: Date;
|
|
843
843
|
storeFqdn?: string | undefined;
|
|
844
844
|
}, {
|
|
845
845
|
accessToken: string;
|
|
@@ -853,8 +853,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
853
853
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
854
854
|
}, "strip", zod.ZodTypeAny, {
|
|
855
855
|
accessToken: string;
|
|
856
|
-
expiresAt: Date;
|
|
857
856
|
scopes: string[];
|
|
857
|
+
expiresAt: Date;
|
|
858
858
|
storeFqdn?: string | undefined;
|
|
859
859
|
}, {
|
|
860
860
|
accessToken: string;
|
|
@@ -866,16 +866,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
866
866
|
identity: {
|
|
867
867
|
accessToken: string;
|
|
868
868
|
refreshToken: string;
|
|
869
|
-
expiresAt: Date;
|
|
870
869
|
scopes: string[];
|
|
870
|
+
expiresAt: Date;
|
|
871
871
|
userId: string;
|
|
872
872
|
alias?: string | undefined;
|
|
873
873
|
};
|
|
874
874
|
applications: {} & {
|
|
875
875
|
[k: string]: {
|
|
876
876
|
accessToken: string;
|
|
877
|
-
expiresAt: Date;
|
|
878
877
|
scopes: string[];
|
|
878
|
+
expiresAt: Date;
|
|
879
879
|
storeFqdn?: string | undefined;
|
|
880
880
|
};
|
|
881
881
|
};
|
|
@@ -907,8 +907,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
907
907
|
}, "strip", zod.ZodTypeAny, {
|
|
908
908
|
accessToken: string;
|
|
909
909
|
refreshToken: string;
|
|
910
|
-
expiresAt: Date;
|
|
911
910
|
scopes: string[];
|
|
911
|
+
expiresAt: Date;
|
|
912
912
|
userId: string;
|
|
913
913
|
alias?: string | undefined;
|
|
914
914
|
}, {
|
|
@@ -926,8 +926,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
926
926
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
927
927
|
}, "strip", zod.ZodTypeAny, {
|
|
928
928
|
accessToken: string;
|
|
929
|
-
expiresAt: Date;
|
|
930
929
|
scopes: string[];
|
|
930
|
+
expiresAt: Date;
|
|
931
931
|
storeFqdn?: string | undefined;
|
|
932
932
|
}, {
|
|
933
933
|
accessToken: string;
|
|
@@ -941,8 +941,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
941
941
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
942
942
|
}, "strip", zod.ZodTypeAny, {
|
|
943
943
|
accessToken: string;
|
|
944
|
-
expiresAt: Date;
|
|
945
944
|
scopes: string[];
|
|
945
|
+
expiresAt: Date;
|
|
946
946
|
storeFqdn?: string | undefined;
|
|
947
947
|
}, {
|
|
948
948
|
accessToken: string;
|
|
@@ -956,8 +956,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
956
956
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
957
957
|
}, "strip", zod.ZodTypeAny, {
|
|
958
958
|
accessToken: string;
|
|
959
|
-
expiresAt: Date;
|
|
960
959
|
scopes: string[];
|
|
960
|
+
expiresAt: Date;
|
|
961
961
|
storeFqdn?: string | undefined;
|
|
962
962
|
}, {
|
|
963
963
|
accessToken: string;
|
|
@@ -969,16 +969,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
969
969
|
identity: {
|
|
970
970
|
accessToken: string;
|
|
971
971
|
refreshToken: string;
|
|
972
|
-
expiresAt: Date;
|
|
973
972
|
scopes: string[];
|
|
973
|
+
expiresAt: Date;
|
|
974
974
|
userId: string;
|
|
975
975
|
alias?: string | undefined;
|
|
976
976
|
};
|
|
977
977
|
applications: {} & {
|
|
978
978
|
[k: string]: {
|
|
979
979
|
accessToken: string;
|
|
980
|
-
expiresAt: Date;
|
|
981
980
|
scopes: string[];
|
|
981
|
+
expiresAt: Date;
|
|
982
982
|
storeFqdn?: string | undefined;
|
|
983
983
|
};
|
|
984
984
|
};
|
|
@@ -1010,8 +1010,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
1010
1010
|
}, "strip", zod.ZodTypeAny, {
|
|
1011
1011
|
accessToken: string;
|
|
1012
1012
|
refreshToken: string;
|
|
1013
|
-
expiresAt: Date;
|
|
1014
1013
|
scopes: string[];
|
|
1014
|
+
expiresAt: Date;
|
|
1015
1015
|
userId: string;
|
|
1016
1016
|
alias?: string | undefined;
|
|
1017
1017
|
}, {
|
|
@@ -1029,8 +1029,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
1029
1029
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
1030
1030
|
}, "strip", zod.ZodTypeAny, {
|
|
1031
1031
|
accessToken: string;
|
|
1032
|
-
expiresAt: Date;
|
|
1033
1032
|
scopes: string[];
|
|
1033
|
+
expiresAt: Date;
|
|
1034
1034
|
storeFqdn?: string | undefined;
|
|
1035
1035
|
}, {
|
|
1036
1036
|
accessToken: string;
|
|
@@ -1044,8 +1044,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
1044
1044
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
1045
1045
|
}, "strip", zod.ZodTypeAny, {
|
|
1046
1046
|
accessToken: string;
|
|
1047
|
-
expiresAt: Date;
|
|
1048
1047
|
scopes: string[];
|
|
1048
|
+
expiresAt: Date;
|
|
1049
1049
|
storeFqdn?: string | undefined;
|
|
1050
1050
|
}, {
|
|
1051
1051
|
accessToken: string;
|
|
@@ -1059,8 +1059,8 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
1059
1059
|
storeFqdn: zod.ZodOptional<zod.ZodString>;
|
|
1060
1060
|
}, "strip", zod.ZodTypeAny, {
|
|
1061
1061
|
accessToken: string;
|
|
1062
|
-
expiresAt: Date;
|
|
1063
1062
|
scopes: string[];
|
|
1063
|
+
expiresAt: Date;
|
|
1064
1064
|
storeFqdn?: string | undefined;
|
|
1065
1065
|
}, {
|
|
1066
1066
|
accessToken: string;
|
|
@@ -1072,16 +1072,16 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
|
|
|
1072
1072
|
identity: {
|
|
1073
1073
|
accessToken: string;
|
|
1074
1074
|
refreshToken: string;
|
|
1075
|
-
expiresAt: Date;
|
|
1076
1075
|
scopes: string[];
|
|
1076
|
+
expiresAt: Date;
|
|
1077
1077
|
userId: string;
|
|
1078
1078
|
alias?: string | undefined;
|
|
1079
1079
|
};
|
|
1080
1080
|
applications: {} & {
|
|
1081
1081
|
[k: string]: {
|
|
1082
1082
|
accessToken: string;
|
|
1083
|
-
expiresAt: Date;
|
|
1084
1083
|
scopes: string[];
|
|
1084
|
+
expiresAt: Date;
|
|
1085
1085
|
storeFqdn?: string | undefined;
|
|
1086
1086
|
};
|
|
1087
1087
|
};
|
|
@@ -35,7 +35,8 @@ export function tokenExchangeScopes(api) {
|
|
|
35
35
|
return [scopeTransform('app-management')];
|
|
36
36
|
case 'business-platform':
|
|
37
37
|
return [scopeTransform('destinations')];
|
|
38
|
-
|
|
38
|
+
case 'admin':
|
|
39
|
+
case 'storefront-renderer':
|
|
39
40
|
throw new BugError(`API not supported for token exchange: ${api}`);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -44,7 +45,7 @@ function defaultApiScopes(api) {
|
|
|
44
45
|
case 'admin':
|
|
45
46
|
return ['graphql', 'themes', 'collaborator'];
|
|
46
47
|
case 'storefront-renderer':
|
|
47
|
-
return ['devtools'];
|
|
48
|
+
return ['devtools', 'graphql'];
|
|
48
49
|
case 'partners':
|
|
49
50
|
return ['cli'];
|
|
50
51
|
case 'business-platform':
|