-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoauther.d.ts
More file actions
66 lines (60 loc) · 1.53 KB
/
oauther.d.ts
File metadata and controls
66 lines (60 loc) · 1.53 KB
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
interface OAutherConfig {
consumer?: {
key: string,
secret: string
},
token?: {
key: string,
secret: string
},
signature_method?: string,
nonce_length?: number
}
interface Signature {
toObject(): SignatureObject,
toHeader(): string,
toForm(): string
}
interface SignatureObject {
oauth_signature_method: string,
oauth_consumer_key: string,
oauth_nonce: string,
oauth_timestamp: number,
oauth_version: string,
oauth_signature: string
}
interface RequestDetails {
baseUrl?: string,
hostname?: string,
protocol?: string,
port?: number,
path?: string,
method?: string,
body?: { [key: string]: any },
query?: { [key: string]: any }
}
interface OAuther {
/**
* Sign OAuth request.
* @param {Object} request data
* {
* hostname : 'example.com',
* method : 'GET',
* path : '/path/to/url',
* port : 80, // optional
* protocol : 'http', // optional, default 'http'
* query, : { 'gaius' : 'baltar' },// optional, query string as json
* body : { 'kara' : 'thrace' } // optional, form encoded body as json
* }
* @return {Object} OAuth data object
*/
sign(request: RequestDetails): Signature,
/**
* A http request to validate
* @param {Object} request request
* @return {Object} true if the signature is valid
*/
validate(request: any): boolean;
}
declare function oauther(config: OAutherConfig): OAuther;
export = oauther;