Module: JsonJws::Encode
- Included in:
- JSON_JWS
- Defined in:
- lib/json_jws/encode.rb
Instance Method Summary collapse
Instance Method Details
#encode(jwk, header, payload) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/json_jws/encode.rb', line 7 def encode(jwk, header, payload) protected_header = Base64.urlsafe_encode64(header.to_json) payload = payload.to_json unless payload.is_a?(String) protected_header, signature = build_signature(jwk, header, payload) { "payload" => Base64.urlsafe_encode64(payload), "signatures" => [ { "protected" => protected_header, "signature" => signature, }, ], } end |