shopify_app 21.0.0 → 22.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE/ENHANCEMENT.md +9 -0
  4. data/.github/ISSUE_TEMPLATE/bug-report.md +30 -47
  5. data/.github/ISSUE_TEMPLATE/feature-request.md +5 -29
  6. data/.github/workflows/build.yml +11 -12
  7. data/.github/workflows/release.yml +2 -2
  8. data/.github/workflows/remove-labels-on-activity.yml +1 -1
  9. data/.github/workflows/rubocop.yml +2 -3
  10. data/.nvmrc +1 -1
  11. data/.rubocop.yml +2 -1
  12. data/.ruby-version +1 -1
  13. data/.spin/rails/prepare-application +8 -0
  14. data/CHANGELOG.md +173 -7
  15. data/CODE_OF_CONDUCT.md +46 -0
  16. data/CONTRIBUTING.md +16 -6
  17. data/Gemfile +1 -0
  18. data/Gemfile.lock +160 -121
  19. data/README.md +67 -19
  20. data/SECURITY.md +1 -1
  21. data/app/assets/javascripts/shopify_app/redirect.js +3 -10
  22. data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +9 -4
  23. data/app/controllers/concerns/shopify_app/ensure_has_session.rb +25 -0
  24. data/app/controllers/concerns/shopify_app/ensure_installed.rb +84 -0
  25. data/app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb +5 -1
  26. data/app/controllers/shopify_app/authenticated_controller.rb +1 -1
  27. data/app/controllers/shopify_app/callback_controller.rb +101 -39
  28. data/app/controllers/shopify_app/extension_verification_controller.rb +4 -1
  29. data/app/controllers/shopify_app/sessions_controller.rb +37 -7
  30. data/app/controllers/shopify_app/webhooks_controller.rb +1 -1
  31. data/app/views/shopify_app/layouts/app_bridge.html.erb +17 -0
  32. data/app/views/shopify_app/sessions/patch_shopify_id_token.html.erb +0 -0
  33. data/app/views/shopify_app/shared/redirect.html.erb +10 -1
  34. data/config/locales/cs.yml +0 -18
  35. data/config/locales/da.yml +0 -15
  36. data/config/locales/de.yml +0 -17
  37. data/config/locales/en.yml +0 -11
  38. data/config/locales/es.yml +0 -17
  39. data/config/locales/fi.yml +0 -15
  40. data/config/locales/fr.yml +0 -18
  41. data/config/locales/it.yml +0 -16
  42. data/config/locales/ja.yml +0 -12
  43. data/config/locales/ko.yml +0 -14
  44. data/config/locales/nb.yml +0 -16
  45. data/config/locales/nl.yml +0 -16
  46. data/config/locales/pl.yml +0 -16
  47. data/config/locales/pt-BR.yml +0 -16
  48. data/config/locales/pt-PT.yml +0 -17
  49. data/config/locales/sv.yml +0 -16
  50. data/config/locales/th.yml +0 -15
  51. data/config/locales/tr.yml +0 -17
  52. data/config/locales/vi.yml +0 -17
  53. data/config/locales/zh-CN.yml +0 -11
  54. data/config/locales/zh-TW.yml +0 -11
  55. data/config/routes.rb +2 -1
  56. data/docs/Quickstart.md +14 -5
  57. data/docs/Troubleshooting.md +38 -25
  58. data/docs/Upgrading.md +103 -32
  59. data/docs/shopify_app/authentication.md +179 -58
  60. data/docs/shopify_app/controller-concerns.md +89 -0
  61. data/docs/shopify_app/engine.md +2 -11
  62. data/docs/shopify_app/generators.md +2 -2
  63. data/docs/shopify_app/logging.md +21 -0
  64. data/docs/shopify_app/sessions.md +358 -0
  65. data/docs/shopify_app/testing.md +32 -10
  66. data/docs/shopify_app/webhooks.md +97 -7
  67. data/karma.conf.js +6 -4
  68. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +6 -3
  69. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -1
  70. data/lib/generators/shopify_app/add_app_uninstalled_job/add_app_uninstalled_job_generator.rb +15 -0
  71. data/lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt +22 -0
  72. data/lib/generators/shopify_app/add_declarative_webhook/add_declarative_webhook_generator.rb +53 -0
  73. data/lib/generators/shopify_app/add_declarative_webhook/templates/webhook_controller.rb.tt +13 -0
  74. data/lib/generators/shopify_app/add_declarative_webhook/templates/webhook_job.rb.tt +15 -0
  75. data/lib/generators/shopify_app/add_privacy_jobs/add_privacy_jobs_generator.rb +23 -0
  76. data/lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt +22 -0
  77. data/lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt +22 -0
  78. data/lib/generators/shopify_app/add_privacy_jobs/templates/shop_redact_job.rb.tt +22 -0
  79. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +8 -3
  80. data/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt +4 -2
  81. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +1 -1
  82. data/lib/generators/shopify_app/authenticated_controller/templates/authenticated_controller.rb +1 -1
  83. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +1 -1
  84. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +1 -1
  85. data/lib/generators/shopify_app/install/install_generator.rb +4 -4
  86. data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +13 -3
  87. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +1 -1
  88. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +1 -1
  89. data/lib/generators/shopify_app/routes/routes_generator.rb +1 -1
  90. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +1 -1
  91. data/lib/generators/shopify_app/shop_model/templates/db/migrate/add_shop_access_scopes_column.erb +1 -1
  92. data/lib/generators/shopify_app/shopify_app_generator.rb +2 -0
  93. data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_access_scopes_column.erb +1 -1
  94. data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_expires_at_column.erb +5 -0
  95. data/lib/generators/shopify_app/user_model/user_model_generator.rb +21 -1
  96. data/lib/shopify_app/access_scopes/noop_strategy.rb +4 -0
  97. data/lib/shopify_app/access_scopes/user_strategy.rb +9 -2
  98. data/lib/shopify_app/admin_api/with_token_refetch.rb +27 -0
  99. data/lib/shopify_app/auth/post_authenticate_tasks.rb +48 -0
  100. data/lib/shopify_app/auth/token_exchange.rb +73 -0
  101. data/lib/shopify_app/configuration.rb +82 -1
  102. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -3
  103. data/lib/shopify_app/controller_concerns/csrf_protection.rb +2 -1
  104. data/lib/shopify_app/controller_concerns/embedded_app.rb +42 -3
  105. data/lib/shopify_app/controller_concerns/ensure_billing.rb +28 -12
  106. data/lib/shopify_app/controller_concerns/frame_ancestors.rb +1 -1
  107. data/lib/shopify_app/controller_concerns/localization.rb +11 -8
  108. data/lib/shopify_app/controller_concerns/login_protection.rb +83 -38
  109. data/lib/shopify_app/controller_concerns/payload_verification.rb +1 -1
  110. data/lib/shopify_app/controller_concerns/redirect_for_embedded.rb +15 -3
  111. data/lib/shopify_app/controller_concerns/sanitized_params.rb +5 -0
  112. data/lib/shopify_app/controller_concerns/token_exchange.rb +111 -0
  113. data/lib/shopify_app/controller_concerns/webhook_verification.rb +4 -1
  114. data/lib/shopify_app/controller_concerns/with_shopify_id_token.rb +48 -0
  115. data/lib/shopify_app/engine.rb +7 -8
  116. data/lib/shopify_app/logger.rb +28 -0
  117. data/lib/shopify_app/managers/webhooks_manager.rb +20 -10
  118. data/lib/shopify_app/middleware/jwt_middleware.rb +13 -9
  119. data/lib/shopify_app/session/in_memory_user_session_store.rb +1 -1
  120. data/lib/shopify_app/session/jwt.rb +11 -2
  121. data/lib/shopify_app/session/session_repository.rb +66 -14
  122. data/lib/shopify_app/session/session_storage.rb +2 -2
  123. data/lib/shopify_app/session/shop_session_storage.rb +5 -1
  124. data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +5 -1
  125. data/lib/shopify_app/session/user_session_storage.rb +6 -2
  126. data/lib/shopify_app/session/user_session_storage_with_scopes.rb +27 -2
  127. data/lib/shopify_app/test_helpers/all.rb +1 -0
  128. data/lib/shopify_app/test_helpers/shopify_session_helper.rb +16 -0
  129. data/lib/shopify_app/utils.rb +82 -20
  130. data/lib/shopify_app/version.rb +1 -1
  131. data/lib/shopify_app.rb +12 -3
  132. data/package.json +5 -6
  133. data/service.yml +0 -2
  134. data/shopify_app.gemspec +6 -5
  135. data/translation.yml +1 -0
  136. data/yarn.lock +2139 -3910
  137. metadata +78 -58
  138. data/.github/workflows/stale.yml +0 -31
  139. data/app/assets/images/storage_access.svg +0 -1
  140. data/app/assets/javascripts/shopify_app/app_bridge_3.1.1.js +0 -10
  141. data/app/assets/javascripts/shopify_app/app_bridge_redirect.js +0 -22
  142. data/app/assets/javascripts/shopify_app/app_bridge_utils_3.1.1.js +0 -1
  143. data/app/assets/javascripts/shopify_app/enable_cookies.js +0 -3
  144. data/app/assets/javascripts/shopify_app/itp_helper.js +0 -40
  145. data/app/assets/javascripts/shopify_app/partition_cookies.js +0 -8
  146. data/app/assets/javascripts/shopify_app/post_redirect.js +0 -9
  147. data/app/assets/javascripts/shopify_app/request_storage_access.js +0 -3
  148. data/app/assets/javascripts/shopify_app/storage_access.js +0 -148
  149. data/app/assets/javascripts/shopify_app/storage_access_redirect.js +0 -17
  150. data/app/assets/javascripts/shopify_app/top_level.js +0 -2
  151. data/app/assets/javascripts/shopify_app/top_level_interaction.js +0 -11
  152. data/app/controllers/concerns/shopify_app/authenticated.rb +0 -19
  153. data/app/controllers/concerns/shopify_app/require_known_shop.rb +0 -48
  154. data/app/views/shopify_app/sessions/enable_cookies.html.erb +0 -70
  155. data/app/views/shopify_app/sessions/request_storage_access.html.erb +0 -68
  156. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +0 -63
  157. data/app/views/shopify_app/shared/post_redirect_to_auth_shopify.html.erb +0 -13
  158. data/docs/shopify_app/script-tags.md +0 -28
  159. data/docs/shopify_app/session-repository.md +0 -88
  160. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +0 -41
  161. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +0 -62
  162. data/lib/shopify_app/controller_concerns/itp.rb +0 -45
  163. data/lib/shopify_app/jobs/scripttags_manager_job.rb +0 -16
  164. data/lib/shopify_app/managers/scripttags_manager.rb +0 -84
data/Gemfile.lock CHANGED
@@ -1,135 +1,151 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_app (21.0.0)
4
+ shopify_app (22.5.0)
5
5
  activeresource
6
- browser_sniffer (~> 2.0)
6
+ addressable (~> 2.7)
7
7
  jwt (>= 2.2.3)
8
8
  rails (> 5.2.1)
9
9
  redirect_safely (~> 1.0)
10
- shopify_api (~> 12.0.0)
10
+ shopify_api (>= 14.7.0, < 15.0)
11
11
  sprockets-rails (>= 2.0.0)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- actioncable (6.1.5)
17
- actionpack (= 6.1.5)
18
- activesupport (= 6.1.5)
16
+ actioncable (6.1.7.9)
17
+ actionpack (= 6.1.7.9)
18
+ activesupport (= 6.1.7.9)
19
19
  nio4r (~> 2.0)
20
20
  websocket-driver (>= 0.6.1)
21
- actionmailbox (6.1.5)
22
- actionpack (= 6.1.5)
23
- activejob (= 6.1.5)
24
- activerecord (= 6.1.5)
25
- activestorage (= 6.1.5)
26
- activesupport (= 6.1.5)
21
+ actionmailbox (6.1.7.9)
22
+ actionpack (= 6.1.7.9)
23
+ activejob (= 6.1.7.9)
24
+ activerecord (= 6.1.7.9)
25
+ activestorage (= 6.1.7.9)
26
+ activesupport (= 6.1.7.9)
27
27
  mail (>= 2.7.1)
28
- actionmailer (6.1.5)
29
- actionpack (= 6.1.5)
30
- actionview (= 6.1.5)
31
- activejob (= 6.1.5)
32
- activesupport (= 6.1.5)
28
+ actionmailer (6.1.7.9)
29
+ actionpack (= 6.1.7.9)
30
+ actionview (= 6.1.7.9)
31
+ activejob (= 6.1.7.9)
32
+ activesupport (= 6.1.7.9)
33
33
  mail (~> 2.5, >= 2.5.4)
34
34
  rails-dom-testing (~> 2.0)
35
- actionpack (6.1.5)
36
- actionview (= 6.1.5)
37
- activesupport (= 6.1.5)
35
+ actionpack (6.1.7.9)
36
+ actionview (= 6.1.7.9)
37
+ activesupport (= 6.1.7.9)
38
38
  rack (~> 2.0, >= 2.0.9)
39
39
  rack-test (>= 0.6.3)
40
40
  rails-dom-testing (~> 2.0)
41
41
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
- actiontext (6.1.5)
43
- actionpack (= 6.1.5)
44
- activerecord (= 6.1.5)
45
- activestorage (= 6.1.5)
46
- activesupport (= 6.1.5)
42
+ actiontext (6.1.7.9)
43
+ actionpack (= 6.1.7.9)
44
+ activerecord (= 6.1.7.9)
45
+ activestorage (= 6.1.7.9)
46
+ activesupport (= 6.1.7.9)
47
47
  nokogiri (>= 1.8.5)
48
- actionview (6.1.5)
49
- activesupport (= 6.1.5)
48
+ actionview (6.1.7.9)
49
+ activesupport (= 6.1.7.9)
50
50
  builder (~> 3.1)
51
51
  erubi (~> 1.4)
52
52
  rails-dom-testing (~> 2.0)
53
53
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
- activejob (6.1.5)
55
- activesupport (= 6.1.5)
54
+ activejob (6.1.7.9)
55
+ activesupport (= 6.1.7.9)
56
56
  globalid (>= 0.3.6)
57
- activemodel (6.1.5)
58
- activesupport (= 6.1.5)
57
+ activemodel (6.1.7.9)
58
+ activesupport (= 6.1.7.9)
59
59
  activemodel-serializers-xml (1.0.2)
60
60
  activemodel (> 5.x)
61
61
  activesupport (> 5.x)
62
62
  builder (~> 3.1)
63
- activerecord (6.1.5)
64
- activemodel (= 6.1.5)
65
- activesupport (= 6.1.5)
66
- activeresource (6.0.0)
63
+ activerecord (6.1.7.9)
64
+ activemodel (= 6.1.7.9)
65
+ activesupport (= 6.1.7.9)
66
+ activeresource (6.1.3)
67
67
  activemodel (>= 6.0)
68
68
  activemodel-serializers-xml (~> 1.0)
69
69
  activesupport (>= 6.0)
70
- activestorage (6.1.5)
71
- actionpack (= 6.1.5)
72
- activejob (= 6.1.5)
73
- activerecord (= 6.1.5)
74
- activesupport (= 6.1.5)
70
+ activestorage (6.1.7.9)
71
+ actionpack (= 6.1.7.9)
72
+ activejob (= 6.1.7.9)
73
+ activerecord (= 6.1.7.9)
74
+ activesupport (= 6.1.7.9)
75
75
  marcel (~> 1.0)
76
76
  mini_mime (>= 1.1.0)
77
- activesupport (6.1.5)
77
+ activesupport (6.1.7.9)
78
78
  concurrent-ruby (~> 1.0, >= 1.0.2)
79
79
  i18n (>= 1.6, < 2)
80
80
  minitest (>= 5.1)
81
81
  tzinfo (~> 2.0)
82
82
  zeitwerk (~> 2.3)
83
- addressable (2.8.0)
84
- public_suffix (>= 2.0.2, < 5.0)
83
+ addressable (2.8.4)
84
+ public_suffix (>= 2.0.2, < 6.0)
85
85
  ast (2.4.2)
86
86
  binding_of_caller (1.0.0)
87
87
  debug_inspector (>= 0.0.1)
88
- browser_sniffer (2.1.0)
89
- builder (3.2.4)
88
+ builder (3.3.0)
90
89
  byebug (11.1.3)
91
90
  coderay (1.1.3)
92
- concurrent-ruby (1.1.10)
91
+ concurrent-ruby (1.3.4)
93
92
  crack (0.4.5)
94
93
  rexml
95
94
  crass (1.0.6)
95
+ date (3.3.4)
96
96
  debug_inspector (1.1.0)
97
- erubi (1.10.0)
98
- globalid (1.0.0)
99
- activesupport (>= 5.0)
97
+ erubi (1.13.0)
98
+ globalid (1.2.1)
99
+ activesupport (>= 6.1)
100
100
  hash_diff (1.1.1)
101
101
  hashdiff (1.0.1)
102
- httparty (0.20.0)
103
- mime-types (~> 3.0)
102
+ httparty (0.21.0)
103
+ mini_mime (>= 1.0.0)
104
104
  multi_xml (>= 0.5.2)
105
- i18n (1.10.0)
105
+ i18n (1.14.6)
106
106
  concurrent-ruby (~> 1.0)
107
- jwt (2.5.0)
108
- loofah (2.15.0)
107
+ json (2.7.2)
108
+ jwt (2.7.0)
109
+ language_server-protocol (3.17.0.3)
110
+ loofah (2.22.0)
109
111
  crass (~> 1.0.2)
110
- nokogiri (>= 1.5.9)
111
- mail (2.7.1)
112
+ nokogiri (>= 1.12.0)
113
+ mail (2.8.1)
112
114
  mini_mime (>= 0.1.1)
115
+ net-imap
116
+ net-pop
117
+ net-smtp
113
118
  marcel (1.0.2)
114
119
  method_source (1.0.0)
115
- mime-types (3.4.1)
116
- mime-types-data (~> 3.2015)
117
- mime-types-data (3.2022.0105)
118
- mini_mime (1.1.2)
119
- mini_portile2 (2.8.0)
120
- minitest (5.15.0)
121
- mocha (1.13.0)
120
+ mini_mime (1.1.5)
121
+ minitest (5.18.0)
122
+ mocha (2.0.2)
123
+ ruby2_keywords (>= 0.0.5)
122
124
  multi_xml (0.6.0)
123
- nio4r (2.5.8)
124
- nokogiri (1.13.4)
125
- mini_portile2 (~> 2.8.0)
125
+ net-imap (0.4.17)
126
+ date
127
+ net-protocol
128
+ net-pop (0.1.2)
129
+ net-protocol
130
+ net-protocol (0.2.2)
131
+ timeout
132
+ net-smtp (0.5.0)
133
+ net-protocol
134
+ nio4r (2.5.9)
135
+ nokogiri (1.16.7-arm64-darwin)
126
136
  racc (~> 1.4)
127
- oj (3.13.21)
128
- openssl (3.0.1)
129
- parallel (1.21.0)
130
- parser (3.1.0.0)
137
+ nokogiri (1.16.7-x86_64-darwin)
138
+ racc (~> 1.4)
139
+ nokogiri (1.16.7-x86_64-linux)
140
+ racc (~> 1.4)
141
+ oj (3.14.3)
142
+ openssl (3.1.0)
143
+ parallel (1.24.0)
144
+ parser (3.3.0.5)
131
145
  ast (~> 2.4.1)
132
- pry (0.14.1)
146
+ racc
147
+ prettier_print (1.2.1)
148
+ pry (0.14.2)
133
149
  coderay (~> 1.1)
134
150
  method_source (~> 1.0)
135
151
  pry-nav (1.0.0)
@@ -137,38 +153,40 @@ GEM
137
153
  pry-stack_explorer (0.6.1)
138
154
  binding_of_caller (~> 1.0)
139
155
  pry (~> 0.13)
140
- public_suffix (4.0.6)
141
- racc (1.6.0)
142
- rack (2.2.3)
143
- rack-test (1.1.0)
144
- rack (>= 1.0, < 3)
145
- rails (6.1.5)
146
- actioncable (= 6.1.5)
147
- actionmailbox (= 6.1.5)
148
- actionmailer (= 6.1.5)
149
- actionpack (= 6.1.5)
150
- actiontext (= 6.1.5)
151
- actionview (= 6.1.5)
152
- activejob (= 6.1.5)
153
- activemodel (= 6.1.5)
154
- activerecord (= 6.1.5)
155
- activestorage (= 6.1.5)
156
- activesupport (= 6.1.5)
156
+ public_suffix (5.0.1)
157
+ racc (1.8.1)
158
+ rack (2.2.10)
159
+ rack-test (2.1.0)
160
+ rack (>= 1.3)
161
+ rails (6.1.7.9)
162
+ actioncable (= 6.1.7.9)
163
+ actionmailbox (= 6.1.7.9)
164
+ actionmailer (= 6.1.7.9)
165
+ actionpack (= 6.1.7.9)
166
+ actiontext (= 6.1.7.9)
167
+ actionview (= 6.1.7.9)
168
+ activejob (= 6.1.7.9)
169
+ activemodel (= 6.1.7.9)
170
+ activerecord (= 6.1.7.9)
171
+ activestorage (= 6.1.7.9)
172
+ activesupport (= 6.1.7.9)
157
173
  bundler (>= 1.15.0)
158
- railties (= 6.1.5)
174
+ railties (= 6.1.7.9)
159
175
  sprockets-rails (>= 2.0.0)
160
176
  rails-controller-testing (1.0.5)
161
177
  actionpack (>= 5.0.1.rc1)
162
178
  actionview (>= 5.0.1.rc1)
163
179
  activesupport (>= 5.0.1.rc1)
164
- rails-dom-testing (2.0.3)
165
- activesupport (>= 4.2.0)
180
+ rails-dom-testing (2.2.0)
181
+ activesupport (>= 5.0.0)
182
+ minitest
166
183
  nokogiri (>= 1.6)
167
- rails-html-sanitizer (1.4.2)
168
- loofah (~> 2.3)
169
- railties (6.1.5)
170
- actionpack (= 6.1.5)
171
- activesupport (= 6.1.5)
184
+ rails-html-sanitizer (1.6.0)
185
+ loofah (~> 2.21)
186
+ nokogiri (~> 1.14)
187
+ railties (6.1.7.9)
188
+ actionpack (= 6.1.7.9)
189
+ activesupport (= 6.1.7.9)
172
190
  method_source
173
191
  rake (>= 12.2)
174
192
  thor (~> 1.0)
@@ -177,24 +195,32 @@ GEM
177
195
  rb-readline (0.5.5)
178
196
  redirect_safely (1.0.0)
179
197
  activemodel
180
- regexp_parser (2.2.0)
181
- rexml (3.2.5)
182
- rubocop (1.25.1)
198
+ regexp_parser (2.9.0)
199
+ rexml (3.3.9)
200
+ rubocop (1.62.1)
201
+ json (~> 2.3)
202
+ language_server-protocol (>= 3.17.0)
183
203
  parallel (~> 1.10)
184
- parser (>= 3.1.0.0)
204
+ parser (>= 3.3.0.2)
185
205
  rainbow (>= 2.2.2, < 4.0)
186
206
  regexp_parser (>= 1.8, < 3.0)
187
- rexml
188
- rubocop-ast (>= 1.15.1, < 2.0)
207
+ rexml (>= 3.2.5, < 4.0)
208
+ rubocop-ast (>= 1.31.1, < 2.0)
189
209
  ruby-progressbar (~> 1.7)
190
- unicode-display_width (>= 1.4.0, < 3.0)
191
- rubocop-ast (1.15.1)
192
- parser (>= 3.0.1.1)
193
- rubocop-shopify (2.4.0)
194
- rubocop (~> 1.24)
195
- ruby-progressbar (1.11.0)
196
- securerandom (0.2.0)
197
- shopify_api (12.0.0)
210
+ unicode-display_width (>= 2.4.0, < 3.0)
211
+ rubocop-ast (1.31.2)
212
+ parser (>= 3.3.0.4)
213
+ rubocop-shopify (2.13.0)
214
+ rubocop (~> 1.50)
215
+ ruby-lsp (0.5.1)
216
+ language_server-protocol (~> 3.17.0)
217
+ sorbet-runtime
218
+ syntax_tree (>= 6.1.1, < 7)
219
+ ruby-progressbar (1.13.0)
220
+ ruby2_keywords (0.0.5)
221
+ securerandom (0.2.2)
222
+ shopify_api (14.7.0)
223
+ activesupport
198
224
  concurrent-ruby
199
225
  hash_diff
200
226
  httparty
@@ -204,30 +230,41 @@ GEM
204
230
  securerandom
205
231
  sorbet-runtime
206
232
  zeitwerk (~> 2.5)
207
- sorbet-runtime (0.5.10477)
208
- sprockets (4.1.1)
233
+ sorbet-runtime (0.5.10835)
234
+ sprockets (4.2.0)
209
235
  concurrent-ruby (~> 1.0)
210
- rack (> 1, < 3)
236
+ rack (>= 2.2.4, < 4)
211
237
  sprockets-rails (3.4.2)
212
238
  actionpack (>= 5.2)
213
239
  activesupport (>= 5.2)
214
240
  sprockets (>= 3.0.0)
215
- sqlite3 (1.4.2)
216
- thor (1.2.1)
217
- tzinfo (2.0.4)
241
+ sqlite3 (1.7.3-arm64-darwin)
242
+ sqlite3 (1.7.3-x86_64-darwin)
243
+ sqlite3 (1.7.3-x86_64-linux)
244
+ syntax_tree (6.1.1)
245
+ prettier_print (>= 1.2.0)
246
+ thor (1.2.2)
247
+ timeout (0.4.1)
248
+ tzinfo (2.0.6)
218
249
  concurrent-ruby (~> 1.0)
219
- unicode-display_width (2.1.0)
220
- webmock (3.14.0)
250
+ unicode-display_width (2.5.0)
251
+ webmock (3.18.1)
221
252
  addressable (>= 2.8.0)
222
253
  crack (>= 0.3.2)
223
254
  hashdiff (>= 0.4.0, < 2.0.0)
224
255
  websocket-driver (0.7.5)
225
256
  websocket-extensions (>= 0.1.0)
226
257
  websocket-extensions (0.1.5)
227
- zeitwerk (2.6.1)
258
+ zeitwerk (2.6.18)
228
259
 
229
260
  PLATFORMS
230
- ruby
261
+ arm64-darwin-21
262
+ arm64-darwin-22
263
+ arm64-darwin-23
264
+ x86_64-darwin-19
265
+ x86_64-darwin-20
266
+ x86_64-darwin-21
267
+ x86_64-linux
231
268
 
232
269
  DEPENDENCIES
233
270
  byebug
@@ -236,13 +273,15 @@ DEPENDENCIES
236
273
  pry
237
274
  pry-nav
238
275
  pry-stack_explorer
276
+ rails (< 7)
239
277
  rails-controller-testing
240
278
  rake
241
279
  rb-readline
242
280
  rubocop-shopify
281
+ ruby-lsp
243
282
  shopify_app!
244
283
  sqlite3 (~> 1.4)
245
284
  webmock
246
285
 
247
286
  BUNDLED WITH
248
- 2.3.5
287
+ 2.4.10
data/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  This gem builds Rails applications that can be embedded in the Shopify Admin.
9
9
 
10
- [Introduction](#introduction) |
11
- [Requirements](#requirements) |
12
- [Usage](#usage) |
13
- [Documentation](#documentation) |
10
+ [Introduction](#introduction) |
11
+ [Requirements](#requirements) |
12
+ [Usage](#usage) |
13
+ [Documentation](#documentation) |
14
14
  [Contributing](/CONTRIBUTING.md) |
15
15
  [License](/LICENSE)
16
16
 
@@ -22,15 +22,12 @@ This gem includes a Rails engine, generators, modules, and mixins that help crea
22
22
  <!-- This section is linked to in `templates/shopify_app.rb.tt`. Be careful renaming this heading. -->
23
23
  ## Requirements
24
24
 
25
- > **Rails compatibility**
26
- > * Use Shopify App `<= v7.2.8` if you need to work with Rails 4.
27
-
28
25
  To become a Shopify app developer, you will need a [Shopify Partners](https://www.shopify.com/partners) account. Explore the [Shopify dev docs](https://shopify.dev/concepts/shopify-introduction) to learn more about [building Shopify apps](https://shopify.dev/concepts/apps).
29
26
 
30
27
  This gem requires that you have the following credentials:
31
28
 
32
- - **Shopify API key:** The API key app credential specified in your [Shopify Partners dashboard](https://partners.shopify.com/organizations).
33
- - **Shopify API secret:** The API secret key app credential specified in your [Shopify Partners dashboard](https://partners.shopify.com/organizations).
29
+ - **Shopify API key:** The API key app credential specified in your [Shopify Partners dashboard](https://partners.shopify.com/organizations).
30
+ - **Shopify API secret:** The API secret key app credential specified in your [Shopify Partners dashboard](https://partners.shopify.com/organizations).
34
31
 
35
32
  ## Usage
36
33
 
@@ -40,21 +37,22 @@ This gem requires that you have the following credentials:
40
37
  rails new my_shopify_app
41
38
  ```
42
39
 
43
- 2. Add the Shopify App gem to `my_shopify_app`'s Gemfile.
40
+ 2. Add the Shopify App gem to the app's Gemfile:
44
41
 
45
42
  ```sh
46
43
  bundle add shopify_app
47
44
  ```
48
45
 
49
- 3. Create a `.env` file in the root of `my_shopify_app` to specify your Shopify API credentials:
46
+ 3. You will need to provide several environment variables to the app.
47
+ There are a variety of way of doing this, but for a development environment we recommended the [`dotenv-rails`](https://github.com/bkeepers/dotenv) gem.
48
+ Create a `.env` file in the root of your Rails app to specify the full host and Shopify API credentials:
50
49
 
51
50
  ```sh
51
+ HOST=http://localhost:3000
52
52
  SHOPIFY_API_KEY=<Your Shopify API key>
53
53
  SHOPIFY_API_SECRET=<Your Shopify API secret>
54
54
  ```
55
55
 
56
- > In a development environment, you can use a gem like `dotenv-rails` to manage environment variables.
57
-
58
56
  4. Run the default Shopify App generator to create an app that can be embedded in the Shopify Admin:
59
57
 
60
58
  ```sh
@@ -67,15 +65,18 @@ rails generate shopify_app
67
65
  rails db:migrate
68
66
  ```
69
67
 
70
- 6. Setup a SSH tunnel to allow the OAuth redirect to work. See how in the [Setup SSH tunnel for development](/docs/Quickstart.md#setup-ssh-tunnel-for-development) section in [Quickstart](/docs/Quickstart.md)
71
-
72
- 7. Run the app:
68
+ 6. Run the app:
73
69
 
74
70
  ```sh
75
71
  rails server
76
72
  ```
77
73
 
78
- 8. Install the app by visiting the server's URL (e.g. http://127.0.0.1:3000) and specifying the subdomain of the shop where you want it to be installed to.
74
+ 7. Within [Shopify Partners](https://www.shopify.com/partners), navigate to your App, then App Setup, and configure the URLs, e.g.:
75
+
76
+ * App URL: http://localhost:3000/
77
+ * Allowed redirection URL(s): http://localhost:3000/auth/shopify/callback
78
+
79
+ 8. Install the app by visiting the server's URL (e.g. http://localhost:3000) and specifying the subdomain of the shop where you want it to be installed to.
79
80
 
80
81
  9. After the app is installed, you're redirected to the embedded app.
81
82
 
@@ -103,13 +104,14 @@ You can find documentation on gem usage, concepts, mixins, installation, and mor
103
104
  [Shopify App](/docs/shopify_app)
104
105
  * [Authentication](/docs/shopify_app/authentication.md)
105
106
  * [Engine](/docs/shopify_app/engine.md)
107
+ * [Controller Concerns](/docs/shopify_app/controller-concerns.md)
106
108
  * [Generators](/docs/shopify_app/generators.md)
107
- * [ScriptTags](/docs/shopify_app/script-tags.md)
108
- * [Session repository](/docs/shopify_app/session-repository.md)
109
+ * [Sessions](/docs/shopify_app/sessions.md)
109
110
  * [Handling changes in access scopes](/docs/shopify_app/handling-access-scopes-changes.md)
110
111
  * [Testing](/docs/shopify_app/testing.md)
111
112
  * [Webhooks](/docs/shopify_app/webhooks.md)
112
113
  * [Content Security Policy](/docs/shopify_app/content-security-policy.md)
114
+ * [Logging](/docs/shopify_app/logging.md)
113
115
 
114
116
  ### Engine
115
117
 
@@ -127,6 +129,52 @@ These routes are configurable. See the more detailed [*Engine*](/docs/shopify_ap
127
129
 
128
130
  To learn more about how this gem authenticates with Shopify, see [*Authentication*](/docs/shopify_app/authentication.md).
129
131
 
132
+ ### New embedded app authorization strategy (Token Exchange)
133
+
134
+ > [!TIP]
135
+ > If you are building an embedded app, we **strongly** recommend using [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)
136
+ > with [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange) instead of the legacy authorization code grant flow.
137
+
138
+ We've introduced a new installation and authorization strategy for **embedded apps** that
139
+ eliminates the redirects that were previously necessary.
140
+ It replaces the existing [installation and authorization code grant flow](https://shopify.dev/docs/apps/auth/get-access-tokens/authorization-code-grant).
141
+
142
+ This is achieved by using [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)
143
+ to handle automatic app installations and scope updates, while utilizing
144
+ [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange) to retrieve an access token for
145
+ authenticated API access.
146
+
147
+ ##### Enabling this new strategy in your app
148
+
149
+ 1. Enable [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)
150
+ by configuring your scopes [through the Shopify CLI](https://shopify.dev/docs/apps/tools/cli/configuration).
151
+ > [!NOTE]
152
+ > Ensure you don't have `use_legacy_install_flow = true` in your `shopify.app.toml` configuration file. If `use_legacy_install_flow` is true, Shopify will not manage the installation process for your app.
153
+ > You should remove the `use_legacy_install_flow` line from your `shopify.app.toml` configuration file or set it to `false`.
154
+
155
+ 2. Enable the new auth strategy in your app's ShopifyApp configuration file.
156
+
157
+ ```ruby
158
+ # config/initializers/shopify_app.rb
159
+ ShopifyApp.configure do |config|
160
+ #.....
161
+ config.embedded_app = true
162
+ config.new_embedded_auth_strategy = true
163
+
164
+ # If your app is configured to use online sessions, you can enable session expiry date check so a new access token
165
+ # is fetched automatically when the session expires.
166
+ # See expiry date check docs: https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/sessions.md#expiry-date
167
+ config.check_session_expiry_date = true
168
+ ...
169
+ end
170
+
171
+ ```
172
+ 3. Handle special callback logic. If your app has overridden the OAuth CallbackController to run special tasks post authorization,
173
+ you'll need to create and configure a custom PostAuthenticateTasks class to run these tasks after the token exchange. The original
174
+ OAuth CallbackController will not be triggered anymore. See [Post Authenticate Tasks documentation](/docs/shopify_app/authentication.md#post-authenticate-tasks) for more information.
175
+ 4. Make sure your `embedded_app` layout is correct. If your app has any controller which includes `ShopifyApp::EnsureInstalled`, they will now also include the `ShopifyApp::EmbeddedApp` concern, which sets `layout 'embedded_app'` for the current controller by default. In cases where the controller originally looked for another layout file, this can cause unexpected behavior. See [`EmbeddedApp` concern's documentation](/docs/shopify_app/controller-concerns.md#embeddedapp) for more information on the effects of this concern and how to disable the layout change if needed.
176
+ 5. Enjoy a smoother and faster app installation process.
177
+
130
178
  ### API Versioning
131
179
 
132
180
  [Shopify's API is versioned](https://shopify.dev/concepts/about-apis/versioning). With Shopify App `v1.11.0`, the included Shopify API gem allows developers to specify and update the Shopify API version they want their app or service to use. The Shopify API gem also surfaces warnings to Rails apps about [deprecated endpoints, GraphQL fields and more](https://shopify.dev/concepts/about-apis/versioning#deprecation-practices).
data/SECURITY.md CHANGED
@@ -56,4 +56,4 @@ We look forward to working with all security researchers and strive to be respec
56
56
 
57
57
  ## Receiving Security Updates
58
58
 
59
- To recieve all general updates to vulnerabilities, please subscribe to our hackerone [Hacktivity](https://hackerone.com/shopify/hacktivity)
59
+ To receive all general updates to vulnerabilities, please subscribe to our hackerone [Hacktivity](https://hackerone.com/shopify/hacktivity)
@@ -1,6 +1,3 @@
1
- //= require ./app_bridge_redirect.js
2
- //= require ./app_bridge_utils_3.1.1.js
3
-
4
1
  (function () {
5
2
  function redirect() {
6
3
  var redirectTargetElement = document.getElementById("redirection-target");
@@ -10,14 +7,10 @@
10
7
  }
11
8
 
12
9
  var targetInfo = JSON.parse(redirectTargetElement.dataset.target);
10
+ var normalizedLink = document.createElement('a');
11
+ normalizedLink.href = targetInfo.url;
13
12
 
14
- var appBridgeUtils = window['app-bridge-utils'];
15
-
16
- if (appBridgeUtils.isShopifyEmbedded()) {
17
- window.appBridgeRedirect(targetInfo.url);
18
- } else {
19
- window.top.location.href = targetInfo.url;
20
- }
13
+ open(normalizedLink.href, '_top');
21
14
  }
22
15
 
23
16
  document.addEventListener("DOMContentLoaded", redirect);
@@ -14,21 +14,26 @@ module ShopifyApp
14
14
  splash_page_with_params(
15
15
  return_to: request.fullpath,
16
16
  shop: current_shopify_domain,
17
- host: params[:host]
17
+ host: params[:host],
18
+ embedded: params[:embedded],
18
19
  )
19
20
  end
20
21
 
21
22
  def splash_page_with_params(params)
22
- uri = URI(root_path)
23
+ uri = URI(base_url)
23
24
  uri.query = params.compact.to_query
24
25
  uri.to_s
25
26
  end
26
27
 
28
+ def base_url
29
+ ShopifyApp.configuration.root_url.presence || root_path
30
+ end
31
+
27
32
  def redirect_to_splash_page
28
33
  redirect_to(splash_page)
29
34
  rescue ::ShopifyApp::ShopifyDomainNotFound => error
30
- Rails.logger.warn("[ShopifyApp::EnsureAuthenticatedLinks] Redirecting to login: [#{error.class}] "\
31
- "Could not determine current shop domain")
35
+ ShopifyApp::Logger.warn("Redirecting to login: [#{error.class}]"\
36
+ " Could not determine current shop domain")
32
37
  redirect_to(ShopifyApp.configuration.login_url)
33
38
  end
34
39
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyApp
4
+ module EnsureHasSession
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include ShopifyApp::Localization
9
+
10
+ if ShopifyApp.configuration.use_new_embedded_auth_strategy?
11
+ include ShopifyApp::TokenExchange
12
+ around_action :activate_shopify_session
13
+ else
14
+ include ShopifyApp::LoginProtection
15
+ before_action :login_again_if_different_user_or_shop
16
+ around_action :activate_shopify_session
17
+ after_action :add_top_level_redirection_headers
18
+ end
19
+
20
+ include ShopifyApp::CsrfProtection
21
+ include ShopifyApp::EmbeddedApp
22
+ include ShopifyApp::EnsureBilling
23
+ end
24
+ end
25
+ end