shopify_app 9.0.0 → 13.0.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -2
  3. data/CHANGELOG.md +159 -0
  4. data/README.md +221 -130
  5. data/app/assets/javascripts/shopify_app/itp_helper.js +6 -6
  6. data/app/assets/javascripts/shopify_app/storage_access.js +36 -7
  7. data/app/controllers/concerns/shopify_app/authenticated.rb +2 -2
  8. data/app/controllers/shopify_app/callback_controller.rb +20 -7
  9. data/app/controllers/shopify_app/extension_verification_controller.rb +20 -0
  10. data/app/controllers/shopify_app/sessions_controller.rb +71 -22
  11. data/app/views/shopify_app/sessions/enable_cookies.html.erb +3 -1
  12. data/app/views/shopify_app/sessions/request_storage_access.html.erb +2 -1
  13. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +1 -0
  14. data/app/views/shopify_app/shared/redirect.html.erb +1 -0
  15. data/config/locales/cs.yml +23 -0
  16. data/config/locales/da.yml +20 -0
  17. data/config/locales/de.yml +5 -5
  18. data/config/locales/en.yml +1 -1
  19. data/config/locales/es.yml +3 -3
  20. data/config/locales/fi.yml +20 -0
  21. data/config/locales/fr.yml +3 -3
  22. data/config/locales/hi.yml +23 -0
  23. data/config/locales/it.yml +2 -3
  24. data/config/locales/ja.yml +1 -1
  25. data/config/locales/ko.yml +19 -0
  26. data/config/locales/ms.yml +22 -0
  27. data/config/locales/nb.yml +21 -0
  28. data/config/locales/nl.yml +3 -3
  29. data/config/locales/pl.yml +21 -0
  30. data/config/locales/pt-BR.yml +9 -10
  31. data/config/locales/pt-PT.yml +22 -0
  32. data/config/locales/sv.yml +21 -0
  33. data/config/locales/th.yml +20 -0
  34. data/config/locales/tr.yml +22 -0
  35. data/config/locales/zh-CN.yml +3 -3
  36. data/config/locales/zh-TW.yml +1 -2
  37. data/docs/Quickstart.md +44 -16
  38. data/docs/Releasing.md +0 -1
  39. data/docs/install-on-dev-shop.png +0 -0
  40. data/docs/test-your-app.png +0 -0
  41. data/karma.conf.js +1 -0
  42. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +2 -2
  43. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +39 -0
  44. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +62 -0
  45. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +0 -6
  46. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +1 -1
  47. data/lib/generators/shopify_app/install/install_generator.rb +27 -11
  48. data/lib/generators/shopify_app/install/templates/_flash_messages.html.erb +1 -17
  49. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +11 -10
  50. data/lib/generators/shopify_app/install/templates/flash_messages.js +26 -0
  51. data/lib/generators/shopify_app/install/templates/shopify_app.js +15 -0
  52. data/lib/generators/shopify_app/install/templates/shopify_app.rb +6 -3
  53. data/lib/generators/shopify_app/install/templates/shopify_app_index.js +2 -0
  54. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +1 -0
  55. data/lib/generators/shopify_app/install/templates/user_agent.rb +5 -0
  56. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +1 -1
  57. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -1
  58. data/lib/generators/shopify_app/user_model/templates/db/migrate/create_users.erb +16 -0
  59. data/lib/generators/shopify_app/user_model/templates/user.rb +7 -0
  60. data/lib/generators/shopify_app/user_model/templates/users.yml +4 -0
  61. data/lib/generators/shopify_app/user_model/user_model_generator.rb +38 -0
  62. data/lib/shopify_app/configuration.rb +22 -10
  63. data/lib/shopify_app/controller_concerns/login_protection.rb +66 -15
  64. data/lib/shopify_app/engine.rb +4 -0
  65. data/lib/shopify_app/managers/webhooks_manager.rb +1 -1
  66. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +33 -0
  67. data/lib/shopify_app/session/in_memory_session_store.rb +1 -1
  68. data/lib/shopify_app/session/in_memory_shop_session_store.rb +4 -0
  69. data/lib/shopify_app/session/in_memory_user_session_store.rb +4 -0
  70. data/lib/shopify_app/session/session_repository.rb +38 -13
  71. data/lib/shopify_app/session/session_storage.rb +0 -22
  72. data/lib/shopify_app/session/shop_session_storage.rb +30 -0
  73. data/lib/shopify_app/session/user_session_storage.rb +31 -0
  74. data/lib/shopify_app/utils.rb +7 -0
  75. data/lib/shopify_app/version.rb +1 -1
  76. data/lib/shopify_app.rb +48 -29
  77. data/package-lock.json +7227 -5
  78. data/package.json +9 -9
  79. data/service.yml +1 -1
  80. data/shopify_app.gemspec +10 -5
  81. data/translation.yml +1 -1
  82. data/yarn.lock +2555 -1886
  83. metadata +117 -19
  84. data/lib/generators/shopify_app/home_controller/templates/shopify_app_ready_script.html.erb +0 -7
@@ -0,0 +1,16 @@
1
+ class CreateUsers < ActiveRecord::Migration[<%= rails_migration_version %>]
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.bigint :shopify_user_id, null: false
5
+ t.string :shopify_domain, null: false
6
+ t.string :shopify_token, null: false
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :users, :shopify_user_id, unique: true
11
+ end
12
+
13
+ def self.down
14
+ drop_table :users
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ class User < ActiveRecord::Base
2
+ include ShopifyApp::UserSessionStorage
3
+
4
+ def api_version
5
+ ShopifyApp.configuration.api_version
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ regular_user:
2
+ shopify_domain: 'regular-shop.myshopify.com'
3
+ shopify_token: 'token'
4
+ shopify_user_id: 1
@@ -0,0 +1,38 @@
1
+ require 'rails/generators/base'
2
+ require 'rails/generators/active_record'
3
+
4
+ module ShopifyApp
5
+ module Generators
6
+ class UserModelGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def create_user_model
11
+ copy_file 'user.rb', 'app/models/user.rb'
12
+ end
13
+
14
+ def create_user_migration
15
+ migration_template 'db/migrate/create_users.erb', 'db/migrate/create_users.rb'
16
+ end
17
+
18
+ def update_shopify_app_initializer
19
+ gsub_file 'config/initializers/shopify_app.rb', 'ShopifyApp::InMemoryUserSessionStore', 'User'
20
+ end
21
+
22
+ def create_user_fixtures
23
+ copy_file 'users.yml', 'test/fixtures/users.yml'
24
+ end
25
+
26
+ private
27
+
28
+ def rails_migration_version
29
+ Rails.version.match(/\d\.\d/)[0]
30
+ end
31
+
32
+ # for generating a timestamp when using `create_migration`
33
+ def self.next_migration_number(dir)
34
+ ActiveRecord::Generators::Base.next_migration_number(dir)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -5,7 +5,7 @@ module ShopifyApp
5
5
  # for the app in your Shopify Partners page. Change your settings in
6
6
  # `config/initializers/shopify_app.rb`
7
7
  attr_accessor :application_name
8
- attr_accessor :api_key
8
+ attr_accessor :api_key
9
9
  attr_accessor :secret
10
10
  attr_accessor :old_secret
11
11
  attr_accessor :scope
@@ -14,7 +14,8 @@ module ShopifyApp
14
14
  attr_accessor :webhooks
15
15
  attr_accessor :scripttags
16
16
  attr_accessor :after_authenticate_job
17
- attr_accessor :session_repository
17
+ attr_reader :shop_session_repository
18
+ attr_reader :user_session_repository
18
19
  attr_accessor :api_version
19
20
 
20
21
  # customise urls
@@ -28,28 +29,35 @@ module ShopifyApp
28
29
  # configure myshopify domain for local shopify development
29
30
  attr_accessor :myshopify_domain
30
31
 
32
+ # ability to have webpacker installed but not used in this gem and the generators
33
+ attr_accessor :disable_webpacker
34
+
31
35
  # allow namespacing webhook jobs
32
36
  attr_accessor :webhook_jobs_namespace
33
37
 
38
+ # allow enabling of same site none on cookies
39
+ attr_accessor :enable_same_site_none
40
+
34
41
  def initialize
35
42
  @root_url = '/'
36
43
  @myshopify_domain = 'myshopify.com'
37
44
  @scripttags_manager_queue_name = Rails.application.config.active_job.queue_name
38
45
  @webhooks_manager_queue_name = Rails.application.config.active_job.queue_name
46
+ @disable_webpacker = ENV['SHOPIFY_APP_DISABLE_WEBPACKER'].present?
39
47
  end
40
48
 
41
49
  def login_url
42
50
  @login_url || File.join(@root_url, 'login')
43
51
  end
44
52
 
45
- def session_repository=(klass)
46
- if Rails.configuration.cache_classes
47
- ShopifyApp::SessionRepository.storage = klass
48
- else
49
- ActiveSupport::Reloader.to_prepare do
50
- ShopifyApp::SessionRepository.storage = klass
51
- end
52
- end
53
+ def user_session_repository=(klass)
54
+ @user_session_repository = klass
55
+ ShopifyApp::SessionRepository.user_storage = klass
56
+ end
57
+
58
+ def shop_session_repository=(klass)
59
+ @shop_session_repository = klass
60
+ ShopifyApp::SessionRepository.shop_storage = klass
53
61
  end
54
62
 
55
63
  def has_webhooks?
@@ -59,6 +67,10 @@ module ShopifyApp
59
67
  def has_scripttags?
60
68
  scripttags.present?
61
69
  end
70
+
71
+ def enable_same_site_none
72
+ !Rails.env.test? && (@enable_same_site_none.nil? ? embedded_app? : @enable_same_site_none)
73
+ end
62
74
  end
63
75
 
64
76
  def self.configuration
@@ -14,26 +14,48 @@ module ShopifyApp
14
14
  rescue_from ActiveResource::UnauthorizedAccess, :with => :close_session
15
15
  end
16
16
 
17
- def shopify_session
18
- return redirect_to_login unless shop_session
17
+ def activate_shopify_session
18
+ return redirect_to_login if current_shopify_session.blank?
19
19
  clear_top_level_oauth_cookie
20
20
 
21
21
  begin
22
- ShopifyAPI::Base.activate_session(shop_session)
22
+ ShopifyAPI::Base.activate_session(current_shopify_session)
23
23
  yield
24
24
  ensure
25
25
  ShopifyAPI::Base.clear_session
26
26
  end
27
27
  end
28
28
 
29
+ def current_shopify_session
30
+ if session[:user_id].present?
31
+ @current_shopify_session ||= user_session
32
+ else
33
+ @current_shopify_session ||= shop_session
34
+ end
35
+ end
36
+
37
+ def user_session
38
+ return if session[:user_id].blank?
39
+ ShopifyApp::SessionRepository.retrieve_user_session(session[:user_id])
40
+ end
41
+
29
42
  def shop_session
30
- return unless session[:shopify]
31
- @shop_session ||= ShopifyApp::SessionRepository.retrieve(session[:shopify])
43
+ return if session[:shop_id].blank?
44
+ ShopifyApp::SessionRepository.retrieve_shop_session(session[:shop_id])
32
45
  end
33
46
 
34
- def login_again_if_different_shop
35
- if shop_session && params[:shop] && params[:shop].is_a?(String) && (shop_session.domain != params[:shop])
36
- clear_shop_session
47
+ def login_again_if_different_user_or_shop
48
+ if session[:user_session].present? && params[:session].present? # session data was sent/stored correctly
49
+ clear_session = session[:user_session] != params[:session] # current user is different from stored user
50
+
51
+ end
52
+
53
+ if current_shopify_session && params[:shop] && params[:shop].is_a?(String) && (current_shopify_session.domain != params[:shop])
54
+ clear_session = true
55
+ end
56
+
57
+ if clear_session
58
+ clear_shopify_session
37
59
  redirect_to_login
38
60
  end
39
61
  end
@@ -45,24 +67,32 @@ module ShopifyApp
45
67
  head :unauthorized
46
68
  else
47
69
  if request.get?
48
- session[:return_to] = "#{request.path}?#{sanitized_params.to_query}"
70
+ path = request.path
71
+ query = sanitized_params.to_query
72
+ else
73
+ referer = URI(request.referer || "/")
74
+ path = referer.path
75
+ query = "#{referer.query}&#{sanitized_params.to_query}"
49
76
  end
50
- redirect_to login_url
77
+ session[:return_to] = "#{path}?#{query}"
78
+ redirect_to(login_url_with_optional_shop)
51
79
  end
52
80
  end
53
81
 
54
82
  def close_session
55
- clear_shop_session
56
- redirect_to login_url
83
+ clear_shopify_session
84
+ redirect_to(login_url_with_optional_shop)
57
85
  end
58
86
 
59
- def clear_shop_session
60
- session[:shopify] = nil
87
+ def clear_shopify_session
88
+ session[:shop_id] = nil
89
+ session[:user_id] = nil
61
90
  session[:shopify_domain] = nil
62
91
  session[:shopify_user] = nil
92
+ session[:user_session] = nil
63
93
  end
64
94
 
65
- def login_url(top_level: false)
95
+ def login_url_with_optional_shop(top_level: false)
66
96
  url = ShopifyApp.configuration.login_url
67
97
 
68
98
  query_params = login_url_params(top_level: top_level)
@@ -75,6 +105,12 @@ module ShopifyApp
75
105
  query_params = {}
76
106
  query_params[:shop] = sanitized_params[:shop] if params[:shop].present?
77
107
 
108
+ return_to = session[:return_to] || params[:return_to]
109
+
110
+ if return_to.present? && return_to_param_required?
111
+ query_params[:return_to] = return_to
112
+ end
113
+
78
114
  has_referer_shop_name = referer_sanitized_shop_name.present?
79
115
 
80
116
  if has_referer_shop_name
@@ -85,6 +121,11 @@ module ShopifyApp
85
121
  query_params
86
122
  end
87
123
 
124
+ def return_to_param_required?
125
+ native_params = %i[shop hmac timestamp locale protocol return_to]
126
+ request.path != '/' || sanitized_params.except(*native_params).any?
127
+ end
128
+
88
129
  def fullpage_redirect_to(url)
89
130
  if ShopifyApp.configuration.embedded_app?
90
131
  render 'shopify_app/shared/redirect', layout: false, locals: { url: url, current_shopify_domain: current_shopify_domain }
@@ -131,5 +172,15 @@ module ShopifyApp
131
172
  def return_address
132
173
  session.delete(:return_to) || ShopifyApp.configuration.root_url
133
174
  end
175
+
176
+ def return_address_with_params(params)
177
+ uri = URI(return_address)
178
+ uri.query = CGI.parse(uri.query.to_s)
179
+ .symbolize_keys
180
+ .transform_values { |v| v.one? ? v.first : v }
181
+ .merge(params)
182
+ .to_query
183
+ uri.to_s
184
+ end
134
185
  end
135
186
  end
@@ -12,5 +12,9 @@ module ShopifyApp
12
12
  storage_access.svg
13
13
  ]
14
14
  end
15
+
16
+ initializer "shopify_app.middleware" do |app|
17
+ app.config.middleware.insert_after(::Rack::Runtime, ShopifyApp::SameSiteCookieMiddleware)
18
+ end
15
19
  end
16
20
  end
@@ -55,7 +55,7 @@ module ShopifyApp
55
55
  end
56
56
 
57
57
  def current_webhooks
58
- @current_webhooks ||= ShopifyAPI::Webhook.all.index_by(&:topic)
58
+ @current_webhooks ||= ShopifyAPI::Webhook.all.to_a.index_by(&:topic)
59
59
  end
60
60
  end
61
61
  end
@@ -0,0 +1,33 @@
1
+ module ShopifyApp
2
+ class SameSiteCookieMiddleware
3
+ COOKIE_SEPARATOR = "\n"
4
+
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ status, headers, body = @app.call(env)
11
+ user_agent = env['HTTP_USER_AGENT']
12
+
13
+ if headers && headers['Set-Cookie'] &&
14
+ BrowserSniffer.new(user_agent).same_site_none_compatible? &&
15
+ ShopifyApp.configuration.enable_same_site_none &&
16
+ Rack::Request.new(env).ssl?
17
+
18
+ set_cookies = headers['Set-Cookie']
19
+ .split(COOKIE_SEPARATOR)
20
+ .compact
21
+ .map do |cookie|
22
+ cookie << '; Secure' if not cookie =~ /;\s*secure/i
23
+ cookie << '; SameSite=None' unless cookie =~ /;\s*samesite=/i
24
+ cookie
25
+ end
26
+
27
+ headers['Set-Cookie'] = set_cookies.join(COOKIE_SEPARATOR)
28
+ end
29
+
30
+ [status, headers, body]
31
+ end
32
+ end
33
+ end
@@ -6,7 +6,7 @@ module ShopifyApp
6
6
  repo[id]
7
7
  end
8
8
 
9
- def self.store(session)
9
+ def self.store(session, *args)
10
10
  id = SecureRandom.uuid
11
11
  repo[id] = session
12
12
  id
@@ -0,0 +1,4 @@
1
+ module ShopifyApp
2
+ class InMemoryShopSessionStore < InMemorySessionStore
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ShopifyApp
2
+ class InMemoryUserSessionStore < InMemorySessionStore
3
+ end
4
+ end
@@ -3,31 +3,56 @@ module ShopifyApp
3
3
  class ConfigurationError < StandardError; end
4
4
 
5
5
  class << self
6
- def storage=(storage)
7
- @storage = storage
6
+ def shop_storage=(storage)
7
+ @shop_storage = storage
8
8
 
9
- unless storage.nil? || self.storage.respond_to?(:store) && self.storage.respond_to?(:retrieve)
10
- raise ArgumentError, "storage must respond to :store and :retrieve"
9
+ unless storage.nil? || self.shop_storage.respond_to?(:store) && self.shop_storage.respond_to?(:retrieve)
10
+ raise ArgumentError, "shop storage must respond to :store and :retrieve"
11
11
  end
12
12
  end
13
13
 
14
- def retrieve(id)
15
- storage.retrieve(id)
14
+ def user_storage=(storage)
15
+ @user_storage = storage
16
+
17
+ unless storage.nil? || self.user_storage.respond_to?(:store) && self.user_storage.respond_to?(:retrieve)
18
+ raise ArgumentError, "user storage must respond to :store and :retrieve"
19
+ end
20
+ end
21
+
22
+ def retrieve_shop_session(id)
23
+ shop_storage.retrieve(id)
24
+ end
25
+
26
+ def retrieve_user_session(id)
27
+ user_storage.retrieve(id)
16
28
  end
17
29
 
18
- def store(session)
19
- storage.store(session)
30
+ def store_shop_session(session)
31
+ shop_storage.store(session)
20
32
  end
21
33
 
22
- def storage
23
- load_storage || raise(ConfigurationError.new("ShopifySessionRepository.storage is not configured!"))
34
+ def store_user_session(session, user)
35
+ user_storage.store(session, user)
36
+ end
37
+
38
+ def shop_storage
39
+ load_shop_storage || raise(ConfigurationError.new("ShopifySessionRepository.shop_storage is not configured!"))
40
+ end
41
+
42
+ def user_storage
43
+ load_user_storage
24
44
  end
25
45
 
26
46
  private
27
47
 
28
- def load_storage
29
- return unless @storage
30
- @storage.respond_to?(:safe_constantize) ? @storage.safe_constantize : @storage
48
+ def load_shop_storage
49
+ return unless @shop_storage
50
+ @shop_storage.respond_to?(:safe_constantize) ? @shop_storage.safe_constantize : @shop_storage
51
+ end
52
+
53
+ def load_user_storage
54
+ return unless @user_storage
55
+ @user_storage.respond_to?(:safe_constantize) ? @user_storage.safe_constantize : @user_storage
31
56
  end
32
57
  end
33
58
  end
@@ -3,7 +3,6 @@ module ShopifyApp
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false }
7
6
  validates :shopify_token, presence: true
8
7
  validates :api_version, presence: true
9
8
  end
@@ -16,26 +15,5 @@ module ShopifyApp
16
15
  &block
17
16
  )
18
17
  end
19
-
20
- class_methods do
21
- def store(session)
22
- shop = find_or_initialize_by(shopify_domain: session.domain)
23
- shop.shopify_token = session.token
24
- shop.save!
25
- shop.id
26
- end
27
-
28
- def retrieve(id)
29
- return unless id
30
-
31
- if shop = self.find_by(id: id)
32
- ShopifyAPI::Session.new(
33
- domain: shop.shopify_domain,
34
- token: shop.shopify_token,
35
- api_version: shop.api_version
36
- )
37
- end
38
- end
39
- end
40
18
  end
41
19
  end
@@ -0,0 +1,30 @@
1
+ module ShopifyApp
2
+ module ShopSessionStorage
3
+ extend ActiveSupport::Concern
4
+ include ::ShopifyApp::SessionStorage
5
+
6
+ included do
7
+ validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false }
8
+ end
9
+
10
+ class_methods do
11
+ def store(auth_session, *args)
12
+ shop = find_or_initialize_by(shopify_domain: auth_session.domain)
13
+ shop.shopify_token = auth_session.token
14
+ shop.save!
15
+ shop.id
16
+ end
17
+
18
+ def retrieve(id)
19
+ return unless id
20
+ if shop = self.find_by(id: id)
21
+ ShopifyAPI::Session.new(
22
+ domain: shop.shopify_domain,
23
+ token: shop.shopify_token,
24
+ api_version: shop.api_version
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module ShopifyApp
2
+ module UserSessionStorage
3
+ extend ActiveSupport::Concern
4
+ include ::ShopifyApp::SessionStorage
5
+
6
+ included do
7
+ validates :shopify_domain, presence: true
8
+ end
9
+
10
+ class_methods do
11
+ def store(auth_session, user)
12
+ user = find_or_initialize_by(shopify_user_id: user[:id])
13
+ user.shopify_token = auth_session.token
14
+ user.shopify_domain = auth_session.domain
15
+ user.save!
16
+ user.id
17
+ end
18
+
19
+ def retrieve(id)
20
+ return unless id
21
+ if user = find_by(id: id)
22
+ ShopifyAPI::Session.new(
23
+ domain: user.shopify_domain,
24
+ token: user.shopify_token,
25
+ api_version: user.api_version
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -12,5 +12,12 @@ module ShopifyApp
12
12
  nil
13
13
  end
14
14
 
15
+ def self.fetch_known_api_versions
16
+ Rails.logger.info("[ShopifyAPI::ApiVersion] Fetching known Admin API Versions from Shopify...")
17
+ ShopifyAPI::ApiVersion.fetch_known_versions
18
+ Rails.logger.info("[ShopifyAPI::ApiVersion] Known API Versions: #{ShopifyAPI::ApiVersion.versions.keys}")
19
+ rescue ActiveResource::ConnectionError
20
+ logger.error( "[ShopifyAPI::ApiVersion] Unable to fetch api_versions from Shopify")
21
+ end
15
22
  end
16
23
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = '9.0.0'.freeze
2
+ VERSION = '13.0.0'.freeze
3
3
  end
data/lib/shopify_app.rb CHANGED
@@ -4,32 +4,51 @@ require 'shopify_app/version'
4
4
  require 'shopify_api'
5
5
  require 'omniauth-shopify-oauth2'
6
6
 
7
- # config
8
- require 'shopify_app/configuration'
9
-
10
- # engine
11
- require 'shopify_app/engine'
12
-
13
- # utils
14
- require 'shopify_app/utils'
15
-
16
- # controller concerns
17
- require 'shopify_app/controller_concerns/localization'
18
- require 'shopify_app/controller_concerns/itp'
19
- require 'shopify_app/controller_concerns/login_protection'
20
- require 'shopify_app/controller_concerns/embedded_app'
21
- require 'shopify_app/controller_concerns/webhook_verification'
22
- require 'shopify_app/controller_concerns/app_proxy_verification'
23
-
24
- # jobs
25
- require 'shopify_app/jobs/webhooks_manager_job'
26
- require 'shopify_app/jobs/scripttags_manager_job'
27
-
28
- # managers
29
- require 'shopify_app/managers/webhooks_manager'
30
- require 'shopify_app/managers/scripttags_manager'
31
-
32
- # session
33
- require 'shopify_app/session/session_storage'
34
- require 'shopify_app/session/session_repository'
35
- require 'shopify_app/session/in_memory_session_store'
7
+ module ShopifyApp
8
+ def self.rails6?
9
+ Rails::VERSION::MAJOR >= 6
10
+ end
11
+
12
+ def self.use_webpacker?
13
+ rails6? &&
14
+ defined?(Webpacker) == 'constant' &&
15
+ !configuration.disable_webpacker
16
+ end
17
+
18
+ # config
19
+ require 'shopify_app/configuration'
20
+
21
+ # engine
22
+ require 'shopify_app/engine'
23
+
24
+ # utils
25
+ require 'shopify_app/utils'
26
+
27
+ # controller concerns
28
+ require 'shopify_app/controller_concerns/localization'
29
+ require 'shopify_app/controller_concerns/itp'
30
+ require 'shopify_app/controller_concerns/login_protection'
31
+ require 'shopify_app/controller_concerns/embedded_app'
32
+ require 'shopify_app/controller_concerns/webhook_verification'
33
+ require 'shopify_app/controller_concerns/app_proxy_verification'
34
+
35
+ # jobs
36
+ require 'shopify_app/jobs/webhooks_manager_job'
37
+ require 'shopify_app/jobs/scripttags_manager_job'
38
+
39
+ # managers
40
+ require 'shopify_app/managers/webhooks_manager'
41
+ require 'shopify_app/managers/scripttags_manager'
42
+
43
+ # middleware
44
+ require 'shopify_app/middleware/same_site_cookie_middleware'
45
+
46
+ # session
47
+ require 'shopify_app/session/session_storage'
48
+ require 'shopify_app/session/shop_session_storage'
49
+ require 'shopify_app/session/user_session_storage'
50
+ require 'shopify_app/session/session_repository'
51
+ require 'shopify_app/session/in_memory_session_store'
52
+ require 'shopify_app/session/in_memory_shop_session_store'
53
+ require 'shopify_app/session/in_memory_user_session_store'
54
+ end