-
Notifications
You must be signed in to change notification settings - Fork 80
/
sasl.d.ts
132 lines (116 loc) · 3.22 KB
/
sasl.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
/// <reference types="node" />
import { Connection } from "./connection";
import { Transport } from "./transport";
import { Socket } from "net";
import { frames } from "./frames";
interface Mechanisms {
[x: string]: Function;
}
declare class PlainServer {
callback: Function;
outcome?: true;
username?: string;
constructor(callback: Function);
start(response: Buffer, hostname: string): void;
}
declare class PlainClient {
username: string;
password: string;
constructor(username: string, password: string);
start(callback: Function): void;
}
declare class AnonymousServer {
outcome?: true;
username?: string;
start(response?: Buffer): void;
}
declare class AnonymousClient {
username: string;
constructor(username: string);
start(callback: Function): void;
}
declare class ExternalServer {
outcome?: true;
username?: string;
start(): void;
}
declare class ExternalClient {
username?: string;
start(callback: Function): void;
step(callback: Function): void;
}
declare class XOAuth2Client {
username: string;
token: string;
constructor(username: string, token: string);
start(callback: Function): void;
}
declare class SaslServer {
connection: Connection;
mechanisms?: Mechanisms;
transport: Transport;
next: Transport;
constructor(connection: Connection, mechanisms?: Mechanisms);
outcome?: boolean;
mechanism?: any;
username?: string;
do_step(challenge: any): void;
on_sasl_init(frame: frames): void;
on_sasl_response(frame: frames): void;
has_writes_pending(): boolean;
write(socket: Socket): void;
peek_size(buffer: Buffer): number | undefined;
read(buffer: Buffer): number;
}
declare class SaslClient {
connection: Connection;
mechanisms: Mechanisms;
mechanism?: any;
transport: Transport;
next: Transport;
mechanism_name?: string;
hostname: string;
failed: boolean;
constructor(connection: Connection, mechanisms: Mechanisms, hostname: string);
on_sasl_mechanisms(frame: frames): void;
on_sasl_challenge(frame: frames): void;
on_sasl_outcome(frame: frames): void;
has_writes_pending(): boolean;
write(socket: Socket): void;
peek_size(buffer: Buffer): number | undefined;
read(buffer: Buffer): number;
}
declare class SelectiveServer {
header_received: boolean;
transports: {
0: Transport,
3: SaslServer
};
selected?: any;
constructor(connection: Connection, mechanisms: Mechanisms);
has_writes_pending(): boolean;
write(socket: Socket): void | number;
peek_size(buffer: Buffer): number | undefined;
read(buffer: Buffer): number;
}
type DefaultServerMechanisms = {
enable_anonymous(): void;
enable_plain(): void;
}
type DefaultClientMmechanisms = {
enable_anonymous(name: string): void;
enable_plain(username: string, password: string): void;
enable_external(): void;
enable_xoauth2(username: string, token: string): void;
}
declare type serverMechanisms = () => DefaultServerMechanisms;
declare type clientMechanisms = () => DefaultClientMmechanisms;
declare type serverAddExternal = (mechs: any) => any;
export interface sasl {
Client: SaslClient;
Server: SaslServer;
Selective: SelectiveServer;
server_mechanisms: serverMechanisms;
client_mechanisms: clientMechanisms;
server_add_external: serverAddExternal;
}