standard_id-apple 0.1.0 → 0.1.1

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: a77a4c61dc7a649544a240e29a318dd89b3973a429fb796992214f043bdd176b
4
- data.tar.gz: a119c315995c98edac369d3d1c96d645b1871811c343e81a3f30e90480d354b8
3
+ metadata.gz: 63120ccfea7a05fb35a42c90548f441a7d719aa3d5a46e0bb9d72ec97e1e5129
4
+ data.tar.gz: '0857aa7e1bbafae5621ce60aa2c3364b01931a836b8e0adc121b50bcfacf42af'
5
5
  SHA512:
6
- metadata.gz: 04a5fc1120b372888042832a64c3508f4dd2e85e6807da34365186ba77ed54846641c58c04880d0f2652776f0429d2abc57c8f613bd21ca417b19750723cc764
7
- data.tar.gz: 609d9235c817d7e9d6805b8b9f91f19f7f213d7475b3d48578cbc4d28065b9a20762fa68968c6634db454bb3e53d842edb5699037b811f6214c29cebb1a7b489
6
+ metadata.gz: da5566c05904516299901bc7cbafb42e97c59c6bfb516959c8a2e77b55afd34f976e07c503ac94781681b972349c82519f4053d97004c7dea6967738ded0fe4a
7
+ data.tar.gz: 95da64b4f2c8deee61e18867133aa36d7ddea30985c276c266dcba0e8448712de8807c1040f224783621cb7319a998264c982ed0b96cb1e3b52a91447bfd1e0f
data/README.md CHANGED
@@ -26,11 +26,11 @@ Configure Apple credentials via the StandardId configuration block:
26
26
 
27
27
  ```ruby
28
28
  StandardId.configure do |config|
29
- config.social.apple_client_id = ENV["APPLE_CLIENT_ID"]
30
- config.social.apple_mobile_client_id = ENV["APPLE_MOBILE_CLIENT_ID"] # optional
31
- config.social.apple_team_id = ENV["APPLE_TEAM_ID"]
32
- config.social.apple_key_id = ENV["APPLE_KEY_ID"]
33
- config.social.apple_private_key = ENV["APPLE_PRIVATE_KEY_PEM"]
29
+ config.apple_client_id = ENV["APPLE_CLIENT_ID"]
30
+ config.apple_mobile_client_id = ENV["APPLE_MOBILE_CLIENT_ID"] # optional
31
+ config.apple_team_id = ENV["APPLE_TEAM_ID"]
32
+ config.apple_key_id = ENV["APPLE_KEY_ID"]
33
+ config.apple_private_key = ENV["APPLE_PRIVATE_KEY_PEM"]
34
34
  end
35
35
  ```
36
36
 
@@ -25,7 +25,7 @@ module StandardId
25
25
  ensure_basic_credentials!
26
26
 
27
27
  query = {
28
- client_id: StandardId.config.social.apple_client_id,
28
+ client_id: StandardId.config.apple_client_id,
29
29
  redirect_uri: redirect_uri,
30
30
  response_type: "code",
31
31
  scope: scope,
@@ -37,7 +37,7 @@ module StandardId
37
37
  end
38
38
 
39
39
  def get_user_info(code: nil, id_token: nil, access_token: nil, redirect_uri: nil, **options)
40
- client_id = options[:client_id] || StandardId.config.social.apple_client_id
40
+ client_id = options[:client_id] || StandardId.config.apple_client_id
41
41
 
42
42
  if id_token.present?
43
43
  build_response(
@@ -77,12 +77,12 @@ module StandardId
77
77
 
78
78
  def resolve_params(params, context: {})
79
79
  flow = context[:flow] || :web
80
- client_id = flow == :mobile ? StandardId.config.social.apple_mobile_client_id : StandardId.config.social.apple_client_id
80
+ client_id = flow == :mobile ? StandardId.config.apple_mobile_client_id : StandardId.config.apple_client_id
81
81
 
82
82
  params.merge(client_id: client_id)
83
83
  end
84
84
 
85
- def exchange_code_for_user_info(code:, redirect_uri:, client_id: StandardId.config.social.apple_client_id)
85
+ def exchange_code_for_user_info(code:, redirect_uri:, client_id: StandardId.config.apple_client_id)
86
86
  ensure_full_credentials!(client_id: client_id)
87
87
  raise StandardId::InvalidRequestError, "Missing authorization code" if code.blank?
88
88
 
@@ -117,7 +117,7 @@ module StandardId
117
117
  raise StandardId::OAuthError, e.message, cause: e
118
118
  end
119
119
 
120
- def verify_id_token(id_token:, client_id: StandardId.config.social.apple_client_id)
120
+ def verify_id_token(id_token:, client_id: StandardId.config.apple_client_id)
121
121
  raise StandardId::InvalidRequestError, "Missing id_token" if id_token.blank?
122
122
  raise StandardId::InvalidRequestError, "Apple client_id is not configured" if client_id.blank?
123
123
 
@@ -155,7 +155,7 @@ module StandardId
155
155
 
156
156
  private
157
157
 
158
- def ensure_basic_credentials!(client_id: StandardId.config.social.apple_client_id)
158
+ def ensure_basic_credentials!(client_id: StandardId.config.apple_client_id)
159
159
  return if client_id.present?
160
160
 
161
161
  raise StandardId::InvalidRequestError, "Apple OAuth is not configured"
@@ -165,9 +165,9 @@ module StandardId
165
165
  ensure_basic_credentials!(client_id: client_id)
166
166
 
167
167
  required = [
168
- StandardId.config.social.apple_private_key,
169
- StandardId.config.social.apple_key_id,
170
- StandardId.config.social.apple_team_id
168
+ StandardId.config.apple_private_key,
169
+ StandardId.config.apple_key_id,
170
+ StandardId.config.apple_team_id
171
171
  ]
172
172
 
173
173
  return unless required.any?(&:blank?)
@@ -175,21 +175,21 @@ module StandardId
175
175
  raise StandardId::InvalidRequestError, "Apple OAuth credentials are incomplete"
176
176
  end
177
177
 
178
- def generate_client_secret(client_id: StandardId.config.social.apple_client_id)
178
+ def generate_client_secret(client_id: StandardId.config.apple_client_id)
179
179
  header = {
180
180
  alg: "ES256",
181
- kid: StandardId.config.social.apple_key_id
181
+ kid: StandardId.config.apple_key_id
182
182
  }
183
183
 
184
184
  payload = {
185
- iss: StandardId.config.social.apple_team_id,
185
+ iss: StandardId.config.apple_team_id,
186
186
  iat: Time.current.to_i,
187
187
  exp: Time.current.to_i + 3600,
188
188
  aud: ISSUER,
189
189
  sub: client_id
190
190
  }
191
191
 
192
- private_key = OpenSSL::PKey::EC.new(StandardId.config.social.apple_private_key)
192
+ private_key = OpenSSL::PKey::EC.new(StandardId.config.apple_private_key)
193
193
  JWT.encode(payload, private_key, "ES256", header)
194
194
  end
195
195
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StandardId
4
4
  module Apple
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_id-apple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaryl Sim