shopify_api 12.0.0 → 12.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6e4e09aa88812707194b0ec0726f1e61f448647a01a9d0709201808c05ad99c
4
- data.tar.gz: ac3fcdb640bb6d1c1614e82d5faf9cd2fce496117187d2daca803a5d96ef8036
3
+ metadata.gz: 2112fae23baafc5b3615a58d54d1c8a2b0a1bfcc4c9a9235b6d76bf80bcdff0e
4
+ data.tar.gz: 438373f5072f981e9449daac622b55101002df6139cd24e6bff0cfa5601275ce
5
5
  SHA512:
6
- metadata.gz: c05d906a83000f3a2134875532798224afac9cf270787fadd493b2cc3d820771eac5e3b609766ff9c3d08138a774d8e681d3d93d3c13079d4b655d7a857dddf3
7
- data.tar.gz: 1b4088cd2457c8d39ec04b466a5dcf492ac62df751c44f359a12a1176ed4b30f4289ae2d8dc0a400c491b377ffc522d71e86b33f898b8ce086b39cec0729495e
6
+ metadata.gz: 700912ad225f507b09b1aef17c8df1f139eb9b951cc7c42115c0db95dd77b3dd4698fdd164744c5312730de7ecaae70b770b4f5b3370d7913150afcab44dfb28
7
+ data.tar.gz: bfd499fc0c32a7e8fc6f523b74b77452ee7edb3581cf045982088d792cb45073846c7138b1c0035b61d1c9420b77500e1be8d2e0cbf89d1e2ff0f2d4f0ba8d90
@@ -12,11 +12,12 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/stale@v5
14
14
  with:
15
- days-before-issue-stale: 90
15
+ days-before-issue-stale: 60
16
16
  days-before-issue-close: 14
17
+ operations-per-run: 1000
17
18
  stale-issue-label: "Stale"
18
19
  stale-issue-message: >
19
- This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.
20
+ This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
20
21
  close-issue-message: |
21
22
  We are closing this issue because it has been inactive for a few months.
22
23
  This probably means that it is not reproducible or it has been fixed in a newer version.
data/CHANGELOG.md CHANGED
@@ -4,10 +4,17 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## Version 12.2.0
8
+
9
+ - [#1023](https://github.com/Shopify/shopify-api-ruby/pull/1023) Allow custom scopes during the OAuth process
10
+
11
+ ## Version 12.1.0
12
+
13
+ - [#1017](https://github.com/Shopify/shopify-api-ruby/pull/1017) Add support for `http` with localhost development without using a TLS tunnel
14
+
7
15
  ## Version 12.0.0
8
16
 
9
17
  - [#1027](https://github.com/Shopify/shopify-api-ruby/pull/1027) ⚠️ [Breaking] Remove support for deprecated API version `2021-10` and added support for version `2022-10`
10
-
11
18
  - [#1008](https://github.com/Shopify/shopify-api-ruby/pull/1008) Increase session token JWT validation leeway from 5s to 10s
12
19
 
13
20
  ## Version 11.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api (12.0.0)
4
+ shopify_api (12.2.0)
5
5
  concurrent-ruby
6
6
  hash_diff
7
7
  httparty
@@ -38,6 +38,7 @@ GEM
38
38
  concurrent-ruby (~> 1.0)
39
39
  json (2.6.2)
40
40
  jwt (2.5.0)
41
+ language_server-protocol (3.17.0.1)
41
42
  method_source (1.0.0)
42
43
  mime-types (3.4.1)
43
44
  mime-types-data (~> 3.2015)
@@ -51,6 +52,7 @@ GEM
51
52
  parallel (1.22.1)
52
53
  parser (3.1.2.1)
53
54
  ast (~> 2.4.1)
55
+ prettier_print (0.1.0)
54
56
  pry (0.14.1)
55
57
  coderay (~> 1.1)
56
58
  method_source (~> 1.0)
@@ -80,6 +82,10 @@ GEM
80
82
  rubocop (~> 1.35)
81
83
  rubocop-sorbet (0.6.11)
82
84
  rubocop (>= 0.90.0)
85
+ ruby-lsp (0.3.2)
86
+ language_server-protocol (~> 3.17.0)
87
+ sorbet-runtime
88
+ syntax_tree (>= 3.4)
83
89
  ruby-progressbar (1.11.0)
84
90
  securerandom (0.2.0)
85
91
  sorbet (0.5.10438)
@@ -94,6 +100,8 @@ GEM
94
100
  sorbet (>= 0.5.9204)
95
101
  sorbet-runtime (>= 0.5.9204)
96
102
  thor (>= 0.19.2)
103
+ syntax_tree (3.6.1)
104
+ prettier_print
97
105
  tapioca (0.10.2)
98
106
  bundler (>= 1.17.3)
99
107
  netrc (>= 0.11.0)
@@ -136,6 +144,7 @@ DEPENDENCIES
136
144
  rubocop
137
145
  rubocop-shopify
138
146
  rubocop-sorbet
147
+ ruby-lsp
139
148
  shopify_api!
140
149
  sorbet
141
150
  tapioca
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  This library provides support for Ruby [Shopify apps](https://apps.shopify.com/) to access the [Shopify Admin API](https://shopify.dev/api/admin), by making it easier to perform the following actions:
8
8
 
9
- - Creating [online](https://shopify.dev/concepts/about-apis/authentication#online-access) or [offline](https://shopify.dev/concepts/about-apis/authentication#offline-access) access tokens for the Admin API via OAuth
9
+ - Creating [online](https://shopify.dev/apps/auth/oauth/access-modes#online-access) or [offline](https://shopify.dev/apps/auth/oauth/access-modes#offline-access) access tokens for the Admin API via OAuth
10
10
  - Making requests to the [REST API](https://shopify.dev/api/admin-rest)
11
11
  - Making requests to the [GraphQL API](https://shopify.dev/api/admin-graphql)
12
12
  - Registering/processing webhooks
@@ -25,8 +25,7 @@ To follow these usage guides, you will need to:
25
25
  - have a Shopify Partner account and development store
26
26
  - _OR_ have a test store where you can create a private app
27
27
  - have an app already set up in your test store or partner account
28
- - use [ngrok](https://ngrok.com/download) to create a secure tunnel to your app running on your localhost
29
- - add the `ngrok` URL and the appropriate redirect for your OAuth callback route to your app settings
28
+ - add the URL and the appropriate redirect for your OAuth callback route to your app settings
30
29
 
31
30
  ## Installation
32
31
 
@@ -5,7 +5,7 @@ The implementation of session storage that you pass in `ShopifyAPI::Context.setu
5
5
 
6
6
  ## Create a New Session Storage Class
7
7
 
8
- You can create a session storage class that includes `ShopifyAPI::Auth::SessionStore` and override the methods as shown in the table and example below:
8
+ You can create a session storage class that includes `ShopifyAPI::Auth::SessionStorage` and override the methods as shown in the table and example below:
9
9
 
10
10
  | Method Name | Input Type | Return Type |
11
11
  | ---------------------- | --------------------------------- | ------------------------------ |
@@ -16,9 +16,18 @@ module ShopifyAPI
16
16
  shop: String,
17
17
  redirect_path: String,
18
18
  is_online: T.nilable(T::Boolean),
19
+ scope_override: T.nilable(T.any(ShopifyAPI::Auth::AuthScopes, T::Array[String], String)),
19
20
  ).returns(T::Hash[Symbol, T.any(String, SessionCookie)])
20
21
  end
21
- def begin_auth(shop:, redirect_path:, is_online: true)
22
+ def begin_auth(shop:, redirect_path:, is_online: true, scope_override: nil)
23
+ scope = if scope_override.nil?
24
+ ShopifyAPI::Context.scope
25
+ elsif scope_override.is_a?(ShopifyAPI::Auth::AuthScopes)
26
+ scope_override
27
+ else
28
+ ShopifyAPI::Auth::AuthScopes.new(scope_override)
29
+ end
30
+
22
31
  unless Context.setup?
23
32
  raise Errors::ContextNotSetupError, "ShopifyAPI::Context not setup, please call ShopifyAPI::Context.setup"
24
33
  end
@@ -30,8 +39,8 @@ module ShopifyAPI
30
39
 
31
40
  query = {
32
41
  client_id: ShopifyAPI::Context.api_key,
33
- scope: ShopifyAPI::Context.scope.to_s,
34
- redirect_uri: "https://#{ShopifyAPI::Context.host_name}#{redirect_path}",
42
+ scope: scope.to_s,
43
+ redirect_uri: "#{ShopifyAPI::Context.host}#{redirect_path}",
35
44
  state: state,
36
45
  "grant_options[]": is_online ? "per-user" : "",
37
46
  }
@@ -36,6 +36,7 @@ module ShopifyAPI
36
36
  is_embedded: T::Boolean,
37
37
  session_storage: ShopifyAPI::Auth::SessionStorage,
38
38
  logger: Logger,
39
+ host: T.nilable(String),
39
40
  private_shop: T.nilable(String),
40
41
  user_agent_prefix: T.nilable(String),
41
42
  old_api_secret_key: T.nilable(String),
@@ -51,19 +52,21 @@ module ShopifyAPI
51
52
  is_embedded:,
52
53
  session_storage:,
53
54
  logger: Logger.new($stdout),
55
+ host: ENV["HOST"] || "https://#{host_name}",
54
56
  private_shop: nil,
55
57
  user_agent_prefix: nil,
56
58
  old_api_secret_key: nil
57
59
  )
58
60
  unless ShopifyAPI::AdminVersions::SUPPORTED_ADMIN_VERSIONS.include?(api_version)
59
61
  raise Errors::UnsupportedVersionError,
60
- "Invalid vession #{api_version}, supported versions: #{ShopifyAPI::AdminVersions::SUPPORTED_ADMIN_VERSIONS}"
62
+ "Invalid version #{api_version}, supported versions: #{ShopifyAPI::AdminVersions::SUPPORTED_ADMIN_VERSIONS}"
61
63
  end
62
64
 
63
65
  @api_key = api_key
64
66
  @api_secret_key = api_secret_key
65
67
  @api_version = api_version
66
68
  @host_name = host_name
69
+ @host = T.let(host, T.nilable(String))
67
70
  @is_private = is_private
68
71
  @scope = Auth::AuthScopes.new(scope)
69
72
  @is_embedded = is_embedded
@@ -122,7 +125,7 @@ module ShopifyAPI
122
125
  end
123
126
 
124
127
  sig { returns(T.nilable(String)) }
125
- attr_reader :private_shop, :user_agent_prefix, :old_api_secret_key
128
+ attr_reader :private_shop, :user_agent_prefix, :old_api_secret_key, :host
126
129
 
127
130
  sig { returns(T::Boolean) }
128
131
  def embedded?
@@ -131,7 +134,7 @@ module ShopifyAPI
131
134
 
132
135
  sig { returns(T::Boolean) }
133
136
  def setup?
134
- !(api_key.empty? || api_secret_key.empty? || host_name.empty?)
137
+ [api_key, api_secret_key, host_name, T.must(host)].none?(&:empty?)
135
138
  end
136
139
 
137
140
  sig { returns(T.nilable(Auth::Session)) }
@@ -150,6 +153,11 @@ module ShopifyAPI
150
153
  def deactivate_session
151
154
  @active_session.value = nil
152
155
  end
156
+
157
+ sig { returns(String) }
158
+ def host_scheme
159
+ T.must(URI.parse(T.must(host)).scheme)
160
+ end
153
161
  end
154
162
  end
155
163
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module ShopifyAPI
5
- VERSION = "12.0.0"
5
+ VERSION = "12.2.0"
6
6
  end
@@ -9,12 +9,12 @@ module ShopifyAPI
9
9
 
10
10
  sig { override.returns(String) }
11
11
  def callback_address
12
- if @path.match?(%r{^https://})
12
+ if @path.match?(%r{^https?://})
13
13
  @path
14
14
  elsif @path.match?(/^#{Context.host_name}/)
15
- "https://#{@path}"
15
+ "#{Context.host_scheme}://#{@path}"
16
16
  else
17
- "https://#{Context.host_name}/#{@path}"
17
+ "#{Context.host}/#{@path}"
18
18
  end
19
19
  end
20
20
 
data/shopify_api.gemspec CHANGED
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.add_development_dependency("rubocop")
48
48
  s.add_development_dependency("rubocop-shopify")
49
49
  s.add_development_dependency("rubocop-sorbet")
50
+ s.add_development_dependency("ruby-lsp")
50
51
  s.add_development_dependency("sorbet")
51
52
  s.add_development_dependency("tapioca")
52
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0
4
+ version: 12.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: ruby-lsp
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: sorbet
211
225
  requirement: !ruby/object:Gem::Requirement