shopify-sinatra-app 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06c208a5e6a5d5b7f496276e1aedea79466f8d7abc6082afdb7cff0b88223d49
4
- data.tar.gz: 18439bd6c8f38719b02b7afdd1ec7559bf1b016f97fcca41d473739c85708042
3
+ metadata.gz: 4dc86b5d946b17ee4bde67fbbc9c6ce4bdae741bfd10b34eb5b9eef269d8d30a
4
+ data.tar.gz: 3512d0ee6d5722ff8277256e5333e2ca779cd7381c0807add32e2787bfe3834d
5
5
  SHA512:
6
- metadata.gz: fbd6555480c19155bb742b423e27df1f53aacdb3779134fdc8b18294926611f863f43abed6a2393e4994247381cc21653c64a4171786063da5f022b1aef52f2d
7
- data.tar.gz: bae80dff8e96cc0dd29febed95b8a2336a944cab4b397803f9ad816b4c93f6996e7cc094e605bb5e3d88a12fbbbb2cf1e516d81f7575cfc7eec68dd50ea8afe1
6
+ metadata.gz: 3cef0cd037591e3d7d19d13e65732b03587e1761dbe2dab73e31c95477d327332644a71aab4f898d7f3fc3cf45c2e3ca9ee7b8ec352862499b100f636395d69c
7
+ data.tar.gz: cbeeef8e569450e84ed861d8bd8ef53b0d1770b7d45256a5e4f73eb58de38ac225f2c07a7fd70360fc75d41fa3dc1adf6d9a4cc16ffeb3c3e534af3c188d03f1
data/CHANGELOG CHANGED
@@ -1,5 +1,13 @@
1
+ 0.12.0
2
+ ------
3
+ * Update to use the Shopify AppBridge instead of the ESDK
4
+ * This change is mostly to generated files so you'll need to apply those updates
5
+ to your own versions.
6
+ * shop_origin no longer includes protocol
7
+ * return_to re-worked to function with the AppBridge
8
+
1
9
  0.11.0
2
- ----------
10
+ ------
3
11
  * remove rack-flash3 use sinatra-flash instead
4
12
  * remove a duplicate config of sessions that was breaking the same_site fix
5
13
  * remove a runtime dependency that didn't end up being used for the same_site fix but was added anyways
@@ -1,11 +1,25 @@
1
1
  <script type="text/javascript">
2
- ShopifyApp.ready(function(){
3
- <% if flash[:notice] %>
4
- ShopifyApp.flashNotice("<%= flash[:notice] %>");
5
- <% end %>
6
-
7
- <% if flash[:error] %>
8
- ShopifyApp.flashError("<%= flash[:error] %>");
9
- <% end %>
10
- });
2
+ var AppBridge = window['app-bridge'];
3
+
4
+ var actions = AppBridge.actions;
5
+ var Toast = actions.Toast;
6
+
7
+ <% if flash[:notice] %>
8
+ var notice = Toast.create(app, {
9
+ message: "<%= flash[:notice] %>",
10
+ duration: 5000
11
+ });
12
+
13
+ notice.dispatch(Toast.Action.SHOW);
14
+ <% end %>
15
+
16
+ <% if flash[:error] %>
17
+ var notice = Toast.create(app, {
18
+ message: "<%= flash[:error] %>",
19
+ duration: 5000,
20
+ isError: true,
21
+ });
22
+
23
+ notice.dispatch(Toast.Action.SHOW);
24
+ <% end %>
11
25
  </script>
@@ -1,7 +1,10 @@
1
1
  <script type="text/javascript">
2
- ShopifyApp.ready(function(){
3
- ShopifyApp.Bar.initialize({
4
- icon: '<%= "#{base_url}/icon.png" %>'
5
- });
2
+ var AppBridge = window['app-bridge'];
3
+
4
+ var actions = AppBridge.actions;
5
+ var TitleBar = actions.TitleBar;
6
+
7
+ var titleBar = TitleBar.create(app, {
8
+ icon: '<%= "#{base_url}/icon.png" %>'
6
9
  });
7
10
  </script>
@@ -1,12 +1,14 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
4
+ <script src="https://unpkg.com/@shopify/app-bridge"></script>
5
5
  <script type="text/javascript">
6
- ShopifyApp.init({
6
+ var AppBridge = window['app-bridge'];
7
+ var createApp = AppBridge.default;
8
+
9
+ var app = createApp({
7
10
  apiKey: "<%= SinatraApp.settings.api_key %>",
8
11
  shopOrigin: "<%= shop_origin %>",
9
- debug: true
10
12
  });
11
13
  </script>
12
14
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous">
@@ -20,9 +20,9 @@ module Sinatra
20
20
  session.clear
21
21
  end
22
22
 
23
- # for the esdk initializer
23
+ # for the app bridge initializer
24
24
  def shop_origin
25
- "https://#{session[:shopify][:shop]}"
25
+ "#{session[:shopify][:shop]}"
26
26
  end
27
27
 
28
28
  def shopify_session(&blk)
@@ -74,7 +74,7 @@ module Sinatra
74
74
  def authenticate(return_to = '/', return_params = nil)
75
75
  if shop_name = sanitized_shop_name
76
76
  session[:return_params] = return_params if return_params
77
- redirect_url = "/auth/shopify?shop=#{shop_name}&return_to=#{base_url}#{return_to}"
77
+ redirect_url = "#{base_url}/auth/shopify"
78
78
  redirect_javascript redirect_url
79
79
  else
80
80
  redirect '/install'
@@ -101,19 +101,37 @@ module Sinatra
101
101
  <meta charset="utf-8" />
102
102
  <base target="_top">
103
103
  <title>Redirecting…</title>
104
-
104
+ <script src="https://unpkg.com/@shopify/app-bridge"></script>
105
105
  <script type='text/javascript'>
106
+ var AppBridge = window['app-bridge'];
107
+ var createApp = AppBridge.createApp;
108
+ var actions = AppBridge.actions;
109
+ var Redirect = actions.Redirect;
110
+
111
+ var apiKey = '#{settings.api_key}';
112
+ var redirectUri = '#{url}';
113
+ var shopOrigin = '#{sanitized_shop_name}';
114
+
115
+ var permissionUrl = 'https://'+
116
+ shopOrigin+
117
+ '/admin'+
118
+ '/oauth/authorize?client_id='+
119
+ apiKey+
120
+ '&scope=#{settings.scope}&redirect_uri='+
121
+ redirectUri;
122
+
106
123
  // If the current window is the 'parent', change the URL by setting location.href
107
124
  if (window.top == window.self) {
108
- window.top.location.href = #{url.to_json};
125
+ window.location.assign(permissionUrl);
109
126
 
110
- // If the current window is the 'child', change the parent's URL with postMessage
127
+ // If the current window is the 'child', change the parent's URL with Shopify App Bridge's Redirect action
111
128
  } else {
112
- message = JSON.stringify({
113
- message: 'Shopify.API.remoteRedirect',
114
- data: { location: window.location.origin + #{url.to_json} }
129
+ var app = createApp({
130
+ apiKey: apiKey,
131
+ shopOrigin: shopOrigin
115
132
  });
116
- window.parent.postMessage(message, 'https://#{sanitized_shop_name}');
133
+
134
+ Redirect.create(app).dispatch(Redirect.Action.REMOTE, permissionUrl);
117
135
  }
118
136
  </script>
119
137
  </head>
@@ -230,10 +248,10 @@ module Sinatra
230
248
 
231
249
  after_shopify_auth()
232
250
 
233
- return_to = env['omniauth.params']['return_to']
234
251
  return_params = session[:return_params]
235
252
  session.delete(:return_params)
236
253
 
254
+ return_to = '/'
237
255
  return_to += "?#{return_params.to_query}" if return_params.present?
238
256
 
239
257
  redirect return_to
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shopify-sinatra-app'
3
- s.version = '0.11.0'
3
+ s.version = '0.12.0'
4
4
 
5
5
  s.summary = 'A classy shopify app'
6
6
  s.description = 'A Sinatra extension for building Shopify Apps. Akin to the shopify_app gem but for Sinatra'
@@ -18,8 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency 'activesupport'
19
19
  s.add_runtime_dependency 'attr_encrypted', '~> 3.1.0'
20
20
 
21
- s.add_runtime_dependency 'shopify_api', '>= 7.0.1', '< 9.1.0'
22
- s.add_runtime_dependency 'omniauth-shopify-oauth2'
21
+ s.add_runtime_dependency 'shopify_api', '>= 7.0.1', '< 9.3.0'
22
+ s.add_runtime_dependency 'omniauth-shopify-oauth2', '>= 2.3.2'
23
+ s.add_runtime_dependency 'omniauth', '1.9.1'
23
24
 
24
25
  s.add_development_dependency 'rake', '>= 12.3.3'
25
26
  s.add_development_dependency 'sqlite3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-sinatra-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Hughes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-29 00:00:00.000000000 Z
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -75,7 +75,7 @@ dependencies:
75
75
  version: 7.0.1
76
76
  - - "<"
77
77
  - !ruby/object:Gem::Version
78
- version: 9.1.0
78
+ version: 9.3.0
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
@@ -85,21 +85,35 @@ dependencies:
85
85
  version: 7.0.1
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 9.1.0
88
+ version: 9.3.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: omniauth-shopify-oauth2
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: 2.3.2
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
102
+ version: 2.3.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: omniauth
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.9.1
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '='
115
+ - !ruby/object:Gem::Version
116
+ version: 1.9.1
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rake
105
119
  requirement: !ruby/object:Gem::Requirement