shopify_app 13.2.0 → 20.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE/bug-report.md +63 -0
  4. data/.github/ISSUE_TEMPLATE/config.yml +1 -0
  5. data/.github/ISSUE_TEMPLATE/feature-request.md +33 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
  7. data/.github/workflows/build.yml +40 -0
  8. data/.github/workflows/cla.yml +22 -0
  9. data/.github/workflows/close-waiting-for-response-issues.yml +20 -0
  10. data/.github/workflows/release.yml +24 -0
  11. data/.github/workflows/remove-labels-on-activity.yml +16 -0
  12. data/.github/workflows/rubocop.yml +22 -0
  13. data/.github/workflows/stale.yml +31 -0
  14. data/.gitignore +1 -2
  15. data/.nvmrc +1 -1
  16. data/.rubocop.yml +2 -0
  17. data/.ruby-version +1 -1
  18. data/CHANGELOG.md +221 -0
  19. data/CONTRIBUTING.md +81 -0
  20. data/Gemfile +5 -2
  21. data/Gemfile.lock +248 -0
  22. data/README.md +74 -563
  23. data/Rakefile +4 -3
  24. data/SECURITY.md +59 -0
  25. data/app/assets/images/storage_access.svg +1 -2
  26. data/app/assets/javascripts/shopify_app/app_bridge_3.1.1.js +10 -0
  27. data/app/assets/javascripts/shopify_app/app_bridge_redirect.js +22 -0
  28. data/app/assets/javascripts/shopify_app/app_bridge_utils_3.1.1.js +1 -0
  29. data/app/assets/javascripts/shopify_app/post_redirect.js +9 -0
  30. data/app/assets/javascripts/shopify_app/redirect.js +10 -14
  31. data/app/assets/javascripts/shopify_app/storage_access.js +5 -10
  32. data/app/assets/javascripts/shopify_app/top_level_interaction.js +1 -1
  33. data/app/controllers/concerns/shopify_app/authenticated.rb +4 -0
  34. data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +39 -0
  35. data/app/controllers/concerns/shopify_app/require_known_shop.rb +48 -0
  36. data/app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb +40 -0
  37. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  38. data/app/controllers/shopify_app/callback_controller.rb +56 -77
  39. data/app/controllers/shopify_app/extension_verification_controller.rb +2 -7
  40. data/app/controllers/shopify_app/sessions_controller.rb +33 -117
  41. data/app/controllers/shopify_app/webhooks_controller.rb +5 -26
  42. data/app/views/shopify_app/partials/_button_styles.html.erb +41 -36
  43. data/app/views/shopify_app/partials/_card_styles.html.erb +3 -3
  44. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +28 -59
  45. data/app/views/shopify_app/partials/_form_styles.html.erb +56 -0
  46. data/app/views/shopify_app/partials/_layout_styles.html.erb +16 -1
  47. data/app/views/shopify_app/partials/_typography_styles.html.erb +6 -6
  48. data/app/views/shopify_app/sessions/enable_cookies.html.erb +2 -7
  49. data/app/views/shopify_app/sessions/new.html.erb +38 -110
  50. data/app/views/shopify_app/sessions/request_storage_access.html.erb +12 -12
  51. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +21 -22
  52. data/app/views/shopify_app/shared/post_redirect_to_auth_shopify.html.erb +13 -0
  53. data/app/views/shopify_app/shared/redirect.html.erb +2 -2
  54. data/config/locales/de.yml +11 -11
  55. data/config/locales/ja.yml +4 -4
  56. data/config/locales/nl.yml +2 -2
  57. data/config/locales/th.yml +4 -4
  58. data/config/locales/vi.yml +22 -0
  59. data/config/locales/zh-CN.yml +2 -2
  60. data/config/routes.rb +20 -12
  61. data/docs/Quickstart.md +19 -83
  62. data/docs/Releasing.md +18 -15
  63. data/docs/Troubleshooting.md +140 -5
  64. data/docs/Upgrading.md +247 -0
  65. data/docs/shopify_app/authentication.md +128 -0
  66. data/docs/shopify_app/content-security-policy.md +10 -0
  67. data/docs/shopify_app/engine.md +82 -0
  68. data/docs/shopify_app/generators.md +127 -0
  69. data/docs/shopify_app/handling-access-scopes-changes.md +24 -0
  70. data/docs/shopify_app/script-tags.md +28 -0
  71. data/docs/shopify_app/session-repository.md +88 -0
  72. data/docs/shopify_app/testing.md +38 -0
  73. data/docs/shopify_app/webhooks.md +72 -0
  74. data/karma.conf.js +1 -1
  75. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +10 -9
  76. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
  77. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +4 -3
  78. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +15 -14
  79. data/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt +9 -1
  80. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +7 -6
  81. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +2 -1
  82. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +1 -1
  83. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +4 -4
  84. data/lib/generators/shopify_app/controllers/controllers_generator.rb +5 -4
  85. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +27 -4
  86. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +12 -2
  87. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +74 -16
  88. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +16 -0
  89. data/lib/generators/shopify_app/install/install_generator.rb +52 -40
  90. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +5 -2
  91. data/lib/generators/shopify_app/install/templates/flash_messages.js +0 -2
  92. data/lib/generators/shopify_app/install/templates/session_store.rb +2 -1
  93. data/lib/generators/shopify_app/install/templates/shopify_app.js +1 -1
  94. data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +43 -5
  95. data/lib/generators/shopify_app/install/templates/shopify_app_importmap.js +13 -0
  96. data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +19 -0
  97. data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +8 -0
  98. data/lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb +4 -4
  99. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +1 -0
  100. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +1 -1
  101. data/lib/generators/shopify_app/routes/routes_generator.rb +6 -5
  102. data/lib/generators/shopify_app/routes/templates/routes.rb +5 -5
  103. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +35 -7
  104. data/lib/generators/shopify_app/shop_model/templates/db/migrate/add_shop_access_scopes_column.erb +5 -0
  105. data/lib/generators/shopify_app/shop_model/templates/shop.rb +2 -1
  106. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  107. data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_access_scopes_column.erb +5 -0
  108. data/lib/generators/shopify_app/user_model/templates/user.rb +2 -1
  109. data/lib/generators/shopify_app/user_model/user_model_generator.rb +35 -7
  110. data/lib/generators/shopify_app/views/views_generator.rb +5 -4
  111. data/lib/shopify_app/access_scopes/noop_strategy.rb +13 -0
  112. data/lib/shopify_app/access_scopes/shop_strategy.rb +24 -0
  113. data/lib/shopify_app/access_scopes/user_strategy.rb +41 -0
  114. data/lib/shopify_app/configuration.rb +58 -11
  115. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +4 -4
  116. data/lib/shopify_app/controller_concerns/csrf_protection.rb +16 -0
  117. data/lib/shopify_app/controller_concerns/embedded_app.rb +6 -3
  118. data/lib/shopify_app/controller_concerns/ensure_billing.rb +243 -0
  119. data/lib/shopify_app/controller_concerns/frame_ancestors.rb +16 -0
  120. data/lib/shopify_app/controller_concerns/itp.rb +3 -3
  121. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  122. data/lib/shopify_app/controller_concerns/login_protection.rb +105 -90
  123. data/lib/shopify_app/controller_concerns/payload_verification.rb +25 -0
  124. data/lib/shopify_app/controller_concerns/redirect_for_embedded.rb +36 -0
  125. data/lib/shopify_app/controller_concerns/sanitized_params.rb +36 -0
  126. data/lib/shopify_app/controller_concerns/webhook_verification.rb +3 -18
  127. data/lib/shopify_app/engine.rb +26 -11
  128. data/lib/shopify_app/errors.rb +34 -0
  129. data/lib/shopify_app/jobs/scripttags_manager_job.rb +2 -2
  130. data/lib/shopify_app/jobs/webhooks_manager_job.rb +4 -5
  131. data/lib/shopify_app/managers/scripttags_manager.rb +12 -6
  132. data/lib/shopify_app/managers/webhooks_manager.rb +62 -42
  133. data/lib/shopify_app/middleware/jwt_middleware.rb +6 -3
  134. data/lib/shopify_app/session/in_memory_session_store.rb +2 -3
  135. data/lib/shopify_app/session/in_memory_shop_session_store.rb +10 -7
  136. data/lib/shopify_app/session/in_memory_user_session_store.rb +10 -7
  137. data/lib/shopify_app/session/jwt.rb +19 -16
  138. data/lib/shopify_app/session/null_user_session_store.rb +2 -1
  139. data/lib/shopify_app/session/session_repository.rb +40 -2
  140. data/lib/shopify_app/session/session_storage.rb +4 -6
  141. data/lib/shopify_app/session/shop_session_storage.rb +6 -6
  142. data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +57 -0
  143. data/lib/shopify_app/session/user_session_storage.rb +20 -7
  144. data/lib/shopify_app/session/user_session_storage_with_scopes.rb +71 -0
  145. data/lib/shopify_app/test_helpers/all.rb +2 -1
  146. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +4 -3
  147. data/lib/shopify_app/utils.rb +14 -7
  148. data/lib/shopify_app/version.rb +2 -1
  149. data/lib/shopify_app.rb +52 -29
  150. data/package.json +7 -8
  151. data/service.yml +1 -5
  152. data/shopify_app.gemspec +22 -20
  153. data/translation.yml +1 -1
  154. data/yarn.lock +2173 -2206
  155. metadata +110 -56
  156. data/.github/ISSUE_TEMPLATE.md +0 -14
  157. data/.github/probots.yml +0 -2
  158. data/.travis.yml +0 -28
  159. data/config/locales/hi.yml +0 -23
  160. data/config/locales/ms.yml +0 -22
  161. data/docs/install-on-dev-shop.png +0 -0
  162. data/docs/test-your-app.png +0 -0
  163. data/lib/generators/shopify_app/install/templates/omniauth.rb +0 -3
  164. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +0 -20
  165. data/lib/generators/shopify_app/install/templates/user_agent.rb +0 -6
  166. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +0 -34
  167. data/package-lock.json +0 -7245
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ShopifyApp
3
- VERSION = '13.2.0'
4
+ VERSION = "20.2.0"
4
5
  end
data/lib/shopify_app.rb CHANGED
@@ -1,59 +1,82 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_app/version'
2
+
3
+ require "shopify_app/version"
3
4
 
4
5
  # deps
5
- require 'shopify_api'
6
- require 'omniauth-shopify-oauth2'
7
- require 'redirect_safely'
6
+ require "shopify_api"
7
+ require "redirect_safely"
8
8
 
9
9
  module ShopifyApp
10
10
  def self.rails6?
11
11
  Rails::VERSION::MAJOR >= 6
12
12
  end
13
13
 
14
+ def self.rails7?
15
+ Rails::VERSION::MAJOR >= 7
16
+ end
17
+
18
+ def self.use_importmap?
19
+ rails7? && File.exist?("config/importmap.rb")
20
+ end
21
+
14
22
  def self.use_webpacker?
15
23
  rails6? &&
16
- defined?(Webpacker) == 'constant' &&
24
+ defined?(Webpacker) == "constant" &&
17
25
  !configuration.disable_webpacker
18
26
  end
19
27
 
20
28
  # config
21
- require 'shopify_app/configuration'
29
+ require "shopify_app/configuration"
22
30
 
23
31
  # engine
24
- require 'shopify_app/engine'
32
+ require "shopify_app/engine"
25
33
 
26
34
  # utils
27
- require 'shopify_app/utils'
35
+ require "shopify_app/utils"
36
+
37
+ # errors
38
+ require "shopify_app/errors"
28
39
 
29
40
  # controller concerns
30
- require 'shopify_app/controller_concerns/localization'
31
- require 'shopify_app/controller_concerns/itp'
32
- require 'shopify_app/controller_concerns/login_protection'
33
- require 'shopify_app/controller_concerns/embedded_app'
34
- require 'shopify_app/controller_concerns/webhook_verification'
35
- require 'shopify_app/controller_concerns/app_proxy_verification'
41
+ require "shopify_app/controller_concerns/csrf_protection"
42
+ require "shopify_app/controller_concerns/localization"
43
+ require "shopify_app/controller_concerns/frame_ancestors"
44
+ require "shopify_app/controller_concerns/itp"
45
+ require "shopify_app/controller_concerns/sanitized_params"
46
+ require "shopify_app/controller_concerns/redirect_for_embedded"
47
+ require "shopify_app/controller_concerns/login_protection"
48
+ require "shopify_app/controller_concerns/ensure_billing"
49
+ require "shopify_app/controller_concerns/embedded_app"
50
+ require "shopify_app/controller_concerns/payload_verification"
51
+ require "shopify_app/controller_concerns/app_proxy_verification"
52
+ require "shopify_app/controller_concerns/webhook_verification"
36
53
 
37
54
  # jobs
38
- require 'shopify_app/jobs/webhooks_manager_job'
39
- require 'shopify_app/jobs/scripttags_manager_job'
55
+ require "shopify_app/jobs/webhooks_manager_job"
56
+ require "shopify_app/jobs/scripttags_manager_job"
40
57
 
41
58
  # managers
42
- require 'shopify_app/managers/webhooks_manager'
43
- require 'shopify_app/managers/scripttags_manager'
59
+ require "shopify_app/managers/webhooks_manager"
60
+ require "shopify_app/managers/scripttags_manager"
44
61
 
45
62
  # middleware
46
- require 'shopify_app/middleware/jwt_middleware'
47
- require 'shopify_app/middleware/same_site_cookie_middleware'
63
+ require "shopify_app/middleware/jwt_middleware"
48
64
 
49
65
  # session
50
- require 'shopify_app/session/in_memory_session_store'
51
- require 'shopify_app/session/in_memory_shop_session_store'
52
- require 'shopify_app/session/in_memory_user_session_store'
53
- require 'shopify_app/session/jwt'
54
- require 'shopify_app/session/null_user_session_store'
55
- require 'shopify_app/session/session_repository'
56
- require 'shopify_app/session/session_storage'
57
- require 'shopify_app/session/shop_session_storage'
58
- require 'shopify_app/session/user_session_storage'
66
+ require "shopify_app/session/in_memory_session_store"
67
+ require "shopify_app/session/in_memory_shop_session_store"
68
+ require "shopify_app/session/in_memory_user_session_store"
69
+ require "shopify_app/session/jwt"
70
+ require "shopify_app/session/null_user_session_store"
71
+ require "shopify_app/session/session_repository"
72
+ require "shopify_app/session/session_storage"
73
+ require "shopify_app/session/shop_session_storage"
74
+ require "shopify_app/session/shop_session_storage_with_scopes"
75
+ require "shopify_app/session/user_session_storage"
76
+ require "shopify_app/session/user_session_storage_with_scopes"
77
+
78
+ # access scopes strategies
79
+ require "shopify_app/access_scopes/shop_strategy"
80
+ require "shopify_app/access_scopes/user_strategy"
81
+ require "shopify_app/access_scopes/noop_strategy"
59
82
  end
data/package.json CHANGED
@@ -1,26 +1,25 @@
1
1
  {
2
2
  "name": "shopify_app",
3
- "version": "13.2.0",
3
+ "version": "20.2.0",
4
4
  "repository": "git@github.com:Shopify/shopify_app.git",
5
5
  "author": "Shopify",
6
6
  "license": "MIT",
7
7
  "dependencies": {},
8
8
  "devDependencies": {
9
9
  "babel-loader": "^8.0.6",
10
- "babel-preset-shopify": "^20.0.0",
10
+ "babel-preset-shopify": "^21.0.0",
11
11
  "chai": "^4.1.2",
12
- "karma": "^4.0.1",
12
+ "karma": "^5.2.1",
13
13
  "karma-chai-sinon": "^0.1.5",
14
14
  "karma-chrome-launcher": "^3.1.0",
15
15
  "karma-cli": "^2.0.0",
16
- "karma-mocha": "^1.3.0",
16
+ "karma-mocha": "^2.0.1",
17
17
  "karma-mocha-clean-reporter": "^0.0.1",
18
- "karma-mocha-debug": "^0.1.2",
19
18
  "karma-webpack": "^4.0.2",
20
- "mocha-debug": "^0.0.1",
21
- "sinon": "^7.4.2",
19
+ "mocha": "^8.1.3",
20
+ "sinon": "^9.0.3",
22
21
  "sinon-chai": "^3.2.0",
23
- "webpack": "^4.41.3"
22
+ "webpack": "^4.44.1"
24
23
  },
25
24
  "scripts": {
26
25
  "test": "./node_modules/.bin/karma start --browsers ChromeHeadless --single-run"
data/service.yml CHANGED
@@ -1,7 +1,3 @@
1
1
  audience: partner
2
- classification: library
3
- org_line: App & Partner Platform
4
- owners:
5
- - Shopify/platform-dev-tools-education
6
2
  slack_channels:
7
- - dev-tools-education
3
+ - shopify_app_gem
data/shopify_app.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.push(File.expand_path('../lib', __FILE__))
2
+
3
+ $LOAD_PATH.push(File.expand_path("../lib", __FILE__))
3
4
  require "shopify_app/version"
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -7,29 +8,30 @@ Gem::Specification.new do |s|
7
8
  s.version = ShopifyApp::VERSION
8
9
  s.platform = Gem::Platform::RUBY
9
10
  s.author = "Shopify"
10
- s.summary = 'This gem is used to get quickly started with the Shopify API'
11
+ s.summary = "This gem is used to get quickly started with the Shopify API"
11
12
 
12
- s.required_ruby_version = ">= 2.4"
13
+ s.required_ruby_version = ">= 2.7"
13
14
 
14
- s.metadata['allowed_push_host'] = 'https://rubygems.org'
15
+ s.metadata["allowed_push_host"] = "https://rubygems.org"
15
16
 
16
- s.add_runtime_dependency('browser_sniffer', '~> 1.2.2')
17
- s.add_runtime_dependency('rails', '> 5.2.1')
18
- s.add_runtime_dependency('shopify_api', '~> 9.1.0')
19
- s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.2.2')
20
- s.add_runtime_dependency('jwt', '~> 2.2.1')
21
- s.add_runtime_dependency('redirect_safely', '~> 1.0')
17
+ s.add_runtime_dependency("activeresource") # TODO: Remove this once all active resource dependencies are removed
18
+ s.add_runtime_dependency("browser_sniffer", "~> 2.0")
19
+ s.add_runtime_dependency("jwt", ">= 2.2.3")
20
+ s.add_runtime_dependency("rails", "> 5.2.1")
21
+ s.add_runtime_dependency("redirect_safely", "~> 1.0")
22
+ s.add_runtime_dependency("shopify_api", "~> 11.1")
23
+ s.add_runtime_dependency("sprockets-rails", ">= 2.0.0")
22
24
 
23
- s.add_development_dependency('rake')
24
- s.add_development_dependency('byebug')
25
- s.add_development_dependency('pry')
26
- s.add_development_dependency('pry-nav')
27
- s.add_development_dependency('pry-stack_explorer')
28
- s.add_development_dependency('rb-readline')
29
- s.add_development_dependency('sqlite3', '~> 1.4')
30
- s.add_development_dependency('minitest')
31
- s.add_development_dependency('mocha')
32
- s.add_development_dependency('webmock')
25
+ s.add_development_dependency("byebug")
26
+ s.add_development_dependency("minitest")
27
+ s.add_development_dependency("mocha")
28
+ s.add_development_dependency("pry")
29
+ s.add_development_dependency("pry-nav")
30
+ s.add_development_dependency("pry-stack_explorer")
31
+ s.add_development_dependency("rake")
32
+ s.add_development_dependency("rb-readline")
33
+ s.add_development_dependency("sqlite3", "~> 1.4")
34
+ s.add_development_dependency("webmock")
33
35
 
34
36
  s.files = %x(git ls-files).split("\n").reject { |f| f.match(%r{^(test|example)/}) }
35
37
  s.test_files = %x(git ls-files -- {test}/*).split("\n")
data/translation.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  source_language: en
2
- target_languages: [cs, da, de, es, fi, fr, hi, it, ja, ko, ms, nb, nl, pl, pt-BR, pt-PT, sv, th, tr, zh-CN, zh-TW]
2
+ target_languages: [cs, da, de, es, fi, fr, it, ja, ko, nb, nl, pl, pt-BR, pt-PT, sv, th, tr, vi, zh-CN, zh-TW]
3
3
  components:
4
4
  - name: 'merchant'
5
5
  paths: