cljs / src / ird / sharing.cljs
213 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(ns ird.sharing
  "Delegated access grants: invite other customers to manage parts of a
  domain, and handle invites you receive. Inviting/revoking on a domain is
  subject to the client's domain gate (ird.gate) when configured.

  NOTE: every operation here requires an account JWT (see
  ird.auth/device-login); API keys are not accepted. Every function returns a
  channel (see ird.async)."
  (:require [ird.gate :as gate]
            [ird.transport :as transport]))

(defn list-domain-grants
  "GET /domains/registrations/{id}/grants — Who has delegated access to
  this domain (outgoing)."
  [client id]
  (transport/request client :get ["domains" "registrations" id "grants"]))

(defn invite
  "POST /domains/registrations/{id}/grants — Invite another customer to
  manage parts of this domain. BODY keys include :email, :scopes, :payer,
  :totp_code."
  [client id body]
  (gate/request client "POST /domains/registrations/{id}/grants" {:registration-id id}
                :post ["domains" "registrations" id "grants"] {:body body}))

(defn revoke-grant
  "DELETE /domains/registrations/{id}/grants/{grant-id} — Revoke delegated
  access."
  [client id grant-id]
  (gate/request client "DELETE /domains/registrations/{id}/grants/{grant-id}" {:registration-id id}
                :delete ["domains" "registrations" id "grants" grant-id]))

(defn list-grants
  "GET /grants — Domains shared with this account (incoming)."
  [client]
  (transport/request client :get "/grants"))

(defn accept-grant
  "POST /grants/{id}/accept — Accept a delegated-access invite."
  [client id]
  (transport/request client :post ["grants" id "accept"]))

(defn decline-grant
  "POST /grants/{id}/decline — Decline a delegated-access invite."
  [client id]
  (transport/request client :post ["grants" id "decline"]))

(defn leave-grant
  "POST /grants/{id}/leave — Walk away from an active grant."
  [client id]
  (transport/request client :post ["grants" id "leave"]))

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/cljs.git