From 982ecf31b68bde8d06bb791de0717b51fb5084e8 Mon Sep 17 00:00:00 2001 From: Joakim Antman Date: Sun, 4 Aug 2024 11:31:31 +0300 Subject: [PATCH] feat: Support the `ED25519` reference when pointing to the algorithm (#12) * Backwards compatibility * try action on ubuntu-22.04 * What about ubuntu-20.04 * Back to ubuntu-latest --- lib/jwt/eddsa/algo.rb | 1 + spec/integration_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/jwt/eddsa/algo.rb b/lib/jwt/eddsa/algo.rb index ca64850..35a6393 100644 --- a/lib/jwt/eddsa/algo.rb +++ b/lib/jwt/eddsa/algo.rb @@ -7,6 +7,7 @@ module Algo include JWT::JWA::SignatureAlgorithm register_algorithm("EdDSA") + register_algorithm("ED25519") class << self def sign(_alg, msg, key) diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 2906f97..8801534 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -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