blue_factory 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7f8f8505228a075534b74c48c3011441aca5f8710bb1dc6fd769fd62cb60d71
4
- data.tar.gz: 303454ba19fee635367049603810cb1ebb7662665ccc05ce99c035b063c94b2c
3
+ metadata.gz: de68a9c6f0b159edc06d950cb3ad558537273ce95637a3c2b2ab183f0eeb52d9
4
+ data.tar.gz: 609d5127c0ee34fbc19bca7b3cb37b01cbde365e05f24699e8cd4b0bd226d340
5
5
  SHA512:
6
- metadata.gz: 17b3606d68a5bc89557e78fc85478319499e84ce903fdc2f4e56a8221f923435f0c5a55b43a1a64fc974dc843b38d6d9a672480e56fe12c3f5eb6e26fbb5cff6
7
- data.tar.gz: b53d4ac56b668b15f256bf5a87abd8f8195d0a91e3f7308b78f24454be9d436a05c539fb31b14fd6febe3b6a7621b7e151ef2c90b3963c64d52c743bd30bb7c6
6
+ metadata.gz: 25dee3b63c24fc48fce4b4aaa04ac8113c92e35df6464b8357053ef422fba14181c2cd3d7e26894fcbb14e736b029b2e5a3f45940d93fc294ddcbc52519f49bf
7
+ data.tar.gz: bad39da56a7a4cec3217dbf507197dc23c2951e855d8501bb89babe8a0966e3809065cbf9a0e1c7c038c77e0d5764a04feb8e6815c931962d40cd1bb29d5c391
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.1.5] - 2025-03-20
2
+
3
+ - added support for feed content mode field (video feeds)
4
+
1
5
  ## [0.1.4] - 2023-08-19
2
6
 
3
7
  - implemented partial authentication, without signature verification (`enable_unsafe_auth` option)
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # BlueFactory 🏭
2
2
 
3
- A Ruby gem for hosting custom feeds for Bluesky
3
+ A Ruby gem for hosting custom feeds for Bluesky.
4
+
5
+ > [!NOTE]
6
+ > ATProto Ruby gems collection: [skyfall](https://github.com/mackuba/skyfall) | [blue_factory](https://github.com/mackuba/blue_factory) | [minisky](https://github.com/mackuba/minisky) | [didkit](https://github.com/mackuba/didkit)
4
7
 
5
8
 
6
9
  ## What does it do
@@ -125,11 +128,11 @@ server {
125
128
 
126
129
  ## Authentication
127
130
 
128
- Feeds are authenticated using [JSON Web Tokens](https://jwt.io). When a user opens, refreshes or scrolls down a feed in their app, a request is made to the feed service from the Bluesky network's IP address with user's authentication token in the `Authorization` HTTP header.
131
+ Feeds are authenticated using a technology called [JSON Web Tokens](https://jwt.io). If a user is logged in, when they open, refresh or scroll down a feed in their app, requests are made to the feed service from the Bluesky network's IP address with user's authentication token in the `Authorization` HTTP header. (This is not the same kind of token as the access token that you use to make API calls - it does not let you perform any actions on user's behalf.)
129
132
 
130
- At the moment, Blue Factory handles authentication in a very simplified way - it extracts the user's DID from the authentication header, but it does not verify the signature. This means that anyone can trivially prepare a fake token and make requests to the `getFeedSkeleton` endpoint as a different user.
133
+ At the moment, Blue Factory handles authentication in a very simplified way - it extracts the user's DID from the authentication header, but it does not verify the signature. This means that anyone with some programming knowledge can trivially prepare a fake token and make requests to the `getFeedSkeleton` endpoint as a different user.
131
134
 
132
- As such, this authentication should not be used for anything critical. It may be used for things like logging, analytics, or as "security by obscurity" to just discourage others from accessing the feed in the app.
135
+ As such, this authentication should not be used for anything critical. It may be used for things like logging, analytics, or as "security by obscurity" to just discourage others from accessing the feed in the app. You can also use this to build personalized feeds, as long as it's not a problem that the user DID may be fake.
133
136
 
134
137
  To use this simple authentication, set the `enable_unsafe_auth` option:
135
138
 
@@ -167,7 +170,24 @@ end
167
170
 
168
171
  <p><img width="400" src="https://github.com/mackuba/blue_factory/assets/28465/9197c0ec-9302-4ca0-b06c-3fce2e0fa4f4"></p>
169
172
 
170
- Note: the `current_user` may be `nil` if the authentication header is not set at all (which may happen if you access the endpoint e.g. with `curl` or in a browser).
173
+
174
+ ### Unauthenticated access
175
+
176
+ Please note that the `current_user` may be nil - this will happen if the authentication header is not set at all. Since the [bsky.app](https://bsky.app) website is now open to the public and can be accessed without authentication, people can also access your feeds without being logged in.
177
+
178
+ If you want the feed to only be available to logged in users (even if it's a non-personalized feed), simply raise an `AuthorizationError` if `current_user` is nil:
179
+
180
+ ```rb
181
+ class RestrictedFeed
182
+ def get_posts(params, current_user)
183
+ if current_user.nil?
184
+ raise BlueFactory::AuthorizationError, "Log in to see this feed"
185
+ end
186
+
187
+ # ...
188
+ end
189
+ end
190
+ ```
171
191
 
172
192
 
173
193
  ## Additional configuration & customizing
@@ -204,6 +224,7 @@ To publish the feed, you will need to provide some additional info about the fee
204
224
  - `display_name` (required) - the publicly visible name of your feed, e.g. "WWDC 23" (should be something short)
205
225
  - `description` (optional) - a longer (~1-2 lines) description of what the feed does, displayed on the feed page as the "bio"
206
226
  - `avatar_file` (optional) - path to an avatar image from the project's root (PNG or JPG)
227
+ - `content_mode` (optional) - return `:video` to create a video feed
207
228
 
208
229
  When you're ready, run the rake task passing the feed key (you will be asked for the uploader account's password):
209
230
 
@@ -211,9 +232,12 @@ When you're ready, run the rake task passing the feed key (you will be asked for
211
232
  bundle exec rake bluesky:publish KEY=wwdc
212
233
  ```
213
234
 
235
+ For non-Bluesky PDSes, you need to also add an env var `SERVER_URL=https://your.pds.host`.
236
+
237
+
214
238
  ## Credits
215
239
 
216
- Copyright © 2023 Kuba Suder ([@mackuba.eu](https://bsky.app/profile/mackuba.eu)).
240
+ Copyright © 2025 Kuba Suder ([@mackuba.eu](https://bsky.app/profile/mackuba.eu)).
217
241
 
218
242
  The code is available under the terms of the [zlib license](https://choosealicense.com/licenses/zlib/) (permissive, similar to MIT).
219
243
 
@@ -13,7 +13,6 @@ module BlueFactory
13
13
  disable :static
14
14
  enable :quiet
15
15
  enable :logging
16
- set :default_content_type, 'application/json'
17
16
  settings.add_charset << 'application/json'
18
17
  end
19
18
 
@@ -26,11 +25,15 @@ module BlueFactory
26
25
  'at://' + config.publisher_did + '/' + FEED_GENERATOR_TYPE + '/' + key
27
26
  end
28
27
 
29
- def json(data)
28
+ def json_response(data)
29
+ content_type :json
30
30
  JSON.generate(data)
31
31
  end
32
32
 
33
+ alias json json_response
34
+
33
35
  def json_error(name, message, status: 400)
36
+ content_type :json
34
37
  [status, JSON.generate({ error: name, message: message })]
35
38
  end
36
39
 
@@ -110,7 +113,7 @@ module BlueFactory
110
113
  output[:feed] = response[:posts].map { |s| { post: s }}
111
114
  output[:cursor] = response[:cursor] if response[:cursor]
112
115
 
113
- return json(output)
116
+ return json_response(output)
114
117
  rescue InvalidRequestError => e
115
118
  return json_error(e.error_type || "InvalidRequest", e.message)
116
119
  rescue AuthorizationError => e
@@ -123,14 +126,14 @@ module BlueFactory
123
126
  end
124
127
 
125
128
  get '/xrpc/app.bsky.feed.describeFeedGenerator' do
126
- return json({
129
+ return json_response({
127
130
  did: config.service_did,
128
131
  feeds: config.feed_keys.map { |f| { uri: feed_uri(f) }}
129
132
  })
130
133
  end
131
134
 
132
135
  get '/.well-known/did.json' do
133
- return json({
136
+ return json_response({
134
137
  '@context': ['https://www.w3.org/ns/did/v1'],
135
138
  id: config.service_did,
136
139
  service: [
@@ -40,6 +40,18 @@ namespace :bluesky do
40
40
  feed_description = feed.description
41
41
  end
42
42
 
43
+ if feed.respond_to?(:content_mode)
44
+ case feed.content_mode
45
+ when nil, :unspecified
46
+ feed_content_mode = "app.bsky.feed.defs#contentModeUnspecified"
47
+ when :video
48
+ feed_content_mode = "app.bsky.feed.defs#contentModeVideo"
49
+ else
50
+ puts "Invalid content mode: #{feed.content_mode.inspect}. Accepted values: :video, :unspecified, nil."
51
+ exit 1
52
+ end
53
+ end
54
+
43
55
  if feed.respond_to?(:avatar_file) && feed.avatar_file.to_s.strip != ''
44
56
  avatar_file = feed.avatar_file
45
57
 
@@ -87,6 +99,7 @@ namespace :bluesky do
87
99
  }
88
100
 
89
101
  record[:avatar] = avatar_ref if avatar_ref
102
+ record[:contentMode] = feed_content_mode if feed_content_mode
90
103
 
91
104
  json = BlueFactory::Net.post_request(server, 'com.atproto.repo.putRecord', {
92
105
  repo: BlueFactory.publisher_did,
@@ -1,3 +1,3 @@
1
1
  module BlueFactory
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-08-19 00:00:00.000000000 Z
10
+ date: 2025-03-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sinatra
@@ -56,7 +55,6 @@ metadata:
56
55
  bug_tracker_uri: https://github.com/mackuba/blue_factory/issues
57
56
  changelog_uri: https://github.com/mackuba/blue_factory/blob/master/CHANGELOG.md
58
57
  source_code_uri: https://github.com/mackuba/blue_factory
59
- post_install_message:
60
58
  rdoc_options: []
61
59
  require_paths:
62
60
  - lib
@@ -71,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
69
  - !ruby/object:Gem::Version
72
70
  version: '0'
73
71
  requirements: []
74
- rubygems_version: 3.4.10
75
- signing_key:
72
+ rubygems_version: 3.6.5
76
73
  specification_version: 4
77
74
  summary: A Ruby gem for hosting custom feeds for Bluesky
78
75
  test_files: []