@cloudbase/oauth 0.0.2-alpha.0 → 0.1.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +137 -5
- package/app/index.d.ts +28 -0
- package/app/index.js +54 -0
- package/app/index.js.map +1 -0
- package/app/internal.d.ts +12 -0
- package/app/internal.js +25 -0
- package/app/internal.js.map +1 -0
- package/app/openuri.d.ts +20 -0
- package/app/openuri.js +104 -0
- package/app/openuri.js.map +1 -0
- package/app/request.d.ts +18 -0
- package/app/request.js +44 -0
- package/app/request.js.map +1 -0
- package/app/storage.d.ts +41 -0
- package/app/storage.js +35 -0
- package/app/storage.js.map +1 -0
- package/{dist/auth → auth}/consts.d.ts +21 -1
- package/auth/consts.js +57 -0
- package/auth/consts.js.map +1 -0
- package/auth/index.d.ts +193 -0
- package/auth/index.js +403 -0
- package/auth/index.js.map +1 -0
- package/{dist/auth → auth}/models.d.ts +35 -22
- package/auth/models.js +3 -0
- package/auth/models.js.map +1 -0
- package/captcha/index.d.ts +45 -0
- package/captcha/index.js +133 -0
- package/captcha/index.js.map +1 -0
- package/index.d.ts +8 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/{dist/oauth2client → oauthclient}/consts.d.ts +1 -22
- package/oauthclient/consts.js +53 -0
- package/oauthclient/consts.js.map +1 -0
- package/oauthclient/index.d.ts +18 -0
- package/oauthclient/index.js +21 -0
- package/oauthclient/index.js.map +1 -0
- package/oauthclient/interface.d.ts +25 -0
- package/oauthclient/interface.js +10 -0
- package/oauthclient/interface.js.map +1 -0
- package/{dist/oauth2client → oauthclient}/models.d.ts +5 -13
- package/oauthclient/models.js +3 -0
- package/oauthclient/models.js.map +1 -0
- package/oauthclient/oauthclient.d.ts +142 -0
- package/{src/oauth2client/oauth2client.ts → oauthclient/oauthclient.js} +113 -265
- package/oauthclient/oauthclient.js.map +1 -0
- package/package.json +20 -19
- package/utils/single-promise.d.ts +18 -0
- package/utils/single-promise.js +48 -0
- package/utils/single-promise.js.map +1 -0
- package/utils/uuid.d.ts +5 -0
- package/utils/uuid.js +16 -0
- package/utils/uuid.js.map +1 -0
- package/.eslintignore +0 -2
- package/.eslintrc +0 -26
- package/dist/auth/apis.d.ts +0 -40
- package/dist/auth/apis.js +0 -422
- package/dist/auth/consts.js +0 -35
- package/dist/auth/models.js +0 -3
- package/dist/captcha/captcha.d.ts +0 -35
- package/dist/captcha/captcha.js +0 -262
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -38
- package/dist/oauth2client/consts.js +0 -73
- package/dist/oauth2client/interface.d.ts +0 -12
- package/dist/oauth2client/interface.js +0 -10
- package/dist/oauth2client/models.js +0 -3
- package/dist/oauth2client/oauth2client.d.ts +0 -64
- package/dist/oauth2client/oauth2client.js +0 -585
- package/dist/utils/function/single-promise.d.ts +0 -5
- package/dist/utils/function/single-promise.js +0 -89
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -12
- package/src/auth/apis.ts +0 -484
- package/src/auth/consts.ts +0 -30
- package/src/auth/models.ts +0 -175
- package/src/captcha/captcha.ts +0 -217
- package/src/index.ts +0 -24
- package/src/oauth2client/consts.ts +0 -69
- package/src/oauth2client/interface.ts +0 -44
- package/src/oauth2client/models.ts +0 -61
- package/src/utils/function/single-promise.ts +0 -40
- package/src/utils/uuid.ts +0 -11
- package/tsconfig.json +0 -44
|
@@ -1,203 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ResponseError,
|
|
8
|
-
RequestOptions,
|
|
9
|
-
RequestFunction,
|
|
10
|
-
OAuth2ClientOptions,
|
|
11
|
-
AuthClientRequestOptions,
|
|
12
|
-
} from './models';
|
|
13
|
-
|
|
14
|
-
import {uuidv4} from '../utils/uuid';
|
|
15
|
-
|
|
16
|
-
import {SinglePromise} from '../utils/function/single-promise';
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth2Client = exports.LocalCredentials = exports.generateRequestId = exports.toResponseError = void 0;
|
|
4
|
+
const consts_1 = require("./consts");
|
|
5
|
+
const uuid_1 = require("../utils/uuid");
|
|
6
|
+
const single_promise_1 = require("../utils/single-promise");
|
|
18
7
|
const RequestIdHeaderName = 'x-request-id';
|
|
19
8
|
const DeviceIdHeaderName = 'x-device-id';
|
|
20
|
-
const DeviceIdSectionName = '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
error_description?: string | null;
|
|
25
|
-
error_uri?: string | null;
|
|
26
|
-
details?: any | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const defaultRequest: RequestFunction = async <T>(
|
|
30
|
-
url: string,
|
|
31
|
-
options?: RequestOptions,
|
|
32
|
-
): Promise<T> => {
|
|
33
|
-
let result: T | null = null;
|
|
34
|
-
let responseError: ResponseError | null = null;
|
|
35
|
-
try {
|
|
36
|
-
// Objects must be copied to prevent modification of data such as body.
|
|
37
|
-
const copyOptions = Object.assign({}, options);
|
|
38
|
-
if (!copyOptions.method) {
|
|
39
|
-
copyOptions.method = 'GET';
|
|
40
|
-
}
|
|
41
|
-
if (copyOptions.body && typeof copyOptions.body !== 'string') {
|
|
42
|
-
copyOptions.body = JSON.stringify(copyOptions.body);
|
|
43
|
-
}
|
|
44
|
-
const responseResult: Response = await fetch(url, copyOptions);
|
|
45
|
-
const jsonResponse = await responseResult.json();
|
|
46
|
-
if (jsonResponse && jsonResponse.error) {
|
|
47
|
-
responseError = jsonResponse as ResponseError;
|
|
48
|
-
responseError.error_uri = new URL(url).pathname;
|
|
49
|
-
} else {
|
|
50
|
-
result = jsonResponse as T;
|
|
51
|
-
}
|
|
52
|
-
} catch (error) {
|
|
53
|
-
responseError = {
|
|
54
|
-
error: ErrorType.UNREACHABLE,
|
|
55
|
-
error_description: error.message,
|
|
56
|
-
error_uri: new URL(url).pathname,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (responseError) {
|
|
60
|
-
throw responseError;
|
|
61
|
-
} else {
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const toResponseError = (
|
|
67
|
-
error: ResponseError | Error,
|
|
68
|
-
options?: ToResponseErrorOptions,
|
|
69
|
-
): ResponseError => {
|
|
70
|
-
let responseError: ResponseError;
|
|
71
|
-
const formatOptions: ToResponseErrorOptions = options || {};
|
|
9
|
+
const DeviceIdSectionName = 'device_';
|
|
10
|
+
exports.toResponseError = (error, options) => {
|
|
11
|
+
let responseError;
|
|
12
|
+
const formatOptions = options || {};
|
|
72
13
|
if (error instanceof Error) {
|
|
73
14
|
responseError = {
|
|
74
|
-
error: formatOptions.error || ErrorType.LOCAL,
|
|
15
|
+
error: formatOptions.error || consts_1.ErrorType.LOCAL,
|
|
75
16
|
error_description: formatOptions.error_description || error.message,
|
|
76
17
|
error_uri: formatOptions.error_uri,
|
|
77
18
|
details: formatOptions.details || error.stack,
|
|
78
19
|
};
|
|
79
|
-
}
|
|
80
|
-
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const formatError = error || {};
|
|
81
23
|
responseError = {
|
|
82
|
-
error: formatOptions.error || formatError.error || ErrorType.LOCAL,
|
|
83
|
-
error_description:
|
|
84
|
-
formatOptions.error_description || formatError.error_description,
|
|
24
|
+
error: formatOptions.error || formatError.error || consts_1.ErrorType.LOCAL,
|
|
25
|
+
error_description: formatOptions.error_description || formatError.error_description,
|
|
85
26
|
error_uri: formatOptions.error_uri || formatError.error_uri,
|
|
86
27
|
details: formatOptions.details || formatError.details,
|
|
87
28
|
};
|
|
88
29
|
}
|
|
89
30
|
return responseError;
|
|
90
31
|
};
|
|
91
|
-
|
|
92
32
|
/**
|
|
93
33
|
* Generate request id.
|
|
94
34
|
* @return {string}
|
|
95
35
|
*/
|
|
96
|
-
|
|
97
|
-
return uuidv4();
|
|
36
|
+
function generateRequestId() {
|
|
37
|
+
return uuid_1.uuidv4();
|
|
98
38
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Default Storage.
|
|
103
|
-
*/
|
|
104
|
-
class DefaultStorage implements SimpleStorage {
|
|
105
|
-
/**
|
|
106
|
-
* Get item.
|
|
107
|
-
* @param {string} key
|
|
108
|
-
*/
|
|
109
|
-
async getItem(key: string): Promise<string | null> {
|
|
110
|
-
return window.localStorage.getItem(key);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Remove item.
|
|
115
|
-
* @param {string} key
|
|
116
|
-
*/
|
|
117
|
-
async removeItem(key: string): Promise<void> {
|
|
118
|
-
window.localStorage.removeItem(key);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Set item.
|
|
123
|
-
* @param {string} key
|
|
124
|
-
* @param {string} value
|
|
125
|
-
*/
|
|
126
|
-
async setItem(key: string, value: string): Promise<void> {
|
|
127
|
-
window.localStorage.setItem(key, value);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export const defaultStorage = new DefaultStorage();
|
|
132
|
-
|
|
133
|
-
interface LocalCredentialsOptions {
|
|
134
|
-
tokenSectionName: string;
|
|
135
|
-
storage: SimpleStorage;
|
|
136
|
-
}
|
|
137
|
-
|
|
39
|
+
exports.generateRequestId = generateRequestId;
|
|
138
40
|
/**
|
|
139
41
|
* Check if credentials is expired.
|
|
140
42
|
* @param {Credentials} credentials
|
|
141
43
|
* @return {boolean}
|
|
142
44
|
*/
|
|
143
|
-
function isCredentialsExpired(credentials
|
|
45
|
+
function isCredentialsExpired(credentials) {
|
|
144
46
|
let isExpired = true;
|
|
145
47
|
if (credentials && credentials.expires_at && credentials.access_token) {
|
|
146
48
|
isExpired = credentials.expires_at < new Date();
|
|
147
49
|
}
|
|
148
50
|
return isExpired;
|
|
149
51
|
}
|
|
150
|
-
|
|
151
52
|
/**
|
|
152
53
|
* Local credentials.
|
|
153
54
|
* Local credentials, with memory cache and storage cache.
|
|
154
55
|
* If the memory cache expires, the storage cache is automatically loaded.
|
|
155
56
|
*/
|
|
156
|
-
|
|
157
|
-
private _tokenSectionName: string;
|
|
158
|
-
|
|
159
|
-
private _storage: SimpleStorage;
|
|
160
|
-
|
|
161
|
-
private _credentials: Credentials | null = null;
|
|
162
|
-
|
|
163
|
-
private _singlePromise: SinglePromise = new SinglePromise();
|
|
164
|
-
|
|
57
|
+
class LocalCredentials {
|
|
165
58
|
/**
|
|
166
59
|
* constructor
|
|
167
60
|
* @param {LocalCredentialsOptions} options
|
|
168
61
|
*/
|
|
169
|
-
constructor(options
|
|
62
|
+
constructor(options) {
|
|
63
|
+
this._credentials = null;
|
|
64
|
+
this._singlePromise = new single_promise_1.SinglePromise();
|
|
170
65
|
this._tokenSectionName = options.tokenSectionName;
|
|
171
66
|
this._storage = options.storage;
|
|
172
67
|
}
|
|
173
|
-
|
|
174
68
|
/**
|
|
175
69
|
* setCredentials Provides an alternative fetch api request implementation with auth credentials
|
|
176
70
|
* @param {Credentials} credentials
|
|
177
71
|
*/
|
|
178
|
-
|
|
72
|
+
async setCredentials(credentials) {
|
|
179
73
|
if (credentials && credentials.expires_in) {
|
|
180
|
-
credentials.expires_at = new Date(
|
|
181
|
-
Date.now() + (credentials.expires_in - 30) * 1000,
|
|
182
|
-
);
|
|
74
|
+
credentials.expires_at = new Date(Date.now() + (credentials.expires_in - 30) * 1000);
|
|
183
75
|
if (this._storage) {
|
|
184
|
-
const tokenStr
|
|
76
|
+
const tokenStr = JSON.stringify(credentials);
|
|
185
77
|
await this._storage.setItem(this._tokenSectionName, tokenStr);
|
|
186
78
|
}
|
|
187
79
|
this._credentials = credentials;
|
|
188
|
-
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
189
82
|
if (this._storage) {
|
|
190
83
|
await this._storage.removeItem(this._tokenSectionName);
|
|
191
84
|
}
|
|
192
85
|
this._credentials = null;
|
|
193
86
|
}
|
|
194
87
|
}
|
|
195
|
-
|
|
196
88
|
/**
|
|
197
89
|
* Get credentials.
|
|
198
90
|
* @return {Promise<Credentials | null>}
|
|
199
91
|
*/
|
|
200
|
-
|
|
92
|
+
async getCredentials() {
|
|
201
93
|
return this._singlePromise.run('getCredentials', async () => {
|
|
202
94
|
if (isCredentialsExpired(this._credentials)) {
|
|
203
95
|
this._credentials = await this._getStorageCredentials();
|
|
@@ -205,23 +97,21 @@ export class LocalCredentials {
|
|
|
205
97
|
return this._credentials;
|
|
206
98
|
});
|
|
207
99
|
}
|
|
208
|
-
|
|
209
100
|
/**
|
|
210
101
|
* Get storage credentials.
|
|
211
102
|
*/
|
|
212
|
-
|
|
103
|
+
async _getStorageCredentials() {
|
|
213
104
|
return this._singlePromise.run('_getStorageCredentials', async () => {
|
|
214
|
-
let credentials
|
|
215
|
-
const tokenStr
|
|
216
|
-
this._tokenSectionName,
|
|
217
|
-
);
|
|
105
|
+
let credentials = null;
|
|
106
|
+
const tokenStr = await this._storage.getItem(this._tokenSectionName);
|
|
218
107
|
if (tokenStr !== undefined && tokenStr !== null) {
|
|
219
108
|
try {
|
|
220
109
|
credentials = JSON.parse(tokenStr);
|
|
221
110
|
if (credentials && credentials.expires_at) {
|
|
222
111
|
credentials.expires_at = new Date(credentials.expires_at);
|
|
223
112
|
}
|
|
224
|
-
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
225
115
|
await this._storage.removeItem(this._tokenSectionName);
|
|
226
116
|
credentials = null;
|
|
227
117
|
}
|
|
@@ -230,91 +120,64 @@ export class LocalCredentials {
|
|
|
230
120
|
});
|
|
231
121
|
}
|
|
232
122
|
}
|
|
233
|
-
|
|
123
|
+
exports.LocalCredentials = LocalCredentials;
|
|
234
124
|
/**
|
|
235
125
|
* OAuth2Client
|
|
236
126
|
*/
|
|
237
|
-
|
|
238
|
-
private static _defaultRetry = 2;
|
|
239
|
-
private static _minRetry = 0;
|
|
240
|
-
private static _maxRetry = 5;
|
|
241
|
-
private static _retryInterval = 1000;
|
|
242
|
-
|
|
243
|
-
private _apiOrigin: string;
|
|
244
|
-
private _clientId: string;
|
|
245
|
-
private _retry: number;
|
|
246
|
-
private _clientSecret?: string;
|
|
247
|
-
private _baseRequest: <T>(
|
|
248
|
-
url: string,
|
|
249
|
-
options?: RequestOptions,
|
|
250
|
-
) => Promise<T>;
|
|
251
|
-
private _localCredentials: LocalCredentials;
|
|
252
|
-
private _storage: SimpleStorage;
|
|
253
|
-
private _deviceID?: string;
|
|
254
|
-
private _tokenInURL?: boolean;
|
|
255
|
-
private _refreshTokenFunc: (refreshToken?: string) => Promise<Credentials>;
|
|
256
|
-
private _headers?: { [key: string]: string };
|
|
257
|
-
private _singlePromise: SinglePromise = new SinglePromise();
|
|
258
|
-
|
|
127
|
+
class OAuth2Client {
|
|
259
128
|
/**
|
|
260
129
|
* constructor
|
|
261
130
|
* @param {OAuth2ClientOptions} options
|
|
262
131
|
*/
|
|
263
|
-
constructor(options
|
|
264
|
-
this.
|
|
265
|
-
this._clientId = options.clientId;
|
|
132
|
+
constructor(options) {
|
|
133
|
+
this._singlePromise = new single_promise_1.SinglePromise();
|
|
266
134
|
this._retry = this._formatRetry(options.retry, OAuth2Client._defaultRetry);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
135
|
+
this._baseRequest = options.request;
|
|
136
|
+
if (!options.clientSecret) {
|
|
137
|
+
options.clientSecret = "";
|
|
138
|
+
}
|
|
139
|
+
if (options.clientId !== '') {
|
|
140
|
+
this._basicAuth = "Basic " + btoa(options.clientId + ":" + options.clientSecret);
|
|
271
141
|
}
|
|
272
142
|
this._tokenInURL = options.tokenInURL;
|
|
273
143
|
this._headers = options.headers;
|
|
274
144
|
// @ts-ignore
|
|
275
145
|
this._storage = options.storage || defaultStorage;
|
|
276
146
|
this._localCredentials = new LocalCredentials({
|
|
277
|
-
tokenSectionName: 'credentials_'
|
|
147
|
+
tokenSectionName: 'credentials_',
|
|
278
148
|
storage: this._storage,
|
|
279
149
|
});
|
|
280
|
-
this._clientSecret = options.clientSecret;
|
|
281
150
|
this._refreshTokenFunc =
|
|
282
151
|
options.refreshTokenFunc || this._defaultRefreshTokenFunc;
|
|
283
152
|
}
|
|
284
|
-
|
|
285
153
|
/**
|
|
286
154
|
* setCredentials Provides an alternative fetch api request implementation with auth credentials
|
|
287
155
|
* @param {Credentials} credentials
|
|
288
156
|
* @return {Promise<void>}
|
|
289
157
|
*/
|
|
290
|
-
|
|
158
|
+
setCredentials(credentials) {
|
|
291
159
|
return this._localCredentials.setCredentials(credentials);
|
|
292
160
|
}
|
|
293
|
-
|
|
294
161
|
/**
|
|
295
162
|
* getAccessToken return a validate access token
|
|
296
163
|
*/
|
|
297
|
-
|
|
298
|
-
const credentials
|
|
164
|
+
async getAccessToken() {
|
|
165
|
+
const credentials = await this._getCredentials();
|
|
299
166
|
if (credentials && credentials.access_token) {
|
|
300
167
|
return Promise.resolve(credentials.access_token);
|
|
301
168
|
}
|
|
302
|
-
return Promise.reject({error: ErrorType.UNAUTHENTICATED}
|
|
169
|
+
return Promise.reject({ error: consts_1.ErrorType.UNAUTHENTICATED });
|
|
303
170
|
}
|
|
304
|
-
|
|
305
171
|
/**
|
|
306
172
|
* request http like simple fetch api, exp:request('/v1/user/me', {withCredentials:true})
|
|
307
173
|
* @param {string} url
|
|
308
174
|
* @param {AuthClientRequestOptions} options
|
|
309
175
|
*/
|
|
310
|
-
|
|
311
|
-
url: string,
|
|
312
|
-
options?: AuthClientRequestOptions,
|
|
313
|
-
): Promise<T> {
|
|
176
|
+
async request(url, options) {
|
|
314
177
|
if (!options) {
|
|
315
178
|
options = {};
|
|
316
179
|
}
|
|
317
|
-
const retry
|
|
180
|
+
const retry = this._formatRetry(options.retry, this._retry);
|
|
318
181
|
options.headers = options.headers || {};
|
|
319
182
|
if (this._headers) {
|
|
320
183
|
options.headers = {
|
|
@@ -326,8 +189,11 @@ export class OAuth2Client implements AuthClient {
|
|
|
326
189
|
options.headers[RequestIdHeaderName] = generateRequestId();
|
|
327
190
|
}
|
|
328
191
|
if (!options.headers[DeviceIdHeaderName]) {
|
|
329
|
-
|
|
330
|
-
|
|
192
|
+
const deviceId = await this._getDeviceId();
|
|
193
|
+
options.headers[DeviceIdHeaderName] = deviceId;
|
|
194
|
+
}
|
|
195
|
+
if (options && options.withBasicAuth && this._basicAuth) {
|
|
196
|
+
options.headers['Authorization'] = this._basicAuth;
|
|
331
197
|
}
|
|
332
198
|
if (options && options.withCredentials) {
|
|
333
199
|
const credentials = await this._getCredentials();
|
|
@@ -337,36 +203,24 @@ export class OAuth2Client implements AuthClient {
|
|
|
337
203
|
url += '?';
|
|
338
204
|
}
|
|
339
205
|
url += 'access_token=' + credentials.access_token;
|
|
340
|
-
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
341
208
|
options.headers['Authorization'] =
|
|
342
209
|
credentials.token_type + ' ' + credentials.access_token;
|
|
343
210
|
}
|
|
344
211
|
}
|
|
345
|
-
} else {
|
|
346
|
-
if (this._clientId && url.indexOf('client_id') < 0) {
|
|
347
|
-
url += url.indexOf('?') < 0 ? '?' : '&';
|
|
348
|
-
url += 'client_id=' + this._clientId;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
if (url.startsWith('/')) {
|
|
352
|
-
url = this._apiOrigin + url;
|
|
353
212
|
}
|
|
354
|
-
let response
|
|
355
|
-
const maxRequestTimes
|
|
356
|
-
for (
|
|
357
|
-
let requestTime = 0;
|
|
358
|
-
requestTime < maxRequestTimes;
|
|
359
|
-
requestTime++
|
|
360
|
-
) {
|
|
213
|
+
let response = null;
|
|
214
|
+
const maxRequestTimes = retry + 1;
|
|
215
|
+
for (let requestTime = 0; requestTime < maxRequestTimes; requestTime++) {
|
|
361
216
|
try {
|
|
362
|
-
response = await this._baseRequest
|
|
217
|
+
response = await this._baseRequest(url, options);
|
|
363
218
|
break;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
219
|
+
}
|
|
220
|
+
catch (responseError) {
|
|
221
|
+
if (requestTime === retry ||
|
|
367
222
|
!responseError ||
|
|
368
|
-
responseError.error !== 'unreachable'
|
|
369
|
-
) {
|
|
223
|
+
responseError.error !== 'unreachable') {
|
|
370
224
|
return Promise.reject(responseError);
|
|
371
225
|
}
|
|
372
226
|
}
|
|
@@ -374,21 +228,18 @@ export class OAuth2Client implements AuthClient {
|
|
|
374
228
|
}
|
|
375
229
|
return response;
|
|
376
230
|
}
|
|
377
|
-
|
|
378
231
|
/**
|
|
379
232
|
* Check retry value.
|
|
380
233
|
* @param {number} retry
|
|
381
234
|
* @return {number}
|
|
382
235
|
*/
|
|
383
|
-
|
|
384
|
-
let responseError
|
|
385
|
-
if (
|
|
386
|
-
typeof retry !== 'number' ||
|
|
236
|
+
_checkRetry(retry) {
|
|
237
|
+
let responseError = null;
|
|
238
|
+
if (typeof retry !== 'number' ||
|
|
387
239
|
retry < OAuth2Client._minRetry ||
|
|
388
|
-
retry > OAuth2Client._maxRetry
|
|
389
|
-
) {
|
|
240
|
+
retry > OAuth2Client._maxRetry) {
|
|
390
241
|
responseError = {
|
|
391
|
-
error: ErrorType.UNREACHABLE,
|
|
242
|
+
error: consts_1.ErrorType.UNREACHABLE,
|
|
392
243
|
error_description: 'wrong options param: retry',
|
|
393
244
|
};
|
|
394
245
|
}
|
|
@@ -397,52 +248,49 @@ export class OAuth2Client implements AuthClient {
|
|
|
397
248
|
}
|
|
398
249
|
return retry;
|
|
399
250
|
}
|
|
400
|
-
|
|
401
251
|
/**
|
|
402
252
|
* Format retry value.
|
|
403
253
|
* @param {number} retry
|
|
404
254
|
* @param {number} defaultVale
|
|
405
255
|
* @return {number}
|
|
406
256
|
*/
|
|
407
|
-
|
|
257
|
+
_formatRetry(retry, defaultVale) {
|
|
408
258
|
if (typeof retry === 'undefined') {
|
|
409
259
|
return defaultVale;
|
|
410
|
-
}
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
411
262
|
return this._checkRetry(retry);
|
|
412
263
|
}
|
|
413
264
|
}
|
|
414
|
-
|
|
415
265
|
/**
|
|
416
266
|
* Sleep.
|
|
417
267
|
* @param {number} ms
|
|
418
268
|
* @return {Promise<void>}
|
|
419
269
|
*/
|
|
420
|
-
|
|
421
|
-
return new Promise
|
|
270
|
+
async _sleep(ms) {
|
|
271
|
+
return new Promise((resolve) => {
|
|
422
272
|
setTimeout(() => {
|
|
423
273
|
resolve();
|
|
424
274
|
}, ms);
|
|
425
275
|
});
|
|
426
276
|
}
|
|
427
|
-
|
|
428
277
|
/**
|
|
429
278
|
* Refresh expired token.
|
|
430
279
|
* @param {Credentials} credentials
|
|
431
280
|
* @return {Promise<Credentials>}
|
|
432
281
|
*/
|
|
433
|
-
|
|
282
|
+
async _refreshToken(credentials) {
|
|
434
283
|
return this._singlePromise.run('_refreshToken', async () => {
|
|
435
284
|
if (!credentials || !credentials.refresh_token) {
|
|
436
285
|
return this._unAuthenticatedError('no refresh token found in credentials');
|
|
437
286
|
}
|
|
438
287
|
try {
|
|
439
|
-
const newCredentials
|
|
440
|
-
credentials.refresh_token,
|
|
441
|
-
);
|
|
288
|
+
const newCredentials = await this._refreshTokenFunc(credentials.refresh_token);
|
|
442
289
|
await this._localCredentials.setCredentials(newCredentials);
|
|
443
|
-
return newCredentials
|
|
444
|
-
}
|
|
445
|
-
|
|
290
|
+
return newCredentials;
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
if (error.error === consts_1.ErrorType.INVALID_GRANT) {
|
|
446
294
|
await this._localCredentials.setCredentials(null);
|
|
447
295
|
return this._unAuthenticatedError(error.error_description);
|
|
448
296
|
}
|
|
@@ -450,29 +298,27 @@ export class OAuth2Client implements AuthClient {
|
|
|
450
298
|
}
|
|
451
299
|
});
|
|
452
300
|
}
|
|
453
|
-
|
|
454
301
|
/**
|
|
455
302
|
* anonymous signIn
|
|
456
303
|
* @param {Credentials} credentials
|
|
457
304
|
* @return {Promise<Credentials>}
|
|
458
305
|
*/
|
|
459
|
-
|
|
306
|
+
async _anonymousSignIn(credentials) {
|
|
460
307
|
return this._singlePromise.run('_anonymous', async () => {
|
|
461
308
|
if (!credentials || credentials.scope !== 'anonymous') {
|
|
462
309
|
return this._unAuthenticatedError('no anonymous in credentials');
|
|
463
310
|
}
|
|
464
311
|
try {
|
|
465
|
-
const newCredentials
|
|
312
|
+
const newCredentials = await this.request('/auth/v1/signin/anonymously', {
|
|
466
313
|
method: 'POST',
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
client_secret: this._clientSecret,
|
|
470
|
-
},
|
|
314
|
+
withBasicAuth: true,
|
|
315
|
+
body: {}
|
|
471
316
|
});
|
|
472
317
|
await this._localCredentials.setCredentials(newCredentials);
|
|
473
|
-
return newCredentials
|
|
474
|
-
}
|
|
475
|
-
|
|
318
|
+
return newCredentials;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
if (error.error === consts_1.ErrorType.INVALID_GRANT) {
|
|
476
322
|
await this._localCredentials.setCredentials(null);
|
|
477
323
|
return this._unAuthenticatedError(error.error_description);
|
|
478
324
|
}
|
|
@@ -480,58 +326,54 @@ export class OAuth2Client implements AuthClient {
|
|
|
480
326
|
}
|
|
481
327
|
});
|
|
482
328
|
}
|
|
483
|
-
|
|
484
329
|
/**
|
|
485
330
|
* Default refresh token function.
|
|
486
331
|
* @param {string} refreshToken
|
|
487
332
|
* @return {Promise<Credentials>}
|
|
488
333
|
*/
|
|
489
|
-
|
|
490
|
-
refreshToken?: string,
|
|
491
|
-
): Promise<Credentials> {
|
|
334
|
+
_defaultRefreshTokenFunc(refreshToken) {
|
|
492
335
|
if (refreshToken === undefined || refreshToken === '') {
|
|
493
336
|
return this._unAuthenticatedError('refresh token not found');
|
|
494
337
|
}
|
|
495
338
|
return this.request('/auth/v1/token', {
|
|
496
339
|
method: 'POST',
|
|
340
|
+
withBasicAuth: true,
|
|
497
341
|
body: {
|
|
498
|
-
client_id: this._clientId,
|
|
499
|
-
client_secret: this._clientSecret,
|
|
500
342
|
grant_type: 'refresh_token',
|
|
501
343
|
refresh_token: refreshToken,
|
|
502
344
|
},
|
|
503
345
|
});
|
|
504
346
|
}
|
|
505
|
-
|
|
506
347
|
/**
|
|
507
348
|
* Get credentials.
|
|
508
349
|
*/
|
|
509
|
-
|
|
510
|
-
let credentials
|
|
350
|
+
async _getCredentials() {
|
|
351
|
+
let credentials = await this._localCredentials.getCredentials();
|
|
352
|
+
if (credentials == null) {
|
|
353
|
+
return this._unAuthenticatedError("credentials not found");
|
|
354
|
+
}
|
|
511
355
|
if (isCredentialsExpired(credentials)) {
|
|
512
356
|
if (credentials && credentials.scope === 'anonymous') {
|
|
513
|
-
credentials = await this.
|
|
514
|
-
}
|
|
357
|
+
credentials = await this._anonymousSignIn(credentials);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
515
360
|
credentials = await this._refreshToken(credentials);
|
|
516
361
|
}
|
|
517
362
|
}
|
|
518
363
|
return credentials;
|
|
519
364
|
}
|
|
520
|
-
|
|
521
365
|
/**
|
|
522
366
|
* Get deviceId
|
|
523
367
|
*/
|
|
524
|
-
|
|
368
|
+
async _getDeviceId() {
|
|
525
369
|
if (this._deviceID) {
|
|
526
370
|
return this._deviceID;
|
|
527
371
|
}
|
|
528
|
-
let deviceId
|
|
529
|
-
DeviceIdSectionName,
|
|
530
|
-
);
|
|
372
|
+
let deviceId = await this._storage.getItem(DeviceIdSectionName);
|
|
531
373
|
if (!(typeof deviceId === 'string' &&
|
|
532
374
|
deviceId.length >= 16 &&
|
|
533
375
|
deviceId.length <= 48)) {
|
|
534
|
-
deviceId = uuidv4();
|
|
376
|
+
deviceId = uuid_1.uuidv4();
|
|
535
377
|
await this._storage.setItem(DeviceIdSectionName, deviceId);
|
|
536
378
|
}
|
|
537
379
|
this._deviceID = deviceId;
|
|
@@ -542,10 +384,16 @@ export class OAuth2Client implements AuthClient {
|
|
|
542
384
|
* @param {string} err
|
|
543
385
|
* @return {Promise<T>}
|
|
544
386
|
*/
|
|
545
|
-
|
|
387
|
+
_unAuthenticatedError(err) {
|
|
546
388
|
return Promise.reject({
|
|
547
|
-
error: ErrorType.UNAUTHENTICATED,
|
|
389
|
+
error: consts_1.ErrorType.UNAUTHENTICATED,
|
|
548
390
|
error_description: err,
|
|
549
|
-
}
|
|
391
|
+
});
|
|
550
392
|
}
|
|
551
393
|
}
|
|
394
|
+
exports.OAuth2Client = OAuth2Client;
|
|
395
|
+
OAuth2Client._defaultRetry = 2;
|
|
396
|
+
OAuth2Client._minRetry = 0;
|
|
397
|
+
OAuth2Client._maxRetry = 5;
|
|
398
|
+
OAuth2Client._retryInterval = 1000;
|
|
399
|
+
//# sourceMappingURL=oauthclient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthclient.js","sourceRoot":"","sources":["../../src/oauthclient/oauthclient.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAYnC,wCAAqC;AAErC,4DAAsD;AAEtD,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAC3C,MAAM,kBAAkB,GAAG,aAAa,CAAC;AACzC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAUzB,QAAA,eAAe,GAAG,CAC3B,KAA4B,EAC5B,OAAgC,EACnB,EAAE;IACf,IAAI,aAA4B,CAAC;IACjC,MAAM,aAAa,GAA2B,OAAO,IAAI,EAAE,CAAC;IAC5D,IAAI,KAAK,YAAY,KAAK,EAAE;QACxB,aAAa,GAAG;YACZ,KAAK,EAAE,aAAa,CAAC,KAAK,IAAI,kBAAS,CAAC,KAAK;YAC7C,iBAAiB,EAAE,aAAa,CAAC,iBAAiB,IAAI,KAAK,CAAC,OAAO;YACnE,SAAS,EAAE,aAAa,CAAC,SAAS;YAClC,OAAO,EAAE,aAAa,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK;SAChD,CAAC;KACL;SAAM;QACH,MAAM,WAAW,GAA2B,KAAK,IAAI,EAAE,CAAC;QACxD,a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