/
PolkitAgent-1.0.d.ts
433 lines (376 loc) · 17.8 KB
/
PolkitAgent-1.0.d.ts
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
// @ts-nocheck
/*
* Type Definitions for node-gtk (https://github.com/romgrk/node-gtk)
*
* These type definitions are automatically generated, do not edit them by hand.
* If you found a bug fix it in ts-for-gir itself or create a bug report on https://github.com/sammydre/ts-for-gjs
*/
/**
* PolkitAgent-1.0
*/
import type Polkit from './Polkit-1.0';
import type Gio from './Gio-2.0';
import type GObject from './GObject-2.0';
import type GLib from './GLib-2.0';
export namespace PolkitAgent {
/**
* Flags used in polkit_agent_listener_register().
* @bitfield
*/
enum RegisterFlags {
/**
* No flags are set.
*/
NONE,
/**
* Run the listener in a dedicated thread.
*/
RUN_IN_THREAD,
}
/**
* (deprecated)
* @param listener A #PolkitAgentListener.
* @param subject The subject to become an authentication agent for, typically a #PolkitUnixSession object.
* @param objectPath The D-Bus object path to use for the authentication agent or %NULL for the default object path.
*/
function registerListener(listener: Listener, subject: Polkit.Subject, objectPath: string): boolean
interface Listener_ConstructProps extends GObject.Object_ConstructProps {
}
interface Listener {
// Own fields of PolkitAgent-1.0.PolkitAgent.Listener
parentInstance: GObject.Object
// Owm methods of PolkitAgent-1.0.PolkitAgent.Listener
/**
* Called on a registered authentication agent (see
* polkit_agent_listener_register()) when the user owning the session
* needs to prove he is one of the identities listed in `identities`.
*
* When the user is done authenticating (for example by dismissing an
* authentication dialog or by successfully entering a password or
* otherwise proving the user is one of the identities in
* `identities)`, `callback` will be invoked. The caller then calls
* polkit_agent_listener_initiate_authentication_finish() to get the
* result.
*
* #PolkitAgentListener derived subclasses imlementing this method
* <emphasis>MUST</emphasis> not ignore `cancellable;` callers of this
* function can and will use it. Additionally, `callback` must be
* invoked in the <link
* linkend="g-main-context-push-thread-default">thread-default main
* loop</link> of the thread that this method is called from.
* @param actionId The action to authenticate for.
* @param message The message to present to the user.
* @param iconName A themed icon name representing the action or %NULL.
* @param details Details describing the action.
* @param cookie The cookie for the authentication request.
* @param identities A list of #PolkitIdentity objects that the user can choose to authenticate as.
* @param cancellable A #GCancellable.
* @param callback Function to call when the user is done authenticating.
*/
initiateAuthentication(actionId: string, message: string, iconName: string, details: Polkit.Details, cookie: string, identities: Polkit.Identity[], cancellable: Gio.Cancellable | null, callback: Gio.AsyncReadyCallback | null): void
/**
* Finishes an authentication request from the PolicyKit daemon, see
* polkit_agent_listener_initiate_authentication() for details.
* @param res A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to polkit_agent_listener_initiate_authentication().
*/
initiateAuthenticationFinish(res: Gio.AsyncResult): boolean
/**
* Registers `listener` with the PolicyKit daemon as an authentication
* agent for `subject`. This is implemented by registering a D-Bus
* object at `object_path` on the unique name assigned by the system
* message bus.
*
* Whenever the PolicyKit daemon needs to authenticate a processes
* that is related to `subject,` the methods
* polkit_agent_listener_initiate_authentication() and
* polkit_agent_listener_initiate_authentication_finish() will be
* invoked on `listener`.
*
* Note that registration of an authentication agent can fail; for
* example another authentication agent may already be registered for
* `subject`.
*
* Note that the calling thread is blocked until a reply is received.
* @param flags A set of flags from the #PolkitAgentRegisterFlags enumeration.
* @param subject The subject to become an authentication agent for, typically a #PolkitUnixSession object.
* @param objectPath The D-Bus object path to use for the authentication agent or %NULL for the default object path.
* @param cancellable A #GCancellable or %NULL.
*/
register(flags: RegisterFlags, subject: Polkit.Subject, objectPath: string, cancellable: Gio.Cancellable | null): object | null
/**
* Like polkit_agent_listener_register() but takes options to influence registration. See the
* <link linkend="eggdbus-method-org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgentWithOptions">RegisterAuthenticationAgentWithOptions()</link> D-Bus method for details.
* @param flags A set of flags from the #PolkitAgentRegisterFlags enumeration.
* @param subject The subject to become an authentication agent for, typically a #PolkitUnixSession object.
* @param objectPath The D-Bus object path to use for the authentication agent or %NULL for the default object path.
* @param options A #GVariant with options or %NULL.
* @param cancellable A #GCancellable or %NULL.
*/
registerWithOptions(flags: RegisterFlags, subject: Polkit.Subject, objectPath: string, options: GLib.Variant | null, cancellable: Gio.Cancellable | null): object | null
// Class property signals of PolkitAgent-1.0.PolkitAgent.Listener
connect(sigName: string, callback: (...args: any[]) => void): number
on(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
once(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
off(sigName: string, callback: (...args: any[]) => void): NodeJS.EventEmitter
emit(sigName: string, ...args: any[]): void
}
/**
* #PolkitAgentListener is an abstract base class used for implementing authentication
* agents. To implement an authentication agent, simply subclass #PolkitAgentListener and
* implement the `initiate_authentication` and `initiate_authentication_finish` methods.
*
* Typically authentication agents use #PolkitAgentSession to
* authenticate users (via passwords) and communicate back the
* authentication result to the PolicyKit daemon.
*
* To register a #PolkitAgentListener with the PolicyKit daemon, use
* polkit_agent_listener_register() or
* polkit_agent_listener_register_with_options().
* @class
*/
class Listener extends GObject.Object {
// Own properties of PolkitAgent-1.0.PolkitAgent.Listener
static name: string
static $gtype: GObject.GType<Listener>
// Constructors of PolkitAgent-1.0.PolkitAgent.Listener
constructor(config?: Listener_ConstructProps)
_init(config?: Listener_ConstructProps): void
/**
* Unregisters `listener`.
* @param registrationHandle A handle obtained from polkit_agent_listener_register().
*/
static unregister(registrationHandle: object | null): void
}
interface Session_ConstructProps extends GObject.Object_ConstructProps {
// Own constructor properties of PolkitAgent-1.0.PolkitAgent.Session
/**
* The cookie obtained from the PolicyKit daemon
*/
cookie?: string | null
/**
* The identity to authenticate.
*/
identity?: Polkit.Identity | null
}
/**
* Signal callback interface for `completed`
*/
interface Session_CompletedSignalCallback {
(gainedAuthorization: boolean): void
}
/**
* Signal callback interface for `request`
*/
interface Session_RequestSignalCallback {
(request: string, echoOn: boolean): void
}
/**
* Signal callback interface for `show-error`
*/
interface Session_ShowErrorSignalCallback {
(text: string): void
}
/**
* Signal callback interface for `show-info`
*/
interface Session_ShowInfoSignalCallback {
(text: string): void
}
interface Session {
// Own properties of PolkitAgent-1.0.PolkitAgent.Session
/**
* The cookie obtained from the PolicyKit daemon
*/
readonly cookie: string
/**
* The identity to authenticate.
*/
readonly identity: Polkit.Identity
// Owm methods of PolkitAgent-1.0.PolkitAgent.Session
/**
* Cancels an authentication session. This will make `session` emit the #PolkitAgentSession::completed
* signal.
*/
cancel(): void
/**
* Initiates the authentication session. Before calling this method,
* make sure to connect to the various signals. The signals will be
* emitted in the <link
* linkend="g-main-context-push-thread-default">thread-default main
* loop</link> that this method is invoked from.
*
* Use polkit_agent_session_cancel() to cancel the session.
*/
initiate(): void
/**
* Function for providing response to requests received
* via the #PolkitAgentSession::request signal.
* @param response Response from the user, typically a password.
*/
response(response: string): void
// Own signals of PolkitAgent-1.0.PolkitAgent.Session
connect(sigName: "completed", callback: Session_CompletedSignalCallback): number
on(sigName: "completed", callback: Session_CompletedSignalCallback, after?: boolean): NodeJS.EventEmitter
once(sigName: "completed", callback: Session_CompletedSignalCallback, after?: boolean): NodeJS.EventEmitter
off(sigName: "completed", callback: Session_CompletedSignalCallback): NodeJS.EventEmitter
emit(sigName: "completed", ...args: any[]): void
connect(sigName: "request", callback: Session_RequestSignalCallback): number
on(sigName: "request", callback: Session_RequestSignalCallback, after?: boolean): NodeJS.EventEmitter
once(sigName: "request", callback: Session_RequestSignalCallback, after?: boolean): NodeJS.EventEmitter
off(sigName: "request", callback: Session_RequestSignalCallback): NodeJS.EventEmitter
emit(sigName: "request", echoOn: boolean, ...args: any[]): void
connect(sigName: "show-error", callback: Session_ShowErrorSignalCallback): number
on(sigName: "show-error", callback: Session_ShowErrorSignalCallback, after?: boolean): NodeJS.EventEmitter
once(sigName: "show-error", callback: Session_ShowErrorSignalCallback, after?: boolean): NodeJS.EventEmitter
off(sigName: "show-error", callback: Session_ShowErrorSignalCallback): NodeJS.EventEmitter
emit(sigName: "show-error", ...args: any[]): void
connect(sigName: "show-info", callback: Session_ShowInfoSignalCallback): number
on(sigName: "show-info", callback: Session_ShowInfoSignalCallback, after?: boolean): NodeJS.EventEmitter
once(sigName: "show-info", callback: Session_ShowInfoSignalCallback, after?: boolean): NodeJS.EventEmitter
off(sigName: "show-info", callback: Session_ShowInfoSignalCallback): NodeJS.EventEmitter
emit(sigName: "show-info", ...args: any[]): void
// Class property signals of PolkitAgent-1.0.PolkitAgent.Session
connect(sigName: "notify::cookie", callback: (...args: any[]) => void): number
on(sigName: "notify::cookie", callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
once(sigName: "notify::cookie", callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
off(sigName: "notify::cookie", callback: (...args: any[]) => void): NodeJS.EventEmitter
emit(sigName: "notify::cookie", ...args: any[]): void
connect(sigName: "notify::identity", callback: (...args: any[]) => void): number
on(sigName: "notify::identity", callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
once(sigName: "notify::identity", callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
off(sigName: "notify::identity", callback: (...args: any[]) => void): NodeJS.EventEmitter
emit(sigName: "notify::identity", ...args: any[]): void
connect(sigName: string, callback: (...args: any[]) => void): number
on(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
once(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
off(sigName: string, callback: (...args: any[]) => void): NodeJS.EventEmitter
emit(sigName: string, ...args: any[]): void
}
/**
* The #PolkitAgentSession class is an abstraction used for interacting with the
* native authentication system (for example PAM) for obtaining authorizations.
* This class is typically used together with instances that are derived from
* the #PolkitAgentListener abstract base class.
*
* To perform the actual authentication, #PolkitAgentSession uses a trusted suid helper.
* The authentication conversation is done through a pipe. This is transparent; the user
* only need to handle the
* #PolkitAgentSession::request,
* #PolkitAgentSession::show-info,
* #PolkitAgentSession::show-error and
* #PolkitAgentSession::completed
* signals and invoke polkit_agent_session_response() in response to requests.
*
* If the user successfully authenticates, the authentication helper will invoke
* a method on the PolicyKit daemon (see polkit_authority_authentication_agent_response_sync())
* with the given `cookie`. Upon receiving a positive response from the PolicyKit daemon (via
* the authentication helper), the #PolkitAgentSession::completed signal will be emitted
* with the `gained_authorization` paramter set to %TRUE.
*
* If the user is unable to authenticate, the #PolkitAgentSession::completed signal will
* be emitted with the `gained_authorization` paramter set to %FALSE.
* @class
*/
class Session extends GObject.Object {
// Own properties of PolkitAgent-1.0.PolkitAgent.Session
static name: string
static $gtype: GObject.GType<Session>
// Constructors of PolkitAgent-1.0.PolkitAgent.Session
constructor(config?: Session_ConstructProps)
/**
* Creates a new authentication session.
*
* The caller should connect to the
* #PolkitAgentSession::request,
* #PolkitAgentSession::show-info,
* #PolkitAgentSession::show-error and
* #PolkitAgentSession::completed
* signals and then call polkit_agent_session_initiate() to initiate the authentication session.
* @constructor
* @param identity The identity to authenticate.
* @param cookie The cookie obtained from the PolicyKit daemon
*/
constructor(identity: Polkit.Identity, cookie: string)
/**
* Creates a new authentication session.
*
* The caller should connect to the
* #PolkitAgentSession::request,
* #PolkitAgentSession::show-info,
* #PolkitAgentSession::show-error and
* #PolkitAgentSession::completed
* signals and then call polkit_agent_session_initiate() to initiate the authentication session.
* @constructor
* @param identity The identity to authenticate.
* @param cookie The cookie obtained from the PolicyKit daemon
*/
static new(identity: Polkit.Identity, cookie: string): Session
_init(config?: Session_ConstructProps): void
}
interface TextListener_ConstructProps extends Gio.Initable_ConstructProps, Listener_ConstructProps {
}
interface TextListener extends Gio.Initable {
// Class property signals of PolkitAgent-1.0.PolkitAgent.TextListener
connect(sigName: string, callback: (...args: any[]) => void): number
on(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
once(sigName: string, callback: (...args: any[]) => void, after?: boolean): NodeJS.EventEmitter
off(sigName: string, callback: (...args: any[]) => void): NodeJS.EventEmitter
emit(sigName: string, ...args: any[]): void
}
/**
* #PolkitAgentTextListener is an #PolkitAgentListener implementation
* that interacts with the user using a textual interface.
* @class
*/
class TextListener extends Listener {
// Own properties of PolkitAgent-1.0.PolkitAgent.TextListener
static name: string
static $gtype: GObject.GType<TextListener>
// Constructors of PolkitAgent-1.0.PolkitAgent.TextListener
constructor(config?: TextListener_ConstructProps)
/**
* Creates a new #PolkitAgentTextListener for authenticating the user
* via an textual interface on the controlling terminal
* (e.g. <filename>/dev/tty</filename>). This can fail if e.g. the
* current process has no controlling terminal.
* @constructor
* @param cancellable A #GCancellable or %NULL.
*/
constructor(cancellable: Gio.Cancellable | null)
/**
* Creates a new #PolkitAgentTextListener for authenticating the user
* via an textual interface on the controlling terminal
* (e.g. <filename>/dev/tty</filename>). This can fail if e.g. the
* current process has no controlling terminal.
* @constructor
* @param cancellable A #GCancellable or %NULL.
*/
static new(cancellable: Gio.Cancellable | null): TextListener
_init(config?: TextListener_ConstructProps): void
}
interface ListenerClass {
// Own fields of PolkitAgent-1.0.PolkitAgent.ListenerClass
/**
* The parent class.
* @field
*/
parentClass: GObject.ObjectClass
initiateAuthentication: (listener: Listener, actionId: string, message: string, iconName: string, details: Polkit.Details, cookie: string, identities: Polkit.Identity[], cancellable: Gio.Cancellable | null, callback: Gio.AsyncReadyCallback | null) => void
initiateAuthenticationFinish: (listener: Listener, res: Gio.AsyncResult) => boolean
}
/**
* VFuncs that authentication agents needs to implement.
* @record
*/
abstract class ListenerClass {
// Own properties of PolkitAgent-1.0.PolkitAgent.ListenerClass
static name: string
}
interface SessionClass {
}
abstract class SessionClass {
// Own properties of PolkitAgent-1.0.PolkitAgent.SessionClass
static name: string
}
}
export default PolkitAgent;