@cloudbase/auth 1.7.3-alpha.0 → 1.8.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/.eslintrc.js +13 -0
- package/dist/cjs/constants.d.ts +0 -1
- package/dist/cjs/constants.js +2 -3
- package/dist/cjs/index.d.ts +9 -13
- package/dist/cjs/index.js +120 -198
- package/dist/cjs/providers/anonymousAuthProvider.js +25 -23
- package/dist/cjs/providers/base.d.ts +1 -2
- package/dist/cjs/providers/base.js +12 -6
- package/dist/cjs/providers/customAuthProvider.js +15 -14
- package/dist/cjs/providers/emailAuthProvider.js +27 -29
- package/dist/cjs/providers/phoneAuthProvider.js +22 -24
- package/dist/cjs/providers/usernameAuthProvider.js +17 -17
- package/dist/cjs/providers/weixinAuthProvider.js +31 -30
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +1 -2
- package/dist/esm/index.d.ts +9 -13
- package/dist/esm/index.js +121 -199
- package/dist/esm/providers/anonymousAuthProvider.js +25 -23
- package/dist/esm/providers/base.d.ts +1 -2
- package/dist/esm/providers/base.js +12 -6
- package/dist/esm/providers/customAuthProvider.js +15 -14
- package/dist/esm/providers/emailAuthProvider.js +27 -29
- package/dist/esm/providers/phoneAuthProvider.js +22 -24
- package/dist/esm/providers/usernameAuthProvider.js +17 -17
- package/dist/esm/providers/weixinAuthProvider.js +31 -30
- package/package.json +8 -12
- package/src/constants.ts +0 -2
- package/src/index.ts +128 -245
- package/src/providers/anonymousAuthProvider.ts +15 -18
- package/src/providers/base.ts +7 -20
- package/src/providers/customAuthProvider.ts +12 -15
- package/src/providers/emailAuthProvider.ts +21 -24
- package/src/providers/phoneAuthProvider.ts +22 -23
- package/src/providers/usernameAuthProvider.ts +10 -11
- package/src/providers/weixinAuthProvider.ts +45 -46
- package/tsconfig.esm.json +2 -19
- package/tsconfig.json +2 -19
- package/.eslintrc +0 -30
- package/dist/cjs/common.d.ts +0 -8
- package/dist/cjs/common.js +0 -64
- package/dist/cjs/providers/oauth2AuthProvider.d.ts +0 -61
- package/dist/cjs/providers/oauth2AuthProvider.js +0 -404
- package/dist/esm/common.d.ts +0 -8
- package/dist/esm/common.js +0 -61
- package/dist/esm/providers/oauth2AuthProvider.d.ts +0 -61
- package/dist/esm/providers/oauth2AuthProvider.js +0 -401
- package/src/common.ts +0 -21
- package/src/providers/oauth2AuthProvider.ts +0 -585
|
@@ -2,7 +2,7 @@ import { AuthProvider } from './base';
|
|
|
2
2
|
import { ICloudbaseAuthConfig } from '@cloudbase/types/auth';
|
|
3
3
|
import { ICloudbaseCache } from '@cloudbase/types/cache';
|
|
4
4
|
import { ICloudbaseRequest } from '@cloudbase/types/request';
|
|
5
|
-
import { constants, adapters,utils, helpers } from '@cloudbase/utilities/';
|
|
5
|
+
import { constants, adapters, utils, helpers } from '@cloudbase/utilities/';
|
|
6
6
|
import { eventBus, EVENTS, LoginState } from '..';
|
|
7
7
|
import { LOGINTYPE } from '../constants';
|
|
8
8
|
|
|
@@ -15,9 +15,9 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
15
15
|
private readonly _scope: string;
|
|
16
16
|
private readonly _state: string;
|
|
17
17
|
private readonly _appid: string;
|
|
18
|
-
private readonly _runtime:string;
|
|
18
|
+
private readonly _runtime: string;
|
|
19
19
|
|
|
20
|
-
constructor(config: ICloudbaseAuthConfig&{cache:ICloudbaseCache,request:ICloudbaseRequest,runtime:string}, appid: string, scope: string, state?: string) {
|
|
20
|
+
constructor(config: ICloudbaseAuthConfig&{cache: ICloudbaseCache, request: ICloudbaseRequest, runtime: string}, appid: string, scope: string, state?: string) {
|
|
21
21
|
super(config);
|
|
22
22
|
|
|
23
23
|
this._runtime = config.runtime;
|
|
@@ -25,17 +25,17 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
25
25
|
this._scope = scope;
|
|
26
26
|
this._state = state || 'weixin';
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
public async signIn(){
|
|
30
|
-
return printWarn(ERRORS.OPERATION_FAIL,'API signIn has been deprecated, please use signInWithRedirect insteed');
|
|
28
|
+
|
|
29
|
+
public async signIn() {
|
|
30
|
+
return printWarn(ERRORS.OPERATION_FAIL, 'API signIn has been deprecated, please use signInWithRedirect insteed');
|
|
31
31
|
}
|
|
32
32
|
@catchErrorsDecorator({
|
|
33
33
|
title: '跳转微信公众号授权失败',
|
|
34
34
|
messages: [
|
|
35
35
|
'请确认以下各项:',
|
|
36
36
|
' 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确',
|
|
37
|
-
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}
|
|
38
|
-
]
|
|
37
|
+
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}`,
|
|
38
|
+
],
|
|
39
39
|
})
|
|
40
40
|
public async signInWithRedirect() {
|
|
41
41
|
return this._redirect();
|
|
@@ -47,15 +47,15 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
47
47
|
' 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确',
|
|
48
48
|
' 2 - 当前环境是否开通了微信公众号登录授权',
|
|
49
49
|
' 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确',
|
|
50
|
-
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}
|
|
51
|
-
]
|
|
50
|
+
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}`,
|
|
51
|
+
],
|
|
52
52
|
})
|
|
53
|
-
public async getRedirectResult(options:{ withUnionId?: boolean; syncUserInfo?: boolean }) {
|
|
53
|
+
public async getRedirectResult(options: { withUnionId?: boolean; syncUserInfo?: boolean }) {
|
|
54
54
|
const code = getWeixinCode();
|
|
55
55
|
if (!code) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
|
-
return this._signInWithCode(code,options);
|
|
58
|
+
return this._signInWithCode(code, options);
|
|
59
59
|
}
|
|
60
60
|
@catchErrorsDecorator({
|
|
61
61
|
title: '获取微信重定向绑定结果',
|
|
@@ -64,8 +64,8 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
64
64
|
' 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确',
|
|
65
65
|
' 2 - 当前环境是否开通了微信公众号登录授权',
|
|
66
66
|
' 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确',
|
|
67
|
-
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}
|
|
68
|
-
]
|
|
67
|
+
`如果问题依然存在,建议到官方问答社区提问或寻找帮助:${COMMUNITY_SITE_URL}`,
|
|
68
|
+
],
|
|
69
69
|
})
|
|
70
70
|
async getLinkRedirectResult(options: { withUnionId?: boolean } = {}) {
|
|
71
71
|
const { withUnionId = false } = options;
|
|
@@ -74,7 +74,7 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
const { _appid: appid } = this;
|
|
77
|
-
const loginType = (scope => {
|
|
77
|
+
const loginType = ((scope) => {
|
|
78
78
|
switch (scope) {
|
|
79
79
|
case 'snsapi_login':
|
|
80
80
|
return 'WECHAT-OPEN';
|
|
@@ -83,14 +83,14 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
83
83
|
}
|
|
84
84
|
})(this._scope);
|
|
85
85
|
const hybridMiniapp = this._runtime === RUNTIME.WX_MP ? '1' : '0';
|
|
86
|
-
return this._request.send('auth.linkWithWeixinCode', {
|
|
87
|
-
payload: {
|
|
88
|
-
appid,
|
|
89
|
-
loginType,
|
|
90
|
-
code,
|
|
91
|
-
hybridMiniapp,
|
|
92
|
-
withUnionId
|
|
93
|
-
}
|
|
86
|
+
return this._request.send('auth.linkWithWeixinCode', {
|
|
87
|
+
payload: {
|
|
88
|
+
appid,
|
|
89
|
+
loginType,
|
|
90
|
+
code,
|
|
91
|
+
hybridMiniapp,
|
|
92
|
+
withUnionId,
|
|
93
|
+
},
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -103,17 +103,17 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
103
103
|
if (this._scope === 'snsapi_login') {
|
|
104
104
|
host = '//open.weixin.qq.com/connect/qrconnect';
|
|
105
105
|
}
|
|
106
|
-
try{
|
|
106
|
+
try {
|
|
107
107
|
location.href = `${host}?appid=${this._appid}&redirect_uri=${currUrl}&response_type=code&scope=${this._scope}&state=${this._state}#wechat_redirect`;
|
|
108
|
-
}catch(e){
|
|
109
|
-
throw new Error(`[${getSdkName()}][${ERRORS.UNKOWN_ERROR}]${e}`)
|
|
108
|
+
} catch (e) {
|
|
109
|
+
throw new Error(`[${getSdkName()}][${ERRORS.UNKOWN_ERROR}]${e}`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
private async _signInWithCode(code:string,options) {
|
|
113
|
+
private async _signInWithCode(code: string, options) {
|
|
114
114
|
const { accessTokenKey, accessTokenExpireKey, refreshTokenKey } = this._cache.keys;
|
|
115
115
|
// 有code,用code换refresh token
|
|
116
|
-
const loginType = (scope => {
|
|
116
|
+
const loginType = ((scope) => {
|
|
117
117
|
switch (scope) {
|
|
118
118
|
case 'snsapi_login':
|
|
119
119
|
return 'WECHAT-OPEN';
|
|
@@ -122,7 +122,7 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
122
122
|
}
|
|
123
123
|
})(this._scope);
|
|
124
124
|
|
|
125
|
-
const refreshTokenRes = await this._getRefreshTokenByWXCode(this._appid, loginType, code,options);
|
|
125
|
+
const refreshTokenRes = await this._getRefreshTokenByWXCode(this._appid, loginType, code, options);
|
|
126
126
|
const { refreshToken } = refreshTokenRes;
|
|
127
127
|
|
|
128
128
|
// 本地存下
|
|
@@ -135,25 +135,25 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
135
135
|
}
|
|
136
136
|
eventBus.fire(EVENTS.LOGIN_STATE_CHANGED);
|
|
137
137
|
// 抛出登录类型更改事件
|
|
138
|
-
eventBus.fire(EVENTS.LOGIN_TYPE_CHANGED, {
|
|
138
|
+
eventBus.fire(EVENTS.LOGIN_TYPE_CHANGED, {
|
|
139
139
|
env: this._config.env,
|
|
140
|
-
loginType: LOGINTYPE.WECHAT,
|
|
141
|
-
persistence: this._config.persistence
|
|
140
|
+
loginType: LOGINTYPE.WECHAT,
|
|
141
|
+
persistence: this._config.persistence,
|
|
142
142
|
});
|
|
143
143
|
await this.refreshUserInfo();
|
|
144
144
|
const loginState = new LoginState({
|
|
145
145
|
envId: this._config.env,
|
|
146
146
|
cache: this._cache,
|
|
147
|
-
request: this._request
|
|
147
|
+
request: this._request,
|
|
148
148
|
});
|
|
149
149
|
await loginState.checkLocalStateAsync();
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
return loginState;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
private async _getRefreshTokenByWXCode(
|
|
155
|
-
appid: string,
|
|
156
|
-
loginType: string,
|
|
155
|
+
appid: string,
|
|
156
|
+
loginType: string,
|
|
157
157
|
code: string,
|
|
158
158
|
options: any = {}
|
|
159
159
|
): Promise<{ refreshToken: string; accessToken: string; accessTokenExpire: number }> {
|
|
@@ -163,15 +163,15 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
163
163
|
|
|
164
164
|
const action = 'auth.signIn';
|
|
165
165
|
const hybridMiniapp = this._runtime === RUNTIME.WX_MP ? '1' : '0';
|
|
166
|
-
return this._request.send(action, {
|
|
167
|
-
appid,
|
|
168
|
-
loginType,
|
|
166
|
+
return this._request.send(action, {
|
|
167
|
+
appid,
|
|
168
|
+
loginType,
|
|
169
169
|
hybridMiniapp,
|
|
170
170
|
syncUserInfo,
|
|
171
171
|
loginCredential: code,
|
|
172
172
|
withUnionId,
|
|
173
|
-
createUser
|
|
174
|
-
}).then(res => {
|
|
173
|
+
createUser,
|
|
174
|
+
}).then((res) => {
|
|
175
175
|
if (res.code) {
|
|
176
176
|
throw new Error(`[${getSdkName()}][${ERRORS.OPERATION_FAIL}] failed login via wechat: ${res.code}`);
|
|
177
177
|
}
|
|
@@ -179,15 +179,14 @@ export class WeixinAuthProvider extends AuthProvider {
|
|
|
179
179
|
return {
|
|
180
180
|
refreshToken: res.refresh_token,
|
|
181
181
|
accessToken: res.access_token,
|
|
182
|
-
accessTokenExpire: res.access_token_expire
|
|
182
|
+
accessTokenExpire: res.access_token_expire,
|
|
183
183
|
};
|
|
184
|
-
} else {
|
|
185
|
-
throw new Error(`[${getSdkName()}][${ERRORS.OPERATION_FAIL}] action:getJwt not return refreshToken`);
|
|
186
184
|
}
|
|
185
|
+
throw new Error(`[${getSdkName()}][${ERRORS.OPERATION_FAIL}] action:getJwt not return refreshToken`);
|
|
187
186
|
});
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
function getWeixinCode
|
|
190
|
+
function getWeixinCode() {
|
|
192
191
|
return getQuery('code') || getHash('code');
|
|
193
|
-
}
|
|
192
|
+
}
|
package/tsconfig.esm.json
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"emitDecoratorMetadata": true,
|
|
9
4
|
"module": "es6",
|
|
10
|
-
"noFallthroughCasesInSwitch": true,
|
|
11
|
-
"noUnusedLocals": true,
|
|
12
|
-
"noUnusedParameters": true,
|
|
13
5
|
"outDir": "dist/esm",
|
|
14
6
|
"rootDir": "src",
|
|
15
|
-
"pretty": true,
|
|
16
|
-
"removeComments": true,
|
|
17
|
-
"inlineSourceMap": true,
|
|
18
|
-
"inlineSources": true,
|
|
19
|
-
"skipLibCheck": true,
|
|
20
|
-
"strictBindCallApply": true,
|
|
21
|
-
"target": "es5",
|
|
22
|
-
"moduleResolution": "node",
|
|
23
|
-
"lib": ["es2015", "dom"]
|
|
24
7
|
},
|
|
25
8
|
"include": [
|
|
26
9
|
"src/**/*.ts",
|
|
@@ -30,4 +13,4 @@
|
|
|
30
13
|
"node_modules",
|
|
31
14
|
"dist"
|
|
32
15
|
]
|
|
33
|
-
}
|
|
16
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"emitDecoratorMetadata": true,
|
|
9
4
|
"module": "commonjs",
|
|
10
|
-
"noFallthroughCasesInSwitch": true,
|
|
11
|
-
"noUnusedLocals": true,
|
|
12
|
-
"noUnusedParameters": true,
|
|
13
5
|
"outDir": "dist/cjs",
|
|
14
6
|
"rootDir": "src",
|
|
15
|
-
"pretty": true,
|
|
16
|
-
"removeComments": true,
|
|
17
|
-
"inlineSourceMap": true,
|
|
18
|
-
"inlineSources": true,
|
|
19
|
-
"skipLibCheck": true,
|
|
20
|
-
"strictBindCallApply": true,
|
|
21
|
-
"target": "es5",
|
|
22
|
-
"moduleResolution": "node",
|
|
23
|
-
"lib": ["es2015", "dom"]
|
|
24
7
|
},
|
|
25
8
|
"include": [
|
|
26
9
|
"src/**/*.ts",
|
|
@@ -30,4 +13,4 @@
|
|
|
30
13
|
"node_modules",
|
|
31
14
|
"dist"
|
|
32
15
|
]
|
|
33
|
-
}
|
|
16
|
+
}
|
package/.eslintrc
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"eslint-config-alloy/typescript"
|
|
4
|
-
],
|
|
5
|
-
"rules": {
|
|
6
|
-
"indent": [
|
|
7
|
-
"error",
|
|
8
|
-
2,
|
|
9
|
-
{
|
|
10
|
-
"SwitchCase": 1,
|
|
11
|
-
"flatTernaryExpressions": true
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"guard-for-in": 0,
|
|
15
|
-
"no-param-reassign": 0,
|
|
16
|
-
"no-undefined": 0,
|
|
17
|
-
"@typescript-eslint/explicit-member-accessibility": 0,
|
|
18
|
-
"@typescript-eslint/no-loss-of-precision": 0,
|
|
19
|
-
"@typescript-eslint/no-invalid-this": 0,
|
|
20
|
-
"@typescript-eslint/no-duplicate-imports": 0,
|
|
21
|
-
"@typescript-eslint/member-ordering": 0
|
|
22
|
-
},
|
|
23
|
-
"parserOptions": {
|
|
24
|
-
"ecmaVersion": 6,
|
|
25
|
-
"sourceType": "module",
|
|
26
|
-
"ecmaFeatures": {
|
|
27
|
-
"modules": true
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
package/dist/cjs/common.d.ts
DELETED
package/dist/cjs/common.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.checkFromAuthV2 = void 0;
|
|
40
|
-
exports.checkFromAuthV2 = function (_fromApp) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
-
var oauthInstance, oauthLogin, _a;
|
|
42
|
-
return __generator(this, function (_b) {
|
|
43
|
-
switch (_b.label) {
|
|
44
|
-
case 0:
|
|
45
|
-
oauthInstance = _fromApp.oauthInstance || _fromApp.oauth();
|
|
46
|
-
_a = oauthInstance;
|
|
47
|
-
if (!_a) return [3, 2];
|
|
48
|
-
return [4, oauthInstance.hasLoginState()];
|
|
49
|
-
case 1:
|
|
50
|
-
_a = (_b.sent());
|
|
51
|
-
_b.label = 2;
|
|
52
|
-
case 2:
|
|
53
|
-
oauthLogin = _a;
|
|
54
|
-
if (oauthLogin) {
|
|
55
|
-
return [2, {
|
|
56
|
-
authType: 'oauth',
|
|
57
|
-
instance: oauthInstance
|
|
58
|
-
}];
|
|
59
|
-
}
|
|
60
|
-
return [2, {}];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); };
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFYSxRQUFBLGVBQWUsR0FBRyxVQUFPLFFBQW9COzs7OztnQkFFbEQsYUFBYSxHQUFHLFFBQVEsQ0FBQyxhQUFhLElBQUssUUFBZ0IsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtnQkFRdEQsS0FBQSxhQUFhLENBQUE7eUJBQWIsY0FBYTtnQkFBSSxXQUFNLGFBQWEsQ0FBQyxhQUFhLEVBQUUsRUFBQTs7c0JBQW5DLFNBQW1DOzs7Z0JBQWpFLFVBQVUsS0FBdUQ7Z0JBQ3ZFLElBQUksVUFBVSxFQUFFO29CQUNkLFdBQU87NEJBQ0wsUUFBUSxFQUFFLE9BQU87NEJBQ2pCLFFBQVEsRUFBRSxhQUFhO3lCQUN4QixFQUFBO2lCQUNGO2dCQUNELFdBQU8sRUFBRSxFQUFBOzs7S0FDVixDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgSUNsb3VkYmFzZSB9IGZyb20gJ0BjbG91ZGJhc2UvdHlwZXMnO1xuXG5leHBvcnQgY29uc3QgY2hlY2tGcm9tQXV0aFYyID0gYXN5bmMgKF9mcm9tQXBwOiBJQ2xvdWRiYXNlKSA9PiB7XG4gIC8vIGNvbnN0IGF1dGhJbnN0YW5jZSA9IF9mcm9tQXBwLmF1dGhJbnN0YW5jZVxuICBjb25zdCBvYXV0aEluc3RhbmNlID0gX2Zyb21BcHAub2F1dGhJbnN0YW5jZSB8fCAoX2Zyb21BcHAgYXMgYW55KS5vYXV0aCgpXG4gIC8vIGNvbnN0IGF1dGhMb2dpbiA9IGF1dGhJbnN0YW5jZSAmJiBhd2FpdCBhdXRoSW5zdGFuY2UuZ2V0TG9naW5TdGF0ZSgpXG4gIC8vIGlmIChhdXRoTG9naW4pIHtcbiAgLy8gICByZXR1cm4ge1xuICAvLyAgICAgYXV0aFR5cGU6ICdhdXRoJyxcbiAgLy8gICAgIGluc3RhbmNlOiBhdXRoSW5zdGFuY2VcbiAgLy8gICB9XG4gIC8vIH1cbiAgY29uc3Qgb2F1dGhMb2dpbiA9IG9hdXRoSW5zdGFuY2UgJiYgYXdhaXQgb2F1dGhJbnN0YW5jZS5oYXNMb2dpblN0YXRlKClcbiAgaWYgKG9hdXRoTG9naW4pIHtcbiAgICByZXR1cm4ge1xuICAgICAgYXV0aFR5cGU6ICdvYXV0aCcsXG4gICAgICBpbnN0YW5jZTogb2F1dGhJbnN0YW5jZVxuICAgIH1cbiAgfVxuICByZXR1cm4ge31cbn0iXX0=
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { AuthProvider } from './base';
|
|
2
|
-
import { ICloudbaseAuthConfig } from '@cloudbase/types/auth';
|
|
3
|
-
import { ICloudbaseCache } from '@cloudbase/types/cache';
|
|
4
|
-
import { ICloudbaseRequest } from '@cloudbase/types/request';
|
|
5
|
-
import { LoginState } from '..';
|
|
6
|
-
interface IPrividerCallbackInfo {
|
|
7
|
-
href: string;
|
|
8
|
-
state: string;
|
|
9
|
-
token_type: string;
|
|
10
|
-
code?: string;
|
|
11
|
-
access_token?: string;
|
|
12
|
-
id_token?: string;
|
|
13
|
-
expires_in: number;
|
|
14
|
-
scope: string;
|
|
15
|
-
authuser: string;
|
|
16
|
-
prompt: string;
|
|
17
|
-
}
|
|
18
|
-
export interface IOAuth2AuthProviderOptions {
|
|
19
|
-
providerId?: string;
|
|
20
|
-
clientId?: string;
|
|
21
|
-
responseType?: string;
|
|
22
|
-
scope?: string;
|
|
23
|
-
redirectUri?: string;
|
|
24
|
-
syncProfile?: boolean;
|
|
25
|
-
forceDisableSignUp?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface ISignInWithPopupOptions {
|
|
28
|
-
popup?: {
|
|
29
|
-
target?: string;
|
|
30
|
-
features?: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export declare class OAuth2AuthProvider extends AuthProvider {
|
|
34
|
-
private providerId;
|
|
35
|
-
private clientId;
|
|
36
|
-
private responseType;
|
|
37
|
-
private scope;
|
|
38
|
-
private redirectUri;
|
|
39
|
-
private syncProfile;
|
|
40
|
-
private forceDisableSignUp;
|
|
41
|
-
private popupWindowUrl;
|
|
42
|
-
private popupWindowRef;
|
|
43
|
-
constructor(config: ICloudbaseAuthConfig & {
|
|
44
|
-
cache: ICloudbaseCache;
|
|
45
|
-
request: ICloudbaseRequest;
|
|
46
|
-
runtime: string;
|
|
47
|
-
}, options?: IOAuth2AuthProviderOptions);
|
|
48
|
-
signIn(): Promise<void>;
|
|
49
|
-
signInWithPopup(options?: ISignInWithPopupOptions): Promise<void>;
|
|
50
|
-
signInWithModal(elemId: string): Promise<void>;
|
|
51
|
-
private jumpToProviderPage;
|
|
52
|
-
private recvMessageFromPopup;
|
|
53
|
-
continueSignIn(callbackInfo?: IPrividerCallbackInfo): Promise<LoginState>;
|
|
54
|
-
private getAuthPrividerCallbackInfoFromUrl;
|
|
55
|
-
private fetchProviderRedirectURI;
|
|
56
|
-
private fetchProviderToken;
|
|
57
|
-
private signInWithProvider;
|
|
58
|
-
refreshUserInfo(): Promise<any>;
|
|
59
|
-
private fetch;
|
|
60
|
-
}
|
|
61
|
-
export {};
|