shopify_app 13.5.0 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +6 -0
- data/README.md +11 -1
- data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +1 -1
- data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +20 -2
- data/lib/generators/shopify_app/home_controller/templates/index.html.erb +67 -17
- data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +10 -0
- data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
- data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +1 -0
- data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +19 -0
- data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +8 -0
- data/lib/generators/shopify_app/shopify_app_generator.rb +1 -1
- data/lib/shopify_app/version.rb +1 -1
- data/package-lock.json +4 -4
- data/package.json +1 -1
- data/shopify_app.gemspec +1 -1
- data/yarn.lock +6 -6
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb6669e0b864299f689103042e4c59cb4ddc7e53481b559275b64accc6e390b9
|
4
|
+
data.tar.gz: 9e3481e24e1e44ef799ac573025e532814acff362d0c9ea3f44b3e4000a68037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13f7898748c764d9093d8479ce61a3b1f2d5e9d3ebf7b04a952af7587ef243f9c785c3573c45a915a909a6b9d6cb15ea0d63ab34ed424c45401419f331aa141d
|
7
|
+
data.tar.gz: ba8649d90387c3c5c8050ad69923a9e56509955016c5d8bfd955e8870bf0d55f6ed3956dc1643e2f11aa655730e82504e7c28a472a7fcc542a4977b76169ebf4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
14.0.0
|
2
|
+
------
|
3
|
+
* Ruby 2.4 is no longer supported by this gem
|
4
|
+
* Bump gemspec ruby dependency to 2.5
|
5
|
+
* (Beta) Add `--with-session-token` flag to the Shopify App generator to create an app that is compatible with App Bridge Authentication
|
6
|
+
|
1
7
|
13.5.0
|
2
8
|
------
|
3
9
|
* Add `signal_access_token_required` helper method for apps to indicate access token has expired and that a new one is required
|
data/README.md
CHANGED
@@ -74,7 +74,7 @@ Generators
|
|
74
74
|
|
75
75
|
### Default Generator
|
76
76
|
|
77
|
-
The default generator will run the `install`, `shop`, and `home_controller` generators. This is the recommended way to start a new app from scratch:
|
77
|
+
The default generator will run the `install`, `shop`, `authenticated_controller`, and `home_controller` generators. This is the recommended way to start a new app from scratch:
|
78
78
|
|
79
79
|
```sh
|
80
80
|
$ rails generate shopify_app
|
@@ -123,6 +123,16 @@ $ rails generate shopify_app:home_controller
|
|
123
123
|
|
124
124
|
This generator creates an example home controller and view which fetches and displays products using the Shopify API.
|
125
125
|
|
126
|
+
Options include:
|
127
|
+
* __[beta]__ `with-session-token`: This flag generates an unauthenticated home_controller and a protected sample products_controller. It also creates a home view that leverages a session token to fetch products from your products_controller. Use this flag if you plan to build a single-page application or to secure your app using JWT session tokens (e.g. `--with-session-token` or `--with-session-token true`).
|
128
|
+
|
129
|
+
### Products Controller Generator
|
130
|
+
|
131
|
+
```sh
|
132
|
+
$ rails generate shopify_app:products_controller
|
133
|
+
```
|
134
|
+
|
135
|
+
This generator creates an example products API controller to fetch products using the Shopify API.
|
126
136
|
|
127
137
|
### App Proxy Controller Generator
|
128
138
|
|
data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb
CHANGED
@@ -7,7 +7,7 @@ module ShopifyApp
|
|
7
7
|
class AuthenticatedControllerGenerator < Rails::Generators::Base
|
8
8
|
source_root File.expand_path('../templates', __FILE__)
|
9
9
|
|
10
|
-
def
|
10
|
+
def create_authenticated_controller
|
11
11
|
template('authenticated_controller.rb', 'app/controllers/authenticated_controller.rb')
|
12
12
|
end
|
13
13
|
end
|
@@ -6,21 +6,39 @@ module ShopifyApp
|
|
6
6
|
class HomeControllerGenerator < Rails::Generators::Base
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
|
+
class_option :with_session_token, type: :boolean, default: false
|
10
|
+
|
9
11
|
def create_home_controller
|
10
|
-
|
12
|
+
@with_session_token = options['with_session_token']
|
13
|
+
|
14
|
+
template(home_controller_template, 'app/controllers/home_controller.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_products_controller
|
18
|
+
generate("shopify_app:products_controller") if with_session_token?
|
11
19
|
end
|
12
20
|
|
13
21
|
def create_home_index_view
|
14
|
-
|
22
|
+
template('index.html.erb', 'app/views/home/index.html.erb')
|
15
23
|
end
|
16
24
|
|
17
25
|
def add_home_index_route
|
18
26
|
route("root :to => 'home#index'")
|
19
27
|
end
|
20
28
|
|
29
|
+
private
|
30
|
+
|
21
31
|
def embedded_app?
|
22
32
|
ShopifyApp.configuration.embedded_app?
|
23
33
|
end
|
34
|
+
|
35
|
+
def with_session_token?
|
36
|
+
@with_session_token
|
37
|
+
end
|
38
|
+
|
39
|
+
def home_controller_template
|
40
|
+
with_session_token? ? 'unauthenticated_home_controller.rb' : 'home_controller.rb'
|
41
|
+
end
|
24
42
|
end
|
25
43
|
end
|
26
44
|
end
|
@@ -1,21 +1,71 @@
|
|
1
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="<%= I18n.locale %>">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
6
|
+
<link
|
7
|
+
rel="stylesheet"
|
8
|
+
href="https://unpkg.com/@shopify/polaris@4.25.0/styles.min.css"
|
9
|
+
/>
|
10
|
+
<% if @with_session_token %> <script>
|
11
|
+
document.addEventListener("DOMContentLoaded", async function() {
|
12
|
+
var SessionToken = window["app-bridge"].actions.SessionToken
|
13
|
+
var app = window.app;
|
2
14
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<% end %>
|
7
|
-
</ul>
|
15
|
+
app.dispatch(
|
16
|
+
SessionToken.request(),
|
17
|
+
);
|
8
18
|
|
9
|
-
|
19
|
+
// Save a session token for future requests
|
20
|
+
window.sessionToken = await new Promise((resolve) => {
|
21
|
+
app.subscribe(SessionToken.ActionType.RESPOND, (data) => {
|
22
|
+
resolve(data.sessionToken || "");
|
23
|
+
});
|
24
|
+
});
|
10
25
|
|
11
|
-
|
26
|
+
var fetchProducts = function() {
|
27
|
+
var headers = new Headers({ "Authorization": "Bearer " + window.sessionToken });
|
28
|
+
return fetch("/products", { headers })
|
29
|
+
.then(response => response.json())
|
30
|
+
.then(data => {
|
31
|
+
var products = data.products;
|
12
32
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
33
|
+
if (products === undefined || products.length == 0) {
|
34
|
+
document.getElementById("products").innerHTML = "<br>No products to display.";
|
35
|
+
} else {
|
36
|
+
var list = "";
|
37
|
+
products.forEach((product) => {
|
38
|
+
var link = `<a target="_top" href="https://<%%= @shop_origin %>/admin/products/${product.id}">`
|
39
|
+
list += "<li>" + link + product.title + "</a></li>";
|
40
|
+
});
|
41
|
+
document.getElementById("products").innerHTML = "<ul>" + list + "</ul>";
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}();
|
45
|
+
});
|
46
|
+
</script>
|
47
|
+
<% end %> </head>
|
48
|
+
<body>
|
49
|
+
<h2>Products</h2>
|
50
|
+
<% if @with_session_token %> <div id="products"><br>Loading...</div><% else %>
|
51
|
+
<ul>
|
52
|
+
<%% @products.each do |product| %>
|
53
|
+
<li><%%= link_to product.title, "https://#{@current_shopify_session.domain}/admin/products/#{product.id}", target: "_top" %></li>
|
54
|
+
<%% end %>
|
55
|
+
</ul>
|
56
|
+
|
57
|
+
<hr>
|
58
|
+
|
59
|
+
<h2>Webhooks</h2>
|
60
|
+
|
61
|
+
<%% if @webhooks.present? %>
|
62
|
+
<ul>
|
63
|
+
<%% @webhooks.each do |webhook| %>
|
64
|
+
<li><%%= webhook.topic %> : <%%= webhook.address %></li>
|
65
|
+
<%% end %>
|
66
|
+
</ul>
|
67
|
+
<%% else %>
|
68
|
+
<p>This app has not created any webhooks for this Shop. Add webhooks to your ShopifyApp initializer if you need webhooks</p>
|
69
|
+
<%% end %><% end %>
|
70
|
+
</body>
|
71
|
+
</html>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
<%= content_tag(:div, nil, id: 'shopify-app-init', data: {
|
30
30
|
api_key: ShopifyApp.configuration.api_key,
|
31
|
-
shop_origin: (@current_shopify_session.domain if @current_shopify_session),
|
31
|
+
shop_origin: @shop_origin || (@current_shopify_session.domain if @current_shopify_session),
|
32
32
|
debug: Rails.env.development?
|
33
33
|
} ) %>
|
34
34
|
|
@@ -9,6 +9,7 @@ ShopifyApp.configure do |config|
|
|
9
9
|
config.after_authenticate_job = false
|
10
10
|
config.api_version = "<%= @api_version %>"
|
11
11
|
config.shop_session_repository = 'Shop'
|
12
|
+
config.allow_jwt_authentication = true
|
12
13
|
end
|
13
14
|
|
14
15
|
# ShopifyApp::Utils.fetch_known_api_versions # Uncomment to fetch known api versions from shopify servers on boot
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module ShopifyApp
|
6
|
+
module Generators
|
7
|
+
class ProductsControllerGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def create_products_controller
|
11
|
+
template('products_controller.rb', 'app/controllers/products_controller.rb')
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_products_route
|
15
|
+
route("get '/products', :to => 'products#index'")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -11,7 +11,7 @@ module ShopifyApp
|
|
11
11
|
generate("shopify_app:install #{@opts.join(' ')}")
|
12
12
|
generate("shopify_app:shop_model")
|
13
13
|
generate("shopify_app:authenticated_controller")
|
14
|
-
generate("shopify_app:home_controller")
|
14
|
+
generate("shopify_app:home_controller #{@opts.join(' ')}")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/shopify_app/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shopify_app",
|
3
|
-
"version": "13.
|
3
|
+
"version": "13.6.0",
|
4
4
|
"lockfileVersion": 1,
|
5
5
|
"requires": true,
|
6
6
|
"dependencies": {
|
@@ -2532,9 +2532,9 @@
|
|
2532
2532
|
"dev": true
|
2533
2533
|
},
|
2534
2534
|
"elliptic": {
|
2535
|
-
"version": "6.5.
|
2536
|
-
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.
|
2537
|
-
"integrity": "sha512-
|
2535
|
+
"version": "6.5.3",
|
2536
|
+
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
|
2537
|
+
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
|
2538
2538
|
"dev": true,
|
2539
2539
|
"requires": {
|
2540
2540
|
"bn.js": "^4.4.0",
|
data/package.json
CHANGED
data/shopify_app.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.author = "Shopify"
|
10
10
|
s.summary = 'This gem is used to get quickly started with the Shopify API'
|
11
11
|
|
12
|
-
s.required_ruby_version = ">= 2.
|
12
|
+
s.required_ruby_version = ">= 2.5"
|
13
13
|
|
14
14
|
s.metadata['allowed_push_host'] = 'https://rubygems.org'
|
15
15
|
|
data/yarn.lock
CHANGED
@@ -1293,9 +1293,9 @@ bluebird@^3.3.0, bluebird@^3.5.5:
|
|
1293
1293
|
integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==
|
1294
1294
|
|
1295
1295
|
bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
|
1296
|
-
version "4.11.
|
1297
|
-
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.
|
1298
|
-
integrity sha512-
|
1296
|
+
version "4.11.9"
|
1297
|
+
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
|
1298
|
+
integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==
|
1299
1299
|
|
1300
1300
|
body-parser@^1.16.1:
|
1301
1301
|
version "1.19.0"
|
@@ -2039,9 +2039,9 @@ electron-to-chromium@^1.3.247:
|
|
2039
2039
|
integrity sha512-wGt+OivF1C1MPwaSv3LJ96ebNbLAWlx3HndivDDWqwIVSQxmhL17Y/YmwUdEMtS/bPyommELt47Dct0/VZNQBQ==
|
2040
2040
|
|
2041
2041
|
elliptic@^6.0.0:
|
2042
|
-
version "6.5.
|
2043
|
-
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.
|
2044
|
-
integrity sha512-
|
2042
|
+
version "6.5.3"
|
2043
|
+
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6"
|
2044
|
+
integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==
|
2045
2045
|
dependencies:
|
2046
2046
|
bn.js "^4.4.0"
|
2047
2047
|
brorand "^1.0.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 14.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: browser_sniffer
|
@@ -330,6 +330,7 @@ files:
|
|
330
330
|
- lib/generators/shopify_app/home_controller/home_controller_generator.rb
|
331
331
|
- lib/generators/shopify_app/home_controller/templates/home_controller.rb
|
332
332
|
- lib/generators/shopify_app/home_controller/templates/index.html.erb
|
333
|
+
- lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb
|
333
334
|
- lib/generators/shopify_app/install/install_generator.rb
|
334
335
|
- lib/generators/shopify_app/install/templates/_flash_messages.html.erb
|
335
336
|
- lib/generators/shopify_app/install/templates/embedded_app.html.erb
|
@@ -341,6 +342,8 @@ files:
|
|
341
342
|
- lib/generators/shopify_app/install/templates/shopify_app_index.js
|
342
343
|
- lib/generators/shopify_app/install/templates/shopify_provider.rb
|
343
344
|
- lib/generators/shopify_app/install/templates/user_agent.rb
|
345
|
+
- lib/generators/shopify_app/products_controller/products_controller_generator.rb
|
346
|
+
- lib/generators/shopify_app/products_controller/templates/products_controller.rb
|
344
347
|
- lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb
|
345
348
|
- lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake
|
346
349
|
- lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb
|
@@ -406,7 +409,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
406
409
|
requirements:
|
407
410
|
- - ">="
|
408
411
|
- !ruby/object:Gem::Version
|
409
|
-
version: '2.
|
412
|
+
version: '2.5'
|
410
413
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
411
414
|
requirements:
|
412
415
|
- - ">="
|