/
reporting_private.clj
146 lines (113 loc) · 5.98 KB
/
reporting_private.clj
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
(ns chromex.ext.enterprise.reporting-private
"Private API for reporting Chrome browser status to admin console.
* available since Chrome 68"
(:refer-clojure :only [defmacro defn apply declare meta let partial])
(:require [chromex.wrapgen :refer [gen-wrap-helper]]
[chromex.callgen :refer [gen-call-helper gen-tap-all-events-call]]))
(declare api-table)
(declare gen-call)
; -- functions --------------------------------------------------------------------------------------------------------------
(defmacro get-device-id
"Gets the identity of device that Chrome browser is running on. The ID is retrieved from the local device and used by the
Google admin console.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [id] where:
|id| - ?
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([] (gen-call :function ::get-device-id &form)))
(defmacro get-persistent-secret
"Gets a randomly generated persistent secret (symmetric key) that can be used to encrypt the data stored with
|setDeviceData|. If the optional parameter |forceCreation| is set to true the secret is recreated in case of any failure to
retrieve the currently stored one. Sets 'runtime.lastError' on failure.
|reset-secret| - ?
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [secret] where:
|secret| - ?
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([reset-secret] (gen-call :function ::get-persistent-secret &form reset-secret))
([] `(get-persistent-secret :omit)))
(defmacro get-device-data
"Gets the device data for |id|. Sets 'runtime.lastError' on failure.
|id| - ?
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [data] where:
|data| - ?
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([id] (gen-call :function ::get-device-data &form id)))
(defmacro set-device-data
"Sets the device data for |id|. Sets 'runtime.lastError' on failure. If the |data| parameter is undefined and there is
already data associated with |id| it will be cleared.
|id| - ?
|data| - ?
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([id data] (gen-call :function ::set-device-data &form id data))
([id] `(set-device-data ~id :omit)))
(defmacro get-device-info
"Gets the device information (including disk encryption status, screen lock status, serial number, model).
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [device-info] where:
|device-info| - ?
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([] (gen-call :function ::get-device-info &form)))
; -- convenience ------------------------------------------------------------------------------------------------------------
(defmacro tap-all-events
"Taps all valid non-deprecated events in chromex.ext.enterprise.reporting-private namespace."
[chan]
(gen-tap-all-events-call api-table (meta &form) chan))
; ---------------------------------------------------------------------------------------------------------------------------
; -- API TABLE --------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------------------
(def api-table
{:namespace "chrome.enterprise.reportingPrivate",
:since "68",
:functions
[{:id ::get-device-id,
:name "getDeviceId",
:since "71",
:callback? true,
:params
[{:name "callback", :optional? true, :type :callback, :callback {:params [{:name "id", :type "string"}]}}]}
{:id ::get-persistent-secret,
:name "getPersistentSecret",
:since "80",
:callback? true,
:params
[{:name "reset-secret", :optional? true, :since "86", :type "boolean"}
{:name "callback", :type :callback, :callback {:params [{:name "secret", :type "ArrayBuffer"}]}}]}
{:id ::get-device-data,
:name "getDeviceData",
:since "80",
:callback? true,
:params
[{:name "id", :type "string"}
{:name "callback", :type :callback, :callback {:params [{:name "data", :type "ArrayBuffer"}]}}]}
{:id ::set-device-data,
:name "setDeviceData",
:since "80",
:callback? true,
:params
[{:name "id", :type "string"}
{:name "data", :optional? true, :type "ArrayBuffer"}
{:name "callback", :optional? true, :type :callback}]}
{:id ::get-device-info,
:name "getDeviceInfo",
:since "80",
:callback? true,
:params
[{:name "callback",
:optional? true,
:type :callback,
:callback {:params [{:name "device-info", :type "object"}]}}]}]})
; -- helpers ----------------------------------------------------------------------------------------------------------------
; code generation for native API wrapper
(defmacro gen-wrap [kind item-id config & args]
(apply gen-wrap-helper api-table kind item-id config args))
; code generation for API call-site
(def gen-call (partial gen-call-helper api-table))