Module: JWT

Defined in:
lib/truelayer-signing/jwt.rb

Overview

TODO: this is a custom patch of payload-related methods, from the ‘jwt’ gem. It prevents the payload from being systematically converted to and from JSON. To be changed in the ‘jwt’ gem directly, or hard-coded in this library.

Defined Under Namespace

Classes: TrueLayerDecode, TrueLayerEncode, TrueLayerEncodedToken, TrueLayerToken

Class Method Summary collapse

Class Method Details

.truelayer_decode(jwt, key, verify = true, options = {}, &keyfinder) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter, Naming/BlockForwarding



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/truelayer-signing/jwt.rb', line 68

def truelayer_decode(jwt, key, verify = true, options = {}, &keyfinder)
  # Support both `truelayer_decode(jwt, key, options)` and
  # `truelayer_decode(jwt, key, verify, options)` call styles by treating a
  # Hash in the `verify` position as the `options` argument.
  if verify.is_a?(Hash)
    options = verify
    verify = true
  end

  TrueLayerDecode.new(
    jwt,
    key,
    verify,
    configuration.decode.to_h.merge(options),
    &keyfinder
  ).decode_segments
end

.truelayer_encode(payload, key, algorithm, headers) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/truelayer-signing/jwt.rb', line 58

def truelayer_encode(payload, key, algorithm, headers)
  TrueLayerEncode.new(
    payload: payload,
    key: key,
    algorithm: algorithm,
    headers: headers
  ).segments
end