@@ -8,7 +8,7 @@ defmodule Assent.JWTAdapter.AssentJWT do
88
99 See `Assent.JWTAdapter` for more.
1010 """
11- alias Assent . { Config , JWTAdapter }
11+ alias Assent.JWTAdapter
1212
1313 @ behaviour Assent.JWTAdapter
1414
@@ -26,9 +26,9 @@ defmodule Assent.JWTAdapter.AssentJWT do
2626
2727 defp encode_header ( alg , opts ) do
2828 header =
29- case Keyword . has_key? ( opts , :private_key_id ) do
30- false -> % { "typ" => "JWT" , "alg" => alg }
31- true -> % { "typ" => "JWT" , "alg" => alg , "kid" => Keyword . get ( opts , : private_key_id) }
29+ case Keyword . fetch ( opts , :private_key_id ) do
30+ :error -> % { "typ" => "JWT" , "alg" => alg }
31+ { :ok , private_key_id } -> % { "typ" => "JWT" , "alg" => alg , "kid" => private_key_id }
3232 end
3333
3434 case encode_json_base64 ( header , opts ) do
@@ -41,7 +41,7 @@ defmodule Assent.JWTAdapter.AssentJWT do
4141 end
4242
4343 defp encode_json_base64 ( map , opts ) do
44- with { :ok , json_library } <- Config . fetch ( opts , :json_library ) ,
44+ with { :ok , json_library } <- Assent . fetch_config ( opts , :json_library ) ,
4545 { :ok , json } <- json_encode ( json_library , map ) do
4646 { :ok , Base . url_encode64 ( json , padding: false ) }
4747 end
@@ -173,7 +173,7 @@ defmodule Assent.JWTAdapter.AssentJWT do
173173 end
174174
175175 defp decode_header ( header , opts ) do
176- with { :ok , json_library } <- Config . fetch ( opts , :json_library ) ,
176+ with { :ok , json_library } <- Assent . fetch_config ( opts , :json_library ) ,
177177 { :ok , header } <- decode_base64_url ( header ) ,
178178 { :ok , header } <- decode_json ( header , json_library ) ,
179179 { :ok , alg } <- fetch_alg ( header ) do
@@ -202,7 +202,7 @@ defmodule Assent.JWTAdapter.AssentJWT do
202202 defp fetch_alg ( _header ) , do: { :error , "No \" alg\" found in header" }
203203
204204 defp decode_claims ( claims , opts ) do
205- with { :ok , json_library } <- Config . fetch ( opts , :json_library ) ,
205+ with { :ok , json_library } <- Assent . fetch_config ( opts , :json_library ) ,
206206 { :ok , claims } <- decode_base64_url ( claims ) ,
207207 { :ok , claims } <- decode_json ( claims , json_library ) do
208208 { :ok , claims }
0 commit comments