<commit_before># frozen_string_literal: true

module Api

  module V1

    module Auth

      module Jwt

        class JsonWebToken

          class << self

            def encode(payload:, exp: 24.hours.from_now)
              payload[:exp] = exp.to_i
              JWT.encode(payload, Rails.application.credentials.secret_key_base)
            rescue JWT::EncodeError => e
              Rails.logger.error "Api::V1::Auth::Jwt::JsonWebToken.encode - #{e.message}"
              nil
            end

            def decode(token:)
              body = JWT.decode(token,
                                Rails.application.credentials.secret_key_base)[0]
              ActiveSupport::HashWithIndifferentAccess.new body
            rescue JWT::ExpiredSignature => e
              raise e
            rescue JWT::DecodeError =>
              Rails.logger.error "Api::V1::Auth::Jwt::JsonWebToken.decode - #{e.message}"<commit_msg>fixed typo<commit_after># frozen_string_literal: true

module Api

  module V1

    module Auth

      module Jwt

        class JsonWebToken

          class << self

            def encode(payload:, exp: 24.hours.from_now)
              payload[:exp] = exp.to_i
              JWT.encode(payload, Rails.application.credentials.secret_key_base)
            rescue JWT::EncodeError => e
              Rails.logger.error "Api::V1::Auth::Jwt::JsonWebToken.encode - #{e.message}"
              nil
            end

            def decode(token:)
              body = JWT.decode(token,
                                Rails.application.credentials.secret_key_base)[0]
              ActiveSupport::HashWithIndifferentAccess.new body
            rescue JWT::ExpiredSignature => e
              raise e
            rescue JWT::DecodeError => e
              Rails.logger.error "Api::V1::Auth::Jwt::JsonWebToken.decode - #{e.message}"
{'fraction_non_alphanumeric': 0.09724473257698542, 'fraction_numerical': 0.006482982171799027, 'mean_word_length': 1.7849624060150375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5387076', 'n_tokens_mistral': 524, 'n_tokens_neox': 505, 'n_words': 97}