forked from Gr3q/types-cjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoup-3.0.d.ts
7676 lines (7432 loc) · 280 KB
/
Soup-3.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** Generated with https://github.com/Gr3q/GIR2TS - If possible do not modify. */
declare namespace imports.gi.Soup {
/** This construct is only for enabling class multi-inheritance,
* use {@link Auth} instead.
*/
interface IAuth {
/**
* The authority (host:port) being authenticated to.
*/
authority: string;
/**
* Whether or not the auth has been authenticated.
*/
// readonly is_authenticated: boolean;
/**
* Whether or not the auth has been cancelled.
*/
// readonly is_cancelled: boolean;
/**
* Whether or not the auth is for a proxy server.
*/
// is_for_proxy: boolean;
/**
* The authentication realm.
*/
realm: string;
/**
* The authentication scheme name.
*/
readonly scheme_name: string;
/**
* Call this on an auth to authenticate it.
*
* Normally this will cause the auth's message to be requeued with the new
* authentication info.
* @param username the username provided by the user or client
* @param password the password provided by the user or client
*/
authenticate(username: string, password: string): void;
/**
* Tests if #auth is able to authenticate by providing credentials to the
* [method#Auth.authenticate].
* @returns %TRUE if #auth is able to accept credentials.
*/
can_authenticate(): boolean;
/**
* Call this on an auth to cancel it.
*
* You need to cancel an auth to complete an asynchronous authenticate operation
* when no credentials are provided ([method#Auth.authenticate] is not called).
* The {@link Auth} will be cancelled on dispose if it hans't been authenticated.
*/
cancel(): void;
/**
* Returns the authority (host:port) that #auth is associated with.
* @returns the authority
*/
get_authority(): string;
/**
* Generates an appropriate "Authorization" header for #msg.
*
* (The session will only call this if [method#Auth.is_authenticated] returned
* %TRUE.)
* @param msg the {@link Message} to be authorized
* @returns the "Authorization" header, which must be freed.
*/
get_authorization(msg: Message): string;
/**
* Gets an opaque identifier for #auth.
*
* The identifier can be used as a hash key or the like. {@link Auth} objects from
* the same server with the same identifier refer to the same authentication
* domain (eg, the URLs associated with them take the same usernames and
* passwords).
* @returns the identifier
*/
get_info(): string;
/**
* Returns a list of paths on the server which #auth extends over.
*
* (All subdirectories of these paths are also assumed to be part
* of #auth's protection space, unless otherwise discovered not to
* be.)
* @param source_uri the URI of the request that #auth was generated in
* response to.
* @returns the list of
* paths, which can be freed with [method#Auth.free_protection_space].
*/
get_protection_space(source_uri: GLib.Uri): string[];
/**
* Returns #auth's realm.
*
* This is an identifier that distinguishes separate authentication spaces on a
* given server, and may be some string that is meaningful to the user.
* (Although it is probably not localized.)
* @returns the realm name
*/
get_realm(): string;
/**
* soup_auth_get_scheme_name: (attributes org.gtk.Method.get_property=scheme-name)
* Returns #auth's scheme name. (Eg, "Basic", "Digest", or "NTLM")
* @returns the scheme name
*/
get_scheme_name(): string;
/**
* Tests if #auth has been given a username and password.
* @returns %TRUE if #auth has been given a username and password
*/
is_authenticated(): boolean;
/**
* Tests if #auth has been cancelled
* @returns %TRUE if #auth has been cancelled
*/
is_cancelled(): boolean;
/**
* Tests whether or not #auth is associated with a proxy server rather
* than an "origin" server.
* @returns %TRUE or %FALSE
*/
is_for_proxy(): boolean;
/**
* Tests if #auth is ready to make a request for #msg with.
*
* For most auths, this is equivalent to [method#Auth.is_authenticated], but for
* some auth types (eg, NTLM), the auth may be sendable (eg, as an
* authentication request) even before it is authenticated.
* @param msg a {@link Message}
* @returns %TRUE if #auth is ready to make a request with.
*/
is_ready(msg: Message): boolean;
/**
* Updates #auth with the information from #msg and #auth_header,
* possibly un-authenticating it.
*
* As with [ctor#Auth.new], this is normally only used by [class#Session].
* @param msg the {@link Message} #auth is being updated for
* @param auth_header the WWW-Authenticate/Proxy-Authenticate header
* @returns %TRUE if #auth is still a valid (but potentially
* unauthenticated) {@link Auth}. %FALSE if something about #auth_params
* could not be parsed or incorporated into #auth at all.
*/
update(msg: Message, auth_header: string): boolean;
connect(signal: "notify::authority", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::is-authenticated", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::is-cancelled", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::is-for-proxy", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::realm", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::scheme-name", callback: (owner: this, ...args: any) => void): number;
}
type AuthInitOptionsMixin = GObject.ObjectInitOptions &
Pick<IAuth,
"authority" |
"is_for_proxy" |
"realm">;
export interface AuthInitOptions extends AuthInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Auth} instead.
*/
type AuthMixin = IAuth & GObject.Object;
/**
* The abstract base class for handling authentication.
*
* Specific HTTP Authentication mechanisms are implemented by its subclasses,
* but applications never need to be aware of the specific subclasses being
* used.
*
* {@link Auth} objects store the authentication data associated with a given bit
* of web space. They are created automatically by [class#Session].
*/
interface Auth extends AuthMixin {}
class Auth {
public constructor(options?: Partial<AuthInitOptions>);
/**
* Creates a new {@link Auth} of type #type with the information from
* #msg and #auth_header.
*
* This is called by [class#Session]; you will normally not create auths
* yourself.
* @param type the type of auth to create (a subtype of {@link Auth})
* @param msg the {@link Message} the auth is being created for
* @param auth_header the WWW-Authenticate/Proxy-Authenticate header
* @returns the new {@link Auth}, or %NULL if it could
* not be created
*/
public static new(type: GObject.Type, msg: Message, auth_header: string): Auth | null;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthBasic} instead.
*/
interface IAuthBasic {
}
type AuthBasicInitOptionsMixin = AuthInitOptions
export interface AuthBasicInitOptions extends AuthBasicInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthBasic} instead.
*/
type AuthBasicMixin = IAuthBasic & Auth;
/**
* HTTP "Basic" authentication.
*
* [class#Session]s support this by default; if you want to disable
* support for it, call [method#Session.remove_feature_by_type],
* passing %SOUP_TYPE_AUTH_BASIC.
*/
interface AuthBasic extends AuthBasicMixin {}
class AuthBasic {
public constructor(options?: Partial<AuthBasicInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDigest} instead.
*/
interface IAuthDigest {
}
type AuthDigestInitOptionsMixin = AuthInitOptions
export interface AuthDigestInitOptions extends AuthDigestInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDigest} instead.
*/
type AuthDigestMixin = IAuthDigest & Auth;
/**
* HTTP "Digest" authentication.
*
* [class#Session]s support this by default; if you want to disable
* support for it, call [method#Session.remove_feature_by_type]
* passing %SOUP_TYPE_AUTH_DIGEST.
*/
interface AuthDigest extends AuthDigestMixin {}
class AuthDigest {
public constructor(options?: Partial<AuthDigestInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomain} instead.
*/
interface IAuthDomain {
/**
* The [callback#AuthDomainFilter] for the domain.
*/
filter: AuthDomainFilter;
/**
* Data to pass to the [callback#AuthDomainFilter].
*/
filter_data: any;
/**
* The [callback#AuthDomainGenericAuthCallback].
*/
generic_auth_callback: AuthDomainGenericAuthCallback;
/**
* The data to pass to the [callback#AuthDomainGenericAuthCallback].
*/
generic_auth_data: any;
/**
* Whether or not this is a proxy auth domain.
*/
proxy: boolean;
/**
* The realm of this auth domain.
*/
realm: string;
/**
* Checks if #msg contains appropriate authorization for #domain to
* accept it.
*
* Mirroring [method#AuthDomain.covers], this does not check whether or not
* #domain *cares* if #msg is authorized.
*
* This is used by [class#Server] internally and is probably of no use to
* anyone else.
* @param msg a {@link ServerMessage}
* @returns the username that #msg has authenticated
* as, if in fact it has authenticated. %NULL otherwise.
*/
accepts(msg: ServerMessage): string | null;
/**
* Adds #path to #domain.
*
* Requests under #path on #domain's server will require authentication (unless
* overridden by [method#AuthDomain.remove_path] or
* [method#AuthDomain.set_filter]).
* @param path the path to add to #domain
*/
add_path(path: string): void;
/**
* Adds a "WWW-Authenticate" or "Proxy-Authenticate" header to #msg.
*
* It requests that the client authenticate, and sets #msg's status accordingly.
*
* This is used by [class#Server] internally and is probably of no use to
* anyone else.
* @param msg a {@link ServerMessage}
*/
challenge(msg: ServerMessage): void;
/**
* Checks if #msg authenticates to #domain via #username and
* #password.
*
* This would normally be called from a
* [callback#AuthDomainGenericAuthCallback].
* @param msg a {@link ServerMessage}
* @param username a username
* @param password a password
* @returns whether or not the message is authenticated
*/
check_password(msg: ServerMessage, username: string, password: string): boolean;
/**
* Checks if #domain requires #msg to be authenticated (according to
* its paths and filter function).
*
* This does not actually look at whether #msg *is* authenticated, merely
* whether or not it needs to be.
*
* This is used by [class#Server] internally and is probably of no use to
* anyone else.
* @param msg a {@link ServerMessage}
* @returns %TRUE if #domain requires #msg to be authenticated
*/
covers(msg: ServerMessage): boolean;
/**
* Gets the realm name associated with #domain.
* @returns #domain's realm
*/
get_realm(): string;
/**
* Removes #path from #domain.
*
* Requests under #path on #domain's server will NOT require
* authentication.
*
* This is not simply an undo-er for [method#AuthDomain.add_path]; it
* can be used to "carve out" a subtree that does not require
* authentication inside a hierarchy that does. Note also that unlike
* with [method#AuthDomain.add_path], this cannot be overridden by
* adding a filter, as filters can only bypass authentication that
* would otherwise be required, not require it where it would
* otherwise be unnecessary.
* @param path the path to remove from #domain
*/
remove_path(path: string): void;
/**
* Adds #filter as an authentication filter to #domain.
*
* The filter gets a chance to bypass authentication for certain requests that
* would otherwise require it. Eg, it might check the message's path in some way
* that is too complicated to do via the other methods, or it might check the
* message's method, and allow GETs but not PUTs.
*
* The filter function returns %TRUE if the request should still
* require authentication, or %FALSE if authentication is unnecessary
* for this request.
*
* To help prevent security holes, your filter should return %TRUE by
* default, and only return %FALSE under specifically-tested
* circumstances, rather than the other way around. Eg, in the example
* above, where you want to authenticate PUTs but not GETs, you should
* check if the method is GET and return %FALSE in that case, and then
* return %TRUE for all other methods (rather than returning %TRUE for
* PUT and %FALSE for all other methods). This way if it turned out
* (now or later) that some paths supported additional methods besides
* GET and PUT, those methods would default to being NOT allowed for
* unauthenticated users.
*
* You can also set the filter by setting the SoupAuthDomain:filter
* and [property#AuthDomain:filter-data properties], which can also be
* used to set the filter at construct time.
* @param filter the auth filter for #domain
*/
set_filter(filter: AuthDomainFilter): void;
/**
* Sets #auth_callback as an authentication-handling callback for #domain.
*
* Whenever a request comes in to #domain which cannot be authenticated via a
* domain-specific auth callback (eg, [callback#AuthDomainDigestAuthCallback]),
* the generic auth callback will be invoked. See
* [callback#AuthDomainGenericAuthCallback] for information on what the callback
* should do.
* @param auth_callback the auth callback
*/
set_generic_auth_callback(auth_callback: AuthDomainGenericAuthCallback): void;
connect(signal: "notify::filter", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::filter-data", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::generic-auth-callback", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::generic-auth-data", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::proxy", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::realm", callback: (owner: this, ...args: any) => void): number;
}
type AuthDomainInitOptionsMixin = GObject.ObjectInitOptions &
Pick<IAuthDomain,
"filter" |
"filter_data" |
"generic_auth_callback" |
"generic_auth_data" |
"proxy" |
"realm">;
export interface AuthDomainInitOptions extends AuthDomainInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomain} instead.
*/
type AuthDomainMixin = IAuthDomain & GObject.Object;
/**
* Server-side authentication.
*
* A {@link AuthDomain} manages authentication for all or part of a
* [class#Server]. To make a server require authentication, first create
* an appropriate subclass of #SoupAuthDomain, and then add it to the
* server with [method#Server.add_auth_domain].
*
* In order for an auth domain to have any effect, you must add one or more
* paths to it (via [method#AuthDomain.add_path]). To require authentication for
* all ordinary requests, add the path `"/"`. (Note that this does not include
* the special `"*"` URI (eg, "OPTIONS *"), which must be added as a separate
* path if you want to cover it.)
*
* If you need greater control over which requests should and shouldn't be
* authenticated, add paths covering everything you *might* want authenticated,
* and then use a filter ([method#AuthDomain.set_filter] to bypass
* authentication for those requests that don't need it.
*/
interface AuthDomain extends AuthDomainMixin {}
class AuthDomain {
public constructor(options?: Partial<AuthDomainInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomainBasic} instead.
*/
interface IAuthDomainBasic {
/**
* The [callback#AuthDomainBasicAuthCallback].
*/
auth_callback: AuthDomainBasicAuthCallback;
/**
* The data to pass to the [callback#AuthDomainBasicAuthCallback].
*/
auth_data: any;
/**
* Sets the callback that #domain will use to authenticate incoming
* requests.
*
* For each request containing authorization, #domain will invoke the callback,
* and then either accept or reject the request based on #callback's return
* value.
*
* You can also set the auth callback by setting the
* [property#AuthDomainBasic:auth-callback] and
* [property#AuthDomainBasic:auth-data] properties, which can also be used to
* set the callback at construct time.
* @param callback the callback
*/
set_auth_callback(callback: AuthDomainBasicAuthCallback): void;
connect(signal: "notify::auth-callback", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::auth-data", callback: (owner: this, ...args: any) => void): number;
}
type AuthDomainBasicInitOptionsMixin = AuthDomainInitOptions &
Pick<IAuthDomainBasic,
"auth_callback" |
"auth_data">;
export interface AuthDomainBasicInitOptions extends AuthDomainBasicInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomainBasic} instead.
*/
type AuthDomainBasicMixin = IAuthDomainBasic & AuthDomain;
/**
* Server-side "Basic" authentication.
*
* {@link AuthDomainBasic} handles the server side of HTTP "Basic" (ie,
* cleartext password) authentication.
*/
interface AuthDomainBasic extends AuthDomainBasicMixin {}
class AuthDomainBasic {
public constructor(options?: Partial<AuthDomainBasicInitOptions>);
/**
* Creates a {@link AuthDomainBasic}.
*
* You must set the [property#AuthDomain:realm] property, to indicate the realm
* name to be returned with the authentication challenge to the client. Other
* parameters are optional.
* @param optname1 name of first option, or %NULL
* @returns the new {@link AuthDomain}
*/
public static new(optname1: string): AuthDomain;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomainDigest} instead.
*/
interface IAuthDomainDigest {
/**
* The [callback#AuthDomainDigestAuthCallback].
*/
auth_callback: AuthDomainDigestAuthCallback;
/**
* The data to pass to the [callback#AuthDomainDigestAuthCallback].
*/
auth_data: any;
/**
* Sets the callback that #domain will use to authenticate incoming
* requests.
*
* For each request containing authorization, #domain will
* invoke the callback, and then either accept or reject the request
* based on #callback's return value.
*
* You can also set the auth callback by setting the
* [property#AuthDomainDigest:auth-callback] and
* [property#AuthDomainDigest:auth-data] properties, which can also be used to
* set the callback at construct time.
* @param callback the callback
*/
set_auth_callback(callback: AuthDomainDigestAuthCallback): void;
connect(signal: "notify::auth-callback", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::auth-data", callback: (owner: this, ...args: any) => void): number;
}
type AuthDomainDigestInitOptionsMixin = AuthDomainInitOptions &
Pick<IAuthDomainDigest,
"auth_callback" |
"auth_data">;
export interface AuthDomainDigestInitOptions extends AuthDomainDigestInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthDomainDigest} instead.
*/
type AuthDomainDigestMixin = IAuthDomainDigest & AuthDomain;
/**
* Server-side "Digest" authentication.
*
* {@link AuthDomainDigest} handles the server side of HTTP "Digest"
* authentication.
*/
interface AuthDomainDigest extends AuthDomainDigestMixin {}
class AuthDomainDigest {
public constructor(options?: Partial<AuthDomainDigestInitOptions>);
/**
* Creates a {@link AuthDomainDigest}.
*
* You must set the [property#AuthDomain:realm] property, to indicate the realm name to
* be returned with the authentication challenge to the client. Other parameters
* are optional.
* @param optname1 name of first option, or %NULL
* @returns the new {@link AuthDomain}
*/
public static new(optname1: string): AuthDomain;
/**
* Encodes the username/realm/password triplet for Digest
* authentication.
*
* That is, it returns a stringified MD5 hash of
* #username, #realm, and #password concatenated together. This is
* the form that is needed as the return value of
* {@link AuthDomainDigest}'s auth handler.
*
* For security reasons, you should store the encoded hash, rather
* than storing the cleartext password itself and calling this method
* only when you need to verify it. This way, if your server is
* compromised, the attackers will not gain access to cleartext
* passwords which might also be usable at other sites. (Note also
* that the encoded password returned by this method is identical to
* the encoded password stored in an Apache .htdigest file.)
* @param username a username
* @param realm an auth realm name
* @param password the password for #username in #realm
* @returns the encoded password
*/
public static encode_password(username: string, realm: string, password: string): string;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthManager} instead.
*/
interface IAuthManager {
/**
* Clear all credentials cached by #manager.
*/
clear_cached_credentials(): void;
/**
* Records that #auth is to be used under #uri, as though a
* WWW-Authenticate header had been received at that URI.
*
* This can be used to "preload" #manager's auth cache, to avoid an extra HTTP
* round trip in the case where you know ahead of time that a 401 response will
* be returned.
*
* This is only useful for authentication types where the initial
* Authorization header does not depend on any additional information
* from the server. (Eg, Basic or NTLM, but not Digest.)
* @param uri the #GUri under which #auth is to be used
* @param auth the {@link Auth} to use
*/
use_auth(uri: GLib.Uri, auth: Auth): void;
}
type AuthManagerInitOptionsMixin = GObject.ObjectInitOptions & SessionFeatureInitOptions
export interface AuthManagerInitOptions extends AuthManagerInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthManager} instead.
*/
type AuthManagerMixin = IAuthManager & GObject.Object & SessionFeature;
/**
* HTTP client-side authentication handler.
*
* {@link AuthManager} is the [iface#SessionFeature] that handles HTTP
* authentication for a [class#Session].
*
* A #SoupAuthManager is added to the session by default, and normally
* you don't need to worry about it at all. However, if you want to
* disable HTTP authentication, you can remove the feature from the
* session with [method#Session.remove_feature_by_type] or disable it on
* individual requests with [method#Message.disable_feature].
*
* You can use this with [method#Session.remove_feature_by_type] or
* [method#Message.disable_feature].
*
* (Although this type has only been publicly visible since libsoup 2.42, it has
* always existed in the background, and you can use `g_type_from_name
* ("SoupAuthManager")` to get its [alias#GLib.Type] in earlier releases.)
*/
interface AuthManager extends AuthManagerMixin {}
class AuthManager {
public constructor(options?: Partial<AuthManagerInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthNTLM} instead.
*/
interface IAuthNTLM {
}
type AuthNTLMInitOptionsMixin = AuthInitOptions
export interface AuthNTLMInitOptions extends AuthNTLMInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthNTLM} instead.
*/
type AuthNTLMMixin = IAuthNTLM & Auth;
/**
* HTTP-based NTLM authentication.
*
* [class#Session]s do not support this type by default; if you want to
* enable support for it, call [method#Session.add_feature_by_type],
* passing %SOUP_TYPE_AUTH_NTLM.
*/
interface AuthNTLM extends AuthNTLMMixin {}
class AuthNTLM {
public constructor(options?: Partial<AuthNTLMInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthNegotiate} instead.
*/
interface IAuthNegotiate {
}
type AuthNegotiateInitOptionsMixin = AuthInitOptions
export interface AuthNegotiateInitOptions extends AuthNegotiateInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link AuthNegotiate} instead.
*/
type AuthNegotiateMixin = IAuthNegotiate & Auth;
/**
* HTTP-based GSS-Negotiate authentication, as defined by
* [RFC 4559](https://datatracker.ietf.org/doc/html/rfc4559).
*
* [class#Session]s do not support this type by default; if you want to
* enable support for it, call [method#Session.add_feature_by_type],
* passing %SOUP_TYPE_AUTH_NEGOTIATE.
*
* This auth type will only work if libsoup was compiled with GSSAPI
* support; you can check [func#AuthNegotiate.supported] to see if it
* was.
*/
interface AuthNegotiate extends AuthNegotiateMixin {}
class AuthNegotiate {
public constructor(options?: Partial<AuthNegotiateInitOptions>);
/**
* Indicates whether libsoup was built with GSSAPI support.
*
* If this is %FALSE, %SOUP_TYPE_AUTH_NEGOTIATE will still be defined and can
* still be added to a [class#Session], but libsoup will never attempt to
* actually use this auth type.
* @returns %TRUE if supported otherwise %FALSE
*/
public static supported(): boolean;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Cache} instead.
*/
interface ICache {
/**
* The directory to store the cache files.
*/
cache_dir: string;
/**
* Whether the cache is private or shared.
*/
cache_type: CacheType;
/**
* Will remove all entries in the #cache plus all the cache files.
*
* This is not thread safe and must be called only from the thread that created the {@link Cache}
*/
clear(): void;
/**
* Synchronously writes the cache index out to disk.
*
* Contrast with [method#Cache.flush], which writes pending cache *entries* to
* disk.
*
* You must call this before exiting if you want your cache data to
* persist between sessions.
*
* This is not thread safe and must be called only from the thread that created the {@link Cache}
*/
dump(): void;
/**
* Forces all pending writes in the #cache to be
* committed to disk.
*
* For doing so it will iterate the [struct#GLib.MainContext] associated with
* #cache's session as long as needed.
*
* Contrast with [method#Cache.dump], which writes out the cache index file.
*/
flush(): void;
/**
* Gets the maximum size of the cache.
* @returns the maximum size of the cache, in bytes.
*/
get_max_size(): number;
/**
* Loads the contents of #cache's index into memory.
*
* This is not thread safe and must be called only from the thread that created the {@link Cache}
*/
load(): void;
/**
* Sets the maximum size of the cache.
* @param max_size the maximum size of the cache, in bytes
*/
set_max_size(max_size: number): void;
connect(signal: "notify::cache-dir", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::cache-type", callback: (owner: this, ...args: any) => void): number;
}
type CacheInitOptionsMixin = GObject.ObjectInitOptions & SessionFeatureInitOptions &
Pick<ICache,
"cache_dir" |
"cache_type">;
export interface CacheInitOptions extends CacheInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Cache} instead.
*/
type CacheMixin = ICache & GObject.Object & SessionFeature;
/**
* File-based cache for HTTP resources.
*/
interface Cache extends CacheMixin {}
class Cache {
public constructor(options?: Partial<CacheInitOptions>);
/**
* Creates a new {@link Cache}.
* @param cache_dir the directory to store the cached data, or %NULL
* to use the default one. Note that since the cache isn't safe to access for
* multiple processes at once, and the default directory isn't namespaced by
* process, clients are strongly discouraged from passing %NULL.
* @param cache_type the {@link CacheType} of the cache
* @returns a new {@link Cache}
*/
public static new(cache_dir: string | null, cache_type: CacheType): Cache;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link ContentDecoder} instead.
*/
interface IContentDecoder {
}
type ContentDecoderInitOptionsMixin = GObject.ObjectInitOptions & SessionFeatureInitOptions
export interface ContentDecoderInitOptions extends ContentDecoderInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link ContentDecoder} instead.
*/
type ContentDecoderMixin = IContentDecoder & GObject.Object & SessionFeature;
/**
* Handles decoding of HTTP messages.
*
* {@link ContentDecoder} handles adding the "Accept-Encoding" header on
* outgoing messages, and processing the "Content-Encoding" header on
* incoming ones. Currently it supports the "gzip", "deflate", and "br"
* content codings.
*
* A #SoupContentDecoder will automatically be
* added to the session by default. (You can use
* [method#Session.remove_feature_by_type] if you don't
* want this.)
*
* If #SoupContentDecoder successfully decodes the Content-Encoding,
* the message body will contain the decoded data; however, the message headers
* will be unchanged (and so "Content-Encoding" will still be present,
* "Content-Length" will describe the original encoded length, etc).
*
* If "Content-Encoding" contains any encoding types that
* #SoupContentDecoder doesn't recognize, then none of the encodings
* will be decoded.
*
* (Note that currently there is no way to (automatically) use
* Content-Encoding when sending a request body, or to pick specific
* encoding types to support.)
*/
interface ContentDecoder extends ContentDecoderMixin {}
class ContentDecoder {
public constructor(options?: Partial<ContentDecoderInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link ContentSniffer} instead.
*/
interface IContentSniffer {
/**
* Sniffs #buffer to determine its Content-Type.
*
* The result may also be influenced by the Content-Type declared in #msg's
* response headers.
* @param msg the message to sniff
* @param buffer a buffer containing the start of #msg's response body
* @returns the sniffed Content-Type of #buffer; this will never be %NULL,
* but may be `application/octet-stream`.
*
* return
* location for Content-Type parameters (eg, "charset"), or %NULL
*/
sniff(msg: Message, buffer: GLib.Bytes): [ string, string[] | null ];
}
type ContentSnifferInitOptionsMixin = GObject.ObjectInitOptions & SessionFeatureInitOptions
export interface ContentSnifferInitOptions extends ContentSnifferInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link ContentSniffer} instead.
*/
type ContentSnifferMixin = IContentSniffer & GObject.Object & SessionFeature;
/**
* Sniffs the mime type of messages.
*
* A {@link ContentSniffer} tries to detect the actual content type of
* the files that are being downloaded by looking at some of the data
* before the [class#Message] emits its [signal#Message::got-headers] signal.
* #SoupContentSniffer implements [iface#SessionFeature], so you can add
* content sniffing to a session with [method#Session.add_feature] or
* [method#Session.add_feature_by_type].
*/
interface ContentSniffer extends ContentSnifferMixin {}
class ContentSniffer {
public constructor(options?: Partial<ContentSnifferInitOptions>);
/**
* Creates a new {@link ContentSniffer}.
* @returns a new {@link ContentSniffer}
*/
public static new(): ContentSniffer;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link CookieJar} instead.
*/
interface ICookieJar {
/**
* The policy the jar should follow to accept or reject cookies.
*/
accept_policy: CookieJarAcceptPolicy;
/**
* Whether or not the cookie jar is read-only.
*/
read_only: boolean;
/**
* Adds #cookie to #jar.
*
* Emits the [signal#CookieJar::changed] signal if we are modifying
* an existing cookie or adding a valid new cookie ('valid' means
* that the cookie's expire date is not in the past).
*
* #cookie will be 'stolen' by the jar, so don't free it afterwards.
* @param cookie a {@link Cookie}
*/
add_cookie(cookie: Cookie): void;
/**
* Adds #cookie to #jar.
*
* Emits the [signal#CookieJar::changed] signal if we are modifying an existing
* cookie or adding a valid new cookie ('valid' means that the cookie's expire
* date is not in the past).
*
* #first_party will be used to reject cookies coming from third party
* resources in case such a security policy is set in the #jar.
*
* #uri will be used to reject setting or overwriting secure cookies
* from insecure origins. %NULL is treated as secure.
*
* #cookie will be 'stolen' by the jar, so don't free it afterwards.
* @param cookie a {@link Cookie}
* @param uri the URI setting the cookie
* @param first_party the URI for the main document
*/
add_cookie_full(cookie: Cookie, uri?: GLib.Uri | null, first_party?: GLib.Uri | null): void;
/**
* Adds #cookie to #jar.
*
* Emits the [signal#CookieJar::changed] signal if we are modifying
* an existing cookie or adding a valid new cookie ('valid' means
* that the cookie's expire date is not in the past).
*
* #first_party will be used to reject cookies coming from third party
* resources in case such a security policy is set in the #jar.
*
* #cookie will be 'stolen' by the jar, so don't free it afterwards.
*
* For secure cookies to work properly you may want to use
* [method#CookieJar.add_cookie_full].
* @param first_party the URI for the main document
* @param cookie a {@link Cookie}
*/
add_cookie_with_first_party(first_party: GLib.Uri, cookie: Cookie): void;
/**
* Constructs a [struct#GLib.List] with every cookie inside the #jar.
*
* The cookies in the list are a copy of the original, so
* you have to free them when you are done with them.
* @returns a #GSList
* with all the cookies in the #jar.
*/
all_cookies(): Cookie[];
/**
* Deletes #cookie from #jar.
*
* Emits the [signal#CookieJar::changed] signal.
* @param cookie a {@link Cookie}
*/
delete_cookie(cookie: Cookie): void;
/**
* Gets #jar's [enum#CookieJarAcceptPolicy].
* @returns the {@link CookieJarAcceptPolicy} set in the #jar
*/
get_accept_policy(): CookieJarAcceptPolicy;
/**
* Retrieves the list of cookies that would be sent with a request to #uri
* as a [struct#GLib.List] of {@link Cookie} objects.