Module: DIDKit::Services Private

Included in:
Document, PLCOperation
Defined in:
lib/didkit/services.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#get_service(key, type) ⇒ ServiceRecord?

Finds a service entry matching the given key and type.

Parameters:

  • key (String)

    service key in the DID document

  • type (String)

    service type identifier

Returns:



20
21
22
# File 'lib/didkit/services.rb', line 20

def get_service(key, type)
  @services&.detect { |s| s.key == key && s.type == type }
end

#labeler_endpointString? Also known as: labeller_endpoint

Returns the labeler service endpoint, if present.

If the DID has an #atproto_labeler service declared in its service section, returns the URL in its serviceEndpoint field.

Returns:

  • (String, nil)

    labeler service endpoint URL



45
46
47
# File 'lib/didkit/services.rb', line 45

def labeler_endpoint
  @labeler_endpoint ||= get_service('atproto_labeler', 'AtprotoLabeler')&.endpoint
end

#labeler_hostString? Also known as: labeller_host

Returns the hostname of the labeler service, if present.

Returns:

  • (String, nil)

    hostname of the labeler endpoint URL



63
64
65
# File 'lib/didkit/services.rb', line 63

def labeler_host
  labeler_endpoint&.then { |x| URI(x).host }
end

#pds_endpointString?

Returns the PDS service endpoint, if present.

If the DID has an #atproto_pds service declared in its service section, returns the URL in its serviceEndpoint field. In other words, this is the URL of the PDS assigned to a given user, which stores the user’s account and repo.

Returns:

  • (String, nil)

    PDS service endpoint URL



33
34
35
# File 'lib/didkit/services.rb', line 33

def pds_endpoint
  @pds_endpoint ||= get_service('atproto_pds', 'AtprotoPersonalDataServer')&.endpoint
end

#pds_hostString?

Returns the hostname of the PDS service, if present.

Returns:

  • (String, nil)

    hostname of the PDS endpoint URL



54
55
56
# File 'lib/didkit/services.rb', line 54

def pds_host
  pds_endpoint&.then { |x| URI(x).host }
end