-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse all services including labelers from DID doc
- Loading branch information
Showing
4 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'uri' | ||
require_relative 'errors' | ||
|
||
module DIDKit | ||
class ServiceRecord | ||
attr_reader :key, :type, :endpoint | ||
|
||
def initialize(key, type, endpoint) | ||
begin | ||
uri = URI(endpoint) | ||
rescue URI::Error | ||
raise FormatError, "Invalid service endpoint: #{endpoint.inspect}" | ||
end | ||
|
||
@key = key | ||
@type = type | ||
@endpoint = endpoint | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module DIDKit | ||
module Services | ||
def get_service(key, type) | ||
@services.detect { |s| s.key == key && s.type == type } | ||
end | ||
|
||
def pds_endpoint | ||
@pds_endpoint ||= get_service('atproto_pds', 'AtprotoPersonalDataServer')&.endpoint | ||
end | ||
|
||
def labeler_endpoint | ||
@labeler_endpoint ||= get_service('atproto_labeler', 'AtprotoLabeler')&.endpoint | ||
end | ||
end | ||
end |