@shopify/cli-kit 3.33.0 → 3.35.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.
Files changed (212) hide show
  1. package/dist/git.js +3 -3
  2. package/dist/git.js.map +1 -1
  3. package/dist/http/fetch.js +1 -1
  4. package/dist/http/fetch.js.map +1 -1
  5. package/dist/http.js +2 -2
  6. package/dist/http.js.map +1 -1
  7. package/dist/index.d.ts +0 -7
  8. package/dist/index.js +0 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/metadata.js +1 -1
  11. package/dist/metadata.js.map +1 -1
  12. package/dist/npm.js +3 -3
  13. package/dist/npm.js.map +1 -1
  14. package/dist/output.js +4 -4
  15. package/dist/output.js.map +1 -1
  16. package/dist/path.d.ts +1 -1
  17. package/dist/path.js +5 -3
  18. package/dist/path.js.map +1 -1
  19. package/dist/private/node/analytics.js +6 -9
  20. package/dist/private/node/analytics.js.map +1 -1
  21. package/dist/private/node/api/graphql.js +2 -1
  22. package/dist/private/node/api/graphql.js.map +1 -1
  23. package/dist/private/node/api/headers.d.ts +2 -2
  24. package/dist/private/node/api/headers.js +4 -4
  25. package/dist/private/node/api/headers.js.map +1 -1
  26. package/dist/private/node/api/rest.d.ts +6 -4
  27. package/dist/private/node/api/rest.js +8 -7
  28. package/dist/private/node/api/rest.js.map +1 -1
  29. package/dist/private/node/constants.d.ts +42 -0
  30. package/dist/private/node/constants.js +58 -0
  31. package/dist/private/node/constants.js.map +1 -0
  32. package/dist/private/node/environment/service.d.ts +18 -0
  33. package/dist/private/node/environment/service.js +32 -0
  34. package/dist/private/node/environment/service.js.map +1 -0
  35. package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
  36. package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
  37. package/dist/private/node/environment/spin-cache.js.map +1 -0
  38. package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
  39. package/dist/{environment → private/node/environment}/utilities.js +0 -0
  40. package/dist/private/node/environment/utilities.js.map +1 -0
  41. package/dist/{session → private/node/session}/authorize.d.ts +1 -5
  42. package/dist/{session → private/node/session}/authorize.js +9 -9
  43. package/dist/private/node/session/authorize.js.map +1 -0
  44. package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
  45. package/dist/{session → private/node/session}/device-authorization.js +7 -9
  46. package/dist/private/node/session/device-authorization.js.map +1 -0
  47. package/dist/{session → private/node/session}/exchange.d.ts +2 -2
  48. package/dist/{session → private/node/session}/exchange.js +5 -5
  49. package/dist/private/node/session/exchange.js.map +1 -0
  50. package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
  51. package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
  52. package/dist/private/node/session/identity-token-validation.js.map +1 -0
  53. package/dist/{session → private/node/session}/identity.d.ts +1 -1
  54. package/dist/{session → private/node/session}/identity.js +2 -3
  55. package/dist/private/node/session/identity.js.map +1 -0
  56. package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
  57. package/dist/{session → private/node/session}/post-auth.js +10 -10
  58. package/dist/private/node/session/post-auth.js.map +1 -0
  59. package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
  60. package/dist/{session → private/node/session}/redirect-listener.js +2 -2
  61. package/dist/private/node/session/redirect-listener.js.map +1 -0
  62. package/dist/{session → private/node/session}/schema.d.ts +1 -1
  63. package/dist/{session → private/node/session}/schema.js +1 -1
  64. package/dist/private/node/session/schema.js.map +1 -0
  65. package/dist/{session → private/node/session}/scopes.d.ts +1 -1
  66. package/dist/{session → private/node/session}/scopes.js +2 -2
  67. package/dist/private/node/session/scopes.js.map +1 -0
  68. package/dist/{session → private/node/session}/store.d.ts +0 -0
  69. package/dist/{session → private/node/session}/store.js +10 -10
  70. package/dist/private/node/session/store.js.map +1 -0
  71. package/dist/{session → private/node/session}/validate.d.ts +0 -0
  72. package/dist/{session → private/node/session}/validate.js +4 -4
  73. package/dist/private/node/session/validate.js.map +1 -0
  74. package/dist/private/node/session.d.ts +56 -0
  75. package/dist/{session.js → private/node/session.js} +98 -134
  76. package/dist/private/node/session.js.map +1 -0
  77. package/dist/private/node/ui/components/SelectPrompt.d.ts +2 -1
  78. package/dist/private/node/ui/components/SelectPrompt.js +2 -1
  79. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  80. package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
  81. package/dist/private/node/ui/components/Table/Column.js +2 -0
  82. package/dist/private/node/ui/components/Table/Column.js.map +1 -0
  83. package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
  84. package/dist/private/node/ui/components/Table/Row.js +24 -0
  85. package/dist/private/node/ui/components/Table/Row.js.map +1 -0
  86. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
  87. package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
  88. package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
  89. package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
  90. package/dist/private/node/ui/components/Table/Table.js +30 -0
  91. package/dist/private/node/ui/components/Table/Table.js.map +1 -0
  92. package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
  93. package/dist/private/node/ui/components/Table/Table.test.js +41 -0
  94. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
  95. package/dist/private/node/ui.js +1 -1
  96. package/dist/private/node/ui.js.map +1 -1
  97. package/dist/public/common/string.d.ts +11 -0
  98. package/dist/public/common/string.js +21 -0
  99. package/dist/public/common/string.js.map +1 -1
  100. package/dist/public/common/version.d.ts +1 -0
  101. package/dist/public/common/version.js +2 -0
  102. package/dist/public/common/version.js.map +1 -0
  103. package/dist/public/node/analytics.js +5 -5
  104. package/dist/public/node/analytics.js.map +1 -1
  105. package/dist/public/node/api/admin.d.ts +5 -2
  106. package/dist/public/node/api/admin.js +4 -3
  107. package/dist/public/node/api/admin.js.map +1 -1
  108. package/dist/public/node/api/partners.js +1 -1
  109. package/dist/public/node/api/partners.js.map +1 -1
  110. package/dist/public/node/base-command.js +2 -2
  111. package/dist/public/node/base-command.js.map +1 -1
  112. package/dist/public/node/cli.d.ts +8 -0
  113. package/dist/public/node/cli.js +25 -8
  114. package/dist/public/node/cli.js.map +1 -1
  115. package/dist/public/node/dot-env.js +2 -2
  116. package/dist/public/node/dot-env.js.map +1 -1
  117. package/dist/public/node/environment/fqdn.d.ts +26 -0
  118. package/dist/{environment → public/node/environment}/fqdn.js +15 -31
  119. package/dist/public/node/environment/fqdn.js.map +1 -0
  120. package/dist/{environment → public/node/environment}/local.d.ts +62 -15
  121. package/dist/{environment → public/node/environment}/local.js +81 -36
  122. package/dist/public/node/environment/local.js.map +1 -0
  123. package/dist/public/node/environment/spin.d.ts +43 -0
  124. package/dist/{environment → public/node/environment}/spin.js +31 -38
  125. package/dist/public/node/environment/spin.js.map +1 -0
  126. package/dist/public/node/error-handler.js +6 -5
  127. package/dist/public/node/error-handler.js.map +1 -1
  128. package/dist/public/node/fs.d.ts +222 -3
  129. package/dist/public/node/fs.js +338 -2
  130. package/dist/public/node/fs.js.map +1 -1
  131. package/dist/public/node/git.d.ts +90 -0
  132. package/dist/public/node/git.js +174 -0
  133. package/dist/public/node/git.js.map +1 -0
  134. package/dist/public/node/liquid.js +6 -6
  135. package/dist/public/node/liquid.js.map +1 -1
  136. package/dist/public/node/node-package-manager.d.ts +0 -10
  137. package/dist/public/node/node-package-manager.js +3 -20
  138. package/dist/public/node/node-package-manager.js.map +1 -1
  139. package/dist/public/node/presets.js +2 -2
  140. package/dist/public/node/presets.js.map +1 -1
  141. package/dist/public/node/ruby.d.ts +1 -1
  142. package/dist/public/node/ruby.js +19 -20
  143. package/dist/public/node/ruby.js.map +1 -1
  144. package/dist/public/node/session.d.ts +53 -0
  145. package/dist/public/node/session.js +95 -0
  146. package/dist/public/node/session.js.map +1 -0
  147. package/dist/public/node/system.d.ts +44 -0
  148. package/dist/{system.js → public/node/system.js} +34 -54
  149. package/dist/public/node/system.js.map +1 -0
  150. package/dist/public/node/tcp.js +1 -1
  151. package/dist/public/node/tcp.js.map +1 -1
  152. package/dist/public/node/ui.d.ts +13 -0
  153. package/dist/public/node/ui.js +14 -0
  154. package/dist/public/node/ui.js.map +1 -1
  155. package/dist/public/node/vscode.js +5 -5
  156. package/dist/public/node/vscode.js.map +1 -1
  157. package/dist/secure-store.js +4 -4
  158. package/dist/secure-store.js.map +1 -1
  159. package/dist/store.d.ts +10 -10
  160. package/dist/store.js +21 -22
  161. package/dist/store.js.map +1 -1
  162. package/dist/testing/store.js +3 -3
  163. package/dist/testing/store.js.map +1 -1
  164. package/dist/testing/ui.js +1 -1
  165. package/dist/testing/ui.js.map +1 -1
  166. package/dist/tsconfig.tsbuildinfo +1 -1
  167. package/dist/ui.js +4 -4
  168. package/dist/ui.js.map +1 -1
  169. package/package.json +10 -7
  170. package/dist/cli.d.ts +0 -8
  171. package/dist/cli.js +0 -18
  172. package/dist/cli.js.map +0 -1
  173. package/dist/constants.d.ts +0 -51
  174. package/dist/constants.js +0 -70
  175. package/dist/constants.js.map +0 -1
  176. package/dist/environment/fqdn.d.ts +0 -29
  177. package/dist/environment/fqdn.js.map +0 -1
  178. package/dist/environment/local.js.map +0 -1
  179. package/dist/environment/service.d.ts +0 -4
  180. package/dist/environment/service.js +0 -19
  181. package/dist/environment/service.js.map +0 -1
  182. package/dist/environment/spin-cache.js.map +0 -1
  183. package/dist/environment/spin.d.ts +0 -50
  184. package/dist/environment/spin.js.map +0 -1
  185. package/dist/environment/utilities.js.map +0 -1
  186. package/dist/environment.d.ts +0 -7
  187. package/dist/environment.js +0 -8
  188. package/dist/environment.js.map +0 -1
  189. package/dist/file.d.ts +0 -98
  190. package/dist/file.js +0 -216
  191. package/dist/file.js.map +0 -1
  192. package/dist/network/service.d.ts +0 -14
  193. package/dist/network/service.js +0 -11
  194. package/dist/network/service.js.map +0 -1
  195. package/dist/session/authorize.js.map +0 -1
  196. package/dist/session/device-authorization.js.map +0 -1
  197. package/dist/session/exchange.js.map +0 -1
  198. package/dist/session/identity-token-validation.js.map +0 -1
  199. package/dist/session/identity.js.map +0 -1
  200. package/dist/session/post-auth.js.map +0 -1
  201. package/dist/session/redirect-listener.js.map +0 -1
  202. package/dist/session/schema.js.map +0 -1
  203. package/dist/session/scopes.js.map +0 -1
  204. package/dist/session/store.js.map +0 -1
  205. package/dist/session/token.d.ts +0 -40
  206. package/dist/session/token.js +0 -22
  207. package/dist/session/token.js.map +0 -1
  208. package/dist/session/validate.js.map +0 -1
  209. package/dist/session.d.ts +0 -96
  210. package/dist/session.js.map +0 -1
  211. package/dist/system.d.ts +0 -51
  212. package/dist/system.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAC,KAAK,EAAE,GAAG,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAC,gBAAgB,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAE,kBAAkB,EAAE,QAAQ,IAAI,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAChC,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,0BAA0B,EAE1B,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAEhD,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MA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GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAA;QAClD,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,WAAW,CAAA;KACjE;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,gBAAgB;AAChB,SAAS,gBAAgB,CAAC,IAAuB;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,IAAI,EAAE,CAAA;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,IAAI,EAAE,CAAA;IAC3D,MAAM,eAAe,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAA;IAC7D,OAAO,gBAAgB,CAAC,eAAe,CAAC,CAAA;AAC1C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAuB;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;IAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,IAAI,EAAE,CAAA;IACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,IAAI,EAAE,CAAA;IACjE,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC;QACrC,QAAQ,EAAE,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;QAC7C,UAAU,EAAE,SAAS,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;KAC/D,CAAA;AACH,CAAC;AAED,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {applicationId} from './session/identity.js'\nimport {Abort, Bug} from './error.js'\nimport {validateSession} from './session/validate.js'\nimport {allDefaultScopes, apiScopes} from './session/scopes.js'\nimport {identity as identityFqdn, normalizeStoreName, partners as partnersFqdn} from './environment/fqdn.js'\nimport {open} from './system.js'\nimport {\n exchangeAccessForApplicationTokens,\n exchangeCodeForAccessToken,\n exchangeCustomPartnerToken,\n ExchangeScopes,\n refreshAccessToken,\n InvalidGrantError,\n InvalidRequestError,\n} from './session/exchange.js'\n\nimport {content, token, debug} from './output.js'\nimport {keypress} from './ui.js'\n\nimport {authorize} from './session/authorize.js'\nimport {IdentityToken, Session} from './session/schema.js'\nimport * as secureStore from './session/store.js'\nimport constants from './constants.js'\nimport * as output from './output.js'\nimport {firstPartyDev, useDeviceAuth} from './environment/local.js'\nimport {pollForDeviceAuthorization, requestDeviceAuthorization} from './session/device-authorization.js'\nimport {AbortError} from './public/node/error.js'\nimport {partnersRequest} from './public/node/api/partners.js'\nimport {RequestClientError} from './private/node/api/headers.js'\nimport {gql} from 'graphql-request'\n\nconst NoSessionError = new Bug('No session found after ensuring authenticated')\nconst MissingPartnerTokenError = new Bug('No partners token found after ensuring authenticated')\nconst MissingAdminTokenError = new Bug('No admin token found after ensuring authenticated')\nconst MissingStorefrontTokenError = new Bug('No storefront token found after ensuring authenticated')\n\n/**\n * A scope supported by the Shopify Admin API.\n */\ntype AdminAPIScope = 'graphql' | 'themes' | 'collaborator' | string\n\n/**\n * It represents the options to authenticate against the Shopify Admin API.\n */\ninterface AdminAPIOAuthOptions {\n /** Store to request permissions for */\n storeFqdn: string\n /** List of scopes to request permissions for */\n scopes: AdminAPIScope[]\n}\n\n/**\n * A scope supported by the Partners API.\n */\ntype PartnersAPIScope = 'cli' | string\ninterface PartnersAPIOAuthOptions {\n /** List of scopes to request permissions for */\n scopes: PartnersAPIScope[]\n}\n\n/**\n * A scope supported by the Storefront Renderer API.\n */\ntype StorefrontRendererScope = 'devtools' | string\ninterface StorefrontRendererAPIOAuthOptions {\n /** List of scopes to request permissions for */\n scopes: StorefrontRendererScope[]\n}\n\n/**\n * It represents the authentication requirements and\n * is the input necessary to trigger the authentication\n * flow.\n */\nexport interface OAuthApplications {\n adminApi?: AdminAPIOAuthOptions\n storefrontRendererApi?: StorefrontRendererAPIOAuthOptions\n partnersApi?: PartnersAPIOAuthOptions\n}\n\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\nexport interface OAuthSession {\n admin?: AdminSession\n partners?: string\n storefront?: string\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(scopes: string[] = [], env = process.env): Promise<string> {\n debug(content`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${token.json(scopes)}\n`)\n const envToken = env[constants.environmentVariables.partnersToken]\n if (envToken) {\n return (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}})\n if (!tokens.partners) {\n throw MissingPartnerTokenError\n }\n return tokens.partners\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n): Promise<string> {\n if (password) return password\n\n debug(content`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}})\n if (!tokens.storefront) {\n throw MissingStorefrontTokenError\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n * @param store - Store fqdn to request auth for\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Admin API\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${token.raw(\n store,\n )}:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)\n if (!tokens.admin) {\n throw MissingAdminTokenError\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n * @param store - Store fqdn to request auth for\n * @param password - Password generated from Theme Access app\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token and store\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${token.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreName(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * This method ensures that we have a valid session to authenticate against the given applications using the provided scopes.\n * @param applications - An object containing the applications we need to be authenticated with.\n * @returns An instance with the access tokens organized by application.\n */\nexport async function ensureAuthenticated(\n applications: OAuthApplications,\n env = process.env,\n forceRefresh = false,\n): Promise<OAuthSession> {\n const fqdn = await identityFqdn()\n\n const previousStoreFqdn = applications.adminApi?.storeFqdn\n if (previousStoreFqdn) {\n const normalizedStoreName = await normalizeStoreName(previousStoreFqdn)\n if (previousStoreFqdn === applications.adminApi?.storeFqdn) {\n applications.adminApi.storeFqdn = normalizedStoreName\n }\n }\n\n const currentSession = (await secureStore.fetch()) || {}\n const fqdnSession = currentSession[fqdn]!\n const scopes = getFlattenScopes(applications)\n\n debug(content`Validating existing session against the scopes:\n${token.json(scopes)}\nFor applications:\n${token.json(applications)}\n`)\n const validationResult = await validateSession(scopes, applications, fqdnSession)\n\n let newSession = {}\n\n if (validationResult === 'needs_full_auth') {\n debug(content`Initiating the full authentication flow...`)\n newSession = await executeCompleteFlow(applications, fqdn)\n } else if (validationResult === 'needs_refresh' || forceRefresh) {\n debug(content`The current session is valid but needs refresh. Refreshing...`)\n try {\n newSession = await refreshTokens(fqdnSession.identity, applications, fqdn)\n } catch (error) {\n if (error instanceof InvalidGrantError) {\n newSession = await executeCompleteFlow(applications, fqdn)\n } else if (error instanceof InvalidRequestError) {\n await secureStore.remove()\n throw new AbortError('\\nError validating auth session', \"We've cleared the current session, please try again\")\n } else {\n throw error\n }\n }\n }\n\n const completeSession: Session = {...currentSession, ...newSession}\n await secureStore.store(completeSession)\n const tokens = await tokensFor(applications, completeSession, fqdn)\n\n // Overwrite partners token if using a custom CLI Token\n const envToken = env[constants.environmentVariables.partnersToken]\n if (envToken && applications.partnersApi) {\n tokens.partners = (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n if (!envToken && tokens.partners) {\n await ensureUserHasPartnerAccount(tokens.partners)\n }\n\n return tokens\n}\n\nexport async function hasPartnerAccount(partnersToken: string): Promise<boolean> {\n try {\n await partnersRequest(\n gql`\n {\n organizations(first: 1) {\n nodes {\n id\n }\n }\n }\n `,\n partnersToken,\n )\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n if (error instanceof RequestClientError && error.statusCode === 404) {\n return false\n } else {\n return true\n }\n }\n}\n\n/**\n * If the user creates an account from the Identity website, the created\n * account won't get a Partner organization created. We need to detect that\n * and take the user to create a partner organization.\n * @param partnersToken - Partners token\n */\nexport async function ensureUserHasPartnerAccount(partnersToken: string) {\n debug(content`Verifying that the user has a Partner organization`)\n if (!(await hasPartnerAccount(partnersToken))) {\n output.info(`\\nA Shopify Partners organization is needed to proceed.`)\n output.info(`👉 Press any key to create one`)\n await keypress()\n await open(`https://${await partnersFqdn()}/signup`)\n output.info(output.content`👉 Press any key when you have ${output.token.cyan('created the organization')}`)\n output.warn(output.content`Make sure you've confirmed your Shopify and the Partner organization from the email`)\n await keypress()\n if (!(await hasPartnerAccount(partnersToken))) {\n throw new Abort(\n `Couldn't find your Shopify Partners organization`,\n `Have you confirmed your accounts from the emails you received?`,\n )\n }\n }\n}\n\nasync function executeCompleteFlow(applications: OAuthApplications, identityFqdn: string): Promise<Session> {\n const scopes = getFlattenScopes(applications)\n const exchangeScopes = getExchangeScopes(applications)\n const store = applications.adminApi?.storeFqdn\n if (firstPartyDev()) {\n debug(content`Authenticating as Shopify Employee...`)\n scopes.push('employee')\n }\n\n let identityToken: IdentityToken\n if (useDeviceAuth()) {\n // Request a device code to authorize without a browser redirect.\n debug(content`Requesting device authorization code...`)\n const deviceAuth = await requestDeviceAuthorization(scopes)\n\n // Poll for the identity token\n debug(content`Starting polling for the identity token...`)\n identityToken = await pollForDeviceAuthorization(deviceAuth.deviceCode, deviceAuth.interval)\n } else {\n // Authorize user via browser\n debug(content`Authorizing through Identity's website...`)\n const code = await authorize(scopes)\n\n // Exchange code for identity token\n debug(content`Authorization code received. Exchanging it for a CLI token...`)\n identityToken = await exchangeCodeForAccessToken(code)\n }\n\n // Exchange identity token for application tokens\n debug(content`CLI token received. Exchanging it for application tokens...`)\n const result = await exchangeAccessForApplicationTokens(identityToken, exchangeScopes, store)\n\n const session: Session = {\n [identityFqdn]: {\n identity: identityToken,\n applications: result,\n },\n }\n\n output.completed('Logged in.')\n\n return session\n}\n\nasync function refreshTokens(token: IdentityToken, applications: OAuthApplications, fqdn: string): Promise<Session> {\n // Refresh Identity Token\n const identityToken = await refreshAccessToken(token)\n // Exchange new identity token for application tokens\n const exchangeScopes = getExchangeScopes(applications)\n const applicationTokens = await exchangeAccessForApplicationTokens(\n identityToken,\n exchangeScopes,\n applications.adminApi?.storeFqdn,\n )\n\n return {\n [fqdn]: {\n identity: identityToken,\n applications: applicationTokens,\n },\n }\n}\n\nasync function tokensFor(applications: OAuthApplications, session: Session, fqdn: string): Promise<OAuthSession> {\n const fqdnSession = session[fqdn]\n if (!fqdnSession) {\n throw NoSessionError\n }\n const tokens: OAuthSession = {}\n if (applications.adminApi) {\n const appId = applicationId('admin')\n const realAppId = `${applications.adminApi.storeFqdn}-${appId}`\n const token = fqdnSession.applications[realAppId]?.accessToken\n if (token) {\n tokens.admin = {token, storeFqdn: applications.adminApi.storeFqdn}\n }\n }\n\n if (applications.partnersApi) {\n const appId = applicationId('partners')\n tokens.partners = fqdnSession.applications[appId]?.accessToken\n }\n\n if (applications.storefrontRendererApi) {\n const appId = applicationId('storefront-renderer')\n tokens.storefront = fqdnSession.applications[appId]?.accessToken\n }\n return tokens\n}\n\n// Scope Helpers\nfunction getFlattenScopes(apps: OAuthApplications): string[] {\n const admin = apps.adminApi?.scopes || []\n const partner = apps.partnersApi?.scopes || []\n const storefront = apps.storefrontRendererApi?.scopes || []\n const requestedScopes = [...admin, ...partner, ...storefront]\n return allDefaultScopes(requestedScopes)\n}\n\nfunction getExchangeScopes(apps: OAuthApplications): ExchangeScopes {\n const adminScope = apps.adminApi?.scopes || []\n const partnerScope = apps.partnersApi?.scopes || []\n const storefrontScopes = apps.storefrontRendererApi?.scopes || []\n return {\n admin: apiScopes('admin', adminScope),\n partners: apiScopes('partners', partnerScope),\n storefront: apiScopes('storefront-renderer', storefrontScopes),\n }\n}\n\nexport function logout() {\n return secureStore.remove()\n}\n"]}
package/dist/system.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /// <reference types="node" />
2
- import { AbortSignal } from './public/node/abort.js';
3
- import type { Writable, Readable } from 'stream';
4
- export interface ExecOptions {
5
- cwd?: string;
6
- env?: {
7
- [key: string]: string | undefined;
8
- };
9
- stdin?: Readable | 'inherit';
10
- stdout?: Writable | 'inherit';
11
- stderr?: Writable | 'inherit';
12
- stdio?: 'inherit';
13
- input?: string;
14
- signal?: AbortSignal;
15
- }
16
- export declare type WritableExecOptions = Omit<ExecOptions, 'stdout'> & {
17
- stdout?: Writable;
18
- };
19
- export declare const open: (url: string) => Promise<void>;
20
- /**
21
- * Runs a command asynchronously, aggregates the stdout data, and returns it.
22
- * @param command - Command to be executed.
23
- * @param args - Arguments to pass to the command.
24
- * @returns A promise that resolves with the aggregatted stdout of the command.
25
- */
26
- export declare const captureOutput: (command: string, args: string[], options?: ExecOptions) => Promise<string>;
27
- export declare const exec: (command: string, args: string[], options?: ExecOptions) => Promise<void>;
28
- interface ConcurrentExecCommand {
29
- prefix: string;
30
- executable: string;
31
- args: string[];
32
- cwd: string;
33
- }
34
- /**
35
- * Runs commands concurrently and combines the standard output and error data
36
- * into a single stream. See {@link renderConcurrent} for more information about
37
- * the output format.
38
- *
39
- * If one of the processes fails, it aborts the running ones and exits with that error.
40
- * @param commands - Commands to execute.
41
- */
42
- export declare const concurrentExec: (commands: ConcurrentExecCommand[]) => Promise<void>;
43
- /**
44
- * Displays a large file using the terminal pager set by the user, or a
45
- * reasonable default for the user's OS:
46
- *
47
- * @param filename - The path to the file to be displayed.
48
- */
49
- export declare function page(filename: string): Promise<void>;
50
- export declare function sleep(seconds: number): Promise<unknown>;
51
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAC,KAAK,EAAE,aAAa,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAehC,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACxC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAAe,EAAE,IAAc,EAAE,OAAqB,EAAmB,EAAE;IAC7G,MAAM,MAAM,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,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;oBACvC,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE;wBAC3C,MAAM;wBACN,MAAM;wBACN,GAAG,EAAE,OAAO,CAAC,GAAG;wBAChB,MAAM;qBACP,CAAC,CAAA;gBACJ,CAAC;aACF,CAAA;QACH,CAAC,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,QAAgB;IACzC,IAAI,UAAkB,CAAA;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACrB,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;KAC/B;SAAM,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC3D,UAAU,GAAG,MAAM,CAAA;KACpB;SAAM;QACL,UAAU,GAAG,UAAU,CAAA;KACxB;IACD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC/D,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {shouldDisplayColors, debug} from './output.js'\nimport {platformAndArch} from './public/node/os.js'\nimport {Abort, ExternalError} from './error.js'\nimport {renderConcurrent} from './public/node/ui.js'\nimport {AbortSignal} from './public/node/abort.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport treeKill from 'tree-kill'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n}\nexport type WritableExecOptions = Omit<ExecOptions, 'stdout'> & {stdout?: Writable}\n\nexport const open = async (url: string) => {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport const captureOutput = async (command: string, args: string[], options?: ExecOptions): Promise<string> => {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\nexport const exec = async (command: string, args: string[], options?: ExecOptions) => {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr)\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout)\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n aborted = true\n treeKill(pid, (err) => {\n if (err) throw new Abort(`Failed to kill process ${pid}: ${err}`)\n })\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n}\n\nconst buildExec = (command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> => {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n debug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? process.cwd()}\n`)\n return commandProcess\n}\n\ninterface ConcurrentExecCommand {\n prefix: string\n executable: string\n args: string[]\n cwd: string\n}\n\n/**\n * Runs commands concurrently and combines the standard output and error data\n * into a single stream. See {@link renderConcurrent} for more information about\n * the output format.\n *\n * If one of the processes fails, it aborts the running ones and exits with that error.\n * @param commands - Commands to execute.\n */\nexport const concurrentExec = async (commands: ConcurrentExecCommand[]): Promise<void> => {\n await renderConcurrent({\n processes: commands.map((command) => {\n return {\n prefix: command.prefix,\n action: async (stdout, stderr, signal) => {\n await exec(command.executable, command.args, {\n stdout,\n stderr,\n cwd: command.cwd,\n signal,\n })\n },\n }\n }),\n })\n}\n\n/**\n * Displays a large file using the terminal pager set by the user, or a\n * reasonable default for the user's OS:\n *\n * @param filename - The path to the file to be displayed.\n */\nexport async function page(filename: string) {\n let executable: string\n if (process.env.PAGER) {\n executable = process.env.PAGER\n } else if ((await platformAndArch()).platform === 'windows') {\n executable = 'more'\n } else {\n executable = 'less -NR'\n }\n const [command, ...args] = [...executable.split(' '), filename]\n await exec(command, args, {stdout: 'inherit', stdin: 'inherit'})\n}\n\nexport async function sleep(seconds: number) {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n"]}