Skip to content

Commit

Permalink
convert hashed string to hex before b64
Browse files Browse the repository at this point in the history
  • Loading branch information
mrashed-dev committed Jan 5, 2024
1 parent 6bc2732 commit e8cdc76
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/nylas/resources/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ def build_query(config)
URI.encode_www_form(params)
end

# Hashes the secret for PKCE authentication.
# Hash a plain text secret for use in PKCE.
#
# @param secret [String] Randomly-generated authentication secret.
# @return [Hash] Hashed authentication secret.
# @param secret [String] The plain text secret to hash.
# @return [String] The hashed secret with base64 encoding (without padding).
def hash_pkce_secret(secret)
Digest::SHA256.digest(secret).unpack1("H*")
Base64.strict_encode64(Digest::SHA256.digest(secret))
sha256_hash = Digest::SHA256.hexdigest(secret)
Base64.urlsafe_encode64(sha256_hash, padding: false)
end

# Sends the token request to the Nylas API.
Expand Down

0 comments on commit e8cdc76

Please sign in to comment.