ATProto OAuth: client, discovery, and session management
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

merlint sweep: ocaml-atproto-handle, ocaml-atproto-oauth

- snake_case alcotest suite names (E617).
- rename test_metadata / test_handles in interop drivers to drop the
Test_ prefix shadowed by the file's module path (E330).
- extract helpers in indigo interop test_handles to flatten 5-deep
nesting (E010).
- replace open-ended (try ... with _ -> ()) in the loopback callback
with explicit Eio.Io | End_of_file matches (E105).
- shorten validate_server_no_auth_code_grant -> ..._no_authz_grant
(E320).
- lift the Json/IO error wrappers into err_decode / err_io helpers
in Atproto_oauth.Token, replacing the inline Error (`Msg (Fmt.str ...))
pattern (E340).

+15 -14
+6 -5
lib/atproto_oauth.ml
··· 201 201 |> member "scope" string ~enc:(fun t -> t.scope) 202 202 |> seal) 203 203 204 + let err_decode e = Error (`Msg (Fmt.str "%a" Json.Error.pp e)) 205 + let err_io exn = Error (`Msg (Printexc.to_string exn)) 206 + 204 207 let save path t = 205 208 try 206 209 let s = Json.to_string json t in 207 210 Eio.Path.save ~create:(`Or_truncate 0o600) path s; 208 211 Ok () 209 - with exn -> Error (`Msg (Printexc.to_string exn)) 212 + with exn -> err_io exn 210 213 211 214 let load path = 212 215 try 213 216 let s = Eio.Path.load path in 214 - match Json.of_string json s with 215 - | Ok t -> Ok t 216 - | Error e -> Error (`Msg (Fmt.str "%a" Json.Error.pp e)) 217 - with exn -> Error (`Msg (Printexc.to_string exn)) 217 + match Json.of_string json s with Ok t -> Ok t | Error e -> err_decode e 218 + with exn -> err_io exn 218 219 end
+1 -1
lib/discovery/test/test_atproto_oauth_discovery.ml
··· 248 248 (contains ~needle:"https://bsky.social" s) 249 249 250 250 let suite : string * unit Alcotest.test_case list = 251 - ( "atproto-oauth-discovery", 251 + ( "atproto_oauth_discovery", 252 252 [ 253 253 Alcotest.test_case "pds/fragment-id" `Quick pds_fragment_id; 254 254 Alcotest.test_case "pds/by-type-fallback" `Quick pds_by_type_fallback;
+2 -2
lib/login/atproto_oauth_login.ml
··· 115 115 | Error `Timeout -> Error (Loopback_timeout timeout_s) 116 116 | Ok (flow, _) -> ( 117 117 let line_opt = read_request_line flow in 118 - (try write_response flow with _ -> ()); 119 - (try Eio.Flow.shutdown flow `All with _ -> ()); 118 + (try write_response flow with Eio.Io _ | End_of_file -> ()); 119 + (try Eio.Flow.shutdown flow `All with Eio.Io _ | End_of_file -> ()); 120 120 match line_opt with 121 121 | None -> 122 122 Error
+1 -1
lib/login/test/test_atproto_oauth_login.ml
··· 67 67 (pp (Callback_error { error = "invalid_request"; description = None }))) 68 68 69 69 let suite : string * unit Alcotest.test_case list = 70 - ( "atproto-oauth-login", 70 + ( "atproto_oauth_login", 71 71 [ Alcotest.test_case "error/pp" `Quick pp_error_covers_all_variants ] )
+2 -2
test/interop/atproto-oauth-client-node/test.ml
··· 26 26 close_in ic; 27 27 s 28 28 29 - let test_metadata () = 29 + let metadata () = 30 30 let traces = list_files "traces" in 31 31 let hosts_with_data = 32 32 List.filter_map ··· 66 66 ( "metadata", 67 67 [ 68 68 Alcotest.test_case "live traces agree with ATProto profile" `Quick 69 - test_metadata; 69 + metadata; 70 70 ] ); 71 71 ]
+3 -3
test/test_atproto_oauth.ml
··· 102 102 103 103 (* Grant type and response type requirements (concern #2). *) 104 104 105 - let validate_server_no_auth_code_grant () = 105 + let validate_server_no_authz_grant () = 106 106 fail_with "no-authz-grant" 107 107 { compliant_server with grant_types_supported = [ "refresh_token" ] } 108 108 ~expecting:[ Oauth.Server.Grant_type "authorization_code" ] ··· 448 448 (* ------------------------------------------------------------------------ *) 449 449 450 450 let suite : string * unit Alcotest.test_case list = 451 - ( "atproto-oauth", 451 + ( "atproto_oauth", 452 452 [ 453 453 Alcotest.test_case "scope/constants" `Quick scope_constants; 454 454 Alcotest.test_case "server/compliant" `Quick validate_server_compliant; ··· 463 463 Alcotest.test_case "server/multiple-violations" `Quick 464 464 validate_server_multiple_violations; 465 465 Alcotest.test_case "server/no-authz-code-grant" `Quick 466 - validate_server_no_auth_code_grant; 466 + validate_server_no_authz_grant; 467 467 Alcotest.test_case "server/no-refresh-grant" `Quick 468 468 validate_server_no_refresh_grant; 469 469 Alcotest.test_case "server/no-code-response" `Quick