@shopify/cli-kit 0.0.0-nightly-20230110194301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +63 -0
- package/assets/auth-error.html +23 -0
- package/assets/empty-url.html +23 -0
- package/assets/favicon.svg +26 -0
- package/assets/missing-code.html +23 -0
- package/assets/missing-state.html +23 -0
- package/assets/style.css +58 -0
- package/assets/success.html +20 -0
- package/dist/api/admin.d.ts +3 -0
- package/dist/api/admin.js +56 -0
- package/dist/api/admin.js.map +1 -0
- package/dist/api/common.d.ts +21 -0
- package/dist/api/common.js +87 -0
- package/dist/api/common.js.map +1 -0
- package/dist/api/graphql/all_app_extension_registrations.d.ts +20 -0
- package/dist/api/graphql/all_app_extension_registrations.js +20 -0
- package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
- package/dist/api/graphql/all_dev_stores_by_org.d.ts +18 -0
- package/dist/api/graphql/all_dev_stores_by_org.js +21 -0
- package/dist/api/graphql/all_dev_stores_by_org.js.map +1 -0
- package/dist/api/graphql/all_orgs.d.ts +12 -0
- package/dist/api/graphql/all_orgs.js +14 -0
- package/dist/api/graphql/all_orgs.js.map +1 -0
- package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
- package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
- package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
- package/dist/api/graphql/create_app.d.ts +29 -0
- package/dist/api/graphql/create_app.js +33 -0
- package/dist/api/graphql/create_app.js.map +1 -0
- package/dist/api/graphql/create_deployment.d.ts +33 -0
- package/dist/api/graphql/create_deployment.js +25 -0
- package/dist/api/graphql/create_deployment.js.map +1 -0
- package/dist/api/graphql/extension_create.d.ts +30 -0
- package/dist/api/graphql/extension_create.js +26 -0
- package/dist/api/graphql/extension_create.js.map +1 -0
- package/dist/api/graphql/extension_specifications.d.ts +27 -0
- package/dist/api/graphql/extension_specifications.js +22 -0
- package/dist/api/graphql/extension_specifications.js.map +1 -0
- package/dist/api/graphql/find_app.d.ts +14 -0
- package/dist/api/graphql/find_app.js +17 -0
- package/dist/api/graphql/find_app.js.map +1 -0
- package/dist/api/graphql/find_org.d.ts +18 -0
- package/dist/api/graphql/find_org.js +21 -0
- package/dist/api/graphql/find_org.js.map +1 -0
- package/dist/api/graphql/find_org_basic.d.ts +11 -0
- package/dist/api/graphql/find_org_basic.js +14 -0
- package/dist/api/graphql/find_org_basic.js.map +1 -0
- package/dist/api/graphql/find_store_by_domain.d.ts +21 -0
- package/dist/api/graphql/find_store_by_domain.js +24 -0
- package/dist/api/graphql/find_store_by_domain.js.map +1 -0
- package/dist/api/graphql/functions/api_schema_definition.d.ts +9 -0
- package/dist/api/graphql/functions/api_schema_definition.js +7 -0
- package/dist/api/graphql/functions/api_schema_definition.js.map +1 -0
- package/dist/api/graphql/functions/app_function_set.d.ts +30 -0
- package/dist/api/graphql/functions/app_function_set.js +38 -0
- package/dist/api/graphql/functions/app_function_set.js.map +1 -0
- package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
- package/dist/api/graphql/functions/function_service_proxy.js +7 -0
- package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
- package/dist/api/graphql/functions/upload_url_generate.d.ts +12 -0
- package/dist/api/graphql/functions/upload_url_generate.js +11 -0
- package/dist/api/graphql/functions/upload_url_generate.js.map +1 -0
- package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
- package/dist/api/graphql/get_urls.d.ts +10 -0
- package/dist/api/graphql/get_urls.js +10 -0
- package/dist/api/graphql/get_urls.js.map +1 -0
- package/dist/api/graphql/get_variant_id.d.ts +17 -0
- package/dist/api/graphql/get_variant_id.js +20 -0
- package/dist/api/graphql/get_variant_id.js.map +1 -0
- package/dist/api/graphql/index.d.ts +21 -0
- package/dist/api/graphql/index.js +22 -0
- package/dist/api/graphql/index.js.map +1 -0
- package/dist/api/graphql/update_draft.d.ts +33 -0
- package/dist/api/graphql/update_draft.js +24 -0
- package/dist/api/graphql/update_draft.js.map +1 -0
- package/dist/api/graphql/update_urls.d.ts +14 -0
- package/dist/api/graphql/update_urls.js +12 -0
- package/dist/api/graphql/update_urls.js.map +1 -0
- package/dist/api/identity.d.ts +1 -0
- package/dist/api/identity.js +41 -0
- package/dist/api/identity.js.map +1 -0
- package/dist/api/oxygen.d.ts +5 -0
- package/dist/api/oxygen.js +30 -0
- package/dist/api/oxygen.js.map +1 -0
- package/dist/api/partners.d.ts +14 -0
- package/dist/api/partners.js +44 -0
- package/dist/api/partners.js.map +1 -0
- package/dist/api.d.ts +6 -0
- package/dist/api.js +7 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.d.ts +52 -0
- package/dist/constants.js +71 -0
- package/dist/constants.js.map +1 -0
- package/dist/content-tokens.d.ts +44 -0
- package/dist/content-tokens.js +105 -0
- package/dist/content-tokens.js.map +1 -0
- package/dist/environment/fqdn.d.ts +29 -0
- package/dist/environment/fqdn.js +72 -0
- package/dist/environment/fqdn.js.map +1 -0
- package/dist/environment/local.d.ts +92 -0
- package/dist/environment/local.js +169 -0
- package/dist/environment/local.js.map +1 -0
- package/dist/environment/service.d.ts +4 -0
- package/dist/environment/service.js +19 -0
- package/dist/environment/service.js.map +1 -0
- package/dist/environment/spin-cache.d.ts +2 -0
- package/dist/environment/spin-cache.js +8 -0
- package/dist/environment/spin-cache.js.map +1 -0
- package/dist/environment/spin.d.ts +50 -0
- package/dist/environment/spin.js +99 -0
- package/dist/environment/spin.js.map +1 -0
- package/dist/environment/utilities.d.ts +8 -0
- package/dist/environment/utilities.js +19 -0
- package/dist/environment/utilities.js.map +1 -0
- package/dist/environment.d.ts +7 -0
- package/dist/environment.js +8 -0
- package/dist/environment.js.map +1 -0
- package/dist/error.d.ts +68 -0
- package/dist/error.js +143 -0
- package/dist/error.js.map +1 -0
- package/dist/file.d.ts +98 -0
- package/dist/file.js +216 -0
- package/dist/file.js.map +1 -0
- package/dist/git.d.ts +36 -0
- package/dist/git.js +133 -0
- package/dist/git.js.map +1 -0
- package/dist/http/fetch.d.ts +22 -0
- package/dist/http/fetch.js +44 -0
- package/dist/http/fetch.js.map +1 -0
- package/dist/http/formdata.d.ts +3 -0
- package/dist/http/formdata.js +6 -0
- package/dist/http/formdata.js.map +1 -0
- package/dist/http/graphql.d.ts +13 -0
- package/dist/http/graphql.js +12 -0
- package/dist/http/graphql.js.map +1 -0
- package/dist/http.d.ts +27 -0
- package/dist/http.js +32 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata.d.ts +53 -0
- package/dist/metadata.js +62 -0
- package/dist/metadata.js.map +1 -0
- package/dist/monorail.d.ts +100 -0
- package/dist/monorail.js +39 -0
- package/dist/monorail.js.map +1 -0
- package/dist/network/api.d.ts +2 -0
- package/dist/network/api.js +2 -0
- package/dist/network/api.js.map +1 -0
- package/dist/network/service.d.ts +14 -0
- package/dist/network/service.js +11 -0
- package/dist/network/service.js.map +1 -0
- package/dist/npm.d.ts +27 -0
- package/dist/npm.js +20 -0
- package/dist/npm.js.map +1 -0
- package/dist/output.d.ts +129 -0
- package/dist/output.js +310 -0
- package/dist/output.js.map +1 -0
- package/dist/path.d.ts +25 -0
- package/dist/path.js +48 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins.d.ts +73 -0
- package/dist/plugins.js +49 -0
- package/dist/plugins.js.map +1 -0
- package/dist/private/common/json.d.ts +6 -0
- package/dist/private/common/json.js +2 -0
- package/dist/private/common/json.js.map +1 -0
- package/dist/private/common/lodash.d.ts +47 -0
- package/dist/private/common/lodash.js +2 -0
- package/dist/private/common/lodash.js.map +1 -0
- package/dist/private/node/analytics.d.ts +27 -0
- package/dist/private/node/analytics.js +57 -0
- package/dist/private/node/analytics.js.map +1 -0
- package/dist/private/node/ui/alert.d.ts +2 -0
- package/dist/private/node/ui/alert.js +18 -0
- package/dist/private/node/ui/alert.js.map +1 -0
- package/dist/private/node/ui/components/Alert.d.ts +17 -0
- package/dist/private/node/ui/components/Alert.js +21 -0
- package/dist/private/node/ui/components/Alert.js.map +1 -0
- package/dist/private/node/ui/components/Alert.test.d.ts +1 -0
- package/dist/private/node/ui/components/Alert.test.js +95 -0
- package/dist/private/node/ui/components/Alert.test.js.map +1 -0
- package/dist/private/node/ui/components/Banner.d.ts +8 -0
- package/dist/private/node/ui/components/Banner.js +41 -0
- package/dist/private/node/ui/components/Banner.js.map +1 -0
- package/dist/private/node/ui/components/Banner.test.d.ts +1 -0
- package/dist/private/node/ui/components/Banner.test.js +52 -0
- package/dist/private/node/ui/components/Banner.test.js.map +1 -0
- package/dist/private/node/ui/components/Command.d.ts +9 -0
- package/dist/private/node/ui/components/Command.js +13 -0
- package/dist/private/node/ui/components/Command.js.map +1 -0
- package/dist/private/node/ui/components/Command.test.d.ts +1 -0
- package/dist/private/node/ui/components/Command.test.js +11 -0
- package/dist/private/node/ui/components/Command.test.js.map +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +47 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js +86 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.test.d.ts +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +54 -0
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -0
- package/dist/private/node/ui/components/FatalError.d.ts +7 -0
- package/dist/private/node/ui/components/FatalError.js +54 -0
- package/dist/private/node/ui/components/FatalError.js.map +1 -0
- package/dist/private/node/ui/components/FatalError.test.d.ts +1 -0
- package/dist/private/node/ui/components/FatalError.test.js +119 -0
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -0
- package/dist/private/node/ui/components/FilePath.d.ts +9 -0
- package/dist/private/node/ui/components/FilePath.js +13 -0
- package/dist/private/node/ui/components/FilePath.js.map +1 -0
- package/dist/private/node/ui/components/FilePath.test.d.ts +1 -0
- package/dist/private/node/ui/components/FilePath.test.js +11 -0
- package/dist/private/node/ui/components/FilePath.test.js.map +1 -0
- package/dist/private/node/ui/components/FullScreen.d.ts +8 -0
- package/dist/private/node/ui/components/FullScreen.js +32 -0
- package/dist/private/node/ui/components/FullScreen.js.map +1 -0
- package/dist/private/node/ui/components/Link.d.ts +10 -0
- package/dist/private/node/ui/components/Link.js +15 -0
- package/dist/private/node/ui/components/Link.js.map +1 -0
- package/dist/private/node/ui/components/Link.test.d.ts +1 -0
- package/dist/private/node/ui/components/Link.test.js +22 -0
- package/dist/private/node/ui/components/Link.test.js.map +1 -0
- package/dist/private/node/ui/components/List.d.ts +13 -0
- package/dist/private/node/ui/components/List.js +19 -0
- package/dist/private/node/ui/components/List.js.map +1 -0
- package/dist/private/node/ui/components/List.test.d.ts +1 -0
- package/dist/private/node/ui/components/List.test.js +34 -0
- package/dist/private/node/ui/components/List.test.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.d.ts +12 -0
- package/dist/private/node/ui/components/SelectInput.js +87 -0
- package/dist/private/node/ui/components/SelectInput.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.test.d.ts +1 -0
- package/dist/private/node/ui/components/SelectInput.test.js +230 -0
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -0
- package/dist/private/node/ui/components/SelectPrompt.d.ts +11 -0
- package/dist/private/node/ui/components/SelectPrompt.js +34 -0
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -0
- package/dist/private/node/ui/components/SelectPrompt.test.d.ts +1 -0
- package/dist/private/node/ui/components/SelectPrompt.test.js +74 -0
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/Table.d.ts +8 -0
- package/dist/private/node/ui/components/Table.js +17 -0
- package/dist/private/node/ui/components/Table.js.map +1 -0
- package/dist/private/node/ui/components/Tasks.d.ts +10 -0
- package/dist/private/node/ui/components/Tasks.js +27 -0
- package/dist/private/node/ui/components/Tasks.js.map +1 -0
- package/dist/private/node/ui/components/Tasks.test.d.ts +1 -0
- package/dist/private/node/ui/components/Tasks.test.js +50 -0
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -0
- package/dist/private/node/ui/components/TextAnimation.d.ts +9 -0
- package/dist/private/node/ui/components/TextAnimation.js +35 -0
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -0
- package/dist/private/node/ui/components/TextInput.d.ts +9 -0
- package/dist/private/node/ui/components/TextInput.js +74 -0
- package/dist/private/node/ui/components/TextInput.js.map +1 -0
- package/dist/private/node/ui/components/TextInput.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextInput.test.js +139 -0
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.d.ts +8 -0
- package/dist/private/node/ui/components/TextPrompt.js +52 -0
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.js +68 -0
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/TokenizedText.d.ts +36 -0
- package/dist/private/node/ui/components/TokenizedText.js +70 -0
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -0
- package/dist/private/node/ui/components/TokenizedText.test.d.ts +1 -0
- package/dist/private/node/ui/components/TokenizedText.test.js +44 -0
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -0
- package/dist/private/node/ui/components/UserInput.d.ts +10 -0
- package/dist/private/node/ui/components/UserInput.js +11 -0
- package/dist/private/node/ui/components/UserInput.js.map +1 -0
- package/dist/private/node/ui/components/UserInput.test.d.ts +1 -0
- package/dist/private/node/ui/components/UserInput.test.js +11 -0
- package/dist/private/node/ui/components/UserInput.test.js.map +1 -0
- package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +6 -0
- package/dist/private/node/ui/hooks/use-async-and-unmount.js +17 -0
- package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -0
- package/dist/private/node/ui/hooks/use-layout.d.ts +6 -0
- package/dist/private/node/ui/hooks/use-layout.js +30 -0
- package/dist/private/node/ui/hooks/use-layout.js.map +1 -0
- package/dist/private/node/ui.d.ts +23 -0
- package/dist/private/node/ui.js +53 -0
- package/dist/private/node/ui.js.map +1 -0
- package/dist/public/common/array.d.ts +37 -0
- package/dist/public/common/array.js +51 -0
- package/dist/public/common/array.js.map +1 -0
- package/dist/public/common/collection.d.ts +23 -0
- package/dist/public/common/collection.js +29 -0
- package/dist/public/common/collection.js.map +1 -0
- package/dist/public/common/function.d.ts +30 -0
- package/dist/public/common/function.js +40 -0
- package/dist/public/common/function.js.map +1 -0
- package/dist/public/common/lang.d.ts +16 -0
- package/dist/public/common/lang.js +22 -0
- package/dist/public/common/lang.js.map +1 -0
- package/dist/public/common/object.d.ts +32 -0
- package/dist/public/common/object.js +45 -0
- package/dist/public/common/object.js.map +1 -0
- package/dist/public/common/string.d.ts +6 -0
- package/dist/public/common/string.js +109 -0
- package/dist/public/common/string.js.map +1 -0
- package/dist/public/common/url.d.ts +7 -0
- package/dist/public/common/url.js +17 -0
- package/dist/public/common/url.js.map +1 -0
- package/dist/public/node/abort.d.ts +16 -0
- package/dist/public/node/abort.js +17 -0
- package/dist/public/node/abort.js.map +1 -0
- package/dist/public/node/analytics.d.ts +13 -0
- package/dist/public/node/analytics.js +82 -0
- package/dist/public/node/analytics.js.map +1 -0
- package/dist/public/node/archiver.d.ts +9 -0
- package/dist/public/node/archiver.js +34 -0
- package/dist/public/node/archiver.js.map +1 -0
- package/dist/public/node/base-command.d.ts +26 -0
- package/dist/public/node/base-command.js +172 -0
- package/dist/public/node/base-command.js.map +1 -0
- package/dist/public/node/checksum.d.ts +20 -0
- package/dist/public/node/checksum.js +32 -0
- package/dist/public/node/checksum.js.map +1 -0
- package/dist/public/node/cli.d.ts +29 -0
- package/dist/public/node/cli.js +106 -0
- package/dist/public/node/cli.js.map +1 -0
- package/dist/public/node/colors.d.ts +2 -0
- package/dist/public/node/colors.js +3 -0
- package/dist/public/node/colors.js.map +1 -0
- package/dist/public/node/dot-env.d.ts +42 -0
- package/dist/public/node/dot-env.js +67 -0
- package/dist/public/node/dot-env.js.map +1 -0
- package/dist/public/node/error-handler.d.ts +41 -0
- package/dist/public/node/error-handler.js +198 -0
- package/dist/public/node/error-handler.js.map +1 -0
- package/dist/public/node/error.d.ts +4 -0
- package/dist/public/node/error.js +5 -0
- package/dist/public/node/error.js.map +1 -0
- package/dist/public/node/framework.d.ts +8 -0
- package/dist/public/node/framework.js +135 -0
- package/dist/public/node/framework.js.map +1 -0
- package/dist/public/node/fs.d.ts +17 -0
- package/dist/public/node/fs.js +21 -0
- package/dist/public/node/fs.js.map +1 -0
- package/dist/public/node/github.d.ts +50 -0
- package/dist/public/node/github.js +71 -0
- package/dist/public/node/github.js.map +1 -0
- package/dist/public/node/hooks/postrun.d.ts +2 -0
- package/dist/public/node/hooks/postrun.js +9 -0
- package/dist/public/node/hooks/postrun.js.map +1 -0
- package/dist/public/node/hooks/prerun.d.ts +12 -0
- package/dist/public/node/hooks/prerun.js +66 -0
- package/dist/public/node/hooks/prerun.js.map +1 -0
- package/dist/public/node/node-package-manager.d.ts +243 -0
- package/dist/public/node/node-package-manager.js +369 -0
- package/dist/public/node/node-package-manager.js.map +1 -0
- package/dist/public/node/os.d.ts +16 -0
- package/dist/public/node/os.js +77 -0
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/plugins/tunnel.d.ts +47 -0
- package/dist/public/node/plugins/tunnel.js +19 -0
- package/dist/public/node/plugins/tunnel.js.map +1 -0
- package/dist/public/node/presets.d.ts +8 -0
- package/dist/public/node/presets.js +26 -0
- package/dist/public/node/presets.js.map +1 -0
- package/dist/public/node/result.d.ts +94 -0
- package/dist/public/node/result.js +134 -0
- package/dist/public/node/result.js.map +1 -0
- package/dist/public/node/ruby.d.ts +38 -0
- package/dist/public/node/ruby.js +234 -0
- package/dist/public/node/ruby.js.map +1 -0
- package/dist/public/node/semver.d.ts +3 -0
- package/dist/public/node/semver.js +6 -0
- package/dist/public/node/semver.js.map +1 -0
- package/dist/public/node/tcp.d.ts +5 -0
- package/dist/public/node/tcp.js +35 -0
- package/dist/public/node/tcp.js.map +1 -0
- package/dist/public/node/ui.d.ts +184 -0
- package/dist/public/node/ui.js +203 -0
- package/dist/public/node/ui.js.map +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/secure-store.d.ts +19 -0
- package/dist/secure-store.js +63 -0
- package/dist/secure-store.js.map +1 -0
- package/dist/session/authorize.d.ts +7 -0
- package/dist/session/authorize.js +52 -0
- package/dist/session/authorize.js.map +1 -0
- package/dist/session/device-authorization.d.ts +32 -0
- package/dist/session/device-authorization.js +92 -0
- package/dist/session/device-authorization.js.map +1 -0
- package/dist/session/exchange.d.ts +48 -0
- package/dist/session/exchange.js +159 -0
- package/dist/session/exchange.js.map +1 -0
- package/dist/session/identity.d.ts +3 -0
- package/dist/session/identity.js +58 -0
- package/dist/session/identity.js.map +1 -0
- package/dist/session/post-auth.d.ts +13 -0
- package/dist/session/post-auth.js +62 -0
- package/dist/session/post-auth.js.map +1 -0
- package/dist/session/redirect-listener.d.ts +34 -0
- package/dist/session/redirect-listener.js +106 -0
- package/dist/session/redirect-listener.js.map +1 -0
- package/dist/session/schema.d.ts +175 -0
- package/dist/session/schema.js +60 -0
- package/dist/session/schema.js.map +1 -0
- package/dist/session/scopes.d.ts +16 -0
- package/dist/session/scopes.js +53 -0
- package/dist/session/scopes.js.map +1 -0
- package/dist/session/store.d.ts +24 -0
- package/dist/session/store.js +89 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/token.d.ts +40 -0
- package/dist/session/token.js +22 -0
- package/dist/session/token.js.map +1 -0
- package/dist/session/validate.d.ts +17 -0
- package/dist/session/validate.js +65 -0
- package/dist/session/validate.js.map +1 -0
- package/dist/session.d.ts +96 -0
- package/dist/session.js +293 -0
- package/dist/session.js.map +1 -0
- package/dist/store/schema.d.ts +3 -0
- package/dist/store/schema.js +27 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store.d.ts +53 -0
- package/dist/store.js +134 -0
- package/dist/store.js.map +1 -0
- package/dist/string.d.ts +28 -0
- package/dist/string.js +77 -0
- package/dist/string.js.map +1 -0
- package/dist/system.d.ts +51 -0
- package/dist/system.js +128 -0
- package/dist/system.js.map +1 -0
- package/dist/template.d.ts +11 -0
- package/dist/template.js +50 -0
- package/dist/template.js.map +1 -0
- package/dist/testing/output.d.ts +10 -0
- package/dist/testing/output.js +16 -0
- package/dist/testing/output.js.map +1 -0
- package/dist/testing/store.d.ts +7 -0
- package/dist/testing/store.js +26 -0
- package/dist/testing/store.js.map +1 -0
- package/dist/testing/ui.d.ts +5 -0
- package/dist/testing/ui.js +23 -0
- package/dist/testing/ui.js.map +1 -0
- package/dist/toml.d.ts +3 -0
- package/dist/toml.js +8 -0
- package/dist/toml.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/typing/deep-required.d.ts +12 -0
- package/dist/typing/deep-required.js +2 -0
- package/dist/typing/deep-required.js.map +1 -0
- package/dist/typing/overloaded-parameters.d.ts +6 -0
- package/dist/typing/overloaded-parameters.js +2 -0
- package/dist/typing/overloaded-parameters.js.map +1 -0
- package/dist/typing/pick-by-prefix.d.ts +12 -0
- package/dist/typing/pick-by-prefix.js +2 -0
- package/dist/typing/pick-by-prefix.js.map +1 -0
- package/dist/typing/simple-definitions.d.ts +4 -0
- package/dist/typing/simple-definitions.js +2 -0
- package/dist/typing/simple-definitions.js.map +1 -0
- package/dist/ui/executor.d.ts +14 -0
- package/dist/ui/executor.js +90 -0
- package/dist/ui/executor.js.map +1 -0
- package/dist/ui/inquirer/autocomplete.d.ts +11 -0
- package/dist/ui/inquirer/autocomplete.js +110 -0
- package/dist/ui/inquirer/autocomplete.js.map +1 -0
- package/dist/ui/inquirer/input.d.ts +16 -0
- package/dist/ui/inquirer/input.js +45 -0
- package/dist/ui/inquirer/input.js.map +1 -0
- package/dist/ui/inquirer/password.d.ts +7 -0
- package/dist/ui/inquirer/password.js +8 -0
- package/dist/ui/inquirer/password.js.map +1 -0
- package/dist/ui/inquirer/select.d.ts +14 -0
- package/dist/ui/inquirer/select.js +26 -0
- package/dist/ui/inquirer/select.js.map +1 -0
- package/dist/ui.d.ts +54 -0
- package/dist/ui.js +128 -0
- package/dist/ui.js.map +1 -0
- package/dist/vscode.d.ts +8 -0
- package/dist/vscode.js +36 -0
- package/dist/vscode.js.map +1 -0
- package/package.json +177 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js';
|
|
2
|
+
import { consoleError } from '../../output.js';
|
|
3
|
+
import { render, renderOnce } from '../../private/node/ui.js';
|
|
4
|
+
import { alert } from '../../private/node/ui/alert.js';
|
|
5
|
+
import { FatalError } from '../../private/node/ui/components/FatalError.js';
|
|
6
|
+
import { SelectPrompt } from '../../private/node/ui/components/SelectPrompt.js';
|
|
7
|
+
import { Tasks } from '../../private/node/ui/components/Tasks.js';
|
|
8
|
+
import { TextPrompt } from '../../private/node/ui/components/TextPrompt.js';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { AbortController } from '@shopify/cli-kit/node/abort';
|
|
11
|
+
/**
|
|
12
|
+
* Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
|
|
13
|
+
*/
|
|
14
|
+
export async function renderConcurrent({ processes, abortController, showTimestamps = true, renderOptions = {}, }) {
|
|
15
|
+
return render(React.createElement(ConcurrentOutput, { processes: processes, abortController: abortController ?? new AbortController(), showTimestamps: showTimestamps }), renderOptions);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders an information banner to the console.
|
|
19
|
+
*
|
|
20
|
+
* Basic:
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* â•─ info ───────────────────────────────────────────────────╮
|
|
24
|
+
* │ │
|
|
25
|
+
* │ Body │
|
|
26
|
+
* │ │
|
|
27
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Complete:
|
|
31
|
+
* ```
|
|
32
|
+
* â•─ info ───────────────────────────────────────────────────╮
|
|
33
|
+
* │ │
|
|
34
|
+
* │ Title │
|
|
35
|
+
* │ │
|
|
36
|
+
* │ Body │
|
|
37
|
+
* │ │
|
|
38
|
+
* │ Next steps │
|
|
39
|
+
* │ • Run `cd santorini-goods` │
|
|
40
|
+
* │ • To preview your project, run `npm app dev` │
|
|
41
|
+
* │ • To add extensions, run `npm generate extension` │
|
|
42
|
+
* │ │
|
|
43
|
+
* │ Reference │
|
|
44
|
+
* │ • Run `npm shopify help` │
|
|
45
|
+
* │ • Press 'return' to open the dev docs: │
|
|
46
|
+
* │ https://shopify.dev │
|
|
47
|
+
* │ │
|
|
48
|
+
* │ Link: https://shopify.com │
|
|
49
|
+
* │ │
|
|
50
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function renderInfo(options) {
|
|
54
|
+
return alert({ ...options, type: 'info' });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Renders a success banner to the console.
|
|
58
|
+
*
|
|
59
|
+
* Basic:
|
|
60
|
+
*
|
|
61
|
+
* ```
|
|
62
|
+
* â•─ success ────────────────────────────────────────────────╮
|
|
63
|
+
* │ │
|
|
64
|
+
* │ Title │
|
|
65
|
+
* │ │
|
|
66
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Complete:
|
|
70
|
+
* ```
|
|
71
|
+
* â•─ success ────────────────────────────────────────────────╮
|
|
72
|
+
* │ │
|
|
73
|
+
* │ Title │
|
|
74
|
+
* │ │
|
|
75
|
+
* │ Body │
|
|
76
|
+
* │ │
|
|
77
|
+
* │ Next steps │
|
|
78
|
+
* │ • Run `cd santorini-goods` │
|
|
79
|
+
* │ • To preview your project, run `npm app dev` │
|
|
80
|
+
* │ • To add extensions, run `npm generate extension` │
|
|
81
|
+
* │ │
|
|
82
|
+
* │ Reference │
|
|
83
|
+
* │ • Run `npm shopify help` │
|
|
84
|
+
* │ • Press 'return' to open the dev docs: │
|
|
85
|
+
* │ https://shopify.dev │
|
|
86
|
+
* │ │
|
|
87
|
+
* │ Link: https://shopify.com │
|
|
88
|
+
* │ │
|
|
89
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export function renderSuccess(options) {
|
|
93
|
+
return alert({ ...options, type: 'success' });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Renders a warning banner to the console.
|
|
97
|
+
*
|
|
98
|
+
* Basic:
|
|
99
|
+
*
|
|
100
|
+
* ```
|
|
101
|
+
* â•─ warning ────────────────────────────────────────────────╮
|
|
102
|
+
* │ │
|
|
103
|
+
* │ Title │
|
|
104
|
+
* │ │
|
|
105
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* Complete:
|
|
109
|
+
* ```
|
|
110
|
+
* â•─ warning ────────────────────────────────────────────────╮
|
|
111
|
+
* │ │
|
|
112
|
+
* │ Title │
|
|
113
|
+
* │ │
|
|
114
|
+
* │ Body │
|
|
115
|
+
* │ │
|
|
116
|
+
* │ Next steps │
|
|
117
|
+
* │ • Run `cd santorini-goods` │
|
|
118
|
+
* │ • To preview your project, run `npm app dev` │
|
|
119
|
+
* │ • To add extensions, run `npm generate extension` │
|
|
120
|
+
* │ │
|
|
121
|
+
* │ Reference │
|
|
122
|
+
* │ • Run `npm shopify help` │
|
|
123
|
+
* │ • Press 'return' to open the dev docs: │
|
|
124
|
+
* │ https://shopify.dev │
|
|
125
|
+
* │ │
|
|
126
|
+
* │ Link: https://shopify.com │
|
|
127
|
+
* │ │
|
|
128
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export function renderWarning(options) {
|
|
132
|
+
return alert({ ...options, type: 'warning' });
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Renders a Fatal error to the console inside a banner.
|
|
136
|
+
*
|
|
137
|
+
* ```
|
|
138
|
+
* â•─ error ──────────────────────────────────────────────────╮
|
|
139
|
+
* │ │
|
|
140
|
+
* │ Couldn't connect to the Shopify Partner Dashboard. │
|
|
141
|
+
* │ │
|
|
142
|
+
* │ Check your internet connection and try again. │
|
|
143
|
+
* │ │
|
|
144
|
+
* ╰──────────────────────────────────────────────────────────╯
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export function renderFatalError(error) {
|
|
148
|
+
return renderOnce(React.createElement(FatalError, { error: error }), 'error', consoleError);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Renders a select prompt to the console.
|
|
152
|
+
*
|
|
153
|
+
* ? Associate your project with the org Castile Ventures?
|
|
154
|
+
*
|
|
155
|
+
* Add: • new-ext
|
|
156
|
+
*
|
|
157
|
+
* Remove: • integrated-demand-ext
|
|
158
|
+
* • order-discount
|
|
159
|
+
|
|
160
|
+
* \> (f) first
|
|
161
|
+
* (s) second
|
|
162
|
+
* (3) third
|
|
163
|
+
* (4) fourth
|
|
164
|
+
* (5) seventh
|
|
165
|
+
* (6) tenth
|
|
166
|
+
|
|
167
|
+
* Automations
|
|
168
|
+
* (7) fifth
|
|
169
|
+
* (8) sixth
|
|
170
|
+
|
|
171
|
+
* Merchant Admin
|
|
172
|
+
* (9) eighth
|
|
173
|
+
* (10) ninth
|
|
174
|
+
|
|
175
|
+
* navigate with arrows, enter to select
|
|
176
|
+
*/
|
|
177
|
+
export function renderSelectPrompt(props) {
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
render(React.createElement(SelectPrompt, { ...props, onSubmit: (value) => resolve(value) }), {
|
|
180
|
+
exitOnCtrlC: false,
|
|
181
|
+
}).catch(reject);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Runs async tasks and displays their progress to the console.
|
|
186
|
+
*/
|
|
187
|
+
export function renderTasks(tasks) {
|
|
188
|
+
return render(React.createElement(Tasks, { tasks: tasks }));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Renders a text prompt to the console.
|
|
192
|
+
*
|
|
193
|
+
* ? What is your name?
|
|
194
|
+
* \> John
|
|
195
|
+
*/
|
|
196
|
+
export function renderTextPrompt(props) {
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
render(React.createElement(TextPrompt, { ...props, onSubmit: (value) => resolve(value) }), {
|
|
199
|
+
exitOnCtrlC: false,
|
|
200
|
+
}).catch(reject);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +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,eAA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AAC,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'>) {\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"]}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { z as define } from 'zod';
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,IAAI,MAAM,EAAC,MAAM,KAAK,CAAA","sourcesContent":["export {z as define} from 'zod'\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches secured content from the system's keychain.
|
|
3
|
+
* @param identifier - Identifier to identify the content.
|
|
4
|
+
* @returns A promise that resolves with the content or null if it doesn't exist.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetch(identifier: string): Promise<string | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Securely stores the content under the given key.
|
|
9
|
+
* @param identifier - Identifier to identify the content.
|
|
10
|
+
* @param content - The content to be stored.
|
|
11
|
+
* @returns A promise that resolves when the storing completes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function store(identifier: string, content: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Removes the content with the given identifier.
|
|
16
|
+
* @param identifier - Identifier to identify the content.
|
|
17
|
+
* @returns A promise that resolves with true if the content was deleted.
|
|
18
|
+
*/
|
|
19
|
+
export declare function remove(identifier: string): Promise<boolean>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import constants from './constants.js';
|
|
2
|
+
import { content as outputContent, debug } from './output.js';
|
|
3
|
+
import { Abort } from './error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Fetches secured content from the system's keychain.
|
|
6
|
+
* @param identifier - Identifier to identify the content.
|
|
7
|
+
* @returns A promise that resolves with the content or null if it doesn't exist.
|
|
8
|
+
*/
|
|
9
|
+
export async function fetch(identifier) {
|
|
10
|
+
debug(outputContent `Reading ${identifier} from the secure store...`);
|
|
11
|
+
try {
|
|
12
|
+
const keytar = await import('keytar');
|
|
13
|
+
const content = await keytar.getPassword(constants.keychain.service, identifier);
|
|
14
|
+
return content;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw createAbort(error, 'Unable to read from the secure store');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Securely stores the content under the given key.
|
|
22
|
+
* @param identifier - Identifier to identify the content.
|
|
23
|
+
* @param content - The content to be stored.
|
|
24
|
+
* @returns A promise that resolves when the storing completes.
|
|
25
|
+
*/
|
|
26
|
+
export async function store(identifier, content) {
|
|
27
|
+
debug(outputContent `Updating ${identifier} in the secure store with new content...`);
|
|
28
|
+
try {
|
|
29
|
+
const keytar = await import('keytar');
|
|
30
|
+
await keytar.default.setPassword(constants.keychain.service, identifier, content);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw createAbort(error, 'Unable to update the secure store');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Removes the content with the given identifier.
|
|
38
|
+
* @param identifier - Identifier to identify the content.
|
|
39
|
+
* @returns A promise that resolves with true if the content was deleted.
|
|
40
|
+
*/
|
|
41
|
+
export async function remove(identifier) {
|
|
42
|
+
debug(outputContent `Removing ${identifier} from the secure store...`);
|
|
43
|
+
try {
|
|
44
|
+
const keytar = await import('keytar');
|
|
45
|
+
const result = await keytar.default.deletePassword(constants.keychain.service, identifier);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw createAbort(error, 'Unable to remove from the secure store');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function createAbort(error, message) {
|
|
53
|
+
let newMessage = message;
|
|
54
|
+
let stack = '';
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
newMessage = message.concat(`: ${error.message}`);
|
|
57
|
+
stack = error.stack;
|
|
58
|
+
}
|
|
59
|
+
const abort = new Abort(newMessage);
|
|
60
|
+
abort.stack = stack;
|
|
61
|
+
return abort;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=secure-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-store.js","sourceRoot":"","sources":["../src/secure-store.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAEhC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB;IAC5C,KAAK,CAAC,aAAa,CAAA,WAAW,UAAU,2BAA2B,CAAC,CAAA;IACpE,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAChF,OAAO,OAAO,CAAA;KACf;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,sCAAsC,CAAC,CAAA;KACjE;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB,EAAE,OAAe;IAC7D,KAAK,CAAC,aAAa,CAAA,YAAY,UAAU,0CAA0C,CAAC,CAAA;IACpF,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;KAClF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,mCAAmC,CAAC,CAAA;KAC9D;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,UAAkB;IAC7C,KAAK,CAAC,aAAa,CAAA,YAAY,UAAU,2BAA2B,CAAC,CAAA;IACrE,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC1F,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,wCAAwC,CAAC,CAAA;KACnE;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,OAAe;IAClD,IAAI,UAAU,GAAG,OAAO,CAAA;IACxB,IAAI,KAAK,GAAuB,EAAE,CAAA;IAClC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACjD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;KACpB;IACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;IACnC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import constants from './constants.js'\nimport {content as outputContent, debug} from './output.js'\nimport {Abort} from './error.js'\n\n/**\n * Fetches secured content from the system's keychain.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with the content or null if it doesn't exist.\n */\nexport async function fetch(identifier: string): Promise<string | null> {\n debug(outputContent`Reading ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const content = await keytar.getPassword(constants.keychain.service, identifier)\n return content\n } catch (error) {\n throw createAbort(error, 'Unable to read from the secure store')\n }\n}\n\n/**\n * Securely stores the content under the given key.\n * @param identifier - Identifier to identify the content.\n * @param content - The content to be stored.\n * @returns A promise that resolves when the storing completes.\n */\nexport async function store(identifier: string, content: string): Promise<void> {\n debug(outputContent`Updating ${identifier} in the secure store with new content...`)\n try {\n const keytar = await import('keytar')\n await keytar.default.setPassword(constants.keychain.service, identifier, content)\n } catch (error) {\n throw createAbort(error, 'Unable to update the secure store')\n }\n}\n\n/**\n * Removes the content with the given identifier.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with true if the content was deleted.\n */\nexport async function remove(identifier: string): Promise<boolean> {\n debug(outputContent`Removing ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const result = await keytar.default.deletePassword(constants.keychain.service, identifier)\n return result\n } catch (error) {\n throw createAbort(error, 'Unable to remove from the secure store')\n }\n}\n\nfunction createAbort(error: unknown, message: string) {\n let newMessage = message\n let stack: string | undefined = ''\n if (error instanceof Error) {\n newMessage = message.concat(`: ${error.message}`)\n stack = error.stack\n }\n const abort = new Abort(newMessage)\n abort.stack = stack\n return abort\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { listenRedirect } from './redirect-listener.js';
|
|
2
|
+
import { clientId } from './identity.js';
|
|
3
|
+
import { generateRandomChallengePair, randomHex } from '../string.js';
|
|
4
|
+
import { open } from '../system.js';
|
|
5
|
+
import { Abort, CancelExecution } from '../error.js';
|
|
6
|
+
import { identity as identityFqdn } from '../environment/fqdn.js';
|
|
7
|
+
import * as output from '../output.js';
|
|
8
|
+
import { keypress, terminateBlockingPortProcessPrompt } from '../ui.js';
|
|
9
|
+
import { checkPort as isPortAvailable } from 'get-port-please';
|
|
10
|
+
export const MismatchStateError = new Abort("The state received from the authentication doesn't match the one that initiated the authentication process.");
|
|
11
|
+
export async function authorize(scopes, state = randomHex(30)) {
|
|
12
|
+
const port = 3456;
|
|
13
|
+
const host = '127.0.0.1';
|
|
14
|
+
const redirectUri = `http://${host}:${port}`;
|
|
15
|
+
const fqdn = await identityFqdn();
|
|
16
|
+
const identityClientId = await clientId();
|
|
17
|
+
await validateRedirectionPortAvailability(port);
|
|
18
|
+
let url = `http://${fqdn}/oauth/authorize`;
|
|
19
|
+
const { codeVerifier, codeChallenge } = generateRandomChallengePair();
|
|
20
|
+
const params = {
|
|
21
|
+
client_id: identityClientId,
|
|
22
|
+
scope: scopes.join(' '),
|
|
23
|
+
redirect_uri: redirectUri,
|
|
24
|
+
state,
|
|
25
|
+
response_type: 'code',
|
|
26
|
+
code_challenge_method: 'S256',
|
|
27
|
+
code_challenge: codeChallenge,
|
|
28
|
+
};
|
|
29
|
+
output.info('\nTo run this command, log in to Shopify Partners.');
|
|
30
|
+
output.info('👉 Press any key to open the login page on your browser');
|
|
31
|
+
await keypress();
|
|
32
|
+
url = `${url}?${new URLSearchParams(params).toString()}`;
|
|
33
|
+
await open(url);
|
|
34
|
+
const result = await listenRedirect(host, port, url);
|
|
35
|
+
if (result.state !== state) {
|
|
36
|
+
throw MismatchStateError;
|
|
37
|
+
}
|
|
38
|
+
return { code: result.code, codeVerifier };
|
|
39
|
+
}
|
|
40
|
+
async function validateRedirectionPortAvailability(port) {
|
|
41
|
+
const { killPortProcess } = await import('kill-port-process');
|
|
42
|
+
if (await isPortAvailable(port)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {
|
|
46
|
+
await killPortProcess(port);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new CancelExecution();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMapp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AAgB;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"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IdentityToken } from './schema.js';
|
|
2
|
+
export interface DeviceAuthorizationResponse {
|
|
3
|
+
deviceCode: string;
|
|
4
|
+
userCode: string;
|
|
5
|
+
verificationUri: string;
|
|
6
|
+
expiresIn: number;
|
|
7
|
+
verificationUriComplete?: string;
|
|
8
|
+
interval?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Initiate a device authorization flow.
|
|
12
|
+
* This will return a DeviceAuthorizationResponse containing the URL where user
|
|
13
|
+
* should go to authorize the device without the need of a callback to the CLI.
|
|
14
|
+
*
|
|
15
|
+
* Also returns a `deviceCode` used for polling the token endpoint in the next step.
|
|
16
|
+
*
|
|
17
|
+
* @param scopes - The scopes to request
|
|
18
|
+
* @returns An object with the device authorization response.
|
|
19
|
+
*/
|
|
20
|
+
export declare function requestDeviceAuthorization(scopes: string[]): Promise<DeviceAuthorizationResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Poll the Oauth token endpoint with the device code obtained from a DeviceAuthorizationResponse.
|
|
23
|
+
* The endpoint will return `authorization_pending` until the user completes the auth flow in the browser.
|
|
24
|
+
* Once the user completes the auth flow, the endpoint will return the identity token.
|
|
25
|
+
*
|
|
26
|
+
* Timeout for the polling is defined by the server and is around 600 seconds.
|
|
27
|
+
*
|
|
28
|
+
* @param code - The device code obtained after starting a device identity flow
|
|
29
|
+
* @param interval - The interval to poll the token endpoint
|
|
30
|
+
* @returns The identity token
|
|
31
|
+
*/
|
|
32
|
+
export declare function pollForDeviceAuthorization(code: string, interval?: number): Promise<IdentityToken>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { clientId } from './identity.js';
|
|
2
|
+
import { exchangeDeviceCodeForAccessToken } from './exchange.js';
|
|
3
|
+
import { identity as identityFqdn } from '../environment/fqdn.js';
|
|
4
|
+
import { shopifyFetch } from '../http.js';
|
|
5
|
+
import { content, debug, info, token } from '../output.js';
|
|
6
|
+
import { Bug } from '../error.js';
|
|
7
|
+
const DeviceAuthError = () => {
|
|
8
|
+
return new Bug('Failed to start authorization process');
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Initiate a device authorization flow.
|
|
12
|
+
* This will return a DeviceAuthorizationResponse containing the URL where user
|
|
13
|
+
* should go to authorize the device without the need of a callback to the CLI.
|
|
14
|
+
*
|
|
15
|
+
* Also returns a `deviceCode` used for polling the token endpoint in the next step.
|
|
16
|
+
*
|
|
17
|
+
* @param scopes - The scopes to request
|
|
18
|
+
* @returns An object with the device authorization response.
|
|
19
|
+
*/
|
|
20
|
+
export async function requestDeviceAuthorization(scopes) {
|
|
21
|
+
const fqdn = await identityFqdn();
|
|
22
|
+
const identityClientId = await clientId();
|
|
23
|
+
const queryParams = { client_id: identityClientId, scope: scopes.join(' ') };
|
|
24
|
+
const url = `https://${fqdn}/oauth/device_authorization`;
|
|
25
|
+
const response = await shopifyFetch(url, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: { 'Content-type': 'application/x-www-form-urlencoded' },
|
|
28
|
+
body: convertRequestToParams(queryParams),
|
|
29
|
+
});
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
const jsonResult = await response.json();
|
|
32
|
+
debug(content `Received device authorization code: ${token.json(jsonResult)}`);
|
|
33
|
+
if (!jsonResult.device_code || !jsonResult.verification_uri_complete)
|
|
34
|
+
throw DeviceAuthError();
|
|
35
|
+
info('\nTo run this command, log in to Shopify Partners.');
|
|
36
|
+
info(content `User verification code: ${jsonResult.user_code}`);
|
|
37
|
+
info(content `👉 Open this link to start the auth process: ${token.green(jsonResult.verification_uri_complete)}`);
|
|
38
|
+
return {
|
|
39
|
+
deviceCode: jsonResult.device_code,
|
|
40
|
+
userCode: jsonResult.user_code,
|
|
41
|
+
verificationUri: jsonResult.verification_uri,
|
|
42
|
+
expiresIn: jsonResult.expires_in,
|
|
43
|
+
verificationUriComplete: jsonResult.verification_uri_complete,
|
|
44
|
+
interval: jsonResult.interval,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Poll the Oauth token endpoint with the device code obtained from a DeviceAuthorizationResponse.
|
|
49
|
+
* The endpoint will return `authorization_pending` until the user completes the auth flow in the browser.
|
|
50
|
+
* Once the user completes the auth flow, the endpoint will return the identity token.
|
|
51
|
+
*
|
|
52
|
+
* Timeout for the polling is defined by the server and is around 600 seconds.
|
|
53
|
+
*
|
|
54
|
+
* @param code - The device code obtained after starting a device identity flow
|
|
55
|
+
* @param interval - The interval to poll the token endpoint
|
|
56
|
+
* @returns The identity token
|
|
57
|
+
*/
|
|
58
|
+
export async function pollForDeviceAuthorization(code, interval = 5) {
|
|
59
|
+
let currentIntervalInSeconds = interval;
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const onPoll = async () => {
|
|
62
|
+
const result = await exchangeDeviceCodeForAccessToken(code);
|
|
63
|
+
if (!result.isErr())
|
|
64
|
+
return resolve(result.value);
|
|
65
|
+
const error = result.error ?? 'unknown_failure';
|
|
66
|
+
debug(content `Polling for device authorization... status: ${error}`);
|
|
67
|
+
switch (error) {
|
|
68
|
+
case 'authorization_pending':
|
|
69
|
+
return startPolling();
|
|
70
|
+
case 'slow_down':
|
|
71
|
+
currentIntervalInSeconds += 5;
|
|
72
|
+
return startPolling();
|
|
73
|
+
case 'access_denied':
|
|
74
|
+
case 'expired_token':
|
|
75
|
+
case 'unknown_failure':
|
|
76
|
+
return reject(result);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const startPolling = () => {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
81
|
+
setTimeout(onPoll, currentIntervalInSeconds * 1000);
|
|
82
|
+
};
|
|
83
|
+
startPolling();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function convertRequestToParams(queryParams) {
|
|
87
|
+
return Object.entries(queryParams)
|
|
88
|
+
.map(([key, value]) => value && `${key}=${value}`)
|
|
89
|
+
.filter((hasValue) => Boolean(hasValue))
|
|
90
|
+
.join('&');
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=device-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-authorization.js","sourceRoot":"","sources":["../../src/session/device-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,gCAAgC,EAAC,MAAM,eAAe,CA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A;aACxB;QACH,CAAC,CAAA;QAED,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,kEAAkE;YAClE,UAAU,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CAAC,CAAA;QACrD,CAAC,CAAA;QAED,YAAY,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,WAA+C;IAC7E,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;SAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;SACjD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SACvC,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC","sourcesContent":["import {clientId} from './identity.js'\nimport {exchangeDeviceCodeForAccessToken} from './exchange.js'\nimport {IdentityToken} from './schema.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport {shopifyFetch} from '../http.js'\nimport {content, debug, info, token} from '../output.js'\nimport {Bug} from '../error.js'\n\nexport interface DeviceAuthorizationResponse {\n deviceCode: string\n userCode: string\n verificationUri: string\n expiresIn: number\n verificationUriComplete?: string\n interval?: number\n}\n\nconst DeviceAuthError = () => {\n return new Bug('Failed to start authorization process')\n}\n\n/**\n * Initiate a device authorization flow.\n * This will return a DeviceAuthorizationResponse containing the URL where user\n * should go to authorize the device without the need of a callback to the CLI.\n *\n * Also returns a `deviceCode` used for polling the token endpoint in the next step.\n *\n * @param scopes - The scopes to request\n * @returns An object with the device authorization response.\n */\nexport async function requestDeviceAuthorization(scopes: string[]): Promise<DeviceAuthorizationResponse> {\n const fqdn = await identityFqdn()\n const identityClientId = await clientId()\n const queryParams = {client_id: identityClientId, scope: scopes.join(' ')}\n const url = `https://${fqdn}/oauth/device_authorization`\n\n const response = await shopifyFetch(url, {\n method: 'POST',\n headers: {'Content-type': 'application/x-www-form-urlencoded'},\n body: convertRequestToParams(queryParams),\n })\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const jsonResult: any = await response.json()\n\n debug(content`Received device authorization code: ${token.json(jsonResult)}`)\n if (!jsonResult.device_code || !jsonResult.verification_uri_complete) throw DeviceAuthError()\n\n info('\\nTo run this command, log in to Shopify Partners.')\n info(content`User verification code: ${jsonResult.user_code}`)\n info(content`👉 Open this link to start the auth process: ${token.green(jsonResult.verification_uri_complete)}`)\n\n return {\n deviceCode: jsonResult.device_code,\n userCode: jsonResult.user_code,\n verificationUri: jsonResult.verification_uri,\n expiresIn: jsonResult.expires_in,\n verificationUriComplete: jsonResult.verification_uri_complete,\n interval: jsonResult.interval,\n }\n}\n\n/**\n * Poll the Oauth token endpoint with the device code obtained from a DeviceAuthorizationResponse.\n * The endpoint will return `authorization_pending` until the user completes the auth flow in the browser.\n * Once the user completes the auth flow, the endpoint will return the identity token.\n *\n * Timeout for the polling is defined by the server and is around 600 seconds.\n *\n * @param code - The device code obtained after starting a device identity flow\n * @param interval - The interval to poll the token endpoint\n * @returns The identity token\n */\nexport async function pollForDeviceAuthorization(code: string, interval = 5): Promise<IdentityToken> {\n let currentIntervalInSeconds = interval\n\n return new Promise<IdentityToken>((resolve, reject) => {\n const onPoll = async () => {\n const result = await exchangeDeviceCodeForAccessToken(code)\n if (!result.isErr()) return resolve(result.value)\n\n const error = result.error ?? 'unknown_failure'\n\n debug(content`Polling for device authorization... status: ${error}`)\n switch (error) {\n case 'authorization_pending':\n return startPolling()\n case 'slow_down':\n currentIntervalInSeconds += 5\n return startPolling()\n case 'access_denied':\n case 'expired_token':\n case 'unknown_failure':\n return reject(result)\n }\n }\n\n const startPolling = () => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n setTimeout(onPoll, currentIntervalInSeconds * 1000)\n }\n\n startPolling()\n })\n}\n\nfunction convertRequestToParams(queryParams: {client_id: string; scope: string}): string {\n return Object.entries(queryParams)\n .map(([key, value]) => value && `${key}=${value}`)\n .filter((hasValue) => Boolean(hasValue))\n .join('&')\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ApplicationToken, IdentityToken } from './schema.js';
|
|
2
|
+
import { CodeAuthResult } from './authorize.js';
|
|
3
|
+
import { Result } from '../public/node/result.js';
|
|
4
|
+
import { ExtendableError } from '../error.js';
|
|
5
|
+
export declare class InvalidGrantError extends ExtendableError {
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidRequestError extends ExtendableError {
|
|
8
|
+
}
|
|
9
|
+
export interface ExchangeScopes {
|
|
10
|
+
admin: string[];
|
|
11
|
+
partners: string[];
|
|
12
|
+
storefront: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Given a valid authorization code, request an identity access token.
|
|
16
|
+
* This token can then be used to get API specific tokens.
|
|
17
|
+
* @param codeData - code and codeVerifier from the authorize endpoint
|
|
18
|
+
* @returns An instance with the identity access tokens.
|
|
19
|
+
*/
|
|
20
|
+
export declare function exchangeCodeForAccessToken(codeData: CodeAuthResult): Promise<IdentityToken>;
|
|
21
|
+
/**
|
|
22
|
+
* Given an identity token, request an application token.
|
|
23
|
+
* @param identityToken - access token obtained in a previous step
|
|
24
|
+
* @param store - the store to use, only needed for admin API
|
|
25
|
+
* @returns An array with the application access tokens.
|
|
26
|
+
*/
|
|
27
|
+
export declare function exchangeAccessForApplicationTokens(identityToken: IdentityToken, scopes: ExchangeScopes, store?: string): Promise<{
|
|
28
|
+
[x: string]: ApplicationToken;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Given an expired access token, refresh it to get a new one.
|
|
32
|
+
*/
|
|
33
|
+
export declare function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken>;
|
|
34
|
+
/**
|
|
35
|
+
* Given a custom CLI token passed as ENV variable, request a valid partners API token
|
|
36
|
+
* This token does not accept extra scopes, just the cli one.
|
|
37
|
+
* @param token - The CLI token passed as ENV variable
|
|
38
|
+
* @returns An instance with the application access tokens.
|
|
39
|
+
*/
|
|
40
|
+
export declare function exchangeCustomPartnerToken(token: string): Promise<ApplicationToken>;
|
|
41
|
+
export declare type IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure';
|
|
42
|
+
/**
|
|
43
|
+
* Given a deviceCode obtained after starting a device identity flow, request an identity token.
|
|
44
|
+
* @param deviceCode - The device code obtained after starting a device identity flow
|
|
45
|
+
* @param scopes - The scopes to request
|
|
46
|
+
* @returns An instance with the identity access tokens.
|
|
47
|
+
*/
|
|
48
|
+
export declare function exchangeDeviceCodeForAccessToken(deviceCode: string): Promise<Result<IdentityToken, IdentityDeviceError>>;
|