jekyll-activity-pub 0.1.0rc13 → 0.1.0rc15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c1484d32011db73dd1d0db605244a6ac077f0820aa4ef0b2c78111a210f0c04
4
- data.tar.gz: 17841d449364d36b5b8a78377234b0215aa09951797776c51a8fd4835142c758
3
+ metadata.gz: 85320eb7b8fa252e8e66bb733d4ab51478b379f4ebd6211c0fbc6387f425cffc
4
+ data.tar.gz: 122b5349c06408910f743f255112df2acc3318cc0ede289ea5811a030fda3b65
5
5
  SHA512:
6
- metadata.gz: 1ec20c6425542d0b83a2e995dcf38e3d9196728fcb5358e782ee66f23ba26aa625ab1523bd9235eebb2684cc1548912f9dd3a24ceac6ec30660fd0664969fac2
7
- data.tar.gz: 8ec390af344d3e4f7558119a00e153c194029206af5c6b431282f2af1d73de22eeeafa6001757ebd368a8d0c5433753df7e09a8596de75b03915a1fca9a0cf2f
6
+ metadata.gz: a2111ddfe7cf26d72088b000014c6ac690a731235c392e9d2cb86a7831913a53d1e27a6a6920c599a52218f275eaf29f473dc37b03b561bbc8abe64d0ddafb6c
7
+ data.tar.gz: 5ec690882fbc64d533a1f02741252215e71b9a156d7697228afa5b71bbd927d4bda149d3724f88ca598bd9e58530c21f350ae5c59694e1e1a9cb0256c505be32
@@ -53,14 +53,20 @@ module Jekyll
53
53
  @@site
54
54
  end
55
55
 
56
+ def url
57
+ config['url'].tap do |u|
58
+ abort_if_missing('activity_pub.url', u, '_config.yml')
59
+ end
60
+ end
61
+
56
62
  # @return [String]
57
63
  def followers_url
58
- "#{config['url']}/v1/#{actor}/followers"
64
+ "#{url}/v1/#{actor}/followers"
59
65
  end
60
66
 
61
67
  # @return [String]
62
68
  def following_url
63
- "#{config['url']}/v1/#{actor}/following"
69
+ "#{url}/v1/#{actor}/following"
64
70
  end
65
71
 
66
72
  # Save the public key URL for later
@@ -70,11 +76,13 @@ module Jekyll
70
76
  data['public_key_url'] = url
71
77
  end
72
78
 
73
- # Public key URL
79
+ # Public key URL, raises error if missing
74
80
  #
75
- # @return [String,nil]
81
+ # @return [String]
76
82
  def public_key_url
77
- data['public_key_url']
83
+ data['public_key_url'].tap do |pk|
84
+ abort_if_missing('public_key_url', pk)
85
+ end
78
86
  end
79
87
 
80
88
  def actor=(actor)
@@ -82,7 +90,9 @@ module Jekyll
82
90
  end
83
91
 
84
92
  def actor
85
- data['actor']
93
+ data['actor'].tap do |a|
94
+ abort_if_missing('actor', a)
95
+ end
86
96
  end
87
97
 
88
98
  def actor_url=(url)
@@ -90,7 +100,9 @@ module Jekyll
90
100
  end
91
101
 
92
102
  def actor_url
93
- data['actor_url']
103
+ data['actor_url'].tap do |au|
104
+ abort_if_missing('actor_url', au)
105
+ end
94
106
  end
95
107
 
96
108
  # Send notifications
@@ -104,10 +116,10 @@ module Jekyll
104
116
 
105
117
  unless response.ok?
106
118
  raise NotificationError,
107
- "Could't fetch public key (#{response.code}: #{response.message})"
119
+ "Could't fetch public key (#{response.code}: #{response.message}). It needs to be available at #{public_key_url} before notifications can work, because it's used for signature verification."
108
120
  end
109
121
 
110
- unless client.private_key.compare? OpenSSL::PKey::RSA.new(response.body)
122
+ unless client.private_key.compare? OpenSSL::PKey::RSA.new(response.parsed_response.dig('publicKey', 'publicKeyPem'))
111
123
  raise NotificationError, "Public key at #{public_key_url} differs from local version"
112
124
  end
113
125
 
@@ -148,6 +160,8 @@ module Jekyll
148
160
 
149
161
  # Store everything for later
150
162
  save
163
+ rescue NotificationError => e
164
+ Jekyll.logger.abort_with 'ActivityPub:', e.message
151
165
  end
152
166
 
153
167
  # Return data
@@ -274,7 +288,9 @@ module Jekyll
274
288
  #
275
289
  # @return [String, nil]
276
290
  def private_key_path
277
- @@private_key_path ||= site.config['activity_pub_private_key']
291
+ @@private_key_path ||= site.config['activity_pub_private_key'].tap do |pk|
292
+ abort_if_missing '--key', pk, 'notify command'
293
+ end
278
294
  end
279
295
 
280
296
  # Returns the private key
@@ -283,8 +299,7 @@ module Jekyll
283
299
  def private_key
284
300
  @@private_key ||= File.read private_key_path
285
301
  rescue StandardError
286
- Jekyll.logger.warn 'ActivityPub:', 'There\'s an issue with your private key'
287
- raise
302
+ Jekyll.logger.abort_with 'ActivityPub:', 'There\'s an issue with your private key'
288
303
  end
289
304
 
290
305
  # @return [Hash]
@@ -295,7 +310,7 @@ module Jekyll
295
310
  def client
296
311
  @@client ||= DistributedPress::V1::Social::Client.new(
297
312
  private_key_pem: private_key,
298
- url: config['url'],
313
+ url: url,
299
314
  public_key_url: public_key_url,
300
315
  logger: Jekyll.logger
301
316
  )
@@ -361,6 +376,12 @@ module Jekyll
361
376
  PseudoObject.new(url: rel, site: site, relative_path: rel, data: data)
362
377
  end
363
378
  end
379
+
380
+ def abort_if_missing(key_name, value, file = '_data/activity_pub.yml')
381
+ return unless value.nil? || value.empty?
382
+
383
+ Jekyll.logger.abort_with 'ActivityPub:', "Missing #{key_name} in #{file}"
384
+ end
364
385
  end
365
386
  end
366
387
  end
@@ -27,14 +27,14 @@ module Jekyll
27
27
 
28
28
  actor.data['publicKey'] = self
29
29
 
30
- Notifier.public_key_url = absolute_url(url)
30
+ Notifier.public_key_url = data['id']
31
31
 
32
32
  trigger_hooks :post_init
33
33
  end
34
34
 
35
35
  def read_yaml(*)
36
36
  self.data = {
37
- 'id' => absolute_url(url),
37
+ 'id' => "#{absolute_url(@actor.url)}#main-key",
38
38
  'owner' => absolute_url(@actor.url),
39
39
  'publicKeyPem' => @public_key.public_to_pem
40
40
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-activity-pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0rc13
4
+ version: 0.1.0rc15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sutty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-05 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: distributed-press-api-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0rc3
19
+ version: 0.3.0rc4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0rc3
26
+ version: 0.3.0rc4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +143,7 @@ files:
143
143
  - lib/jekyll/activity_pub.rb
144
144
  - lib/jekyll/activity_pub/activity.rb
145
145
  - lib/jekyll/activity_pub/actor.rb
146
- - lib/jekyll/activity_pub/cache.rb
146
+ - lib/jekyll/activity_pub/cache.rb~
147
147
  - lib/jekyll/activity_pub/commands.rb
148
148
  - lib/jekyll/activity_pub/create.rb
149
149
  - lib/jekyll/activity_pub/delete.rb
@@ -158,7 +158,7 @@ files:
158
158
  - lib/jekyll/activity_pub/outbox.rb
159
159
  - lib/jekyll/activity_pub/property_value.rb
160
160
  - lib/jekyll/activity_pub/public_key.rb
161
- - lib/jekyll/activity_pub/tomsbtone.rb
161
+ - lib/jekyll/activity_pub/tomsbtone.rb~
162
162
  - lib/jekyll/activity_pub/update.rb
163
163
  - lib/jekyll/activity_pub/webfinger.rb
164
164
  - lib/jekyll/command_extension.rb
File without changes