Skip to content

Commit

Permalink
Backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Aug 3, 2024
1 parent a0f8200 commit 2906984
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jwt/eddsa/algo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Algo
include JWT::JWA::Algorithm

register_algorithm("EdDSA")
register_algorithm("ED25519")

class << self
def sign(_algorithm, msg, key)
Expand Down
8 changes: 8 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
end
end

context "when encoding with ED25519" do
it "executes successfully" do
token = JWT.encode(payload, private_key, "ED25519")
expect(JWT.decode(token, public_key, true, algorithm: "EdDSA"))
.to eq([payload, { "alg" => "EdDSA" }])
end
end

context "when decoding key is wrong" do
let(:public_key) { Ed25519::SigningKey.new("a" * 32).verify_key }
it "raises decoding error" do
Expand Down

0 comments on commit 2906984

Please sign in to comment.