Sha256: 8701be6fd04eb13c985f97c4ea8d822c70277f36e68db7f29d447bfaf74b1c3d

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

require 'syruppay_jose'

module BjondJwt
  def jwt_encode_payload(json, bjond_registration)
    payload = {
      :json => json,
      :iss => 'Bjönd, Inc.',
      :aud => ENV['BJOND_ADAPTER_AUDIENCE'],
      :exp => Time.now.to_i + 10*3600,
      :nbf => Time.now.to_i - 2*3600,
      :sub => ENV['BJOND_ADAPTER_SUBJECT']
    }.to_json
    header = {:alg => 'A128KW', :enc => 'A128CBC-HS256'}
    ap payload
    puts payload
    return SyrupPay::JsonEncryptionCompactSerialization.serialization(Base64.decode64(bjond_registration.encryption_key), header, payload)
  end

  def jwt_decode_payload_and_return_json(token, bjond_registration)
    claims_json = SyrupPay::CompactDeserialization.deserialization(Base64.decode64(bjond_registration.encryption_key), token)
    claims = JSON.parse(claims_json)
    return JSON.parse(claims['json'][0])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bjond-api-0.2.5 lib/bjond-jwt.rb