back interdiff of round #3 and #2

Implement OAuth #2

closed
opened by futur.blue targeting main

𝒴𝑜𝓊 𝒸𝒶𝓃 𝓃𝑜𝓌 use pdsls

ERROR
.ocamlformat

Failed to calculate interdiff for this file.

ERROR
bin/main.ml

Failed to calculate interdiff for this file.

ERROR
dune

Failed to calculate interdiff for this file.

ERROR
dune-project

Failed to calculate interdiff for this file.

ERROR
kleidos/kleidos.ml

Failed to calculate interdiff for this file.

REBASED
mist/lib/mst.ml

This patch was likely rebased, as context lines do not match.

ERROR
pegasus.opam

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/account_/login.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/account_/logout.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/actor/putPreferences.ml

Failed to calculate interdiff for this file.

REBASED
pegasus/lib/api/identity/updateHandle.ml

This patch was likely rebased, as context lines do not match.

ERROR
pegasus/lib/api/oauth_/authorize.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/oauth_/par.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/oauth_/token.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/server/createSession.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/server/getServiceAuth.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/api/well_known.ml

Failed to calculate interdiff for this file.

REBASED
pegasus/lib/auth.ml

This patch was likely rebased, as context lines do not match.

REBASED
pegasus/lib/data_store.ml

This patch was likely rebased, as context lines do not match.

ERROR
pegasus/lib/dune

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/env.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/errors.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/id_resolver.ml

Failed to calculate interdiff for this file.

REBASED
pegasus/lib/jwt.ml

This patch was likely rebased, as context lines do not match.

ERROR
pegasus/lib/oauth/client.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/oauth/constants.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/oauth/dpop.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/oauth/queries.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/oauth/types.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/plc.ml

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/components/button.mlx

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/components/input.mlx

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/icons/circle_alert.mlx

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/layout.mlx

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/login.mlx

Failed to calculate interdiff for this file.

ERROR
pegasus/lib/templates/oauth_authorize.mlx

Failed to calculate interdiff for this file.

REBASED
pegasus/lib/util.ml

This patch was likely rebased, as context lines do not match.

REBASED
pegasus/lib/xrpc.ml

This patch was likely rebased, as context lines do not match.

ERROR
public/fonts/Fragment.woff

Failed to calculate interdiff for this file.

ERROR
public/fonts/Fragment.woff2

Failed to calculate interdiff for this file.

ERROR
public/main.css

Failed to calculate interdiff for this file.

ERROR
tailwindcss.opam

Failed to calculate interdiff for this file.

ERROR
tools/tailwindcss/dune

Failed to calculate interdiff for this file.

NEW
ipld/lib/dag_cbor.ml
···
write_type_and_argument t 5 (Int64.of_int len) ;
ordered_map_keys m
|> List.iter (fun k ->
-
write_string t k ;
-
write_value t (String_map.find k m) )
| `Link cid ->
write_cid t cid
···
write_type_and_argument t 5 (Int64.of_int len) ;
ordered_map_keys m
|> List.iter (fun k ->
+
write_string t k ;
+
write_value t (String_map.find k m) )
| `Link cid ->
write_cid t cid
NEW
ipld/test/test_dag_cbor.ml
···
let rec stringify_map m =
String_map.bindings m
|> List.map (fun (k, v) ->
-
Format.sprintf "\"%s\": %s" k (stringify_ipld_value v) )
|> String.concat ", " |> Format.sprintf "{%s}"
and stringify_ipld_value (value : Dag_cbor.value) =
···
Hashtbl.add cases (to_base_16 (Dag_cbor.encode `Null)) (Bytes.of_string "f6") ;
cases
|> Hashtbl.iter (fun key value ->
-
Alcotest.(check bytes)
-
("encoded bytes for " ^ key)
-
value (Bytes.of_string key) )
let test_round_trip () =
let test_cid =
···
let rec stringify_map m =
String_map.bindings m
|> List.map (fun (k, v) ->
+
Format.sprintf "\"%s\": %s" k (stringify_ipld_value v) )
|> String.concat ", " |> Format.sprintf "{%s}"
and stringify_ipld_value (value : Dag_cbor.value) =
···
Hashtbl.add cases (to_base_16 (Dag_cbor.encode `Null)) (Bytes.of_string "f6") ;
cases
|> Hashtbl.iter (fun key value ->
+
Alcotest.(check bytes)
+
("encoded bytes for " ^ key)
+
value (Bytes.of_string key) )
let test_round_trip () =
let test_cid =
NEW
mist/test/test_util.ml
···
Hashtbl.add cases "app.bsky.feed.post/9adeb165882c" 8 ;
cases
|> Hashtbl.iter (fun key value ->
-
Alcotest.(check int)
-
("leading zeros on hash " ^ key)
-
value
-
(leading_zeros_on_hash key) )
let test_shared_prefix_length () =
let cases = Hashtbl.create 5 in
···
Hashtbl.add cases ("2653ae71", "0653ae71") 0 ;
cases
|> Hashtbl.iter (fun (a, b) value ->
-
Alcotest.(check int)
-
("prefix length between " ^ a ^ " and " ^ b)
-
value (shared_prefix_length a b) )
let () =
Alcotest.run "util"
···
Hashtbl.add cases "app.bsky.feed.post/9adeb165882c" 8 ;
cases
|> Hashtbl.iter (fun key value ->
+
Alcotest.(check int)
+
("leading zeros on hash " ^ key)
+
value
+
(leading_zeros_on_hash key) )
let test_shared_prefix_length () =
let cases = Hashtbl.create 5 in
···
Hashtbl.add cases ("2653ae71", "0653ae71") 0 ;
cases
|> Hashtbl.iter (fun (a, b) value ->
+
Alcotest.(check int)
+
("prefix length between " ^ a ^ " and " ^ b)
+
value (shared_prefix_length a b) )
let () =
Alcotest.run "util"
NEW
pegasus/lib/api/identity/resolveHandle.ml
···
Dream.json @@ Yojson.Safe.to_string
@@ response_to_yojson {did= actor.did}
| None -> (
-
match%lwt Id_resolver.Handle.resolve handle with
-
| Ok did ->
-
Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {did}
-
| Error e ->
-
Errors.log_exn (Failure e) ;
-
Errors.internal_error ~msg:"could not resolve handle" () ) )
···
Dream.json @@ Yojson.Safe.to_string
@@ response_to_yojson {did= actor.did}
| None -> (
+
match%lwt Id_resolver.Handle.resolve handle with
+
| Ok did ->
+
Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {did}
+
| Error e ->
+
Errors.log_exn (Failure e) ;
+
Errors.internal_error ~msg:"could not resolve handle" () ) )
NEW
pegasus/lib/api/repo/createAccount.ml
···
let%lwt did =
match input.did with
| Some did -> (
-
match%lwt Data_store.get_actor_by_identifier did ctx.db with
-
| Some _ ->
-
Errors.invalid_request "an account with that did already exists"
-
| None ->
-
Lwt.return did )
| None -> (
let sk_did = Kleidos.K256.pubkey_to_did_key signing_pubkey in
let rotation_did_keys =
···
let%lwt _ =
match input.invite_code with
| Some code -> (
-
match%lwt Data_store.use_invite ~code ctx.db with
-
| Some _ ->
-
Lwt.return ()
-
| None ->
-
failwith "failed to use invite code" )
| None ->
Lwt.return ()
in
···
let%lwt did =
match input.did with
| Some did -> (
+
match%lwt Data_store.get_actor_by_identifier did ctx.db with
+
| Some _ ->
+
Errors.invalid_request "an account with that did already exists"
+
| None ->
+
Lwt.return did )
| None -> (
let sk_did = Kleidos.K256.pubkey_to_did_key signing_pubkey in
let rotation_did_keys =
···
let%lwt _ =
match input.invite_code with
| Some code -> (
+
match%lwt Data_store.use_invite ~code ctx.db with
+
| Some _ ->
+
Lwt.return ()
+
| None ->
+
failwith "failed to use invite code" )
| None ->
Lwt.return ()
in
NEW
pegasus/lib/repository.ml
···
let%lwt map = get_map t in
String_map.bindings map
|> List.filter (fun (path, _) ->
-
String.starts_with ~prefix:(path ^ "/") collection )
|> Lwt_list.fold_left_s
(fun acc (path, cid) ->
match%lwt User_store.get_record t.db path with
···
let%lwt () =
match old_cid with
| Some _ -> (
-
match%lwt User_store.get_record t.db path with
-
| Some record ->
-
let refs =
-
Util.find_blob_refs record.value
-
|> List.map (fun (r : Mist.Blob_ref.t) -> r.ref)
-
in
-
let%lwt () = User_store.clear_blob_refs t.db path refs in
-
Lwt.return_unit
-
| None ->
-
Lwt.return_unit )
| None ->
Lwt.return_unit
in
···
let%lwt map = get_map t in
String_map.bindings map
|> List.filter (fun (path, _) ->
+
String.starts_with ~prefix:(path ^ "/") collection )
|> Lwt_list.fold_left_s
(fun acc (path, cid) ->
match%lwt User_store.get_record t.db path with
···
let%lwt () =
match old_cid with
| Some _ -> (
+
match%lwt User_store.get_record t.db path with
+
| Some record ->
+
let refs =
+
Util.find_blob_refs record.value
+
|> List.map (fun (r : Mist.Blob_ref.t) -> r.ref)
+
in
+
let%lwt () = User_store.clear_blob_refs t.db path refs in
+
Lwt.return_unit
+
| None ->
+
Lwt.return_unit )
| None ->
Lwt.return_unit
in
NEW
pegasus/lib/sequencer.ml
···
let blobs =
j |> member "blobs" |> to_list
|> List.filter_map (fun x ->
-
match Cid.of_yojson x with Ok c -> Some c | _ -> None )
in
let prev_data =
match j |> member "prevData" with
···
let ops =
j |> member "ops" |> to_list
|> List.map (fun opj ->
-
let action =
-
match opj |> member "action" |> to_string with
-
| "create" ->
-
`Create
-
| "update" ->
-
`Update
-
| "delete" ->
-
`Delete
-
| _ ->
-
`Create
-
in
-
let path = opj |> member "path" |> to_string in
-
let cid =
-
match opj |> member "cid" with
-
| `Null ->
-
None
-
| v -> (
-
match Cid.of_yojson v with Ok c -> Some c | _ -> None )
-
in
-
let prev =
-
match opj |> member "prev" with
-
| `Null ->
-
None
-
| v -> (
-
match Cid.of_yojson v with Ok c -> Some c | _ -> None )
-
in
-
{action; path; cid; prev} )
in
Ok
{ rebase
···
let blobs =
j |> member "blobs" |> to_list
|> List.filter_map (fun x ->
+
match Cid.of_yojson x with Ok c -> Some c | _ -> None )
in
let prev_data =
match j |> member "prevData" with
···
let ops =
j |> member "ops" |> to_list
|> List.map (fun opj ->
+
let action =
+
match opj |> member "action" |> to_string with
+
| "create" ->
+
`Create
+
| "update" ->
+
`Update
+
| "delete" ->
+
`Delete
+
| _ ->
+
`Create
+
in
+
let path = opj |> member "path" |> to_string in
+
let cid =
+
match opj |> member "cid" with
+
| `Null ->
+
None
+
| v -> (
+
match Cid.of_yojson v with Ok c -> Some c | _ -> None )
+
in
+
let prev =
+
match opj |> member "prev" with
+
| `Null ->
+
None
+
| v -> (
+
match Cid.of_yojson v with Ok c -> Some c | _ -> None )
+
in
+
{action; path; cid; prev} )
in
Ok
{ rebase
NEW
pegasus/lib/user_store.ml
···
let get_record t path : record option Lwt.t =
Util.use_pool t.db @@ Queries.get_record ~path
>|= Option.map (fun (cid, data, since) ->
-
{path; cid; value= Lex.of_cbor data; since} )
let list_records t ?(limit = 100) ?(cursor = "") ?(reverse = false) collection :
record list Lwt.t =
···
in
Util.use_pool t.db @@ fn ~collection ~limit ~cursor
>|= List.map (fun (path, cid, data, since) ->
-
{path; cid; value= Lex.of_cbor data; since} )
let put_record t record path : (Cid.t * bytes) Lwt.t =
let cid, data = Lex.to_cbor_block record in
···
let get_record t path : record option Lwt.t =
Util.use_pool t.db @@ Queries.get_record ~path
>|= Option.map (fun (cid, data, since) ->
+
{path; cid; value= Lex.of_cbor data; since} )
let list_records t ?(limit = 100) ?(cursor = "") ?(reverse = false) collection :
record list Lwt.t =
···
in
Util.use_pool t.db @@ fn ~collection ~limit ~cursor
>|= List.map (fun (path, cid, data, since) ->
+
{path; cid; value= Lex.of_cbor data; since} )
let put_record t record path : (Cid.t * bytes) Lwt.t =
let cid, data = Lex.to_cbor_block record in