{"id":16312475,"url":"https://github.com/kiranandcode/http_sig_ocaml","last_synced_at":"2025-04-22T11:53:35.544Z","repository":{"id":112325966,"uuid":"540447794","full_name":"kiranandcode/http_sig_ocaml","owner":"kiranandcode","description":"HTTP Signatures for OCaml","archived":false,"fork":false,"pushed_at":"2022-09-23T13:16:36.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-16T14:25:07.701Z","etag":null,"topics":["http","http-signature","ocaml","ocaml-library"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiranandcode.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-23T13:15:56.000Z","updated_at":"2022-09-23T13:31:21.000Z","dependencies_parsed_at":"2023-05-12T23:00:17.249Z","dependency_job_id":null,"html_url":"https://github.com/kiranandcode/http_sig_ocaml","commit_stats":null,"previous_names":["kiranandcode/http_sig_ocaml"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranandcode%2Fhttp_sig_ocaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranandcode%2Fhttp_sig_ocaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranandcode%2Fhttp_sig_ocaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranandcode%2Fhttp_sig_ocaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiranandcode","download_url":"https://codeload.github.com/kiranandcode/http_sig_ocaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237805,"owners_count":21397399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","http-signature","ocaml","ocaml-library"],"created_at":"2024-10-10T21:48:11.488Z","updated_at":"2025-04-22T11:53:35.514Z","avatar_url":"https://github.com/kiranandcode.png","language":"OCaml","readme":"# Http_sig - Http Signature Signing Scheme for OCaml\n\nThis library implements the [Http_sig\nRFC](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12)\n(or a subset therein).\n\n## Examples\n \n- For validating incoming requests:\n```ocaml\nlet resolve_public_key url =\n  let+ (_, body) = activity_req (Uri.of_string url) in\n  let+ pub_key = Cohttp_lwt.Body.to_string body in\n  let pub_key =\n    pub_key\n    |\u003e Cstruct.of_string\n    |\u003e X509.Public_key.decode_pem\n    |\u003e Result.map_err (fun (`Msg err) -\u003e err) in\n  Lwt.return pub_key\n\n\nlet handle_post req =\n  let+ valid_request =\n    Http_sig.verify_request\n      ~resolve_public_key req in\n  if not valid \n  then Dream.respond ~status:`Bad_Request \"\"\n  else Dream.respond \"OK\"\n```\n\n- For sending requests:\n```ocaml\nlet req_post ~headers url body =\n  let body = Cohttp_lwt.Body.of_string body in\n  try\n    Cohttp_lwt_unix.Client.post\n      ~headers\n      ~body\n      url \u003e\u003e Result.return\n  with exn -\u003e\n    Lwt.return (Result.of_exn exn)\n\nlet signed_post ~headers (key_id, priv_key) uri body_str =\n  let current_time = Ptime_clock.now () in\n  let headers =\n    Http_sig.build_signed_headers\n      ~current_time ~method_:\"POST\" ~body_str\n      ~headers ~key_id ~priv_key ~uri\n    |\u003e Cohttp.Header.of_list in\n  req_post ~headers uri body_str\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranandcode%2Fhttp_sig_ocaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiranandcode%2Fhttp_sig_ocaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranandcode%2Fhttp_sig_ocaml/lists"}