Packages

Gleam library for interacting with Automatic Certificate Management Environment (ACME) servers like Let's Encrypt

Retired package: Release invalid

Current section

Files

Jump to
acumen src acumen@deactivate_authorization.erl
Raw

src/acumen@deactivate_authorization.erl

-module(acumen@deactivate_authorization).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/acumen/deactivate_authorization.gleam").
-export([build/3, response/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Deactivate an ACME authorization.\n"
"\n"
" Relinquish authorization to issue certificates for an identifier. Use\n"
" this when you no longer want the server to consider you authorized.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" import acumen\n"
" import acumen/deactivate_authorization\n"
"\n"
" let assert Ok(#(resp, ctx)) = acumen.execute(\n"
" ctx,\n"
" build: deactivate_authorization.build(authz_url, _, registered_key),\n"
" send: httpc.send,\n"
" )\n"
"\n"
" let assert Ok(authz) = deactivate_authorization.response(resp, authz_url)\n"
" // authz.status == Deactivated\n"
" ```\n"
).
-file("src/acumen/deactivate_authorization.gleam", 33).
?DOC(" Builds a request to deactivate an ACME authorization.\n").
-spec build(acumen@url:url(), acumen:context(), acumen:registered_key()) -> {ok,
gleam@http@request:request(binary())} |
{error, acumen:acme_error()}.
build(Url, Context, Key) ->
_pipe = gleam@json:object(
[{<<"status"/utf8>>, gleam@json:string(<<"deactivated"/utf8>>)}]
),
_pipe@1 = gleam@json:to_string(_pipe),
_pipe@2 = acumen@internal@jws:sign_with_kid(
erlang:element(2, Key),
erlang:element(3, Key),
_pipe@1,
erlang:element(3, Context),
Url
),
_pipe@3 = gleam@result:map_error(
_pipe@2,
fun(Field@0) -> {jws_error, Field@0} end
),
gleam@result:'try'(
_pipe@3,
fun(_capture) -> acumen:build_post_request(Url, _capture) end
).
-file("src/acumen/deactivate_authorization.gleam", 52).
?DOC(" Parses the authorization deactivation response.\n").
-spec response(gleam@http@response:response(binary()), acumen@url:url()) -> {ok,
acumen@authorization:authorization()} |
{error, acumen:acme_error()}.
response(Resp, Url) ->
case erlang:element(2, Resp) of
200 ->
acumen@authorization:parse_authorization_response(Resp, Url);
_ ->
{error,
{invalid_response,
acumen@internal@utils:unexpected_status_message(
erlang:element(2, Resp)
)}}
end.