@cloudbase/oauth 3.0.0 → 3.0.1
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/dist/cjs/auth/apis.d.ts +22 -4
- package/dist/cjs/auth/apis.js +255 -66
- package/dist/cjs/auth/auth-error.d.ts +6 -0
- package/dist/cjs/auth/auth-error.js +32 -0
- package/dist/cjs/auth/consts.d.ts +22 -0
- package/dist/cjs/auth/consts.js +24 -2
- package/dist/cjs/auth/models.d.ts +13 -4
- package/dist/cjs/auth/models.js +1 -1
- package/dist/cjs/captcha/captcha-dom.d.ts +3 -0
- package/dist/cjs/captcha/captcha-dom.js +223 -0
- package/dist/cjs/captcha/captcha.d.ts +3 -1
- package/dist/cjs/captcha/captcha.js +11 -102
- package/dist/cjs/index.d.ts +12 -2
- package/dist/cjs/index.js +27 -4
- package/dist/cjs/oauth2client/interface.d.ts +1 -1
- package/dist/cjs/oauth2client/interface.js +1 -1
- package/dist/cjs/oauth2client/models.d.ts +15 -1
- package/dist/cjs/oauth2client/models.js +1 -1
- package/dist/cjs/oauth2client/oauth2client.d.ts +62 -3
- package/dist/cjs/oauth2client/oauth2client.js +426 -131
- package/dist/cjs/utils/base64.d.ts +5 -0
- package/dist/cjs/utils/base64.js +15 -2
- package/dist/cjs/utils/encryptlong/index.js +22 -16
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/mp.js +4 -4
- package/dist/cjs/utils/urlSearchParams.js +1 -1
- package/dist/esm/auth/apis.d.ts +22 -4
- package/dist/esm/auth/apis.js +130 -10
- package/dist/esm/auth/auth-error.d.ts +6 -0
- package/dist/esm/auth/auth-error.js +9 -0
- package/dist/esm/auth/consts.d.ts +22 -0
- package/dist/esm/auth/consts.js +22 -0
- package/dist/esm/auth/models.d.ts +13 -4
- package/dist/esm/captcha/captcha-dom.d.ts +3 -0
- package/dist/esm/captcha/captcha-dom.js +129 -0
- package/dist/esm/captcha/captcha.d.ts +3 -1
- package/dist/esm/captcha/captcha.js +14 -97
- package/dist/esm/index.d.ts +12 -2
- package/dist/esm/index.js +20 -3
- package/dist/esm/oauth2client/interface.d.ts +1 -1
- package/dist/esm/oauth2client/models.d.ts +15 -1
- package/dist/esm/oauth2client/oauth2client.d.ts +62 -3
- package/dist/esm/oauth2client/oauth2client.js +200 -55
- package/dist/esm/utils/base64.d.ts +5 -0
- package/dist/esm/utils/base64.js +12 -0
- package/dist/esm/utils/encryptlong/index.js +21 -15
- package/dist/esm/utils/mp.js +3 -3
- package/dist/miniprogram/index.js +1 -1
- package/package.json +10 -4
- package/src/auth/apis.ts +222 -17
- package/src/auth/auth-error.ts +21 -0
- package/src/auth/consts.ts +28 -0
- package/src/auth/models.ts +13 -4
- package/src/captcha/captcha-dom.ts +178 -0
- package/src/captcha/captcha.ts +25 -114
- package/src/index.ts +54 -4
- package/src/oauth2client/interface.ts +1 -1
- package/src/oauth2client/models.ts +29 -1
- package/src/oauth2client/oauth2client.ts +308 -55
- package/src/utils/base64.ts +12 -0
- package/src/utils/encryptlong/index.js +20 -14
- package/src/utils/index.ts +1 -0
- package/src/utils/mp.ts +3 -3
- package/src/utils/urlSearchParams.ts +2 -0
- package/tsconfig.json +1 -0
- package/dist/cjs/utils/cloudbase-adapter-wx_mp.d.ts +0 -1
- package/dist/cjs/utils/cloudbase-adapter-wx_mp.js +0 -40
- package/dist/esm/utils/cloudbase-adapter-wx_mp.d.ts +0 -1
- package/dist/esm/utils/cloudbase-adapter-wx_mp.js +0 -35
- package/src/utils/cloudbase-adapter-wx_mp.ts +0 -42
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SimpleStorage, RequestFunction } from '../oauth2client/interface';
|
|
2
2
|
import { AuthClientRequestOptions } from '../oauth2client/models';
|
|
3
3
|
import { SDKAdapterInterface } from '@cloudbase/adapter-interface';
|
|
4
|
+
import { Auth } from '../auth/apis';
|
|
4
5
|
export interface CaptchaOptions {
|
|
6
|
+
env: string;
|
|
5
7
|
clientId: string;
|
|
6
8
|
request: RequestFunction;
|
|
7
9
|
storage: SimpleStorage;
|
|
@@ -9,6 +11,7 @@ export interface CaptchaOptions {
|
|
|
9
11
|
adapter?: SDKAdapterInterface & {
|
|
10
12
|
isMatch?: () => boolean;
|
|
11
13
|
};
|
|
14
|
+
oauthInstance?: Auth;
|
|
12
15
|
}
|
|
13
16
|
type OpenURIWithCallbackFuction = (url: string) => Promise<CaptchaToken>;
|
|
14
17
|
export interface CaptchaToken {
|
|
@@ -31,7 +34,6 @@ export declare class Captcha {
|
|
|
31
34
|
isMatch(): boolean;
|
|
32
35
|
request<T>(url: string, options?: CaptchaRequestOptions): Promise<T>;
|
|
33
36
|
private getDefaultOpenURIWithCallback;
|
|
34
|
-
private defaultOpenURIWithCallback;
|
|
35
37
|
private getCaptchaToken;
|
|
36
38
|
private appendCaptchaTokenToURL;
|
|
37
39
|
private saveCaptchaToken;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiUrls, ErrorType } from '../auth/consts';
|
|
2
2
|
import { defaultStorage } from '../oauth2client/oauth2client';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { isMp } from '../utils/mp';
|
|
4
|
+
import { openURIWithCallback } from './captcha-dom';
|
|
5
5
|
export class Captcha {
|
|
6
6
|
constructor(opts) {
|
|
7
7
|
if (!opts.openURIWithCallback) {
|
|
@@ -11,7 +11,7 @@ export class Captcha {
|
|
|
11
11
|
opts.storage = defaultStorage;
|
|
12
12
|
}
|
|
13
13
|
this.config = opts;
|
|
14
|
-
this.tokenSectionName = `captcha_${opts.clientId}`;
|
|
14
|
+
this.tokenSectionName = `captcha_${opts.clientId || opts.env}`;
|
|
15
15
|
}
|
|
16
16
|
isMatch() {
|
|
17
17
|
return this.config?.adapter?.isMatch?.() || isMp();
|
|
@@ -42,65 +42,7 @@ export class Captcha {
|
|
|
42
42
|
return resp;
|
|
43
43
|
}
|
|
44
44
|
getDefaultOpenURIWithCallback() {
|
|
45
|
-
|
|
46
|
-
if (window.location.search.indexOf('__captcha') > 0) {
|
|
47
|
-
document.body.style.display = 'none';
|
|
48
|
-
}
|
|
49
|
-
if (document.getElementById('captcha_panel_wrap') === null) {
|
|
50
|
-
const elementDiv = document.createElement('div');
|
|
51
|
-
elementDiv.style.cssText = 'background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;';
|
|
52
|
-
elementDiv.setAttribute('id', 'captcha_panel_wrap');
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
document.body.appendChild(elementDiv);
|
|
55
|
-
}, 0);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return this.defaultOpenURIWithCallback;
|
|
59
|
-
}
|
|
60
|
-
async defaultOpenURIWithCallback(url, opts) {
|
|
61
|
-
const { width = '355px', height = '355px' } = opts || {};
|
|
62
|
-
const matched = url.match(/^(data:.*)$/);
|
|
63
|
-
if (matched) {
|
|
64
|
-
return Promise.reject({
|
|
65
|
-
error: ErrorType.UNIMPLEMENTED,
|
|
66
|
-
error_description: 'need to impl captcha data',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const target = document.getElementById('captcha_panel_wrap');
|
|
70
|
-
const iframe = document.createElement('iframe');
|
|
71
|
-
target.innerHTML = '';
|
|
72
|
-
iframe.setAttribute('src', url);
|
|
73
|
-
iframe.setAttribute('id', 'review-panel-iframe');
|
|
74
|
-
iframe.style.cssText = `min-width:${width};display:block;height:${height};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`;
|
|
75
|
-
target.appendChild(iframe);
|
|
76
|
-
target.style.display = 'block';
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
iframe.onload = function () {
|
|
79
|
-
try {
|
|
80
|
-
const windowLocation = window.location;
|
|
81
|
-
const iframeLocation = iframe.contentWindow.location;
|
|
82
|
-
if (iframeLocation.host + iframeLocation.pathname === windowLocation.host + windowLocation.pathname) {
|
|
83
|
-
target.style.display = 'none';
|
|
84
|
-
const iframeUrlParams = new MyURLSearchParams(iframeLocation.search);
|
|
85
|
-
const captchToken = iframeUrlParams.get('captcha_token');
|
|
86
|
-
if (captchToken) {
|
|
87
|
-
return resolve({
|
|
88
|
-
captcha_token: captchToken,
|
|
89
|
-
expires_in: Number(iframeUrlParams.get('expires_in')),
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return reject({
|
|
93
|
-
error: iframeUrlParams.get('error'),
|
|
94
|
-
error_description: iframeUrlParams.get('error_description'),
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
target.style.display = 'block';
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
target.style.display = 'block';
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
});
|
|
45
|
+
return (url) => openURIWithCallback(url, this.config.oauthInstance);
|
|
104
46
|
}
|
|
105
47
|
async getCaptchaToken(forceNewToken, state) {
|
|
106
48
|
if (!forceNewToken) {
|
|
@@ -109,41 +51,16 @@ export class Captcha {
|
|
|
109
51
|
return captchaToken;
|
|
110
52
|
}
|
|
111
53
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
withCredentials: false,
|
|
123
|
-
});
|
|
124
|
-
if (captchaTokenResp.captcha_token) {
|
|
125
|
-
const captchaToken = {
|
|
126
|
-
captcha_token: captchaTokenResp.captcha_token,
|
|
127
|
-
expires_in: captchaTokenResp.expires_in,
|
|
128
|
-
};
|
|
129
|
-
this.saveCaptchaToken(captchaToken);
|
|
130
|
-
return captchaTokenResp.captcha_token;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const captchaDataResp = await this.config.request(ApiUrls.CAPTCHA_DATA_URL, {
|
|
135
|
-
method: 'POST',
|
|
136
|
-
body: {
|
|
137
|
-
state,
|
|
138
|
-
redirect_uri: '',
|
|
139
|
-
},
|
|
140
|
-
withCredentials: false,
|
|
141
|
-
});
|
|
142
|
-
captchaTokenResp = {
|
|
143
|
-
url: `${captchaDataResp.data}?state=${encodeURIComponent(state)}&token=${encodeURIComponent(captchaDataResp.token)}`,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
const captchaToken = await this.config.openURIWithCallback(captchaTokenResp.url);
|
|
54
|
+
const captchaDataResp = await this.config.request(ApiUrls.CAPTCHA_DATA_URL, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
body: {
|
|
57
|
+
state,
|
|
58
|
+
redirect_uri: '',
|
|
59
|
+
},
|
|
60
|
+
withCredentials: false,
|
|
61
|
+
});
|
|
62
|
+
const captchaTokenUrl = `${captchaDataResp.data}?state=${encodeURIComponent(state)}&token=${encodeURIComponent(captchaDataResp.token)}`;
|
|
63
|
+
const captchaToken = await this.config.openURIWithCallback(captchaTokenUrl);
|
|
147
64
|
this.saveCaptchaToken(captchaToken);
|
|
148
65
|
return captchaToken.captcha_token;
|
|
149
66
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { OAuth2Client } from './oauth2client/oauth2client';
|
|
2
2
|
import { AuthOptions, Auth } from './auth/apis';
|
|
3
|
+
import { Credentials } from './oauth2client/models';
|
|
3
4
|
export { Auth } from './auth/apis';
|
|
4
|
-
export { AUTH_API_PREFIX } from './auth/consts';
|
|
5
|
+
export { AUTH_API_PREFIX, OAUTH_TYPE } from './auth/consts';
|
|
6
|
+
export { AuthError } from './auth/auth-error';
|
|
5
7
|
export * as authModels from './auth/models';
|
|
6
|
-
export type { ProviderProfile } from './auth/models';
|
|
8
|
+
export type { ProviderProfile, UserInfo, ModifyUserBasicInfoRequest } from './auth/models';
|
|
7
9
|
export type { Credentials, OAuth2ClientOptions, ResponseError, AuthClientRequestOptions } from './oauth2client/models';
|
|
8
10
|
export type { AuthOptions } from './auth/apis';
|
|
11
|
+
export { weAppJwtDecodeAll } from './utils/base64';
|
|
12
|
+
export { LOGIN_STATE_CHANGED_TYPE, EVENTS, AUTH_STATE_CHANGED_TYPE } from './auth/consts';
|
|
9
13
|
export declare class CloudbaseOAuth {
|
|
10
14
|
oauth2client: OAuth2Client;
|
|
11
15
|
authApi: Auth;
|
|
16
|
+
private detectSessionInUrl;
|
|
12
17
|
constructor(authOptions: AuthOptions);
|
|
18
|
+
initializeSession(onUserObtained?: (data: {
|
|
19
|
+
session: Credentials;
|
|
20
|
+
user?: any;
|
|
21
|
+
type?: string;
|
|
22
|
+
}, error?: any) => void | Promise<void>): void;
|
|
13
23
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,12 +2,16 @@ import { OAuth2Client } from './oauth2client/oauth2client';
|
|
|
2
2
|
import { Auth } from './auth/apis';
|
|
3
3
|
import { AUTH_API_PREFIX } from './auth/consts';
|
|
4
4
|
export { Auth } from './auth/apis';
|
|
5
|
-
export { AUTH_API_PREFIX } from './auth/consts';
|
|
5
|
+
export { AUTH_API_PREFIX, OAUTH_TYPE } from './auth/consts';
|
|
6
|
+
export { AuthError } from './auth/auth-error';
|
|
6
7
|
import * as authModels_1 from './auth/models';
|
|
7
8
|
export { authModels_1 as authModels };
|
|
9
|
+
export { weAppJwtDecodeAll } from './utils/base64';
|
|
10
|
+
export { LOGIN_STATE_CHANGED_TYPE, EVENTS, AUTH_STATE_CHANGED_TYPE } from './auth/consts';
|
|
8
11
|
export class CloudbaseOAuth {
|
|
9
12
|
constructor(authOptions) {
|
|
10
|
-
const { apiOrigin, apiPath = AUTH_API_PREFIX, clientId, env, storage, request, baseRequest, anonymousSignInFunc, wxCloud, adapter, onCredentialsError, headers, i18n,
|
|
13
|
+
const { apiOrigin, apiPath = AUTH_API_PREFIX, clientId, env, storage, request, baseRequest, anonymousSignInFunc, wxCloud, adapter, onCredentialsError, headers, i18n, useWxCloud, eventBus, detectSessionInUrl, debug, } = authOptions;
|
|
14
|
+
this.detectSessionInUrl = detectSessionInUrl ?? false;
|
|
11
15
|
this.oauth2client = new OAuth2Client({
|
|
12
16
|
apiOrigin,
|
|
13
17
|
apiPath,
|
|
@@ -20,7 +24,9 @@ export class CloudbaseOAuth {
|
|
|
20
24
|
onCredentialsError,
|
|
21
25
|
headers: headers || {},
|
|
22
26
|
i18n,
|
|
23
|
-
|
|
27
|
+
useWxCloud,
|
|
28
|
+
eventBus,
|
|
29
|
+
debug,
|
|
24
30
|
});
|
|
25
31
|
this.authApi = new Auth({
|
|
26
32
|
credentialsClient: this.oauth2client,
|
|
@@ -28,5 +34,16 @@ export class CloudbaseOAuth {
|
|
|
28
34
|
request: request ? this.oauth2client.request.bind(this.oauth2client) : undefined,
|
|
29
35
|
adapter,
|
|
30
36
|
});
|
|
37
|
+
if (detectSessionInUrl) {
|
|
38
|
+
this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
initializeSession(onUserObtained) {
|
|
42
|
+
if (!this.detectSessionInUrl) {
|
|
43
|
+
this.oauth2client.initialize(Promise.resolve({ error: null }));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.oauth2client.setOnInitialSessionObtained(onUserObtained);
|
|
47
|
+
this.oauth2client.initialize();
|
|
31
48
|
}
|
|
32
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Credentials, AuthClientRequestOptions } from './models';
|
|
2
2
|
export declare abstract class AuthClient {
|
|
3
3
|
abstract request: RequestFunction;
|
|
4
|
-
abstract setCredentials(credentials?: Credentials): void
|
|
4
|
+
abstract setCredentials(credentials?: Credentials): Promise<void>;
|
|
5
5
|
abstract getAccessToken(): Promise<string>;
|
|
6
6
|
}
|
|
7
7
|
export type RequestFunction = <T>(url: string, options?: AuthClientRequestOptions) => Promise<T>;
|
|
@@ -35,6 +35,7 @@ export interface AuthClientRequestOptions extends RequestOptions {
|
|
|
35
35
|
withBasicAuth?: boolean;
|
|
36
36
|
retry?: number;
|
|
37
37
|
useWxCloud?: boolean;
|
|
38
|
+
getCredentials?: () => Credentials | Promise<Credentials | null> | null;
|
|
38
39
|
[key: string]: any;
|
|
39
40
|
}
|
|
40
41
|
export interface OAuth2ClientOptions {
|
|
@@ -56,5 +57,18 @@ export interface OAuth2ClientOptions {
|
|
|
56
57
|
wxCloud?: any;
|
|
57
58
|
onCredentialsError?: AuthOptions['onCredentialsError'];
|
|
58
59
|
i18n?: ICloudbaseConfig['i18n'];
|
|
59
|
-
|
|
60
|
+
useWxCloud?: boolean;
|
|
61
|
+
eventBus?: any;
|
|
62
|
+
debug?: boolean;
|
|
63
|
+
getInitialSession?: () => Promise<{
|
|
64
|
+
data: {
|
|
65
|
+
session: Credentials;
|
|
66
|
+
user?: any;
|
|
67
|
+
} | null;
|
|
68
|
+
error: Error | null;
|
|
69
|
+
}>;
|
|
70
|
+
onInitialSessionObtained?: (data: {
|
|
71
|
+
session: Credentials;
|
|
72
|
+
user?: any;
|
|
73
|
+
}) => void | Promise<void>;
|
|
60
74
|
}
|
|
@@ -23,11 +23,45 @@ declare class DefaultStorage implements SimpleStorage {
|
|
|
23
23
|
setItemSync(key: string, value: string): void;
|
|
24
24
|
}
|
|
25
25
|
export declare const defaultStorage: DefaultStorage;
|
|
26
|
+
interface LocalCredentialsOptions {
|
|
27
|
+
tokenSectionName: string;
|
|
28
|
+
storage: SimpleStorage;
|
|
29
|
+
clientId: string;
|
|
30
|
+
credentials?: Credentials;
|
|
31
|
+
}
|
|
32
|
+
declare class LocalCredentials {
|
|
33
|
+
private tokenSectionName;
|
|
34
|
+
private storage;
|
|
35
|
+
private clientId;
|
|
36
|
+
private credentials;
|
|
37
|
+
private accessKeyCredentials;
|
|
38
|
+
private singlePromise;
|
|
39
|
+
constructor(options: LocalCredentialsOptions);
|
|
40
|
+
getStorageCredentialsSync(): Credentials | null;
|
|
41
|
+
setCredentials(credentials?: Credentials): Promise<void>;
|
|
42
|
+
setAccessKeyCredentials(credentials?: Credentials): void;
|
|
43
|
+
getCredentials(): Promise<Credentials | null>;
|
|
44
|
+
private getStorageCredentials;
|
|
45
|
+
}
|
|
26
46
|
export declare class OAuth2Client implements AuthClient {
|
|
27
47
|
private static defaultRetry;
|
|
28
48
|
private static minRetry;
|
|
29
49
|
private static maxRetry;
|
|
30
50
|
private static retryInterval;
|
|
51
|
+
localCredentials: LocalCredentials;
|
|
52
|
+
initializePromise: Promise<{
|
|
53
|
+
error: Error | null;
|
|
54
|
+
}> | null;
|
|
55
|
+
protected lockAcquired: boolean;
|
|
56
|
+
protected pendingInLock: Promise<any>[];
|
|
57
|
+
protected logDebugMessages: boolean;
|
|
58
|
+
protected getInitialSession?: () => Promise<{
|
|
59
|
+
data: {
|
|
60
|
+
session: Credentials;
|
|
61
|
+
user?: any;
|
|
62
|
+
} | null;
|
|
63
|
+
error: Error | null;
|
|
64
|
+
}>;
|
|
31
65
|
private apiOrigin;
|
|
32
66
|
private apiPath;
|
|
33
67
|
private clientId;
|
|
@@ -35,7 +69,6 @@ export declare class OAuth2Client implements AuthClient {
|
|
|
35
69
|
private retry;
|
|
36
70
|
private clientSecret?;
|
|
37
71
|
private baseRequest;
|
|
38
|
-
private localCredentials;
|
|
39
72
|
private storage;
|
|
40
73
|
private deviceID?;
|
|
41
74
|
private tokenInURL?;
|
|
@@ -44,11 +77,30 @@ export declare class OAuth2Client implements AuthClient {
|
|
|
44
77
|
private singlePromise;
|
|
45
78
|
private anonymousSignInFunc;
|
|
46
79
|
private wxCloud;
|
|
80
|
+
private useWxCloud;
|
|
81
|
+
private eventBus;
|
|
47
82
|
private basicAuth;
|
|
48
83
|
private onCredentialsError;
|
|
49
|
-
private
|
|
84
|
+
private onInitialSessionObtained?;
|
|
50
85
|
constructor(options: OAuth2ClientOptions);
|
|
86
|
+
setGetInitialSession(callback: () => Promise<{
|
|
87
|
+
data: {
|
|
88
|
+
session: Credentials;
|
|
89
|
+
user?: any;
|
|
90
|
+
} | null;
|
|
91
|
+
error: Error | null;
|
|
92
|
+
}>): void;
|
|
93
|
+
setOnInitialSessionObtained(callback: (data: {
|
|
94
|
+
session: Credentials;
|
|
95
|
+
user?: any;
|
|
96
|
+
}) => void | Promise<void>): void;
|
|
97
|
+
initialize(func?: Promise<{
|
|
98
|
+
error: Error | null;
|
|
99
|
+
}>): Promise<{
|
|
100
|
+
error: Error | null;
|
|
101
|
+
}>;
|
|
51
102
|
setCredentials(credentials?: Credentials): Promise<void>;
|
|
103
|
+
setAccessKeyCredentials(credentials?: Credentials): void;
|
|
52
104
|
getAccessToken(): Promise<string>;
|
|
53
105
|
request<T>(url: string, options?: AuthClientRequestOptions): Promise<T>;
|
|
54
106
|
wxCloudCallFunction<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
@@ -57,7 +109,10 @@ export declare class OAuth2Client implements AuthClient {
|
|
|
57
109
|
getCredentialsAsync(): Promise<Credentials | null>;
|
|
58
110
|
getScope(): Promise<string>;
|
|
59
111
|
getGroups(): Promise<string[]>;
|
|
60
|
-
refreshToken(credentials: Credentials
|
|
112
|
+
refreshToken(credentials: Credentials, options?: {
|
|
113
|
+
throwError?: boolean;
|
|
114
|
+
}): Promise<Credentials>;
|
|
115
|
+
private _refreshToken;
|
|
61
116
|
private anonymousLogin;
|
|
62
117
|
private checkRetry;
|
|
63
118
|
private formatRetry;
|
|
@@ -66,5 +121,9 @@ export declare class OAuth2Client implements AuthClient {
|
|
|
66
121
|
private defaultRefreshTokenFunc;
|
|
67
122
|
private getDeviceId;
|
|
68
123
|
private unAuthenticatedError;
|
|
124
|
+
private _debug;
|
|
125
|
+
private _initialize;
|
|
126
|
+
private _acquireLock;
|
|
127
|
+
private _getCredentials;
|
|
69
128
|
}
|
|
70
129
|
export {};
|