@shopify/cli-kit 3.33.0 → 3.34.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 (149) hide show
  1. package/dist/constants.d.ts +2 -5
  2. package/dist/constants.js +0 -3
  3. package/dist/constants.js.map +1 -1
  4. package/dist/file.d.ts +1 -1
  5. package/dist/git.js +1 -1
  6. package/dist/git.js.map +1 -1
  7. package/dist/http.js +2 -2
  8. package/dist/http.js.map +1 -1
  9. package/dist/index.d.ts +0 -4
  10. package/dist/index.js +0 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/metadata.js +1 -1
  13. package/dist/metadata.js.map +1 -1
  14. package/dist/output.js +1 -1
  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 +1 -0
  22. package/dist/private/node/api/graphql.js.map +1 -1
  23. package/dist/private/node/api/headers.js +1 -1
  24. package/dist/private/node/api/headers.js.map +1 -1
  25. package/dist/private/node/api/rest.d.ts +1 -1
  26. package/dist/private/node/api/rest.js.map +1 -1
  27. package/dist/private/node/environment/service.d.ts +18 -0
  28. package/dist/private/node/environment/service.js +32 -0
  29. package/dist/private/node/environment/service.js.map +1 -0
  30. package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
  31. package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
  32. package/dist/private/node/environment/spin-cache.js.map +1 -0
  33. package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
  34. package/dist/{environment → private/node/environment}/utilities.js +0 -0
  35. package/dist/private/node/environment/utilities.js.map +1 -0
  36. package/dist/{session → private/node/session}/authorize.d.ts +1 -5
  37. package/dist/{session → private/node/session}/authorize.js +9 -9
  38. package/dist/private/node/session/authorize.js.map +1 -0
  39. package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
  40. package/dist/{session → private/node/session}/device-authorization.js +7 -9
  41. package/dist/private/node/session/device-authorization.js.map +1 -0
  42. package/dist/{session → private/node/session}/exchange.d.ts +2 -2
  43. package/dist/{session → private/node/session}/exchange.js +5 -5
  44. package/dist/private/node/session/exchange.js.map +1 -0
  45. package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
  46. package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
  47. package/dist/private/node/session/identity-token-validation.js.map +1 -0
  48. package/dist/{session → private/node/session}/identity.d.ts +1 -1
  49. package/dist/{session → private/node/session}/identity.js +2 -3
  50. package/dist/private/node/session/identity.js.map +1 -0
  51. package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
  52. package/dist/{session → private/node/session}/post-auth.js +3 -3
  53. package/dist/private/node/session/post-auth.js.map +1 -0
  54. package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
  55. package/dist/{session → private/node/session}/redirect-listener.js +2 -2
  56. package/dist/private/node/session/redirect-listener.js.map +1 -0
  57. package/dist/{session → private/node/session}/schema.d.ts +1 -1
  58. package/dist/{session → private/node/session}/schema.js +1 -1
  59. package/dist/private/node/session/schema.js.map +1 -0
  60. package/dist/{session → private/node/session}/scopes.d.ts +1 -1
  61. package/dist/{session → private/node/session}/scopes.js +2 -2
  62. package/dist/private/node/session/scopes.js.map +1 -0
  63. package/dist/{session → private/node/session}/store.d.ts +0 -0
  64. package/dist/{session → private/node/session}/store.js +5 -5
  65. package/dist/private/node/session/store.js.map +1 -0
  66. package/dist/{session → private/node/session}/validate.d.ts +0 -0
  67. package/dist/{session → private/node/session}/validate.js +3 -3
  68. package/dist/private/node/session/validate.js.map +1 -0
  69. package/dist/private/node/session.d.ts +56 -0
  70. package/dist/{session.js → private/node/session.js} +97 -133
  71. package/dist/private/node/session.js.map +1 -0
  72. package/dist/private/node/ui.js +1 -1
  73. package/dist/private/node/ui.js.map +1 -1
  74. package/dist/public/node/analytics.js +3 -3
  75. package/dist/public/node/analytics.js.map +1 -1
  76. package/dist/public/node/api/admin.d.ts +1 -1
  77. package/dist/public/node/api/admin.js.map +1 -1
  78. package/dist/public/node/api/partners.js +1 -1
  79. package/dist/public/node/api/partners.js.map +1 -1
  80. package/dist/public/node/base-command.js +2 -2
  81. package/dist/public/node/base-command.js.map +1 -1
  82. package/dist/public/node/cli.d.ts +8 -0
  83. package/dist/public/node/cli.js +21 -4
  84. package/dist/public/node/cli.js.map +1 -1
  85. package/dist/public/node/environment/fqdn.d.ts +26 -0
  86. package/dist/{environment → public/node/environment}/fqdn.js +15 -31
  87. package/dist/public/node/environment/fqdn.js.map +1 -0
  88. package/dist/{environment → public/node/environment}/local.d.ts +62 -15
  89. package/dist/{environment → public/node/environment}/local.js +66 -21
  90. package/dist/public/node/environment/local.js.map +1 -0
  91. package/dist/public/node/environment/spin.d.ts +43 -0
  92. package/dist/{environment → public/node/environment}/spin.js +28 -35
  93. package/dist/public/node/environment/spin.js.map +1 -0
  94. package/dist/public/node/node-package-manager.js +1 -1
  95. package/dist/public/node/node-package-manager.js.map +1 -1
  96. package/dist/public/node/ruby.d.ts +1 -1
  97. package/dist/public/node/ruby.js +11 -12
  98. package/dist/public/node/ruby.js.map +1 -1
  99. package/dist/public/node/session.d.ts +53 -0
  100. package/dist/public/node/session.js +95 -0
  101. package/dist/public/node/session.js.map +1 -0
  102. package/dist/public/node/system.d.ts +44 -0
  103. package/dist/{system.js → public/node/system.js} +34 -54
  104. package/dist/public/node/system.js.map +1 -0
  105. package/dist/public/node/tcp.js +1 -1
  106. package/dist/public/node/tcp.js.map +1 -1
  107. package/dist/testing/ui.js +1 -1
  108. package/dist/testing/ui.js.map +1 -1
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/dist/ui.js +1 -1
  111. package/dist/ui.js.map +1 -1
  112. package/package.json +9 -6
  113. package/dist/cli.d.ts +0 -8
  114. package/dist/cli.js +0 -18
  115. package/dist/cli.js.map +0 -1
  116. package/dist/environment/fqdn.d.ts +0 -29
  117. package/dist/environment/fqdn.js.map +0 -1
  118. package/dist/environment/local.js.map +0 -1
  119. package/dist/environment/service.d.ts +0 -4
  120. package/dist/environment/service.js +0 -19
  121. package/dist/environment/service.js.map +0 -1
  122. package/dist/environment/spin-cache.js.map +0 -1
  123. package/dist/environment/spin.d.ts +0 -50
  124. package/dist/environment/spin.js.map +0 -1
  125. package/dist/environment/utilities.js.map +0 -1
  126. package/dist/environment.d.ts +0 -7
  127. package/dist/environment.js +0 -8
  128. package/dist/environment.js.map +0 -1
  129. package/dist/network/service.d.ts +0 -14
  130. package/dist/network/service.js +0 -11
  131. package/dist/network/service.js.map +0 -1
  132. package/dist/session/authorize.js.map +0 -1
  133. package/dist/session/device-authorization.js.map +0 -1
  134. package/dist/session/exchange.js.map +0 -1
  135. package/dist/session/identity-token-validation.js.map +0 -1
  136. package/dist/session/identity.js.map +0 -1
  137. package/dist/session/post-auth.js.map +0 -1
  138. package/dist/session/redirect-listener.js.map +0 -1
  139. package/dist/session/schema.js.map +0 -1
  140. package/dist/session/scopes.js.map +0 -1
  141. package/dist/session/store.js.map +0 -1
  142. package/dist/session/token.d.ts +0 -40
  143. package/dist/session/token.js +0 -22
  144. package/dist/session/token.js.map +0 -1
  145. package/dist/session/validate.js.map +0 -1
  146. package/dist/session.d.ts +0 -96
  147. package/dist/session.js.map +0 -1
  148. package/dist/system.d.ts +0 -51
  149. package/dist/system.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/session/token.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,KAAK;IA2BT,YAAY,OAAsG;QAChH,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACtC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QACxC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;IACpC,CAAC;CACF;AAED,eAAe,KAAK,CAAA","sourcesContent":["/**\n * It represents a temporary token that can be\n * used to send authenticated HTTP requests.\n */\nclass Token {\n /**\n * A fully-qualified domain name of the service\n * this token is for.\n */\n fqdn: string\n\n /**\n * Access token\n */\n accessToken: string\n\n /**\n * Token to refresh the access token if it has expired.\n */\n refreshToken?: string\n\n /**\n * The expiration date of the session\n */\n expiresAt: Date\n\n /**\n * The list of scopes the token has access to.\n */\n scopes: string[]\n\n constructor(options: {fqdn: string; accessToken: string; refreshToken?: string; expiresAt: Date; scopes: string[]}) {\n this.fqdn = options.fqdn\n this.accessToken = options.accessToken\n this.refreshToken = options.refreshToken\n this.expiresAt = options.expiresAt\n this.scopes = options.scopes\n }\n\n /**\n * Returns true if the session is expired.\n * @returns True if the session is expired.\n */\n get isExpired(): boolean {\n return new Date() > this.expiresAt\n }\n}\n\nexport default Token\n"]}
@@ -1 +0,0 @@
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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OAAO,CAAC,YAAY,CAAC,SAAS,CAAE,CAAA;QAC9C,gBAAgB,GAAG,gBAAgB,IAAI,cAAc,CAAC,KAAK,CAAC,CAAA;KAC7D;IAED,KAAK,CAAC;;kBAEU,gBAAgB;8BACJ,CAAC,eAAe;GAC3C,CAAC,CAAA;IAEF,IAAI,gBAAgB;QAAE,OAAO,eAAe,CAAA;IAC5C,IAAI,CAAC,eAAe;QAAE,OAAO,iBAAiB,CAAA;IAC9C,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,cAAc,CAAC,KAAuB;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,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.d.ts DELETED
@@ -1,96 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * A scope supported by the Shopify Admin API.
4
- */
5
- declare type AdminAPIScope = 'graphql' | 'themes' | 'collaborator' | string;
6
- /**
7
- * It represents the options to authenticate against the Shopify Admin API.
8
- */
9
- interface AdminAPIOAuthOptions {
10
- /** Store to request permissions for */
11
- storeFqdn: string;
12
- /** List of scopes to request permissions for */
13
- scopes: AdminAPIScope[];
14
- }
15
- /**
16
- * A scope supported by the Partners API.
17
- */
18
- declare type PartnersAPIScope = 'cli' | string;
19
- interface PartnersAPIOAuthOptions {
20
- /** List of scopes to request permissions for */
21
- scopes: PartnersAPIScope[];
22
- }
23
- /**
24
- * A scope supported by the Storefront Renderer API.
25
- */
26
- declare type StorefrontRendererScope = 'devtools' | string;
27
- interface StorefrontRendererAPIOAuthOptions {
28
- /** List of scopes to request permissions for */
29
- scopes: StorefrontRendererScope[];
30
- }
31
- /**
32
- * It represents the authentication requirements and
33
- * is the input necessary to trigger the authentication
34
- * flow.
35
- */
36
- export interface OAuthApplications {
37
- adminApi?: AdminAPIOAuthOptions;
38
- storefrontRendererApi?: StorefrontRendererAPIOAuthOptions;
39
- partnersApi?: PartnersAPIOAuthOptions;
40
- }
41
- export interface AdminSession {
42
- token: string;
43
- storeFqdn: string;
44
- }
45
- export interface OAuthSession {
46
- admin?: AdminSession;
47
- partners?: string;
48
- storefront?: string;
49
- }
50
- /**
51
- * Ensure that we have a valid session to access the Partners API.
52
- * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token
53
- * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored
54
- * @param scopes - Optional array of extra scopes to authenticate with.
55
- * @returns The access token for the Partners API.
56
- */
57
- export declare function ensureAuthenticatedPartners(scopes?: string[], env?: NodeJS.ProcessEnv): Promise<string>;
58
- /**
59
- * Ensure that we have a valid session to access the Storefront API.
60
- * @param scopes - Optional array of extra scopes to authenticate with.
61
- * @returns The access token for the Storefront API.
62
- */
63
- export declare function ensureAuthenticatedStorefront(scopes?: string[], password?: string | undefined): Promise<string>;
64
- /**
65
- * Ensure that we have a valid Admin session for the given store.
66
- * @param store - Store fqdn to request auth for
67
- * @param scopes - Optional array of extra scopes to authenticate with.
68
- * @returns The access token for the Admin API
69
- */
70
- export declare function ensureAuthenticatedAdmin(store: string, scopes?: string[], forceRefresh?: boolean): Promise<AdminSession>;
71
- /**
72
- * Ensure that we have a valid session to access the Theme API.
73
- * If a password is provided, that token will be used against Theme Access API.
74
- * Otherwise, it will ensure that the user is authenticated with the Admin API.
75
- * @param store - Store fqdn to request auth for
76
- * @param password - Password generated from Theme Access app
77
- * @param scopes - Optional array of extra scopes to authenticate with.
78
- * @returns The access token and store
79
- */
80
- export declare function ensureAuthenticatedThemes(store: string, password: string | undefined, scopes?: string[], forceRefresh?: boolean): Promise<AdminSession>;
81
- /**
82
- * This method ensures that we have a valid session to authenticate against the given applications using the provided scopes.
83
- * @param applications - An object containing the applications we need to be authenticated with.
84
- * @returns An instance with the access tokens organized by application.
85
- */
86
- export declare function ensureAuthenticated(applications: OAuthApplications, env?: NodeJS.ProcessEnv, forceRefresh?: boolean): Promise<OAuthSession>;
87
- export declare function hasPartnerAccount(partnersToken: string): Promise<boolean>;
88
- /**
89
- * If the user creates an account from the Identity website, the created
90
- * account won't get a Partner organization created. We need to detect that
91
- * and take the user to create a partner organization.
92
- * @param partnersToken - Partners token
93
- */
94
- export declare function ensureUserHasPartnerAccount(partnersToken: string): Promise<void>;
95
- export declare function logout(): Promise<void>;
96
- export {};
@@ -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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AE,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,MAA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O,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"]}