forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meteor-prime8consulting-oauth2.d.ts
116 lines (99 loc) · 3.01 KB
/
meteor-prime8consulting-oauth2.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
// Type definitions for prime8consulting:meteor-oauth2
// Project: https://github.com/prime-8-consulting/meteor-oauth2/
// Definitions by: Robbie Van Gorkom <https://github.com/vangorra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../meteor/meteor.d.ts" />
declare namespace OAuth2Server {
interface RefreshToken {
refreshToken : string;
clientId : string;
userId : string;
expires : Date;
}
interface AuthCode {
authCode : string;
clientId : string;
userId : string;
expires : Date;
}
interface AccessToken {
accessToken : string;
clientId : string;
userId : string;
expires : Date
}
interface Client {
clientId : string;
active : boolean;
redirectUri : string;
clientSecret : string;
}
interface PubSubNames {
/**
* Constant string representing the auth codes pub/sub.
*/
authCodes : string;
/**
* Constant string representing the refresh token pub/sub.
*/
refreshTokens : string;
}
interface MethodNames {
/**
* Constant string representing th authCodeGran meteor method.
*/
authCodeGrant : string;
}
interface Collections {
/**
* Collection of the refresh tokens.
*/
refreshToken : Mongo.Collection<RefreshToken>;
/**
* Collection of the authorization codes.
*/
authCode : Mongo.Collection<AuthCode>;
/**
* (server only) Collection of the access tokens.
*/
accessToken : Mongo.Collection<AccessToken>;
/**
* (server only) Collection of the clients authorized to use the oauth2 service.
*/
client : Mongo.Collection<Client>;
}
interface SubscribeTo {
/**
* Wrapper function to subscribe to the auth code subscription. Returns a standard subscription handle.
*/
authCode() : Meteor.SubscriptionHandle;
}
interface AuthCodeGrantResult {
success : boolean;
error : any;
authorizationCode : string;
redirectToUri : string;
}
interface CallMethod {
/**
* Wrapper for Meteor.method to create an authorization code. This is an async function and a callback must be provided to be of any use.
*/
authCodeGrant(
client_id : string,
redirect_uri : string,
response_type : string,
scope : string[],
state : string,
callback : (err : Meteor.Error, authCodeGrantResult : AuthCodeGrantResult) => void
) : void;
}
interface OAuth2Server {
pubSubNames : PubSubNames;
methodNames : MethodNames;
collections : Collections;
oauthserver : any;
subscribeTo : SubscribeTo;
callMethod : CallMethod;
}
}
declare var oAuth2Server : OAuth2Server.OAuth2Server;