authproto 0.3.0.beta4 → 0.3.0.beta5

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +474 -311
  4. data/examples/basic_webapp/Gemfile +14 -0
  5. data/examples/{confidential_client → basic_webapp}/Gemfile.lock +1 -1
  6. data/examples/basic_webapp/README.md +300 -0
  7. data/examples/basic_webapp/app.rb +351 -0
  8. data/examples/basic_webapp/config/oauth-client-metadata.localhost.json +11 -0
  9. data/examples/basic_webapp/public/styles.css +346 -0
  10. data/examples/basic_webapp/scripts/generate_keys.rb +35 -0
  11. data/examples/basic_webapp/views/authorized.erb +48 -0
  12. data/examples/basic_webapp/views/index.erb +48 -0
  13. data/examples/{confidential_client → basic_webapp}/views/layout.erb +2 -2
  14. data/examples/bookmarks/Gemfile +16 -0
  15. data/examples/bookmarks/Gemfile.lock +158 -0
  16. data/examples/bookmarks/README.md +170 -0
  17. data/examples/bookmarks/Rakefile +23 -0
  18. data/examples/bookmarks/app/account.rb +16 -0
  19. data/examples/bookmarks/app/bookmark.rb +89 -0
  20. data/examples/bookmarks/app/init.rb +26 -0
  21. data/examples/bookmarks/app/oauth.rb +43 -0
  22. data/examples/bookmarks/app/server.rb +184 -0
  23. data/examples/bookmarks/config/oauth-client-metadata.localhost.json +11 -0
  24. data/examples/bookmarks/config/oauth-client-metadata.production.json +19 -0
  25. data/examples/bookmarks/config.ru +5 -0
  26. data/examples/bookmarks/db/migrate/20261107004141_create_bookmarks.rb +27 -0
  27. data/examples/bookmarks/db/schema.rb +33 -0
  28. data/examples/bookmarks/public/styles.css +59 -0
  29. data/examples/bookmarks/scripts/generate_keys.rb +35 -0
  30. data/examples/bookmarks/views/bookmarks.erb +86 -0
  31. data/examples/bookmarks/views/index.erb +17 -0
  32. data/examples/bookmarks/views/layout.erb +20 -0
  33. data/examples/minisky_console/Gemfile.lock +2 -2
  34. data/examples/minisky_console/README.md +29 -25
  35. data/examples/minisky_console/app.rb +3 -3
  36. data/examples/minisky_console/localhost.rb +5 -7
  37. data/examples/minisky_console/production.rb +6 -8
  38. data/lib/authproto/client.rb +413 -126
  39. data/lib/authproto/configuration.rb +1 -1
  40. data/lib/authproto/dpop/client.rb +28 -25
  41. data/lib/authproto/dpop/key_set.rb +2 -0
  42. data/lib/authproto/dpop/nonce_manager.rb +23 -20
  43. data/lib/authproto/dpop/proof_generator.rb +6 -3
  44. data/lib/authproto/dpop/stored_nonce.rb +7 -5
  45. data/lib/authproto/dpop.rb +2 -0
  46. data/lib/authproto/encryption.rb +2 -0
  47. data/lib/authproto/http_client.rb +5 -5
  48. data/lib/authproto/http_helpers.rb +6 -0
  49. data/lib/authproto/metadata/authorization_server.rb +4 -3
  50. data/lib/authproto/metadata/client_metadata.rb +6 -2
  51. data/lib/authproto/metadata/resource_server.rb +4 -3
  52. data/lib/authproto/minisky.rb +120 -33
  53. data/lib/authproto/par/client.rb +4 -2
  54. data/lib/authproto/par/client_assertion.rb +4 -1
  55. data/lib/authproto/par/request.rb +2 -0
  56. data/lib/authproto/par/response.rb +2 -0
  57. data/lib/authproto/par.rb +2 -0
  58. data/lib/authproto/pkce.rb +2 -0
  59. data/lib/authproto/serialization/session.rb +2 -2
  60. data/lib/authproto/serialization/stored_nonce.rb +2 -2
  61. data/lib/authproto/state/session.rb +8 -41
  62. data/lib/authproto/state/session_info.rb +150 -0
  63. data/lib/authproto/state/session_manager.rb +18 -15
  64. data/lib/authproto/state.rb +3 -1
  65. data/lib/authproto/storage/interface.rb +10 -0
  66. data/lib/authproto/storage/key_builder.rb +3 -3
  67. data/lib/authproto/storage/memory.rb +24 -18
  68. data/lib/authproto/storage/sqlite.rb +14 -0
  69. data/lib/authproto/token/refresh.rb +2 -2
  70. data/lib/authproto/token/response.rb +2 -0
  71. data/lib/authproto/token/revocation.rb +4 -2
  72. data/lib/authproto/version.rb +1 -1
  73. data/lib/authproto.rb +6 -3
  74. data/sig/authproto/client.rbs +33 -10
  75. data/sig/authproto/dpop/client.rbs +9 -3
  76. data/sig/authproto/dpop/nonce_manager.rbs +6 -6
  77. data/sig/authproto/dpop/proof_generator.rbs +4 -4
  78. data/sig/authproto/dpop/stored_nonce.rbs +2 -2
  79. data/sig/authproto/http_client.rbs +23 -6
  80. data/sig/authproto/http_helpers.rbs +1 -0
  81. data/sig/authproto/metadata/authorization_server.rbs +3 -3
  82. data/sig/authproto/metadata/client_metadata.rbs +1 -1
  83. data/sig/authproto/metadata/resource_server.rbs +2 -2
  84. data/sig/authproto/minisky.rbs +57 -0
  85. data/sig/authproto/state/session.rbs +12 -6
  86. data/sig/authproto/state/session_info.rbs +23 -0
  87. data/sig/authproto/state/session_manager.rbs +7 -2
  88. data/sig/authproto/storage/interface.rbs +1 -0
  89. data/sig/authproto/storage/key_builder.rbs +1 -1
  90. data/sig/authproto/storage/memory.rbs +1 -1
  91. data/sig/authproto/storage/sqlite.rbs +1 -0
  92. data/sig/authproto/token/revocation.rbs +1 -0
  93. data/sig/authproto.rbs +3 -8
  94. metadata +37 -15
  95. data/examples/confidential_client/Gemfile +0 -14
  96. data/examples/confidential_client/README.md +0 -236
  97. data/examples/confidential_client/app.rb +0 -308
  98. data/examples/confidential_client/public/styles.css +0 -70
  99. data/examples/confidential_client/scripts/generate_keys.rb +0 -21
  100. data/examples/confidential_client/views/authorized.erb +0 -46
  101. data/examples/confidential_client/views/index.erb +0 -44
  102. data/sig/authproto/minisky_oauth.rbs +0 -27
  103. /data/examples/{confidential_client/config/oauth-client-metadata.example.json → basic_webapp/config/oauth-client-metadata.production.json} +0 -0
  104. /data/examples/{confidential_client → basic_webapp}/config.ru +0 -0
  105. /data/examples/{confidential_client → basic_webapp}/screenshots/screenshot-1-sign-in.png +0 -0
  106. /data/examples/{confidential_client → basic_webapp}/screenshots/screenshot-2-success.png +0 -0
@@ -1,308 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cgi'
4
- require 'json'
5
- require 'securerandom'
6
- require 'time'
7
- require 'uri'
8
-
9
- require 'authproto'
10
- require 'dotenv/load'
11
- require 'faraday'
12
- require 'sinatra/base'
13
- require 'sinatra/reloader'
14
-
15
- $session_secret = ENV.fetch("SESSION_SECRET") { SecureRandom.hex(32) }
16
- raise "SESSION_SECRET must be at least 64 characters long (got: #{$session_secret})" if $session_secret.length < 64
17
-
18
- # Main app entry point
19
- class ExampleApp < Sinatra::Base
20
- def check_stored_session(session_id)
21
- return false unless session_id
22
-
23
- settings.oauth_client.authorized?(session_id)
24
- rescue AuthProto::SessionError
25
- false
26
- end
27
-
28
- configure :development do
29
- register Sinatra::Reloader
30
- end
31
-
32
- # Initialize the AT Protocol OAuth client
33
- configure do
34
- # Configure AuthProto settings
35
- AuthProto.configure do |config|
36
- config.http_client = AuthProto::HTTPClient.new(timeout: 10, verify_ssl: true)
37
- config.dpop_nonce_lifetime = 300
38
-
39
- case ENV.fetch("STORAGE_BACKEND", "memory")
40
- when "memory"
41
- config.storage = AuthProto::Storage::Memory.new
42
- when "sqlite"
43
- config.storage = AuthProto::Storage::SQLite.new(
44
- path: ENV.fetch("SQLITE_PATH", File.join(__dir__, "db", "authproto.sqlite3"))
45
- )
46
- when "redis"
47
- config.storage = AuthProto::Storage::Redis.new(
48
- redis_client: Redis.new(url: ENV.fetch("REDIS_URL"))
49
- )
50
- else
51
- raise "STORAGE_BACKEND must be memory, sqlite, or redis"
52
- end
53
- end
54
-
55
- # Load client metadata
56
- metadata_path = File.join(__dir__, "config", "oauth-client-metadata.json")
57
- metadata = JSON.parse(File.read(metadata_path))
58
-
59
- client_id = metadata['client_id']
60
- redirect_uri = metadata['redirect_uris'][0]
61
-
62
- # Private client-authentication keys are kept outside public metadata.
63
- keys_file = File.join(__dir__, "config", "keys.json")
64
- signing_key = JSON.parse(File.read(keys_file))['keys'].first if File.exist?(keys_file)
65
-
66
- if client_id.chomp("/") == "http://localhost"
67
- scope = CGI.escape(metadata['scope'])
68
- redirect = CGI.escape(metadata['redirect_uris'][0])
69
- client_id += "?scope=#{scope}&redirect_uri=#{redirect}"
70
- metadata = nil
71
-
72
- if signing_key
73
- warn "-" * 100
74
- warn "Running the app on localhost as a public client - confidential clients require a production server."
75
- warn "-" * 100
76
-
77
- signing_key = nil
78
- end
79
- else
80
- if !signing_key
81
- warn "-" * 100
82
- warn "Missing config/keys.json - running the app as a public client."
83
- warn "-" * 100
84
- end
85
- end
86
-
87
- # Create OAuth client
88
- set :oauth_client, AuthProto::Client.new(
89
- client_id: client_id,
90
- redirect_uri: redirect_uri,
91
- metadata: metadata,
92
- signing_key: signing_key
93
- )
94
- end
95
-
96
- set :host_authorization, {
97
- permitted_hosts: ["localhost", ENV.fetch("PERMITTED_DOMAIN", nil)].compact
98
- }
99
-
100
- use Rack::Session::Cookie,
101
- key: "atproto.session",
102
- expire_after: 86_400, # 1 day in seconds
103
- secret: $session_secret,
104
- secure: ENV.fetch("RACK_ENV", "development") == "production", # Only send over HTTPS
105
- httponly: true, # Not accessible via JavaScript
106
- same_site: :lax # CSRF protection
107
-
108
- helpers do
109
- def recover_session
110
- session_id = session[:oauth_session_id]
111
- return nil unless session_id
112
-
113
- begin
114
- # Check if session is still valid
115
- return nil unless settings.oauth_client.authorized?(session_id)
116
-
117
- session_id
118
- rescue AuthProto::Client::SessionError
119
- # Clear invalid session
120
- session.delete(:oauth_session_id)
121
- nil
122
- end
123
- end
124
- end
125
-
126
- get "/" do
127
- # Check for existing session
128
- redirect "/authorized" if recover_session
129
-
130
- erb :index
131
- end
132
-
133
- get "/oauth-client-metadata.json" do
134
- content_type :json
135
-
136
- # Read metadata from config file
137
- metadata_path = File.join(__dir__, "config", "oauth-client-metadata.json")
138
- metadata = JSON.parse(File.read(metadata_path))
139
-
140
- # This file contains only the public counterparts of config/keys.json.
141
- JSON.generate(metadata)
142
- end
143
-
144
- # Start OAuth flow
145
- post "/auth" do
146
- handle = params[:handle]
147
-
148
- begin
149
- # Start authorization flow
150
- auth = settings.oauth_client.authorize(
151
- handle: handle,
152
- scope: "atproto repo:app.bsky.feed.post"
153
- )
154
-
155
- # Bind the pending authorization attempt to this browser, separately from any active login.
156
- session[:pending_oauth_session_id] = auth[:session_id]
157
-
158
- # Redirect to authorization URL
159
- redirect auth[:url]
160
- rescue StandardError => e
161
- session[:error] = "Authorization failed: #{e.message}"
162
- redirect "/"
163
- end
164
- end
165
-
166
- # OAuth callback handler
167
- get "/callback" do
168
- # Handle the callback
169
- result = settings.oauth_client.handle_callback(
170
- code: params[:code],
171
- state: params[:state],
172
- iss: params[:iss],
173
- expected_session_id: session[:pending_oauth_session_id]
174
- )
175
-
176
- session.delete(:pending_oauth_session_id)
177
-
178
- # Remember the authenticated session ID.
179
- session[:oauth_session_id] = result[:session_id]
180
-
181
- redirect "/authorized"
182
- rescue StandardError => e
183
- session[:error] = "Callback failed: #{e.message}"
184
- redirect "/"
185
- end
186
-
187
- # Show authorized state and test API call
188
- get "/authorized" do
189
- session_id = session[:oauth_session_id]
190
- return redirect "/" unless check_stored_session(session_id)
191
-
192
- begin
193
- # Get current session tokens
194
- oauth_session = settings.oauth_client.get_tokens(session_id)
195
-
196
- # Check if token needs refresh
197
- if oauth_session[:expires_in] < 30
198
- # Refresh token
199
- oauth_session = settings.oauth_client.refresh_token(session_id)
200
- end
201
-
202
- # Make test API call to com.atproto.identity.resolveHandle
203
- conn = Faraday.new(url: "https://api.bsky.app") do |f|
204
- f.request :json
205
- f.response :json
206
- end
207
-
208
- # Get auth headers for request
209
- headers = settings.oauth_client.auth_headers(
210
- session_id: session_id,
211
- method: 'GET',
212
- url: "https://api.bsky.app/xrpc/com.atproto.identity.resolveHandle"
213
- )
214
-
215
- # Make authenticated request
216
- response = conn.get("/xrpc/com.atproto.identity.resolveHandle") do |req|
217
- headers.each { |k, v| req.headers[k] = v }
218
- req.params[:handle] = "bsky.app"
219
- end
220
-
221
- @api_result = response.body
222
- @session = oauth_session
223
- erb :authorized
224
- rescue StandardError => e
225
- session[:error] = "API call failed: #{e.message}"
226
- redirect "/"
227
- end
228
- end
229
-
230
- post "/posts" do
231
- session_id = session[:oauth_session_id]
232
- return redirect "/" unless check_stored_session(session_id)
233
-
234
- text = params[:text].to_s
235
- if text.strip.empty?
236
- session[:error] = "Post text cannot be empty"
237
- return redirect "/authorized"
238
- end
239
-
240
- if text.length > 300 || text.bytesize > 3_000
241
- session[:error] = "Post text must be at most 300 characters and 3,000 bytes"
242
- return redirect "/authorized"
243
- end
244
-
245
- oauth_session = settings.oauth_client.session_manager.get_session(session_id)
246
-
247
- pds_url = ENV['PDS_URL'] || DIDKit::DID.new(oauth_session.did).document.pds_endpoint
248
- raise "No HTTPS PDS location found" unless pds_url && URI(pds_url).is_a?(URI::HTTPS)
249
-
250
- endpoint = URI.join(
251
- "#{pds_url.chomp("/")}/",
252
- "xrpc/com.atproto.repo.createRecord"
253
- ).to_s
254
-
255
- headers = settings.oauth_client.auth_headers(
256
- session_id: session_id,
257
- method: 'POST',
258
- url: endpoint
259
- )
260
-
261
- conn = Faraday.new do |f|
262
- f.request :json
263
- f.response :json
264
- end
265
- response = conn.post(endpoint) do |req|
266
- headers.each { |key, value| req.headers[key] = value }
267
- req.body = {
268
- repo: oauth_session.did,
269
- collection: "app.bsky.feed.post",
270
- record: {
271
- "$type": "app.bsky.feed.post",
272
- text: text,
273
- langs: ["en"],
274
- createdAt: Time.now.utc.iso8601(3)
275
- }
276
- }
277
- end
278
-
279
- unless response.success?
280
- error_body = response.body.is_a?(String) ? response.body : JSON.generate(response.body)
281
- raise "PDS rejected post (#{response.status}): #{error_body}"
282
- end
283
-
284
- session[:notice] = "Post published successfully"
285
- redirect "/authorized"
286
- rescue StandardError => e
287
- session[:error] = "Publishing post failed: #{e.message}"
288
- redirect "/authorized"
289
- end
290
-
291
- get "/signout" do
292
- if session[:oauth_session_id]
293
- # Clean up stored session
294
- settings.oauth_client.delete_session(session[:oauth_session_id], revoke: true)
295
- end
296
-
297
- session.clear
298
- session[:notice] = "Successfully signed out"
299
- redirect "/"
300
- end
301
-
302
- # Helper method to check if user is authenticated
303
- def authenticated?
304
- return false unless session[:tokens]
305
-
306
- settings.oauth_client.authorized?(session[:tokens][:session_id])
307
- end
308
- end
@@ -1,70 +0,0 @@
1
- .container {
2
- max-width: 800px;
3
- margin: 0 auto;
4
- padding: 20px;
5
- }
6
-
7
- .header {
8
- max-width: 400px;
9
- margin: 0 auto;
10
- }
11
-
12
- .error {
13
- background-color: #ffebee;
14
- color: #c62828;
15
- padding: 10px;
16
- margin-bottom: 20px;
17
- border-radius: 4px;
18
- }
19
-
20
- .auth-form {
21
- max-width: 400px;
22
- margin: 40px auto;
23
- }
24
-
25
- .form-group {
26
- margin-bottom: 15px;
27
- }
28
-
29
- .form-group label {
30
- display: block;
31
- margin-bottom: 5px;
32
- }
33
-
34
- .form-group input {
35
- width: 100%;
36
- padding: 8px;
37
- border: 1px solid #ddd;
38
- border-radius: 4px;
39
- }
40
-
41
- button {
42
- background: #2196f3;
43
- color: white;
44
- padding: 10px 20px;
45
- border: none;
46
- border-radius: 4px;
47
- cursor: pointer;
48
- }
49
-
50
- button:hover {
51
- background: #1976d2;
52
- }
53
-
54
- .token-info,
55
- .api-test {
56
- margin-top: 20px;
57
- padding: 15px;
58
- background: #f5f5f5;
59
- border-radius: 4px;
60
- }
61
-
62
- pre {
63
- overflow-x: auto;
64
- white-space: pre-wrap;
65
- word-wrap: break-word;
66
- }
67
-
68
- code {
69
- font-size: 14px;
70
- }
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'jose'
4
- require 'json'
5
-
6
- key = JOSE::JWK.generate_key([:ec, "P-256"])
7
-
8
- private_jwk = key.to_map.to_h.merge("kid" => "key-1", "use" => "sig")
9
- public_jwk = key.to_public_map.to_h.merge("kid" => "key-1", "use" => "sig")
10
-
11
- config_dir = File.expand_path('../config', __dir__)
12
- private_path = File.join(config_dir, 'keys.json')
13
-
14
- File.open(private_path, File::WRONLY | File::CREAT | File::TRUNC, 0o600) do |file|
15
- file.chmod(0o600)
16
- file.write(JSON.pretty_generate('keys' => [private_jwk]) + "\n")
17
- end
18
-
19
- File.write(File.join(config_dir, 'public-keys.json'), JSON.pretty_generate('keys' => [public_jwk]) + "\n")
20
-
21
- puts "Private keys saved to config/keys.json; publish only config/public-keys.json in metadata."
@@ -1,46 +0,0 @@
1
- <div class="flex flex-col items-center md:flex md:flex-row md:justify-stretch md:items-center min-h-screen min-w-screen bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
2
- <div class="px-6 pt-4 md:max-w-lg md:grid md:content-center md:justify-items-end md:self-stretch md:w-1/2 md:max-w-fix md:p-4 md:text-right md:dark:border-r md:dark:border-gray-700 md:bg-gray-100 md:dark:bg-gray-800">
3
- <h1 class="text-xl md:text-2xl lg:text-5xl md:mt-4 mb-4 font-semibold text-brand">Successfully Authenticated!</h1>
4
- </div>
5
- <div class="w-full px-6 md:max-w-3xl md:px-12">
6
- <div class="space-y-8">
7
- <% if session[:error] %>
8
- <div class="mb-8 bg-red-50 border-red-700 text-red-700 p-4 rounded-md">
9
- <%= session[:error] %>
10
- <% session[:error] = nil %>
11
- </div>
12
- <% end %>
13
-
14
- <% if session[:notice] %>
15
- <div class="mb-8 bg-green-50 border-green-700 text-green-700 p-4 rounded-md">
16
- <%= session[:notice] %>
17
- <% session[:notice] = nil %>
18
- </div>
19
- <% end %>
20
-
21
- <form method="post" action="/posts" class="flex flex-col py-4 space-y-4">
22
- <fieldset>
23
- <label for="post-text" class="mb-1 block text-gray-600 dark:text-gray-400 text-sm font-medium">New Bluesky post</label>
24
- <textarea id="post-text" name="text" rows="4" maxlength="300" required placeholder="What's up?" class="w-full rounded-lg text-gray-700 dark:text-gray-100 bg-gray-100 dark:bg-gray-800 p-3 outline-none border-solid border-2 border-transparent hover:border-gray-400 focus:border-brand dark:hover:border-gray-500"></textarea>
25
- </fieldset>
26
- <div>
27
- <button type="submit" class="py-2 px-6 rounded-lg cursor-pointer touch-manipulation tracking-wide bg-blue-400 text-white">Post to Bluesky</button>
28
- </div>
29
- </form>
30
-
31
- <div class="token-info">
32
- <p class="mb-1 text-gray-600 dark:text-gray-400 text-sm font-medium">Token Information</p>
33
- <pre class="rounded-lg text-gray-700 dark:text-gray-100 bg-gray-100 dark:bg-slate-800 border border-gray-400 p-2 overflow-auto"><code><%= JSON.pretty_generate(@session) %></code></pre>
34
- </div>
35
-
36
- <div class="api-test">
37
- <p class="mb-1 text-gray-600 dark:text-gray-400 text-sm font-medium">Test API Call Result</p>
38
- <pre class="rounded-lg text-gray-700 dark:text-gray-100 bg-gray-100 dark:bg-slate-800 border border-gray-400 p-2 overflow-auto"><code><%= JSON.pretty_generate(@api_result) %></code></pre>
39
- </div>
40
-
41
- <div class="flex">
42
- <a href="/signout" aria-label="Signout" class="py-2 px-6 rounded-lg truncate cursor-pointer touch-manipulation tracking-wide overflow-hidden bg-blue-400 text-white">Sign out</a>
43
- </div>
44
- </div>
45
- </div>
46
- </div>
@@ -1,44 +0,0 @@
1
- <div class="flex flex-col items-center md:flex md:flex-row md:justify-stretch md:items-center min-h-screen min-w-screen bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
2
- <div class="px-6 pt-4 md:max-w-lg md:grid md:content-center md:justify-items-end md:self-stretch md:w-1/2 md:max-w-fix md:p-4 md:text-right md:dark:border-r md:dark:border-gray-700 md:bg-gray-100 md:dark:bg-gray-800">
3
- <h1 class="text-xl md:text-2xl lg:text-5xl md:mt-4 mb-4 font-semibold text-brand">Sign in</h1>
4
- <p class="hidden md:block max-w-xs text-gray-500 dark:text-gray-500">Enter your AT Protocol handle</p>
5
- </div>
6
- <div class="w-full px-6 md:max-w-3xl md:px-12">
7
- <form method="post" action="/auth" class="flex flex-col py-4 space-y-4">
8
- <div class="space-y-4">
9
- <% if session[:error] %>
10
- <div class="mb-8 bg-red-50 border-red-700 text-red-700 p-4 rounded-md">
11
- <%= session[:error] %>
12
- <% session[:error] = nil %>
13
- </div>
14
- <% end %>
15
- <% if session[:notice] %>
16
- <div class="mb-8 bg-yellow-50 border-yellow-700 text-yellow-700 p-4 rounded-md">
17
- <%= session[:notice] %>
18
- <% session[:notice] = nil %>
19
- </div>
20
- <% end %>
21
- <fieldset>
22
- <p class="mb-1 text-gray-600 dark:text-gray-400 text-sm font-medium">Handle</p>
23
- <div class="flex flex-col space-y-4">
24
- <div class="pl-1 pr-2 min-h-12 flex items-center justify-stretch rounded-lg text-gray-700 dark:text-gray-100 bg-gray-100 has-[:focus]:bg-gray-200 dark:bg-gray-800 dark:has-[:focus]:bg-gray-700 outline-none border-solid border-2 border-transparent hover:border-gray-400 has-[:focus]:border-brand hover:has-[:focus]:border-brand dark:hover:border-gray-500">
25
- <div class="self-start shrink-0 grow-0 w-8 h-12 flex items-center justify-center text-gray-500">
26
- <div>
27
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-5">
28
- <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M12 4a8 8 0 1 0 4.21 14.804 1 1 0 0 1 1.054 1.7A9.958 9.958 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 1.104-.27 2.31-.949 3.243-.716.984-1.849 1.6-3.331 1.465a4.207 4.207 0 0 1-2.93-1.585c-.94 1.21-2.388 1.94-3.985 1.715-2.53-.356-4.04-2.91-3.682-5.458.358-2.547 2.514-4.586 5.044-4.23.905.127 1.68.536 2.286 1.126a1 1 0 0 1 1.964.368l-.515 3.545v.002a2.222 2.222 0 0 0 1.999 2.526c.75.068 1.212-.21 1.533-.65.358-.493.566-1.245.566-2.067a8 8 0 0 0-8-8Zm-.112 5.13c-1.195-.168-2.544.819-2.784 2.529-.24 1.71.784 3.03 1.98 3.198 1.195.168 2.543-.819 2.784-2.529.24-1.71-.784-3.03-1.98-3.198Z"></path>
29
- </svg>
30
- </div>
31
- </div>
32
- <div class="relative">
33
- <input class="w-full bg-transparent bg-clip-padding text-base text-inherit outline-none dark:placeholder-gray-500" name="handle" type="text" placeholder="handle.bsky.social" aria-label="Handle" autocapitalize="none" autocorrect="off" autocomplete="username" spellcheck="false" dir="auto" enterkeyhint="next" required title="valid handle">
34
- </div>
35
- </div>
36
- </div>
37
- </fieldset>
38
- </div>
39
- <div class="pt-4">
40
- <button role="Button" type="submit" aria-label="Next" class="py-2 px-6 rounded-lg truncate cursor-pointer touch-manipulation tracking-wide overflow-hidden bg-blue-400 text-white">Next</button>
41
- </div>
42
- </form>
43
- </div>
44
- </div>
@@ -1,27 +0,0 @@
1
- # Signatures for the methods defined by the optional Minisky adapter.
2
- # Additional methods mixed in from Minisky::Requests belong to the minisky gem.
3
- class Minisky
4
- class OAuthClient
5
- include AuthProto::HTTPHelpers
6
- MAX_NONCE_RETRIES: Integer
7
- attr_reader host: String
8
- attr_reader oauth_client: AuthProto::Client
9
- attr_reader session_id: String?
10
-
11
- def initialize: (String host, client_id: String, redirect_uri: String, ?metadata: AuthProto::json_object?, ?signing_key: (AuthProto::json_object | JOSE::JWK)?, ?session_id: String?) -> void
12
- def config: () -> nil
13
- def authorize: (?handle: String?, ?pds: String?, ?scope: String) -> AuthProto::authorization_result
14
- def handle_callback: (
15
- code: String, state: String, iss: String, expected_session_id: String
16
- ) -> AuthProto::callback_result
17
- def get_request: (String | URI::HTTP method, ?Hash[untyped, untyped]? params, ?auth: bool, ?headers: Hash[String, String]?) -> untyped
18
- def post_request: (String | URI::HTTP method, ?untyped data, ?auth: bool, ?headers: Hash[String, String]?, ?params: Hash[untyped, untyped]?) -> untyped
19
- def log_in: (*untyped args) -> bot
20
- def perform_token_refresh: () -> AuthProto::refreshed_tokens
21
- def check_access: () -> (:ok | :refreshed)
22
-
23
- private
24
- def oauth_request: (singleton(Net::HTTP::Get) | singleton(Net::HTTP::Post) request_class, URI::HTTP url, Hash[String, String] headers, ?body: String?) -> Net::HTTPResponse
25
- def authentication_error: (Net::HTTPResponse response) -> String?
26
- end
27
- end