-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreact-native-plugin-ms-adal.d.ts
214 lines (185 loc) · 9.56 KB
/
react-native-plugin-ms-adal.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
// Type definitions for Active Directory Authentication Library (ADAL) plugin for Apache Cordova
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-cordova
// Definitions by: Kai Walter https://github.com/KaiWalter
// Definitions: ...
declare namespace Microsoft {
namespace ADAL {
interface IUserInfo {
displayableId: string,
userId: string,
familyName: string,
givenName: string,
identityProvider: string,
passwordChangeUrl: string,
passwordExpiresOn: Date,
uniqueId: string,
}
interface ITokenCache {
contextAuthority: string
}
interface ITokenCacheItem {
accessToken: string,
authority: string,
clientId: string,
displayableId: string,
expiresOn: Date,
isMultipleResourceRefreshToken: boolean,
resource: string,
tenantId: string,
userInfo: IUserInfo
}
interface IPromise {
then(doneCallBack: () => void, failCallBack?: (message: string) => void);
}
interface IPromiseTokenCacheItems {
then(doneCallBack: (tokenCacheItems: ITokenCacheItem[]) => void, failCallBack?: (message: string) => void);
}
class TokenCache implements ITokenCache {
contextAuthority: string
/**
* Clears the cache by deleting all the items.
*
* @returns {Promise} Promise either fulfilled when operation is completed or rejected with error.
*/
clear(): IPromise;
/**
* Gets all cached items.
*
* @returns {Promise} Promise either fulfilled with array of cached items or rejected with error.
*/
readItems(): IPromiseTokenCacheItems;
/**
* Deletes cached item.
*
* @param {TokenCacheItem} item Cached item to delete from cache
*
* @returns {Promise} Promise either fulfilled when operation is completed or rejected with error.
*/
deleteItem(item: ITokenCacheItem): IPromise;
}
interface IAuthenticationResult {
accessToken: string,
accessTokenType: string,
expiresOn: Date,
idToken: string,
isMultipleResourceRefreshToken: boolean,
status: string,
statusCode: string,
tenantId: string,
userInfo: IUserInfo
}
class AuthenticationResult implements IAuthenticationResult {
accessToken: string;
accessTokenType: string;
expiresOn: Date;
idToken: string;
isMultipleResourceRefreshToken: boolean;
status: string;
statusCode: string;
tenantId: string;
userInfo: IUserInfo;
/**
* Creates authorization header for web requests.
*
* @returns {String} The authorization header.
*/
createAuthorizationHeader(): string;
}
interface IPromiseAuthenticationResult {
then(doneCallBack: (context: IAuthenticationResult) => void, failCallBack?: (message: string) => void);
}
interface IAuthenticationContext {
authority: string,
validateAuthority: boolean,
tokenCache: TokenCache
/**
* Acquires token using interactive flow if needed. It checks the cache to return existing result
* if not expired. It tries to use refresh token if available. If it fails to get token with
* refresh token, it will remove this refresh token from cache and start authentication.
*
* @param {String} resourceUrl Resource identifier
* @param {String} clientId Client (application) identifier
* @param {String} redirectUrl Redirect url for this application
* @param {String} userId User identifier (optional)
* @param {String} extraQueryParameters
* Extra query parameters (optional)
* Parameters should be escaped before passing to this method (e.g. using 'encodeURI()')
*
* @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error
*/
acquireTokenAsync(resourceUrl: string, clientId: string, redirectUrl: string, userId?: string, extraQueryParameters?: string): IPromiseAuthenticationResult;
/**
* Acquires token WITHOUT using interactive flow. It checks the cache to return existing result
* if not expired. It tries to use refresh token if available. If it fails to get token without
* displaying UI it will fail. This method guarantees that no UI will be shown to user.
*
* @param {String} resourceUrl Resource identifier
* @param {String} clientId Client (application) identifier
* @param {String} userId User identifier (optional)
*
* @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error
*/
acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId: string): IPromiseAuthenticationResult;
}
interface IPromiseAuthenticationContext {
then(doneCallBack: (context: IAuthenticationContext) => void, failCallBack?: (message: string) => void);
}
class AuthenticationContext implements IAuthenticationContext {
authority: string;
validateAuthority: boolean;
tokenCache: TokenCache;
/**
* Constructs context to use with known authority to get the token. It reuses existing context
* for this authority URL in native proxy or creates a new one if it doesn't exists.
* Corresponding native context will be created at first time when it will be needed.
*
* @param {String} authority Authority url to send code and token requests
* @param {Boolean} validateAuthority Validate authority before sending token request
* When context is being created syncronously using this constructor
* validateAuthority in native context will be disabled to prevent
* context initialization failure
*
* @returns {Object} Newly created authentication context.
*/
constructor(authority: string, validateAuthority?: boolean);
/**
* Constructs context asynchronously to use with known authority to get the token.
* It reuses existing context for this authority URL in native proxy or creates a new one if it doesn't exists.
*
* @param {String} authority Authority url to send code and token requests
* @param {Boolean} validateAuthority Validate authority before sending token request. True by default
*
* @returns {Promise} Promise either fulfilled with newly created authentication context or rejected with error
*/
static createAsync(authority: string, validateAuthority?: boolean): IPromiseAuthenticationContext;
/**
* Acquires token using interactive flow if needed. It checks the cache to return existing result
* if not expired. It tries to use refresh token if available. If it fails to get token with
* refresh token, it will remove this refresh token from cache and start authentication.
*
* @param {String} resourceUrl Resource identifier
* @param {String} clientId Client (application) identifier
* @param {String} redirectUrl Redirect url for this application
* @param {String} userId User identifier (optional)
* @param {String} extraQueryParameters
* Extra query parameters (optional)
* Parameters should be escaped before passing to this method (e.g. using 'encodeURI()')
*
* @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error
*/
acquireTokenAsync(resourceUrl: string, clientId: string, redirectUrl: string, userId?: string, extraQueryParameters?: string): IPromiseAuthenticationResult;
/**
* Acquires token WITHOUT using interactive flow. It checks the cache to return existing result
* if not expired. It tries to use refresh token if available. If it fails to get token without
* displaying UI it will fail. This method guarantees that no UI will be shown to user.
*
* @param {String} resourceUrl Resource identifier
* @param {String} clientId Client (application) identifier
* @param {String} userId User identifier (optional)
*
* @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error
*/
acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId: string): IPromiseAuthenticationResult;
}
}
}