shopify_app 7.4.0 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.babelrc +5 -0
  3. data/.github/CODEOWNERS +1 -0
  4. data/.github/probots.yml +2 -0
  5. data/.gitignore +5 -0
  6. data/.nvmrc +1 -0
  7. data/.rubocop.yml +10 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +26 -3
  10. data/CHANGELOG.md +95 -0
  11. data/Gemfile +2 -0
  12. data/README.md +113 -56
  13. data/app/assets/images/storage_access.svg +2 -0
  14. data/app/assets/javascripts/shopify_app/enable_cookies.js +3 -0
  15. data/app/assets/javascripts/shopify_app/itp_helper.js +40 -0
  16. data/app/assets/javascripts/shopify_app/partition_cookies.js +7 -0
  17. data/app/assets/javascripts/shopify_app/redirect.js +33 -0
  18. data/app/assets/javascripts/shopify_app/request_storage_access.js +3 -0
  19. data/app/assets/javascripts/shopify_app/storage_access.js +121 -0
  20. data/app/assets/javascripts/shopify_app/storage_access_redirect.js +17 -0
  21. data/app/assets/javascripts/shopify_app/top_level.js +2 -0
  22. data/app/assets/javascripts/shopify_app/top_level_interaction.js +11 -0
  23. data/app/controllers/shopify_app/authenticated_controller.rb +3 -4
  24. data/{lib/shopify_app/sessions_concern.rb → app/controllers/shopify_app/callback_controller.rb} +27 -38
  25. data/app/controllers/shopify_app/sessions_controller.rb +120 -2
  26. data/app/controllers/shopify_app/webhooks_controller.rb +11 -3
  27. data/app/views/shopify_app/partials/_button_styles.html.erb +104 -0
  28. data/app/views/shopify_app/partials/_card_styles.html.erb +33 -0
  29. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +129 -0
  30. data/app/views/shopify_app/partials/_layout_styles.html.erb +167 -0
  31. data/app/views/shopify_app/partials/_typography_styles.html.erb +35 -0
  32. data/app/views/shopify_app/sessions/enable_cookies.html.erb +59 -0
  33. data/app/views/shopify_app/sessions/new.html.erb +88 -60
  34. data/app/views/shopify_app/sessions/request_storage_access.html.erb +67 -0
  35. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +63 -0
  36. data/app/views/shopify_app/shared/redirect.html.erb +22 -0
  37. data/config/locales/de.yml +21 -2
  38. data/config/locales/en.yml +12 -0
  39. data/config/locales/es.yml +21 -2
  40. data/config/locales/fr.yml +22 -2
  41. data/config/locales/it.yml +22 -0
  42. data/config/locales/ja.yml +16 -2
  43. data/config/locales/nl.yml +21 -0
  44. data/config/locales/pt-BR.yml +22 -0
  45. data/config/locales/zh-CN.yml +16 -0
  46. data/config/locales/zh-TW.yml +17 -0
  47. data/config/routes.rb +11 -1
  48. data/docs/Quickstart.md +26 -23
  49. data/docs/Releasing.md +1 -0
  50. data/karma.conf.js +43 -0
  51. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +3 -1
  52. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +1 -0
  53. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +14 -0
  54. data/lib/generators/shopify_app/home_controller/templates/shopify_app_ready_script.html.erb +1 -5
  55. data/lib/generators/shopify_app/install/install_generator.rb +3 -13
  56. data/lib/generators/shopify_app/install/templates/_flash_messages.html.erb +13 -9
  57. data/lib/generators/shopify_app/install/templates/shopify_app.rb +4 -1
  58. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +19 -4
  59. data/lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb +16 -0
  60. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +17 -0
  61. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +42 -0
  62. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +3 -3
  63. data/lib/generators/shopify_app/shop_model/templates/shop.rb +0 -1
  64. data/lib/shopify_app.rb +21 -17
  65. data/lib/shopify_app/configuration.rb +26 -8
  66. data/lib/shopify_app/{app_proxy_verification.rb → controller_concerns/app_proxy_verification.rb} +1 -1
  67. data/lib/shopify_app/controller_concerns/embedded_app.rb +19 -0
  68. data/lib/shopify_app/controller_concerns/itp.rb +45 -0
  69. data/lib/shopify_app/{localization.rb → controller_concerns/localization.rb} +6 -0
  70. data/lib/shopify_app/controller_concerns/login_protection.rb +135 -0
  71. data/lib/shopify_app/{webhook_verification.rb → controller_concerns/webhook_verification.rb} +10 -6
  72. data/lib/shopify_app/engine.rb +10 -0
  73. data/lib/shopify_app/{scripttags_manager_job.rb → jobs/scripttags_manager_job.rb} +0 -0
  74. data/lib/shopify_app/{webhooks_manager_job.rb → jobs/webhooks_manager_job.rb} +0 -0
  75. data/lib/shopify_app/{scripttags_manager.rb → managers/scripttags_manager.rb} +0 -0
  76. data/lib/shopify_app/{webhooks_manager.rb → managers/webhooks_manager.rb} +0 -0
  77. data/lib/shopify_app/session/in_memory_session_store.rb +27 -0
  78. data/lib/shopify_app/{shopify_session_repository.rb → session/session_repository.rb} +0 -0
  79. data/lib/shopify_app/{session_storage.rb → session/session_storage.rb} +9 -0
  80. data/lib/shopify_app/utils.rb +2 -2
  81. data/lib/shopify_app/version.rb +1 -1
  82. data/package-lock.json +23 -0
  83. data/package.json +28 -0
  84. data/service.yml +7 -0
  85. data/shipit.rubygems.yml +2 -0
  86. data/shopify_app.gemspec +5 -4
  87. data/translation.yml +7 -0
  88. data/webpack.config.js +24 -0
  89. data/yarn.lock +4594 -0
  90. metadata +80 -27
  91. data/lib/generators/shopify_app/install/templates/shopify_session_repository.rb +0 -23
  92. data/lib/generators/shopify_app/shop_model/templates/shopify_session_repository.rb +0 -9
  93. data/lib/shopify_app/in_memory_session_store.rb +0 -25
  94. data/lib/shopify_app/login_protection.rb +0 -119
  95. data/lib/shopify_app/shop.rb +0 -15
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 8.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: browser_sniffer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,28 +44,28 @@ dependencies:
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 4.3.2
47
+ version: 4.3.5
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 4.3.2
54
+ version: 4.3.5
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: omniauth-shopify-oauth2
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 1.2.0
61
+ version: 2.1.0
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 1.2.0
68
+ version: 2.1.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +98,16 @@ dependencies:
84
98
  name: sqlite3
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '0'
103
+ version: 1.3.6
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '0'
110
+ version: 1.3.6
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: minitest
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +142,60 @@ executables: []
128
142
  extensions: []
129
143
  extra_rdoc_files: []
130
144
  files:
145
+ - ".babelrc"
146
+ - ".github/CODEOWNERS"
131
147
  - ".github/ISSUE_TEMPLATE.md"
148
+ - ".github/probots.yml"
132
149
  - ".gitignore"
150
+ - ".nvmrc"
151
+ - ".rubocop.yml"
152
+ - ".ruby-version"
133
153
  - ".travis.yml"
134
154
  - CHANGELOG.md
135
155
  - Gemfile
136
156
  - LICENSE
137
157
  - README.md
138
158
  - Rakefile
159
+ - app/assets/images/storage_access.svg
160
+ - app/assets/javascripts/shopify_app/enable_cookies.js
161
+ - app/assets/javascripts/shopify_app/itp_helper.js
162
+ - app/assets/javascripts/shopify_app/partition_cookies.js
163
+ - app/assets/javascripts/shopify_app/redirect.js
164
+ - app/assets/javascripts/shopify_app/request_storage_access.js
165
+ - app/assets/javascripts/shopify_app/storage_access.js
166
+ - app/assets/javascripts/shopify_app/storage_access_redirect.js
167
+ - app/assets/javascripts/shopify_app/top_level.js
168
+ - app/assets/javascripts/shopify_app/top_level_interaction.js
139
169
  - app/controllers/shopify_app/authenticated_controller.rb
170
+ - app/controllers/shopify_app/callback_controller.rb
140
171
  - app/controllers/shopify_app/sessions_controller.rb
141
172
  - app/controllers/shopify_app/webhooks_controller.rb
173
+ - app/views/shopify_app/partials/_button_styles.html.erb
174
+ - app/views/shopify_app/partials/_card_styles.html.erb
175
+ - app/views/shopify_app/partials/_empty_state_styles.html.erb
176
+ - app/views/shopify_app/partials/_layout_styles.html.erb
177
+ - app/views/shopify_app/partials/_typography_styles.html.erb
178
+ - app/views/shopify_app/sessions/enable_cookies.html.erb
142
179
  - app/views/shopify_app/sessions/new.html.erb
180
+ - app/views/shopify_app/sessions/request_storage_access.html.erb
181
+ - app/views/shopify_app/sessions/top_level_interaction.html.erb
182
+ - app/views/shopify_app/shared/redirect.html.erb
143
183
  - config/locales/de.yml
144
184
  - config/locales/en.yml
145
185
  - config/locales/es.yml
146
186
  - config/locales/fr.yml
187
+ - config/locales/it.yml
147
188
  - config/locales/ja.yml
189
+ - config/locales/nl.yml
190
+ - config/locales/pt-BR.yml
191
+ - config/locales/zh-CN.yml
192
+ - config/locales/zh-TW.yml
148
193
  - config/routes.rb
149
194
  - docs/Quickstart.md
150
195
  - docs/Releasing.md
151
196
  - docs/Troubleshooting.md
152
197
  - images/app-proxy-screenshot.png
198
+ - karma.conf.js
153
199
  - lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb
154
200
  - lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb
155
201
  - lib/generators/shopify_app/add_webhook/add_webhook_generator.rb
@@ -169,36 +215,43 @@ files:
169
215
  - lib/generators/shopify_app/install/templates/omniauth.rb
170
216
  - lib/generators/shopify_app/install/templates/shopify_app.rb
171
217
  - lib/generators/shopify_app/install/templates/shopify_provider.rb
172
- - lib/generators/shopify_app/install/templates/shopify_session_repository.rb
218
+ - lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb
219
+ - lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake
220
+ - lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb
173
221
  - lib/generators/shopify_app/routes/routes_generator.rb
174
222
  - lib/generators/shopify_app/routes/templates/routes.rb
175
223
  - lib/generators/shopify_app/shop_model/shop_model_generator.rb
176
224
  - lib/generators/shopify_app/shop_model/templates/db/migrate/create_shops.erb
177
225
  - lib/generators/shopify_app/shop_model/templates/shop.rb
178
- - lib/generators/shopify_app/shop_model/templates/shopify_session_repository.rb
179
226
  - lib/generators/shopify_app/shop_model/templates/shops.yml
180
227
  - lib/generators/shopify_app/shopify_app_generator.rb
181
228
  - lib/generators/shopify_app/views/views_generator.rb
182
229
  - lib/shopify_app.rb
183
- - lib/shopify_app/app_proxy_verification.rb
184
230
  - lib/shopify_app/configuration.rb
231
+ - lib/shopify_app/controller_concerns/app_proxy_verification.rb
232
+ - lib/shopify_app/controller_concerns/embedded_app.rb
233
+ - lib/shopify_app/controller_concerns/itp.rb
234
+ - lib/shopify_app/controller_concerns/localization.rb
235
+ - lib/shopify_app/controller_concerns/login_protection.rb
236
+ - lib/shopify_app/controller_concerns/webhook_verification.rb
185
237
  - lib/shopify_app/engine.rb
186
- - lib/shopify_app/in_memory_session_store.rb
187
- - lib/shopify_app/localization.rb
188
- - lib/shopify_app/login_protection.rb
189
- - lib/shopify_app/scripttags_manager.rb
190
- - lib/shopify_app/scripttags_manager_job.rb
191
- - lib/shopify_app/session_storage.rb
192
- - lib/shopify_app/sessions_concern.rb
193
- - lib/shopify_app/shop.rb
194
- - lib/shopify_app/shopify_session_repository.rb
238
+ - lib/shopify_app/jobs/scripttags_manager_job.rb
239
+ - lib/shopify_app/jobs/webhooks_manager_job.rb
240
+ - lib/shopify_app/managers/scripttags_manager.rb
241
+ - lib/shopify_app/managers/webhooks_manager.rb
242
+ - lib/shopify_app/session/in_memory_session_store.rb
243
+ - lib/shopify_app/session/session_repository.rb
244
+ - lib/shopify_app/session/session_storage.rb
195
245
  - lib/shopify_app/utils.rb
196
246
  - lib/shopify_app/version.rb
197
- - lib/shopify_app/webhook_verification.rb
198
- - lib/shopify_app/webhooks_manager.rb
199
- - lib/shopify_app/webhooks_manager_job.rb
247
+ - package-lock.json
248
+ - package.json
249
+ - service.yml
200
250
  - shipit.rubygems.yml
201
251
  - shopify_app.gemspec
252
+ - translation.yml
253
+ - webpack.config.js
254
+ - yarn.lock
202
255
  homepage:
203
256
  licenses: []
204
257
  metadata: {}
@@ -210,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
263
  requirements:
211
264
  - - ">="
212
265
  - !ruby/object:Gem::Version
213
- version: 2.2.2
266
+ version: 2.3.1
214
267
  required_rubygems_version: !ruby/object:Gem::Requirement
215
268
  requirements:
216
269
  - - ">="
@@ -218,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
271
  version: '0'
219
272
  requirements: []
220
273
  rubyforge_project:
221
- rubygems_version: 2.5.2
274
+ rubygems_version: 2.7.6
222
275
  signing_key:
223
276
  specification_version: 4
224
277
  summary: This gem is used to get quickly started with the Shopify API
@@ -1,23 +0,0 @@
1
- # You should replace InMemorySessionStore with what you will be using
2
- # in Production. For example a model called "Shop":
3
- #
4
- # ShopifySessionRepository.storage = 'Shop'
5
- #
6
- # Interface to implement are self.retrieve(id) and self.store(ShopifyAPI::Session)
7
- # Here is how you would add these functions to an ActiveRecord:
8
- #
9
- # class Shop < ActiveRecord::Base
10
- # def self.store(session)
11
- # shop = self.new(domain: session.url, token: session.token)
12
- # shop.save!
13
- # shop.id
14
- # end
15
- #
16
- # def self.retrieve(id)
17
- # if shop = self.where(id: id).first
18
- # ShopifyAPI::Session.new(shop.domain, shop.token)
19
- # end
20
- # end
21
- # end
22
-
23
- ShopifyApp::SessionRepository.storage = InMemorySessionStore
@@ -1,9 +0,0 @@
1
- if Rails.configuration.cache_classes
2
- ShopifyApp::SessionRepository.storage = Shop
3
- else
4
- reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
5
-
6
- reloader.to_prepare do
7
- ShopifyApp::SessionRepository.storage = Shop
8
- end
9
- end
@@ -1,25 +0,0 @@
1
- # WARNING - This really only works for development, see README for more details
2
- class InMemorySessionStore
3
- class EnvironmentError < StandardError; end
4
-
5
- def self.retrieve(id)
6
- repo[id]
7
- end
8
-
9
- def self.store(session)
10
- id = SecureRandom.uuid
11
- repo[id] = session
12
- id
13
- end
14
-
15
- def self.clear
16
- @@repo = nil
17
- end
18
-
19
- def self.repo
20
- if Rails.env.production?
21
- raise EnvironmentError.new("Cannot use InMemorySessionStore in a Production environment")
22
- end
23
- @@repo ||= {}
24
- end
25
- end
@@ -1,119 +0,0 @@
1
- module ShopifyApp
2
- module LoginProtection
3
- extend ActiveSupport::Concern
4
-
5
- class ShopifyDomainNotFound < StandardError; end
6
-
7
- included do
8
- rescue_from ActiveResource::UnauthorizedAccess, :with => :close_session
9
- end
10
-
11
- def shopify_session
12
- if shop_session
13
- begin
14
- ShopifyAPI::Base.activate_session(shop_session)
15
- yield
16
- ensure
17
- ShopifyAPI::Base.clear_session
18
- end
19
- else
20
- redirect_to_login
21
- end
22
- end
23
-
24
- def shop_session
25
- return unless session[:shopify]
26
- @shop_session ||= ShopifyApp::SessionRepository.retrieve(session[:shopify])
27
- end
28
-
29
- def login_again_if_different_shop
30
- if shop_session && params[:shop] && (shop_session.url != params[:shop])
31
- session[:shopify] = nil
32
- session[:shopify_domain] = nil
33
- redirect_to_login
34
- end
35
- end
36
-
37
- protected
38
-
39
- def redirect_to_login
40
- if request.xhr?
41
- head :unauthorized
42
- else
43
- session[:return_to] = request.fullpath if request.get?
44
- redirect_to main_or_engine_login_url(shop: params[:shop])
45
- end
46
- end
47
-
48
- def close_session
49
- session[:shopify] = nil
50
- session[:shopify_domain] = nil
51
- redirect_to main_or_engine_login_url(shop: params[:shop])
52
- end
53
-
54
- def main_or_engine_login_url(params = {})
55
- main_app.login_url(params)
56
- rescue NoMethodError
57
- shopify_app.login_url(params)
58
- end
59
-
60
- def fullpage_redirect_to(url)
61
- if ShopifyApp.configuration.embedded_app?
62
- render inline: redirection_javascript(url)
63
- else
64
- redirect_to url
65
- end
66
- end
67
-
68
- def redirection_javascript(url)
69
- %(
70
- <!DOCTYPE html>
71
- <html lang="en">
72
- <head>
73
- <meta charset="utf-8" />
74
- <base target="_top">
75
- <title>Redirecting…</title>
76
- <script type="text/javascript">
77
-
78
- // If the current window is the 'parent', change the URL by setting location.href
79
- if (window.top == window.self) {
80
- window.top.location.href = #{url.to_json};
81
-
82
- // If the current window is the 'child', change the parent's URL with postMessage
83
- } else {
84
- normalizedLink = document.createElement('a');
85
- normalizedLink.href = #{url.to_json};
86
-
87
- data = JSON.stringify({
88
- message: 'Shopify.API.remoteRedirect',
89
- data: { location: normalizedLink.href }
90
- });
91
- window.parent.postMessage(data, "https://#{current_shopify_domain}");
92
- }
93
-
94
- </script>
95
- </head>
96
- <body>
97
- </body>
98
- </html>
99
- )
100
- end
101
-
102
- def current_shopify_domain
103
- shopify_domain = sanitized_shop_name || session[:shopify_domain]
104
- return shopify_domain if shopify_domain.present?
105
-
106
- raise ShopifyDomainNotFound
107
- end
108
-
109
- def sanitized_shop_name
110
- @sanitized_shop_name ||= sanitize_shop_param(params)
111
- end
112
-
113
- def sanitize_shop_param(params)
114
- return unless params[:shop].present?
115
- ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
116
- end
117
-
118
- end
119
- end
@@ -1,15 +0,0 @@
1
- module ShopifyApp
2
- module Shop
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- validates :shopify_domain, presence: true, uniqueness: true
7
- validates :shopify_token, presence: true
8
- end
9
-
10
- def with_shopify_session(&block)
11
- ShopifyAPI::Session.temp(shopify_domain, shopify_token, &block)
12
- end
13
-
14
- end
15
- end