Class: TrueLayerSigning::Signer

Inherits:
JwsBase
  • Object
show all
Defined in:
lib/truelayer-signing/signer.rb

Instance Attribute Summary collapse

Attributes inherited from JwsBase

#body, #headers, #method, #path

Instance Method Summary collapse

Methods inherited from JwsBase

#add_header, #initialize, #set_body, #set_headers, #set_method, #set_path

Constructor Details

This class inherits a constructor from TrueLayerSigning::JwsBase

Instance Attribute Details

#jws_jkuObject (readonly)

Returns the value of attribute jws_jku.



5
6
7
# File 'lib/truelayer-signing/signer.rb', line 5

def jws_jku
  @jws_jku
end

Instance Method Details

#set_jku(jku) ⇒ Object



23
24
25
26
27
# File 'lib/truelayer-signing/signer.rb', line 23

def set_jku(jku)
  @jws_jku = jku

  self
end

#signObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/truelayer-signing/signer.rb', line 7

def sign
  ensure_signer_config!

  private_key = OpenSSL::PKey.read(TrueLayerSigning.private_key)
  jws_header = generate_jws_header!
  jwt = JWT.truelayer_encode(
    build_signing_payload,
    private_key,
    TrueLayerSigning.algorithm,
    jws_header
  )
  header, _, signature = jwt.split(".")

  "#{header}..#{signature}"
end