about summary refs log tree commit diff
path: root/app/serializers/activitypub/one_time_key_serializer.rb
blob: 5932eb5b55afeeeaf241f73227052d3bf3066d32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class ActivityPub::OneTimeKeySerializer < ActivityPub::Serializer
  context :security

  context_extensions :olm

  class SignatureSerializer < ActivityPub::Serializer
    attributes :type, :signature_value

    def type
      'Ed25519Signature'
    end

    def signature_value
      object.signature
    end
  end

  attributes :key_id, :type, :public_key_base64

  has_one :signature, serializer: SignatureSerializer

  def type
    'Curve25519Key'
  end

  def public_key_base64
    object.key
  end

  def signature
    object
  end
end