xero-ruby 2.10.1 → 2.10.2

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: 5dde5ec413261e2fef5f4d89ce60978e33390ec6432d7fa168a0ba323f82de78
4
- data.tar.gz: 6bfe429d8c97d99a9b7f9acf5ae734f19228e3e1fbc11a7b5139dd09ee47e35f
3
+ metadata.gz: aaa8295ee798049a210f04184b5a9bd47e6c6d06b5f5e7a7197a021ca997cdf0
4
+ data.tar.gz: 8048f7bc8f95742fbdf1804ed40ea6325c3f87e54d2454cea05f1c444d45558d
5
5
  SHA512:
6
- metadata.gz: a1ab5683ecba461f6c4921e42d1916376ecf68fbb978bfcb13e57847a7a6eb50be792746dea2f8c9bc0d9bddc72e8eec12870628f203a10d550152b667f3b18f
7
- data.tar.gz: 1456130cc746216ed8712df80951699e647a6054c9dd137ef743dbd89b442ed04c40b24f58b8f9371116a0b205750be9877fb02dc7302fc703f1613fed549a5b
6
+ metadata.gz: e469a609bad593d2a26dfe78a8864c7a9a067b8c2b26ae707a910a6de4c53b8a368daaff62dd3adea72159a7467cc0025d31eba39b728c00829a45329756dc3c
7
+ data.tar.gz: 01d586c5e99f4ecc8bea4551d44604c09e0bb3890c8756935bc9a6905b8c5b6cf86e4aeef39c2b0d2666e44b1ff5017d6812c809629c9bdc26585fd37d944cc9
data/README.md CHANGED
@@ -110,15 +110,15 @@ A `token_set` is what we call the XeroAPI response that contains data about your
110
110
 
111
111
  Note that an `access_token` is valid for 30 minutes but a `refresh_token` can be used once in up to a 60 day window. If a refresh_token is used to refresh access you must replace the entire token_set.
112
112
 
113
- Both the `id_token` & `access_token` are JWT's, and can be decoded for to see additional metadata described in the Token Helpers section:
113
+ Both the `id_token` & `access_token` are JWT's, and can be decoded to see additional metadata described in the Token Helpers section:
114
114
  ## Making API calls with a valid token_set
115
115
  After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client.
116
116
  ```ruby
117
117
  xero_client.set_token_set(user.token_set)
118
-
118
+ # or set it and refresh in same go
119
119
  xero_client.refresh_token_set(user.token_set)
120
120
  ```
121
- This sets the access_token on the client, and returns a refreshed `token_set` you should save in your database for the next time you need to connect to Xero's API.
121
+ This sets the access_token on the client returns either the existing, or newly refreshed `token_set`. You should save in your database for the next time you need to connect to Xero's AP and repeat the process. Assuming you keep your connection live at least once per 60 days, you can persist infinite API connection assuming the user does not revoke your API access.
122
122
  ## Token Helpers
123
123
  ```ruby
124
124
  xero_client.token_set
@@ -110,11 +110,11 @@ module XeroRuby
110
110
  end
111
111
 
112
112
  def decoded_access_token
113
- decode_jwt(@config.access_token)
113
+ decode_jwt(@config.access_token, false)
114
114
  end
115
115
 
116
116
  def decoded_id_token
117
- decode_jwt(@config.id_token)
117
+ decode_jwt(@config.id_token, false)
118
118
  end
119
119
 
120
120
  def set_token_set(token_set)
@@ -166,10 +166,14 @@ module XeroRuby
166
166
  return true
167
167
  end
168
168
 
169
- def decode_jwt(tkn)
170
- jwks_data = JSON.parse(Faraday.get('https://identity.xero.com/.well-known/openid-configuration/jwks').body)
171
- jwk_set = JSON::JWK::Set.new(jwks_data)
172
- JSON::JWT.decode(tkn, jwk_set)
169
+ def decode_jwt(tkn, verify=true)
170
+ if verify == true
171
+ jwks_data = JSON.parse(Faraday.get('https://identity.xero.com/.well-known/openid-configuration/jwks').body)
172
+ jwk_set = JSON::JWK::Set.new(jwks_data)
173
+ JSON::JWT.decode(tkn, jwk_set)
174
+ else
175
+ JSON::JWT.decode(tkn, :skip_verification)
176
+ end
173
177
  end
174
178
 
175
179
  def token_expired?
@@ -11,5 +11,5 @@ The version of the XeroOpenAPI document: 2.11.0
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '2.10.1'
14
+ VERSION = '2.10.2'
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xero-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xero API Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-29 00:00:00.000000000 Z
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -995,7 +995,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
995
995
  - !ruby/object:Gem::Version
996
996
  version: '0'
997
997
  requirements: []
998
- rubygems_version: 3.1.4
998
+ rubygems_version: 3.1.2
999
999
  signing_key:
1000
1000
  specification_version: 4
1001
1001
  summary: Xero Accounting API Ruby Gem