apple_id 0.3.0 → 0.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/apple_id/id_token.rb +19 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a72028240d0516b2b84199b0ca75a6c6e063a99057e42f5ed9a296a037a34f0
4
- data.tar.gz: f986485593e4d31a2dc51f5fb84286546331546ac82615ab8dbdf378cdc3f630
3
+ metadata.gz: '018fb2f186c24595a953c2fe8e79c9091fcf83d10915b701dac91021dacfc04b'
4
+ data.tar.gz: a8b6bf32091ff20b60779551469a383f09ccf90d736ea1004046a9a635f993d2
5
5
  SHA512:
6
- metadata.gz: e3708b78af629597f380242036e79b9c36b9a00f4cb1ad878d992cd5de63e68e8d1ee7bb98fc8098ccf50bedbfe0a7cb86373905e849f6169ab0ea3834433858
7
- data.tar.gz: 0037f65c22bfb46a532a8ae46d895514759ff628e1940182c53c1f56f5b9e70fbc8fba038bc151c484fd9c6658c93df301605115ac8fd0614af4f96cc5276104
6
+ metadata.gz: 195ae7e87dff57ca72ee84be036a2a5927c9fdb7cbd9fa2f48e3a7421a0a9d77cd9ef7a042e1c567cdfff8f72305d9623889fade86a18b3939c2d0ba1efb7d32
7
+ data.tar.gz: acbc83c4ceb9c38e18db63b66a55855b96a26ca1b01f208cc7258bcb4c582487026c35bbe8b0446b0d8d0118c575b0201b7aab77b74e4d48f3b89bf83bc5d46c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -2,13 +2,22 @@ module AppleID
2
2
  class IdToken < OpenIDConnect::ResponseObject::IdToken
3
3
  class VerificationFailed < StandardError; end
4
4
 
5
- attr_optional :email
5
+ attr_optional :email, :email_verified, :is_private_email, :nonce_supported
6
6
  attr_accessor :original_jwt_string
7
7
  alias_method :original_jwt, :raw_attributes
8
8
 
9
- # NOTE:
10
- # Apple doesn't support nonce, c_hash and s_hash right now.
11
- # Don't pass nonce, code and access_token until they support them.
9
+ [:email_verified, :is_private_email, :nonce_supported].each do |boolean_claim|
10
+ define_method :"#{boolean_claim}?" do
11
+ claim_value = send(boolean_claim)
12
+ case claim_value
13
+ when String
14
+ claim_value == 'true'
15
+ else
16
+ !!claim_value
17
+ end
18
+ end
19
+ end
20
+
12
21
  def verify!(verify_signature: true, client: nil, nonce: nil, state: nil, access_token: nil, code: nil)
13
22
  verify_signature! if verify_signature
14
23
  verify_claims! client, nonce, state, access_token, code
@@ -63,8 +72,12 @@ module AppleID
63
72
  if aud.present? && self.aud != aud
64
73
  failure_reasons << :aud
65
74
  end
66
- if nonce.present? && self.nonce != nonce
67
- failure_reasons << :nonce
75
+ if !nonce_supported? && self.nonce.blank?
76
+ AppleID.logger.warn 'nonce is\'nt supported on this platform'
77
+ else
78
+ if nonce.present? && self.nonce != nonce
79
+ failure_reasons << :nonce
80
+ end
68
81
  end
69
82
  if s_hash.present? && self.s_hash != s_hash
70
83
  failure_reasons << :s_hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-17 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-oauth2