@shopify/cli-kit 3.32.0 → 3.33.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 (211) hide show
  1. package/dist/constants.d.ts +0 -1
  2. package/dist/constants.js +0 -1
  3. package/dist/constants.js.map +1 -1
  4. package/dist/environment/local.d.ts +0 -1
  5. package/dist/environment/local.js +0 -3
  6. package/dist/environment/local.js.map +1 -1
  7. package/dist/http/fetch.js +1 -1
  8. package/dist/http/fetch.js.map +1 -1
  9. package/dist/http.d.ts +0 -1
  10. package/dist/http.js +0 -1
  11. package/dist/http.js.map +1 -1
  12. package/dist/index.d.ts +0 -6
  13. package/dist/index.js +0 -6
  14. package/dist/index.js.map +1 -1
  15. package/dist/npm.js +1 -1
  16. package/dist/npm.js.map +1 -1
  17. package/dist/private/common/array.d.ts +1 -0
  18. package/dist/private/common/array.js +4 -0
  19. package/dist/private/common/array.js.map +1 -0
  20. package/dist/private/node/analytics.js +2 -2
  21. package/dist/private/node/analytics.js.map +1 -1
  22. package/dist/private/node/api/graphql.d.ts +5 -0
  23. package/dist/private/node/api/graphql.js +63 -0
  24. package/dist/private/node/api/graphql.js.map +1 -0
  25. package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
  26. package/dist/{api/common.js → private/node/api/headers.js} +20 -60
  27. package/dist/private/node/api/headers.js.map +1 -0
  28. package/dist/private/node/api/rest.d.ts +6 -0
  29. package/dist/private/node/api/rest.js +27 -0
  30. package/dist/private/node/api/rest.js.map +1 -0
  31. package/dist/private/node/ui/components/FullScreen.js +11 -9
  32. package/dist/private/node/ui/components/FullScreen.js.map +1 -1
  33. package/dist/private/node/ui/components/SelectPrompt.js +15 -3
  34. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  35. package/dist/private/node/ui/components/Subdued.d.ts +9 -0
  36. package/dist/private/node/ui/components/Subdued.js +10 -0
  37. package/dist/private/node/ui/components/Subdued.js.map +1 -0
  38. package/dist/private/node/ui/components/Subdued.test.d.ts +1 -0
  39. package/dist/private/node/ui/components/Subdued.test.js +11 -0
  40. package/dist/private/node/ui/components/Subdued.test.js.map +1 -0
  41. package/dist/private/node/ui/components/Table.js +1 -1
  42. package/dist/private/node/ui/components/Table.js.map +1 -1
  43. package/dist/private/node/ui/components/TokenizedText.d.ts +4 -1
  44. package/dist/private/node/ui/components/TokenizedText.js +4 -0
  45. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  46. package/dist/private/node/ui/components/TokenizedText.test.js +4 -1
  47. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  48. package/dist/public/common/array.d.ts +4 -0
  49. package/dist/public/common/array.js +4 -0
  50. package/dist/public/common/array.js.map +1 -1
  51. package/dist/public/common/collection.js.map +1 -1
  52. package/dist/public/common/object.d.ts +3 -3
  53. package/dist/public/common/object.js +5 -7
  54. package/dist/public/common/object.js.map +1 -1
  55. package/dist/public/common/string.d.ts +55 -1
  56. package/dist/public/common/string.js +93 -1
  57. package/dist/public/common/string.js.map +1 -1
  58. package/dist/public/common/url.d.ts +2 -1
  59. package/dist/public/common/url.js +3 -2
  60. package/dist/public/common/url.js.map +1 -1
  61. package/dist/public/node/api/admin.d.ts +41 -0
  62. package/dist/public/node/api/admin.js +98 -0
  63. package/dist/public/node/api/admin.js.map +1 -0
  64. package/dist/public/node/api/oxygen.d.ts +22 -0
  65. package/dist/public/node/api/oxygen.js +40 -0
  66. package/dist/public/node/api/oxygen.js.map +1 -0
  67. package/dist/{api → public/node/api}/partners.d.ts +11 -3
  68. package/dist/public/node/api/partners.js +45 -0
  69. package/dist/public/node/api/partners.js.map +1 -0
  70. package/dist/public/node/base-command.js +1 -1
  71. package/dist/public/node/base-command.js.map +1 -1
  72. package/dist/public/node/crypto.d.ts +42 -0
  73. package/dist/public/node/crypto.js +55 -0
  74. package/dist/public/node/crypto.js.map +1 -0
  75. package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
  76. package/dist/{template.js → public/node/liquid.js} +18 -13
  77. package/dist/public/node/liquid.js.map +1 -0
  78. package/dist/public/node/os.d.ts +16 -0
  79. package/dist/{os.js → public/node/os.js} +33 -28
  80. package/dist/public/node/os.js.map +1 -0
  81. package/dist/public/node/presets.js +2 -2
  82. package/dist/public/node/presets.js.map +1 -1
  83. package/dist/public/node/ruby.d.ts +11 -7
  84. package/dist/public/node/ruby.js +90 -22
  85. package/dist/public/node/ruby.js.map +1 -1
  86. package/dist/public/node/tcp.d.ts +2 -0
  87. package/dist/public/node/tcp.js +9 -0
  88. package/dist/public/node/tcp.js.map +1 -1
  89. package/dist/public/node/toml.d.ts +15 -0
  90. package/dist/public/node/toml.js +20 -0
  91. package/dist/public/node/toml.js.map +1 -0
  92. package/dist/public/node/ui.d.ts +1 -1
  93. package/dist/public/node/ui.js.map +1 -1
  94. package/dist/public/node/vscode.d.ts +14 -0
  95. package/dist/{vscode.js → public/node/vscode.js} +13 -7
  96. package/dist/public/node/vscode.js.map +1 -0
  97. package/dist/session/authorize.d.ts +4 -0
  98. package/dist/session/authorize.js +7 -2
  99. package/dist/session/authorize.js.map +1 -1
  100. package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
  101. package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
  102. package/dist/session/identity-token-validation.js.map +1 -0
  103. package/dist/session/schema.d.ts +18 -18
  104. package/dist/session/store.js +1 -1
  105. package/dist/session/store.js.map +1 -1
  106. package/dist/session/validate.js +2 -2
  107. package/dist/session/validate.js.map +1 -1
  108. package/dist/session.js +3 -3
  109. package/dist/session.js.map +1 -1
  110. package/dist/system.js +1 -1
  111. package/dist/system.js.map +1 -1
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/dist/ui/inquirer/autocomplete.js +1 -1
  114. package/dist/ui/inquirer/autocomplete.js.map +1 -1
  115. package/package.json +2 -2
  116. package/dist/api/admin.d.ts +0 -3
  117. package/dist/api/admin.js +0 -56
  118. package/dist/api/admin.js.map +0 -1
  119. package/dist/api/common.js.map +0 -1
  120. package/dist/api/graphql/all_app_extension_registrations.d.ts +0 -20
  121. package/dist/api/graphql/all_app_extension_registrations.js +0 -20
  122. package/dist/api/graphql/all_app_extension_registrations.js.map +0 -1
  123. package/dist/api/graphql/all_dev_stores_by_org.d.ts +0 -18
  124. package/dist/api/graphql/all_dev_stores_by_org.js +0 -21
  125. package/dist/api/graphql/all_dev_stores_by_org.js.map +0 -1
  126. package/dist/api/graphql/all_orgs.d.ts +0 -12
  127. package/dist/api/graphql/all_orgs.js +0 -14
  128. package/dist/api/graphql/all_orgs.js.map +0 -1
  129. package/dist/api/graphql/convert_dev_to_test_store.d.ts +0 -16
  130. package/dist/api/graphql/convert_dev_to_test_store.js +0 -13
  131. package/dist/api/graphql/convert_dev_to_test_store.js.map +0 -1
  132. package/dist/api/graphql/create_app.d.ts +0 -29
  133. package/dist/api/graphql/create_app.js +0 -33
  134. package/dist/api/graphql/create_app.js.map +0 -1
  135. package/dist/api/graphql/create_deployment.d.ts +0 -33
  136. package/dist/api/graphql/create_deployment.js +0 -25
  137. package/dist/api/graphql/create_deployment.js.map +0 -1
  138. package/dist/api/graphql/extension_create.d.ts +0 -30
  139. package/dist/api/graphql/extension_create.js +0 -26
  140. package/dist/api/graphql/extension_create.js.map +0 -1
  141. package/dist/api/graphql/extension_specifications.d.ts +0 -27
  142. package/dist/api/graphql/extension_specifications.js +0 -22
  143. package/dist/api/graphql/extension_specifications.js.map +0 -1
  144. package/dist/api/graphql/find_app.d.ts +0 -14
  145. package/dist/api/graphql/find_app.js +0 -17
  146. package/dist/api/graphql/find_app.js.map +0 -1
  147. package/dist/api/graphql/find_org.d.ts +0 -18
  148. package/dist/api/graphql/find_org.js +0 -21
  149. package/dist/api/graphql/find_org.js.map +0 -1
  150. package/dist/api/graphql/find_org_basic.d.ts +0 -11
  151. package/dist/api/graphql/find_org_basic.js +0 -14
  152. package/dist/api/graphql/find_org_basic.js.map +0 -1
  153. package/dist/api/graphql/find_store_by_domain.d.ts +0 -21
  154. package/dist/api/graphql/find_store_by_domain.js +0 -24
  155. package/dist/api/graphql/find_store_by_domain.js.map +0 -1
  156. package/dist/api/graphql/functions/api_schema_definition.d.ts +0 -9
  157. package/dist/api/graphql/functions/api_schema_definition.js +0 -7
  158. package/dist/api/graphql/functions/api_schema_definition.js.map +0 -1
  159. package/dist/api/graphql/functions/app_function_set.d.ts +0 -30
  160. package/dist/api/graphql/functions/app_function_set.js +0 -38
  161. package/dist/api/graphql/functions/app_function_set.js.map +0 -1
  162. package/dist/api/graphql/functions/function_service_proxy.d.ts +0 -4
  163. package/dist/api/graphql/functions/function_service_proxy.js +0 -7
  164. package/dist/api/graphql/functions/function_service_proxy.js.map +0 -1
  165. package/dist/api/graphql/functions/upload_url_generate.d.ts +0 -12
  166. package/dist/api/graphql/functions/upload_url_generate.js +0 -11
  167. package/dist/api/graphql/functions/upload_url_generate.js.map +0 -1
  168. package/dist/api/graphql/generate_signed_upload_url.d.ts +0 -15
  169. package/dist/api/graphql/generate_signed_upload_url.js +0 -15
  170. package/dist/api/graphql/generate_signed_upload_url.js.map +0 -1
  171. package/dist/api/graphql/get_urls.d.ts +0 -10
  172. package/dist/api/graphql/get_urls.js +0 -10
  173. package/dist/api/graphql/get_urls.js.map +0 -1
  174. package/dist/api/graphql/get_variant_id.d.ts +0 -17
  175. package/dist/api/graphql/get_variant_id.js +0 -20
  176. package/dist/api/graphql/get_variant_id.js.map +0 -1
  177. package/dist/api/graphql/index.d.ts +0 -21
  178. package/dist/api/graphql/index.js +0 -22
  179. package/dist/api/graphql/index.js.map +0 -1
  180. package/dist/api/graphql/update_draft.d.ts +0 -33
  181. package/dist/api/graphql/update_draft.js +0 -24
  182. package/dist/api/graphql/update_draft.js.map +0 -1
  183. package/dist/api/graphql/update_urls.d.ts +0 -14
  184. package/dist/api/graphql/update_urls.js +0 -12
  185. package/dist/api/graphql/update_urls.js.map +0 -1
  186. package/dist/api/identity.js.map +0 -1
  187. package/dist/api/oxygen.d.ts +0 -5
  188. package/dist/api/oxygen.js +0 -30
  189. package/dist/api/oxygen.js.map +0 -1
  190. package/dist/api/partners.js +0 -44
  191. package/dist/api/partners.js.map +0 -1
  192. package/dist/api.d.ts +0 -6
  193. package/dist/api.js +0 -7
  194. package/dist/api.js.map +0 -1
  195. package/dist/http/graphql.d.ts +0 -13
  196. package/dist/http/graphql.js +0 -12
  197. package/dist/http/graphql.js.map +0 -1
  198. package/dist/os.d.ts +0 -11
  199. package/dist/os.js.map +0 -1
  200. package/dist/public/node/checksum.d.ts +0 -20
  201. package/dist/public/node/checksum.js +0 -32
  202. package/dist/public/node/checksum.js.map +0 -1
  203. package/dist/string.d.ts +0 -28
  204. package/dist/string.js +0 -77
  205. package/dist/string.js.map +0 -1
  206. package/dist/template.js.map +0 -1
  207. package/dist/toml.d.ts +0 -3
  208. package/dist/toml.js +0 -8
  209. package/dist/toml.js.map +0 -1
  210. package/dist/vscode.d.ts +0 -8
  211. package/dist/vscode.js.map +0 -1
@@ -4,7 +4,9 @@ import { sleep } from '../../system.js';
4
4
  import * as port from 'get-port-please';
5
5
  /**
6
6
  * Returns an available port in the current environment.
7
+ *
7
8
  * @returns A promise that resolves with an availabe port.
9
+ * @example
8
10
  */
9
11
  export async function getAvailableTCPPort() {
10
12
  debug(content `Getting a random port...`);
@@ -12,6 +14,13 @@ export async function getAvailableTCPPort() {
12
14
  debug(content `Random port obtained: ${token.raw(`${randomPort}`)}`);
13
15
  return randomPort;
14
16
  }
17
+ /**
18
+ * Given a function, it runs it and retries in case of failiure up to the provided number of times.
19
+ *
20
+ * @param execute - The function to execute.
21
+ * @param maxTries - The maximum retries.
22
+ * @param waitTimeInSeconds - The time to wait between retries.
23
+ */
15
24
  async function retryOnError(execute, maxTries = 5, waitTimeInSeconds = 1) {
16
25
  let retryCount = 1;
17
26
  while (true) {
@@ -1 +1 @@
1
- {"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACjE,KAAK,CAAC,OAAO,CAAA,yBAAyB,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IACnE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,KAAK,UAAU,YAAY,CAAI,OAAgB,EAAE,QAAQ,GAAG,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAClF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,OAAO,IAAI,EAAE;QACX,IAAI;YACF,4CAA4C;YAC5C,OAAO,MAAM,OAAO,EAAE,CAAA;YACtB,8DAA8D;SAC/D;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,UAAU,EAAE,GAAG,QAAQ,EAAE;gBAC3B,KAAK,CAAC,OAAO,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACvE,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;KACF;AACH,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport {sleep} from '../../system.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n * @returns A promise that resolves with an availabe port.\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACjE,KAAK,CAAC,OAAO,CAAA,yBAAyB,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IACnE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAI,OAAgB,EAAE,QAAQ,GAAG,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAClF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,OAAO,IAAI,EAAE;QACX,IAAI;YACF,4CAA4C;YAC5C,OAAO,MAAM,OAAO,EAAE,CAAA;YACtB,8DAA8D;SAC/D;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,UAAU,EAAE,GAAG,QAAQ,EAAE;gBAC3B,KAAK,CAAC,OAAO,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACvE,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;KACF;AACH,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport {sleep} from '../../system.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n *\n * @returns A promise that resolves with an availabe port.\n * @example\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import * as toml from '@iarna/toml';
2
+ /**
3
+ * Given a TOML string, it returns a JSON object.
4
+ *
5
+ * @param input - TOML string.
6
+ * @returns JSON object.
7
+ */
8
+ export declare function decodeToml(input: string): object;
9
+ /**
10
+ * Given a JSON object, it returns a TOML string.
11
+ *
12
+ * @param content - JSON object.
13
+ * @returns TOML string.
14
+ */
15
+ export declare function encodeToml(content: toml.JsonMap): string;
@@ -0,0 +1,20 @@
1
+ import * as toml from '@iarna/toml';
2
+ /**
3
+ * Given a TOML string, it returns a JSON object.
4
+ *
5
+ * @param input - TOML string.
6
+ * @returns JSON object.
7
+ */
8
+ export function decodeToml(input) {
9
+ return toml.parse(input);
10
+ }
11
+ /**
12
+ * Given a JSON object, it returns a TOML string.
13
+ *
14
+ * @param content - JSON object.
15
+ * @returns TOML string.
16
+ */
17
+ export function encodeToml(content) {
18
+ return toml.stringify(content);
19
+ }
20
+ //# sourceMappingURL=toml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toml.js","sourceRoot":"","sources":["../../../src/public/node/toml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqB;IAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as toml from '@iarna/toml'\n\n/**\n * Given a TOML string, it returns a JSON object.\n *\n * @param input - TOML string.\n * @returns JSON object.\n */\nexport function decodeToml(input: string): object {\n return toml.parse(input)\n}\n\n/**\n * Given a JSON object, it returns a TOML string.\n *\n * @param content - JSON object.\n * @returns TOML string.\n */\nexport function encodeToml(content: toml.JsonMap): string {\n return toml.stringify(content)\n}\n"]}
@@ -169,7 +169,7 @@ export declare function renderFatalError(error: Fatal): void;
169
169
 
170
170
  * navigate with arrows, enter to select
171
171
  */
172
- export declare function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<unknown>;
172
+ export declare function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T>;
173
173
  /**
174
174
  * Runs async tasks and displays their progress to the console.
175
175
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,gDAAgD,CAAA;AACzE,OAAO,EAAC,YAAY,EAA6B,MAAM,kDAAkD,CAAA;AACzG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAA2B,MAAM,gDAAgD,CAAA;AACnG,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAS3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,SAAS,EACT,eAAe,EACf,cAAc,GAAG,IAAI,EACrB,aAAa,GAAG,EAAE,GACM;IACxB,OAAO,MAAM,CACX,oBAAC,gBAAgB,IACf,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,IAAI,IAAI,eAAe,EAAE,EACzD,cAAc,EAAE,cAAc,GAC9B,EACF,aAAa,CACd,CAAA;AACH,CAAC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,OAAO,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;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AC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC7E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {consoleError, OutputProcess} from '../../output.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n\n * Automations\n * (7) fifth\n * (8) sixth\n\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n\n * navigate with arrows, enter to select\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>) {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport function renderTasks(tasks: Task[]) {\n return render(<Tasks tasks={tasks} />)\n}\n\n/**\n * Renders a text prompt to the console.\n *\n * ? What is your name?\n * \\> John\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>) {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA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;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,OAAO,UAAU,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;AACxE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAA6C;IACjF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,YAAY,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC1E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwC;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,UAAU,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC7E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {consoleError, OutputProcess} from '../../output.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n\n * Automations\n * (7) fifth\n * (8) sixth\n\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n\n * navigate with arrows, enter to select\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T> {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport function renderTasks(tasks: Task[]) {\n return render(<Tasks tasks={tasks} />)\n}\n\n/**\n * Renders a text prompt to the console.\n *\n * ? What is your name?\n * \\> John\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>) {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if user editor is VS Code.
3
+ *
4
+ * @param root - Root directory to start searching for .vscode directory.
5
+ * @returns True if user editor is VS Code.
6
+ */
7
+ export declare function isVSCode(root?: string): Promise<boolean>;
8
+ /**
9
+ * Add VSCode extension recommendations.
10
+ *
11
+ * @param directory - Directory that contains the .vscode folder.
12
+ * @param recommendations - List of VSCode extensions to recommend.
13
+ */
14
+ export declare function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void>;
@@ -1,19 +1,25 @@
1
- import { exists, write, read } from './file.js';
2
- import { findUp, join } from './path.js';
3
- import { content, token, debug } from './output.js';
1
+ import { exists, write, read } from '../../file.js';
2
+ import { findUp, join } from '../../path.js';
3
+ import { content, token, debug } from '../../output.js';
4
4
  /**
5
- * Check if user editor is VS Code
5
+ * Check if user editor is VS Code.
6
+ *
7
+ * @param root - Root directory to start searching for .vscode directory.
8
+ * @returns True if user editor is VS Code.
6
9
  */
7
- export const isVSCode = async (root = process.cwd()) => {
10
+ export async function isVSCode(root = process.cwd()) {
8
11
  debug(content `Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `);
9
12
  const config = await findUp(join(root, '.vscode'), { type: 'directory' });
10
13
  if (!config) {
11
14
  return false;
12
15
  }
13
16
  return exists(config);
14
- };
17
+ }
15
18
  /**
16
- * Add VSCode extension recommendations
19
+ * Add VSCode extension recommendations.
20
+ *
21
+ * @param directory - Directory that contains the .vscode folder.
22
+ * @param recommendations - List of VSCode extensions to recommend.
17
23
  */
18
24
  export async function addRecommendedExtensions(directory, recommendations) {
19
25
  debug(content `Adding VSCode recommended extensions at ${token.path(directory)}:
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../../../src/public/node/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;IACjD,KAAK,CAAC,OAAO,CAAA,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IAC/G,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,CAAA;IAEvE,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAA;KACb;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAiB,EAAE,eAAyB;IACzF,KAAK,CAAC,OAAO,CAAA,2CAA2C,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;EAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;GAC1B,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;IAEjE,IAAI,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,sBAAsB,GAAG,EAAC,eAAe,EAAE,EAAE,EAAC,CAAA;QAClD,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,CAAA;YACzD,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;SAC5D;QACD,MAAM,iBAAiB,GAAG;YACxB,GAAG,sBAAsB;YACzB,eAAe,EAAE,CAAC,GAAG,sBAAsB,CAAC,eAAe,EAAE,GAAG,eAAe,CAAC;SACjF,CAAA;QACD,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KACxE;AACH,CAAC","sourcesContent":["import {exists, write, read} from '../../file.js'\nimport {findUp, join} from '../../path.js'\nimport {content, token, debug} from '../../output.js'\n\n/**\n * Check if user editor is VS Code.\n *\n * @param root - Root directory to start searching for .vscode directory.\n * @returns True if user editor is VS Code.\n */\nexport async function isVSCode(root = process.cwd()): Promise<boolean> {\n debug(content`Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `)\n const config = await findUp(join(root, '.vscode'), {type: 'directory'})\n\n if (!config) {\n return false\n }\n\n return exists(config)\n}\n\n/**\n * Add VSCode extension recommendations.\n *\n * @param directory - Directory that contains the .vscode folder.\n * @param recommendations - List of VSCode extensions to recommend.\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void> {\n debug(content`Adding VSCode recommended extensions at ${token.path(directory)}:\n${token.json(recommendations)}\n `)\n const extensionsPath = join(directory, '.vscode/extensions.json')\n\n if (await isVSCode(directory)) {\n let originalExtensionsJson = {recommendations: []}\n if (await exists(extensionsPath)) {\n const originalExtensionsFile = await read(extensionsPath)\n originalExtensionsJson = JSON.parse(originalExtensionsFile)\n }\n const newExtensionsJson = {\n ...originalExtensionsJson,\n recommendations: [...originalExtensionsJson.recommendations, ...recommendations],\n }\n await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2))\n }\n}\n"]}
@@ -5,3 +5,7 @@ export interface CodeAuthResult {
5
5
  codeVerifier: string;
6
6
  }
7
7
  export declare function authorize(scopes: string[], state?: string): Promise<CodeAuthResult>;
8
+ export declare function generateRandomChallengePair(): {
9
+ codeVerifier: string;
10
+ codeChallenge: string;
11
+ };
@@ -1,6 +1,6 @@
1
1
  import { listenRedirect } from './redirect-listener.js';
2
2
  import { clientId } from './identity.js';
3
- import { generateRandomChallengePair, randomHex } from '../string.js';
3
+ import { base64URLEncode, randomBytes, randomHex, sha256 } from '../public/node/crypto.js';
4
4
  import { open } from '../system.js';
5
5
  import { Abort, CancelExecution } from '../error.js';
6
6
  import { identity as identityFqdn } from '../environment/fqdn.js';
@@ -13,7 +13,7 @@ export async function authorize(scopes, state = randomHex(30)) {
13
13
  const host = '127.0.0.1';
14
14
  const redirectUri = `http://${host}:${port}`;
15
15
  const fqdn = await identityFqdn();
16
- const identityClientId = await clientId();
16
+ const identityClientId = clientId();
17
17
  await validateRedirectionPortAvailability(port);
18
18
  let url = `http://${fqdn}/oauth/authorize`;
19
19
  const { codeVerifier, codeChallenge } = generateRandomChallengePair();
@@ -37,6 +37,11 @@ export async function authorize(scopes, state = randomHex(30)) {
37
37
  }
38
38
  return { code: result.code, codeVerifier };
39
39
  }
40
+ export function generateRandomChallengePair() {
41
+ const codeVerifier = base64URLEncode(randomBytes(32));
42
+ const codeChallenge = base64URLEncode(sha256(codeVerifier));
43
+ return { codeVerifier, codeChallenge };
44
+ }
40
45
  async function validateRedirectionPortAvailability(port) {
41
46
  const { killPortProcess } = await import('kill-port-process');
42
47
  if (await isPortAvailable(port)) {
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/session/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,2BAA2B,EAAE,SAAS,EAAC,MAAM,cAAc,CAAA;AACnE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAE,kCAAkC,EAAC,MAAM,UAAU,CAAA;AACrE,OAAO,EAAC,SAAS,IAAI,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CACzC,6GAA6G,CAC9G,CAAA;AAOD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAgB,EAAE,QAAgB,SAAS,CAAC,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAG,IAAI,CAAA;IACjB,MAAM,IAAI,GAAG,WAAW,CAAA;IACxB,MAAM,WAAW,GAAG,UAAU,IAAI,IAAI,IAAI,EAAE,CAAA;IAC5C,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,gBAAgB,GAAG,MAAM,QAAQ,EAAE,CAAA;IAEzC,MAAM,mCAAmC,CAAC,IAAI,CAAC,CAAA;IAE/C,IAAI,GAAG,GAAG,UAAU,IAAI,kBAAkB,CAAA;IAE1C,MAAM,EAAC,YAAY,EAAE,aAAa,EAAC,GAAG,2BAA2B,EAAE,CAAA;IAEnE,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,gBAAgB;QAC3B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,YAAY,EAAE,WAAW;QACzB,KAAK;QACL,aAAa,EAAE,MAAM;QACrB,qBAAqB,EAAE,MAAM;QAC7B,cAAc,EAAE,aAAa;KAC9B,CAAA;IAED,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IACjE,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACtE,MAAM,QAAQ,EAAE,CAAA;IAEhB,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;IACxD,MAAM,IAAI,CAAC,GAAG,CAAC,CAAA;IAEf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;QAC1B,MAAM,kBAAkB,CAAA;KACzB;IAED,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAC,CAAA;AAC1C,CAAC;AAED,KAAK,UAAU,mCAAmC,CAAC,IAAY;IAC7D,MAAM,EAAC,eAAe,EAAC,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;IAE3D,IAAI,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE;QAC/B,OAAM;KACP;IAED,IAAI,MAAM,kCAAkC,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE;QACpE,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;KAC5B;SAAM;QACL,MAAM,IAAI,eAAe,EAAE,CAAA;KAC5B;AACH,CAAC","sourcesContent":["import {listenRedirect} from './redirect-listener.js'\nimport {clientId} from './identity.js'\nimport {generateRandomChallengePair, randomHex} from '../string.js'\nimport {open} from '../system.js'\nimport {Abort, CancelExecution} from '../error.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport * as output from '../output.js'\nimport {keypress, terminateBlockingPortProcessPrompt} from '../ui.js'\nimport {checkPort as isPortAvailable} from 'get-port-please'\n\nexport const MismatchStateError = new Abort(\n \"The state received from the authentication doesn't match the one that initiated the authentication process.\",\n)\n\nexport interface CodeAuthResult {\n code: string\n codeVerifier: string\n}\n\nexport async function authorize(scopes: string[], state: string = randomHex(30)): Promise<CodeAuthResult> {\n const port = 3456\n const host = '127.0.0.1'\n const redirectUri = `http://${host}:${port}`\n const fqdn = await identityFqdn()\n const identityClientId = await clientId()\n\n await validateRedirectionPortAvailability(port)\n\n let url = `http://${fqdn}/oauth/authorize`\n\n const {codeVerifier, codeChallenge} = generateRandomChallengePair()\n\n const params = {\n client_id: identityClientId,\n scope: scopes.join(' '),\n redirect_uri: redirectUri,\n state,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n }\n\n output.info('\\nTo run this command, log in to Shopify Partners.')\n output.info('👉 Press any key to open the login page on your browser')\n await keypress()\n\n url = `${url}?${new URLSearchParams(params).toString()}`\n await open(url)\n\n const result = await listenRedirect(host, port, url)\n\n if (result.state !== state) {\n throw MismatchStateError\n }\n\n return {code: result.code, codeVerifier}\n}\n\nasync function validateRedirectionPortAvailability(port: number) {\n const {killPortProcess} = await import('kill-port-process')\n\n if (await isPortAvailable(port)) {\n return\n }\n\n if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {\n await killPortProcess(port)\n } else {\n throw new CancelExecution()\n }\n}\n"]}
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/session/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE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C,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACtE,MAAM,QAAQ,EAAE,CAAA;IAEhB,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;IACxD,MAAM,IAAI,CAAC,GAAG,CAAC,CAAA;IAEf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;QAC1B,MAAM,kBAAkB,CAAA;KACzB;IAED,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAC,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;IACrD,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3D,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,CAAA;AACtC,CAAC;AAED,KAAK,UAAU,mCAAmC,CAAC,IAAY;IAC7D,MAAM,EAAC,eAAe,EAAC,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;IAE3D,IAAI,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE;QAC/B,OAAM;KACP;IAED,IAAI,MAAM,kCAAkC,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE;QACpE,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;KAC5B;SAAM;QACL,MAAM,IAAI,eAAe,EAAE,CAAA;KAC5B;AACH,CAAC","sourcesContent":["import {listenRedirect} from './redirect-listener.js'\nimport {clientId} from './identity.js'\nimport {base64URLEncode, randomBytes, randomHex, sha256} from '../public/node/crypto.js'\nimport {open} from '../system.js'\nimport {Abort, CancelExecution} from '../error.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport * as output from '../output.js'\nimport {keypress, terminateBlockingPortProcessPrompt} from '../ui.js'\nimport {checkPort as isPortAvailable} from 'get-port-please'\n\nexport const MismatchStateError = new Abort(\n \"The state received from the authentication doesn't match the one that initiated the authentication process.\",\n)\n\nexport interface CodeAuthResult {\n code: string\n codeVerifier: string\n}\n\nexport async function authorize(scopes: string[], state: string = randomHex(30)): Promise<CodeAuthResult> {\n const port = 3456\n const host = '127.0.0.1'\n const redirectUri = `http://${host}:${port}`\n const fqdn = await identityFqdn()\n const identityClientId = clientId()\n\n await validateRedirectionPortAvailability(port)\n\n let url = `http://${fqdn}/oauth/authorize`\n\n const {codeVerifier, codeChallenge} = generateRandomChallengePair()\n\n const params = {\n client_id: identityClientId,\n scope: scopes.join(' '),\n redirect_uri: redirectUri,\n state,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n }\n\n output.info('\\nTo run this command, log in to Shopify Partners.')\n output.info('👉 Press any key to open the login page on your browser')\n await keypress()\n\n url = `${url}?${new URLSearchParams(params).toString()}`\n await open(url)\n\n const result = await listenRedirect(host, port, url)\n\n if (result.state !== state) {\n throw MismatchStateError\n }\n\n return {code: result.code, codeVerifier}\n}\n\nexport function generateRandomChallengePair() {\n const codeVerifier = base64URLEncode(randomBytes(32))\n const codeChallenge = base64URLEncode(sha256(codeVerifier))\n return {codeVerifier, codeChallenge}\n}\n\nasync function validateRedirectionPortAvailability(port: number) {\n const {killPortProcess} = await import('kill-port-process')\n\n if (await isPortAvailable(port)) {\n return\n }\n\n if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {\n await killPortProcess(port)\n } else {\n throw new CancelExecution()\n }\n}\n"]}
@@ -38,4 +38,4 @@ async function getInstrospectionEndpoint() {
38
38
  const json = await response.json();
39
39
  return json.introspection_endpoint;
40
40
  }
41
- //# sourceMappingURL=identity.js.map
41
+ //# sourceMappingURL=identity-token-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-token-validation.js","sourceRoot":"","sources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AA;SACb;QACD,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACxG,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n\n if (response.ok && response.headers.get('content-type')?.includes('json')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n } else {\n const text = await response.text()\n debug(`The Introspection request failed with:\n - status: ${response.status}\n - www-authenticate header: ${JSON.stringify(response.headers.get('www-authenticate'))}\n - body: ${JSON.stringify(text)}`)\n return false\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
@@ -8,15 +8,15 @@ declare const IdentityTokenSchema: define.ZodObject<{
8
8
  expiresAt: define.ZodEffects<define.ZodDate, Date, Date>;
9
9
  scopes: define.ZodArray<define.ZodString, "many">;
10
10
  }, "strip", define.ZodTypeAny, {
11
+ scopes: string[];
11
12
  accessToken: string;
12
13
  refreshToken: string;
13
14
  expiresAt: Date;
14
- scopes: string[];
15
15
  }, {
16
+ scopes: string[];
16
17
  accessToken: string;
17
18
  refreshToken: string;
18
19
  expiresAt: Date;
19
- scopes: string[];
20
20
  }>;
21
21
  /**
22
22
  * The schema represents an application token.
@@ -26,13 +26,13 @@ declare const ApplicationTokenSchema: define.ZodObject<{
26
26
  expiresAt: define.ZodEffects<define.ZodDate, Date, Date>;
27
27
  scopes: define.ZodArray<define.ZodString, "many">;
28
28
  }, "strip", define.ZodTypeAny, {
29
+ scopes: string[];
29
30
  accessToken: string;
30
31
  expiresAt: Date;
31
- scopes: string[];
32
32
  }, {
33
+ scopes: string[];
33
34
  accessToken: string;
34
35
  expiresAt: Date;
35
- scopes: string[];
36
36
  }>;
37
37
  /**
38
38
  * This schema represents the format of the session
@@ -69,15 +69,15 @@ export declare const SessionSchema: define.ZodObject<{}, "strip", define.ZodObje
69
69
  expiresAt: define.ZodEffects<define.ZodDate, Date, Date>;
70
70
  scopes: define.ZodArray<define.ZodString, "many">;
71
71
  }, "strip", define.ZodTypeAny, {
72
+ scopes: string[];
72
73
  accessToken: string;
73
74
  refreshToken: string;
74
75
  expiresAt: Date;
75
- scopes: string[];
76
76
  }, {
77
+ scopes: string[];
77
78
  accessToken: string;
78
79
  refreshToken: string;
79
80
  expiresAt: Date;
80
- scopes: string[];
81
81
  }>;
82
82
  /**
83
83
  * It contains exchanged tokens for the applications the CLI
@@ -88,83 +88,83 @@ export declare const SessionSchema: define.ZodObject<{}, "strip", define.ZodObje
88
88
  expiresAt: define.ZodEffects<define.ZodDate, Date, Date>;
89
89
  scopes: define.ZodArray<define.ZodString, "many">;
90
90
  }, "strip", define.ZodTypeAny, {
91
+ scopes: string[];
91
92
  accessToken: string;
92
93
  expiresAt: Date;
93
- scopes: string[];
94
94
  }, {
95
+ scopes: string[];
95
96
  accessToken: string;
96
97
  expiresAt: Date;
97
- scopes: string[];
98
98
  }>, {
99
99
  [x: string]: {
100
+ scopes: string[];
100
101
  accessToken: string;
101
102
  expiresAt: Date;
102
- scopes: string[];
103
103
  };
104
104
  }, {
105
105
  [x: string]: {
106
+ scopes: string[];
106
107
  accessToken: string;
107
108
  expiresAt: Date;
108
- scopes: string[];
109
109
  };
110
110
  }>;
111
111
  }, "strip", define.ZodTypeAny, {
112
112
  identity: {
113
+ scopes: string[];
113
114
  accessToken: string;
114
115
  refreshToken: string;
115
116
  expiresAt: Date;
116
- scopes: string[];
117
117
  };
118
118
  applications: {
119
119
  [x: string]: {
120
+ scopes: string[];
120
121
  accessToken: string;
121
122
  expiresAt: Date;
122
- scopes: string[];
123
123
  };
124
124
  };
125
125
  }, {
126
126
  identity: {
127
+ scopes: string[];
127
128
  accessToken: string;
128
129
  refreshToken: string;
129
130
  expiresAt: Date;
130
- scopes: string[];
131
131
  };
132
132
  applications: {
133
133
  [x: string]: {
134
+ scopes: string[];
134
135
  accessToken: string;
135
136
  expiresAt: Date;
136
- scopes: string[];
137
137
  };
138
138
  };
139
139
  }>, {
140
140
  [x: string]: {
141
141
  identity: {
142
+ scopes: string[];
142
143
  accessToken: string;
143
144
  refreshToken: string;
144
145
  expiresAt: Date;
145
- scopes: string[];
146
146
  };
147
147
  applications: {
148
148
  [x: string]: {
149
+ scopes: string[];
149
150
  accessToken: string;
150
151
  expiresAt: Date;
151
- scopes: string[];
152
152
  };
153
153
  };
154
154
  };
155
155
  }, {
156
156
  [x: string]: {
157
157
  identity: {
158
+ scopes: string[];
158
159
  accessToken: string;
159
160
  refreshToken: string;
160
161
  expiresAt: Date;
161
- scopes: string[];
162
162
  };
163
163
  applications: {
164
164
  [x: string]: {
165
+ scopes: string[];
165
166
  accessToken: string;
166
167
  expiresAt: Date;
167
- scopes: string[];
168
168
  };
169
169
  };
170
170
  };
@@ -1,6 +1,6 @@
1
1
  import { SessionSchema } from './schema.js';
2
2
  import constants from '../constants.js';
3
- import { platformAndArch } from '../os.js';
3
+ import { platformAndArch } from '../public/node/os.js';
4
4
  import { store as secureStore, fetch as secureFetch, remove as secureRemove } from '../secure-store.js';
5
5
  import { content, debug } from '../output.js';
6
6
  import { getSession, removeSession, setSession, clearAllAppInfo } from '../store.js';
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,IAAI,YAAY,EAAC,MAAM,oBAAoB,CAAA;AACrG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAGlF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AAEnC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAgB;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAC3C,IAAI,MAAM,oBAAoB,EAAE,EAAE;QAChC,MAAM,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;KAC3C;SAAM;QACL,MAAM,UAAU,CAAC,WAAW,CAAC,CAAA;KAC9B;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,IAAI,OAAO,CAAA;IACX,IAAI,MAAM,oBAAoB,EAAE,EAAE;QAChC,OAAO,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,CAAA;KACxC;SAAM;QACL,OAAO,GAAG,MAAM,UAAU,EAAE,CAAA;KAC7B;IAED,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACvC,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;IACrE,IAAI,aAAa,CAAC,OAAO,EAAE;QACzB,OAAO,aAAa,CAAC,IAAI,CAAA;KAC1B;SAAM;QACL,MAAM,MAAM,EAAE,CAAA;QACd,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI,MAAM,oBAAoB,EAAE,EAAE;QAChC,MAAM,YAAY,CAAC,UAAU,CAAC,CAAA;KAC/B;SAAM;QACL,MAAM,aAAa,EAAE,CAAA;KACtB;IAED,MAAM,eAAe,EAAE,CAAA;AACzB,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,oBAAoB;IACjC,IAAI;QACF,IAAI,eAAe,EAAE,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC5C,KAAK,CAAC,OAAO,CAAA,uCAAuC,CAAC,CAAA;YACrD,OAAO,KAAK,CAAA;SACb;QACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChE,KAAK,CAAC,OAAO,CAAA,2BAA2B,CAAC,CAAA;QACzC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,OAAO,MAAM,EAAE;QACf,KAAK,CAAC,OAAO,CAAA,6BAA6B,CAAC,CAAA;QAC3C,OAAO,KAAK,CAAA;KACb;AACH,CAAC","sourcesContent":["import {SessionSchema} from './schema.js'\nimport constants from '../constants.js'\nimport {platformAndArch} from '../os.js'\nimport {store as secureStore, fetch as secureFetch, remove as secureRemove} from '../secure-store.js'\nimport {content, debug} from '../output.js'\nimport {getSession, removeSession, setSession, clearAllAppInfo} from '../store.js'\nimport type {Session} from './schema.js'\n\n/**\n * The identifier of the session in the secure store.\n */\nexport const identifier = 'session'\n\n/**\n * Serializes the session as a JSON and stores it securely in the system.\n * If the secure store is not available, the session is stored in the local config.\n * @param session - the session to store.\n */\nexport async function store(session: Session) {\n const jsonSession = JSON.stringify(session)\n if (await secureStoreAvailable()) {\n await secureStore(identifier, jsonSession)\n } else {\n await setSession(jsonSession)\n }\n}\n\n/**\n * Fetches the session from the secure store and returns it.\n * If the secure store is not available, the session is fetched from the local config.\n * If the format of the session is invalid, the method will discard it.\n * In the future might add some logic for supporting migrating the schema\n * of already-persisted sessions.\n * @returns Returns a promise that resolves with the session if it exists and is valid.\n */\nexport async function fetch(): Promise<Session | undefined> {\n let content\n if (await secureStoreAvailable()) {\n content = await secureFetch(identifier)\n } else {\n content = await getSession()\n }\n\n if (!content) {\n return undefined\n }\n const contentJson = JSON.parse(content)\n const parsedSession = await SessionSchema.safeParseAsync(contentJson)\n if (parsedSession.success) {\n return parsedSession.data\n } else {\n await remove()\n return undefined\n }\n}\n\n/**\n * Removes a session from the system.\n */\nexport async function remove() {\n if (await secureStoreAvailable()) {\n await secureRemove(identifier)\n } else {\n await removeSession()\n }\n\n await clearAllAppInfo()\n}\n\n/**\n * Returns true if the secure store is available on the system.\n * Keytar it's not supported on some Linux environments or Windows.\n * More details: https://github.com/Shopify/shopify-cli-planning/issues/261\n * @returns a boolean indicating if the secure store is available.\n */\nasync function secureStoreAvailable(): Promise<boolean> {\n try {\n if (platformAndArch().platform === 'windows') {\n debug(content`Secure store not supported on Windows`)\n return false\n }\n const keytar = await import('keytar')\n await keytar.default.findCredentials(constants.keychain.service)\n debug(content`Secure store is available`)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_error) {\n debug(content`Failed to load secure store`)\n return false\n }\n}\n"]}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CAAC,CAAA;IACrE,IAAI,aAAa,CAAC,OAAO,EAAE;QACzB,OAAO,aAAa,CAAC,IAAI,CAAA;KAC1B;SAAM;QACL,MAAM,MAAM,EAAE,CAAA;QACd,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI,MAAM,oBAAoB,EAAE,EAAE;QAChC,MAAM,YAAY,CAAC,UAAU,CAAC,CAAA;KAC/B;SAAM;QACL,MAAM,aAAa,EAAE,CAAA;KACtB;IAED,MAAM,eAAe,EAAE,CAAA;AACzB,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,oBAAoB;IACjC,IAAI;QACF,IAAI,eAAe,EAAE,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC5C,KAAK,CAAC,OAAO,CAAA,uCAAuC,CAAC,CAAA;YACrD,OAAO,KAAK,CAAA;SACb;QACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChE,KAAK,CAAC,OAAO,CAAA,2BAA2B,CAAC,CAAA;QACzC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,OAAO,MAAM,EAAE;QACf,KAAK,CAAC,OAAO,CAAA,6BAA6B,CAAC,CAAA;QAC3C,OAAO,KAAK,CAAA;KACb;AACH,CAAC","sourcesContent":["import {SessionSchema} from './schema.js'\nimport constants from '../constants.js'\nimport {platformAndArch} from '../public/node/os.js'\nimport {store as secureStore, fetch as secureFetch, remove as secureRemove} from '../secure-store.js'\nimport {content, debug} from '../output.js'\nimport {getSession, removeSession, setSession, clearAllAppInfo} from '../store.js'\nimport type {Session} from './schema.js'\n\n/**\n * The identifier of the session in the secure store.\n */\nexport const identifier = 'session'\n\n/**\n * Serializes the session as a JSON and stores it securely in the system.\n * If the secure store is not available, the session is stored in the local config.\n * @param session - the session to store.\n */\nexport async function store(session: Session) {\n const jsonSession = JSON.stringify(session)\n if (await secureStoreAvailable()) {\n await secureStore(identifier, jsonSession)\n } else {\n await setSession(jsonSession)\n }\n}\n\n/**\n * Fetches the session from the secure store and returns it.\n * If the secure store is not available, the session is fetched from the local config.\n * If the format of the session is invalid, the method will discard it.\n * In the future might add some logic for supporting migrating the schema\n * of already-persisted sessions.\n * @returns Returns a promise that resolves with the session if it exists and is valid.\n */\nexport async function fetch(): Promise<Session | undefined> {\n let content\n if (await secureStoreAvailable()) {\n content = await secureFetch(identifier)\n } else {\n content = await getSession()\n }\n\n if (!content) {\n return undefined\n }\n const contentJson = JSON.parse(content)\n const parsedSession = await SessionSchema.safeParseAsync(contentJson)\n if (parsedSession.success) {\n return parsedSession.data\n } else {\n await remove()\n return undefined\n }\n}\n\n/**\n * Removes a session from the system.\n */\nexport async function remove() {\n if (await secureStoreAvailable()) {\n await secureRemove(identifier)\n } else {\n await removeSession()\n }\n\n await clearAllAppInfo()\n}\n\n/**\n * Returns true if the secure store is available on the system.\n * Keytar it's not supported on some Linux environments or Windows.\n * More details: https://github.com/Shopify/shopify-cli-planning/issues/261\n * @returns a boolean indicating if the secure store is available.\n */\nasync function secureStoreAvailable(): Promise<boolean> {\n try {\n if (platformAndArch().platform === 'windows') {\n debug(content`Secure store not supported on Windows`)\n return false\n }\n const keytar = await import('keytar')\n await keytar.default.findCredentials(constants.keychain.service)\n debug(content`Secure store is available`)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_error) {\n debug(content`Failed to load secure store`)\n return false\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { applicationId } from './identity.js';
2
+ import { validateIdentityToken } from './identity-token-validation.js';
2
3
  import constants from '../constants.js';
3
- import { identity } from '../api.js';
4
4
  import { debug } from '../output.js';
5
5
  import { firstPartyDev } from '../environment/local.js';
6
6
  /**
@@ -23,7 +23,7 @@ export async function validateSession(scopes, applications, session) {
23
23
  if (!session)
24
24
  return 'needs_full_auth';
25
25
  const scopesAreValid = validateScopes(scopes, session.identity);
26
- const identityIsValid = await identity.validateIdentityToken(session.identity.accessToken);
26
+ const identityIsValid = await validateIdentityToken(session.identity.accessToken);
27
27
  if (!scopesAreValid)
28
28
  return 'needs_full_auth';
29
29
  let tokensAreExpired = isTokenExpired(session.identity);
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/session/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAA;AAE3C,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAIrD;;GAEG;AACH,SAAS,cAAc,CAAC,eAAyB,EAAE,QAAuB;IACxE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAA;IACrC,IAAI,aAAa,EAAE,KAAK,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAA;IACxE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAgB,EAChB,YAA+B,EAC/B,OAGC;IAED,IAAI,CAAC,OAAO;QAAE,OAAO,iBAAiB,CAAA;IACtC,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/D,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC1F,IAAI,CAAC,cAAc;QAAE,OAAO,iB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;IACtB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,6BAA6B,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import {applicationId} from './identity.js'\nimport {ApplicationToken, IdentityToken} from './schema.js'\nimport constants from '../constants.js'\nimport {OAuthApplications} from '../session.js'\nimport {identity} from '../api.js'\nimport {debug} from '../output.js'\nimport {firstPartyDev} from '../environment/local.js'\n\ntype ValidationResult = 'needs_refresh' | 'needs_full_auth' | 'ok'\n\n/**\n * Validate if an identity token is valid for the requested scopes\n */\nfunction validateScopes(requestedScopes: string[], identity: IdentityToken) {\n const currentScopes = identity.scopes\n if (firstPartyDev() !== currentScopes.includes('employee')) return false\n return requestedScopes.every((scope) => currentScopes.includes(scope))\n}\n\n/**\n * Validate if the current session is valid or we need to refresh/re-authenticate\n * @param scopes - requested scopes to validate\n * @param applications - requested applications\n * @param session - current session with identity and application tokens\n * @returns 'ok' if the session is valid, 'needs_full_auth' if we need to re-authenticate, 'needs_refresh' if we need to refresh the session\n */\nexport async function validateSession(\n scopes: string[],\n applications: OAuthApplications,\n session: {\n identity: IdentityToken\n applications: {[x: string]: ApplicationToken}\n },\n): Promise<ValidationResult> {\n if (!session) return 'needs_full_auth'\n const scopesAreValid = validateScopes(scopes, session.identity)\n const identityIsValid = await identity.validateIdentityToken(session.identity.accessToken)\n if (!scopesAreValid) return 'needs_full_auth'\n let tokensAreExpired = isTokenExpired(session.identity)\n\n if (applications.partnersApi) {\n const appId = applicationId('partners')\n const token = session.applications[appId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n if (applications.storefrontRendererApi) {\n const appId = applicationId('storefront-renderer')\n const token = session.applications[appId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n if (applications.adminApi) {\n const appId = applicationId('admin')\n const realAppId = `${applications.adminApi.storeFqdn}-${appId}`\n const token = session.applications[realAppId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n debug(`\nThe validation of the token for application/identity completed with the following results:\n- It's expired: ${tokensAreExpired}\n- It's invalid in identity: ${!identityIsValid}\n `)\n\n if (tokensAreExpired) return 'needs_refresh'\n if (!identityIsValid) return 'needs_full_auth'\n return 'ok'\n}\n\nfunction isTokenExpired(token: ApplicationToken): boolean {\n if (!token) return true\n return token.expiresAt < expireThreshold()\n}\n\nfunction expireThreshold(): Date {\n return new Date(Date.now() + constants.session.expirationTimeMarginInMinutes * 60 * 1000)\n}\n"]}
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/session/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAIrD;;GAEG;AACH,SAAS,cAAc,CAAC,eAAyB,EAAE,QAAuB;IACxE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAA;IACrC,IAAI,aAAa,EAAE,KAAK,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAA;IACxE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAgB,EAChB,YAA+B,EAC/B,OAGC;IAED,IAAI,CAAC,OAAO;QAAE,OAAO,iBAAiB,CAAA;IACtC,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/D,MAAM,eAAe,GAAG,MA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AAO,IAAI,CAAA;IACvB,OAAO,KAAK,CAAC,SAAS,GAAG,eAAe,EAAE,CAAA;AAC5C,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,6BAA6B,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import {applicationId} from './identity.js'\nimport {ApplicationToken, IdentityToken} from './schema.js'\nimport {validateIdentityToken} from './identity-token-validation.js'\nimport constants from '../constants.js'\nimport {OAuthApplications} from '../session.js'\nimport {debug} from '../output.js'\nimport {firstPartyDev} from '../environment/local.js'\n\ntype ValidationResult = 'needs_refresh' | 'needs_full_auth' | 'ok'\n\n/**\n * Validate if an identity token is valid for the requested scopes\n */\nfunction validateScopes(requestedScopes: string[], identity: IdentityToken) {\n const currentScopes = identity.scopes\n if (firstPartyDev() !== currentScopes.includes('employee')) return false\n return requestedScopes.every((scope) => currentScopes.includes(scope))\n}\n\n/**\n * Validate if the current session is valid or we need to refresh/re-authenticate\n * @param scopes - requested scopes to validate\n * @param applications - requested applications\n * @param session - current session with identity and application tokens\n * @returns 'ok' if the session is valid, 'needs_full_auth' if we need to re-authenticate, 'needs_refresh' if we need to refresh the session\n */\nexport async function validateSession(\n scopes: string[],\n applications: OAuthApplications,\n session: {\n identity: IdentityToken\n applications: {[x: string]: ApplicationToken}\n },\n): Promise<ValidationResult> {\n if (!session) return 'needs_full_auth'\n const scopesAreValid = validateScopes(scopes, session.identity)\n const identityIsValid = await validateIdentityToken(session.identity.accessToken)\n if (!scopesAreValid) return 'needs_full_auth'\n let tokensAreExpired = isTokenExpired(session.identity)\n\n if (applications.partnersApi) {\n const appId = applicationId('partners')\n const token = session.applications[appId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n if (applications.storefrontRendererApi) {\n const appId = applicationId('storefront-renderer')\n const token = session.applications[appId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n if (applications.adminApi) {\n const appId = applicationId('admin')\n const realAppId = `${applications.adminApi.storeFqdn}-${appId}`\n const token = session.applications[realAppId]!\n tokensAreExpired = tokensAreExpired || isTokenExpired(token)\n }\n\n debug(`\nThe validation of the token for application/identity completed with the following results:\n- It's expired: ${tokensAreExpired}\n- It's invalid in identity: ${!identityIsValid}\n `)\n\n if (tokensAreExpired) return 'needs_refresh'\n if (!identityIsValid) return 'needs_full_auth'\n return 'ok'\n}\n\nfunction isTokenExpired(token: ApplicationToken): boolean {\n if (!token) return true\n return token.expiresAt < expireThreshold()\n}\n\nfunction expireThreshold(): Date {\n return new Date(Date.now() + constants.session.expirationTimeMarginInMinutes * 60 * 1000)\n}\n"]}
package/dist/session.js CHANGED
@@ -11,11 +11,11 @@ import { authorize } from './session/authorize.js';
11
11
  import * as secureStore from './session/store.js';
12
12
  import constants from './constants.js';
13
13
  import * as output from './output.js';
14
- import { partners } from './api.js';
15
- import { RequestClientError } from './api/common.js';
16
14
  import { firstPartyDev, useDeviceAuth } from './environment/local.js';
17
15
  import { pollForDeviceAuthorization, requestDeviceAuthorization } from './session/device-authorization.js';
18
16
  import { AbortError } from './public/node/error.js';
17
+ import { partnersRequest } from './public/node/api/partners.js';
18
+ import { RequestClientError } from './private/node/api/headers.js';
19
19
  import { gql } from 'graphql-request';
20
20
  const NoSessionError = new Bug('No session found after ensuring authenticated');
21
21
  const MissingPartnerTokenError = new Bug('No partners token found after ensuring authenticated');
@@ -153,7 +153,7 @@ ${token.json(applications)}
153
153
  }
154
154
  export async function hasPartnerAccount(partnersToken) {
155
155
  try {
156
- await partners.request(gql `
156
+ await partnersRequest(gql `
157
157
  {
158
158
  organizations(first: 1) {
159
159
  nodes {