didkit 0.3.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,33 +21,61 @@ module DIDKit
21
21
  @services&.detect { |s| s.key == key && s.type == type }
22
22
  end
23
23
 
24
- # Returns the PDS service endpoint, if present.
24
+ # Returns the PDS service endpoint, if present and valid.
25
25
  #
26
26
  # If the DID has an `#atproto_pds` service declared in its `service` section,
27
27
  # returns the URL in its `serviceEndpoint` field. In other words, this is the URL
28
28
  # of the PDS assigned to a given user, which stores the user's account and repo.
29
29
  #
30
+ # Returns nil if the service record is present, but the URL is not a valid HTTP(S) URL.
31
+ # For PDS endpoint specifically, the URL should only contain the scheme, hostname, and
32
+ # optional port number, but no userinfo, path, query or other components. As an exception,
33
+ # a path in the form of a single trailing slash is also allowed.
34
+ #
30
35
  # @api public
31
36
  # @return [String, nil] PDS service endpoint URL
32
37
 
33
38
  def pds_endpoint
34
- @pds_endpoint ||= get_service('atproto_pds', 'AtprotoPersonalDataServer')&.endpoint
39
+ return @pds_endpoint if @pds_endpoint
40
+
41
+ endpoint = get_service('atproto_pds', 'AtprotoPersonalDataServer')&.endpoint
42
+ return nil if endpoint.nil?
43
+
44
+ uri = URI(endpoint)
45
+
46
+ return nil if uri.scheme !~ /^https?$/ || uri.host.nil? || uri.host.empty?
47
+ return nil if uri.userinfo || uri.query || uri.fragment
48
+ return nil unless uri.path.empty? || uri.path == '/'
49
+
50
+ @pds_endpoint = endpoint
35
51
  end
36
52
 
37
- # Returns the labeler service endpoint, if present.
53
+ # Returns the labeler service endpoint, if present and valid.
38
54
  #
39
55
  # If the DID has an `#atproto_labeler` service declared in its `service` section,
40
56
  # returns the URL in its `serviceEndpoint` field.
41
57
  #
58
+ # Returns nil if the service record is present, but the URL is not an HTTP(S) URL.
59
+ #
42
60
  # @api public
43
61
  # @return [String, nil] labeler service endpoint URL
44
62
 
45
63
  def labeler_endpoint
46
- @labeler_endpoint ||= get_service('atproto_labeler', 'AtprotoLabeler')&.endpoint
64
+ return @labeler_endpoint if @labeler_endpoint
65
+
66
+ endpoint = get_service('atproto_labeler', 'AtprotoLabeler')&.endpoint
67
+ return nil if endpoint.nil?
68
+
69
+ uri = URI(endpoint)
70
+ return nil if uri.scheme !~ /^https?$/ || uri.host.nil? || uri.host.empty?
71
+
72
+ @labeler_endpoint = endpoint
47
73
  end
48
74
 
49
75
  # Returns the hostname of the PDS service, if present.
50
76
  #
77
+ # If the endpoint URL includes a port number, it is excluded.
78
+ #
51
79
  # @api public
52
80
  # @return [String, nil] hostname of the PDS endpoint URL
53
81
 
@@ -57,6 +85,8 @@ module DIDKit
57
85
 
58
86
  # Returns the hostname of the labeler service, if present.
59
87
  #
88
+ # If the endpoint URL includes a port number, it is excluded.
89
+ #
60
90
  # @api public
61
91
  # @return [String, nil] hostname of the labeler endpoint URL
62
92
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DIDKit
4
- VERSION = "0.3.3"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/didkit.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "didkit/constants"
3
4
  require_relative "didkit/did"
4
5
  require_relative "didkit/document"
6
+ require_relative "didkit/global_did"
5
7
  require_relative "didkit/plc_importer"
6
8
  require_relative "didkit/plc_operation"
7
9
  require_relative "didkit/resolver"
@@ -9,5 +11,3 @@ require_relative "didkit/version"
9
11
 
10
12
  module DIDKit
11
13
  end
12
-
13
- DID = DIDKit::DID
metadata CHANGED
@@ -1,14 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: didkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base58
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
12
26
  email:
13
27
  - jakub.suder@gmail.com
14
28
  executables: []
@@ -18,19 +32,22 @@ files:
18
32
  - CHANGELOG.md
19
33
  - LICENSE.txt
20
34
  - README.md
35
+ - SECURITY.md
21
36
  - lib/didkit.rb
22
37
  - lib/didkit/at_handles.rb
38
+ - lib/didkit/constants.rb
23
39
  - lib/didkit/did.rb
24
40
  - lib/didkit/document.rb
25
41
  - lib/didkit/errors.rb
42
+ - lib/didkit/global_did.rb
26
43
  - lib/didkit/plc_importer.rb
27
44
  - lib/didkit/plc_operation.rb
45
+ - lib/didkit/public_key.rb
28
46
  - lib/didkit/requests.rb
29
47
  - lib/didkit/resolver.rb
30
48
  - lib/didkit/service_record.rb
31
49
  - lib/didkit/services.rb
32
50
  - lib/didkit/version.rb
33
- - sig/didkit.rbs
34
51
  homepage: https://ruby.sdk.blue
35
52
  licenses:
36
53
  - Zlib
@@ -38,6 +55,7 @@ metadata:
38
55
  bug_tracker_uri: https://tangled.org/mackuba.eu/didkit/issues
39
56
  changelog_uri: https://tangled.org/mackuba.eu/didkit/blob/master/CHANGELOG.md
40
57
  source_code_uri: https://tangled.org/mackuba.eu/didkit
58
+ rubygems_mfa_required: 'true'
41
59
  rdoc_options: []
42
60
  require_paths:
43
61
  - lib
@@ -52,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
70
  - !ruby/object:Gem::Version
53
71
  version: '0'
54
72
  requirements: []
55
- rubygems_version: 4.0.3
73
+ rubygems_version: 4.0.18
56
74
  specification_version: 4
57
75
  summary: A library for handling Distributed ID (DID) identifiers used in Bluesky AT
58
76
  Protocol
data/sig/didkit.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Didkit
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end