Skip to content

Commit

Permalink
Remove deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Dec 28, 2024
1 parent beafbba commit 9621d8c
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 552 deletions.
3 changes: 0 additions & 3 deletions lib/jwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
require 'jwt/encoded_token'
require 'jwt/token'

require 'jwt/claims_validator'
require 'jwt/verify'

# JSON Web Token implementation
#
# Should be up to date with the latest spec:
Expand Down
6 changes: 0 additions & 6 deletions lib/jwt/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ module Claims
Error = Struct.new(:message, keyword_init: true)

class << self
# @deprecated Use {verify_payload!} instead. Will be removed in the next major version of ruby-jwt.
def verify!(payload, options)
Deprecations.warning('The ::JWT::Claims.verify! method is deprecated will be removed in the next major version of ruby-jwt')
DecodeVerifier.verify!(payload, options)
end

# Checks if the claims in the JWT payload are valid.
# @example
#
Expand Down
32 changes: 0 additions & 32 deletions lib/jwt/claims/numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ module Claims
# The Numeric class is responsible for validating numeric claims in a JWT token.
# The numeric claims are: exp, iat and nbf
class Numeric
# The Compat class provides backward compatibility for numeric claim validation.
# @api private
class Compat
def initialize(payload)
@payload = payload
end

def verify!
JWT::Claims.verify_payload!(@payload, :numeric)
end
end

# List of numeric claims that can be validated.
NUMERIC_CLAIMS = %i[
exp
Expand All @@ -26,14 +14,6 @@ def verify!

private_constant(:NUMERIC_CLAIMS)

# @api private
def self.new(*args)
return super if args.empty?

Deprecations.warning('Calling ::JWT::Claims::Numeric.new with the payload will be removed in the next major version of ruby-jwt')
Compat.new(*args)
end

# Verifies the numeric claims in the JWT context.
#
# @param context [Object] the context containing the JWT payload.
Expand All @@ -43,18 +23,6 @@ def verify!(context:)
validate_numeric_claims(context.payload)
end

# Verifies the numeric claims in the JWT payload.
#
# @param payload [Hash] the JWT payload containing the claims.
# @param _args [Hash] additional arguments (not used).
# @raise [JWT::InvalidClaimError] if any numeric claim is invalid.
# @return [nil]
# @deprecated The ::JWT::Claims::Numeric.verify! method will be removed in the next major version of ruby-jwt
def self.verify!(payload:, **_args)
Deprecations.warning('The ::JWT::Claims::Numeric.verify! method will be removed in the next major version of ruby-jwt.')
JWT::Claims.verify_payload!(payload, :numeric)
end

private

def validate_numeric_claims(payload)
Expand Down
18 changes: 0 additions & 18 deletions lib/jwt/claims_validator.rb

This file was deleted.

6 changes: 0 additions & 6 deletions lib/jwt/jwa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ def resolve_and_sort(algorithms:, preferred_algorithm:)
algs = Array(algorithms).map { |alg| JWA.resolve(alg) }
algs.partition { |alg| alg.valid_alg?(preferred_algorithm) }.flatten
end

# @deprecated The `::JWT::JWA.create` method is deprecated and will be removed in the next major version of ruby-jwt.
def create(algorithm)
Deprecations.warning('The ::JWT::JWA.create method is deprecated and will be removed in the next major version of ruby-jwt.')
resolve(algorithm)
end
end
end
end
40 changes: 0 additions & 40 deletions lib/jwt/verify.rb

This file was deleted.

19 changes: 0 additions & 19 deletions spec/jwt/claims/numeric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,4 @@
it_should_behave_like 'a NumericDate claim', :nbf
end
end

context 'Legacy use' do
let(:validator) { described_class.new(claims) }
describe '#verify!' do
subject { validator.verify! }

context 'exp claim' do
it_should_behave_like 'a NumericDate claim', :exp
end

context 'iat claim' do
it_should_behave_like 'a NumericDate claim', :iat
end

context 'nbf claim' do
it_should_behave_like 'a NumericDate claim', :nbf
end
end
end
end
80 changes: 0 additions & 80 deletions spec/jwt/claims_validator_spec.rb

This file was deleted.

12 changes: 0 additions & 12 deletions spec/jwt/jwa_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# frozen_string_literal: true

RSpec.describe JWT::JWA do
describe '.create' do
describe 'Backwards compatibility' do
describe 'create, sign and verify' do
it 'finds an algorithm with old api' do
alg = described_class.create('HS256')
signature = alg.sign(data: 'data', signing_key: 'key')
expect(signature).to be_a(String)
expect(alg.verify(data: 'data', signature: signature, verification_key: 'key')).to be(true)
end
end
end
end
describe '.resolve_and_sort' do
let(:subject) { described_class.resolve_and_sort(algorithms: algorithms, preferred_algorithm: preferred_algorithm).map(&:alg) }

Expand Down
Loading

0 comments on commit 9621d8c

Please sign in to comment.