Sha256: d88ca6ba44a7a6c9ed3a9e8b68956ff7b1273d81d368dcec8e8f40a0ec0c47c8
Contents?: true
Size: 991 Bytes
Versions: 3
Compression:
Stored size: 991 Bytes
Contents
# frozen_string_literal: true require_relative 'jwa' module JWT # The Encode class is responsible for encoding JWT tokens. class Encode # Initializes a new Encode instance. # # @param options [Hash] the options for encoding the JWT token. # @option options [Hash] :payload the payload of the JWT token. # @option options [Hash] :headers the headers of the JWT token. # @option options [String] :key the key used to sign the JWT token. # @option options [String] :algorithm the algorithm used to sign the JWT token. def initialize(options) @token = Token.new(payload: options[:payload], header: options[:headers]) @key = options[:key] @algorithm = options[:algorithm] end # Encodes the JWT token and returns its segments. # # @return [String] the encoded JWT token. def segments @token.verify_claims!(:numeric) @token.sign!(algorithm: @algorithm, key: @key) @token.jwt end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
minato_ruby_api_client-0.2.2 | vendor/bundle/ruby/3.2.0/gems/jwt-2.10.1/lib/jwt/encode.rb |
jwt-2.10.1 | lib/jwt/encode.rb |
jwt-2.10.0 | lib/jwt/encode.rb |