@cloudbase/auth 3.1.11 → 3.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/auth",
3
- "version": "3.1.11",
3
+ "version": "3.2.0",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
34
  "@cloudbase/adapter-wx_mp": "^1.3.1",
35
- "@cloudbase/oauth": "3.1.11",
36
- "@cloudbase/utilities": "3.1.11"
35
+ "@cloudbase/oauth": "3.2.0",
36
+ "@cloudbase/utilities": "3.2.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@cloudbase/types": "3.1.11",
39
+ "@cloudbase/types": "3.2.0",
40
40
  "@types/node": "^22.1.0",
41
41
  "terser-webpack-plugin": "^3.0.2",
42
42
  "webpack-bundle-analyzer": "^4.9.1"
43
43
  },
44
- "gitHead": "9663760a8d10c980aa3c9ae2c522190398c4ede3"
44
+ "gitHead": "55df54d2e1e0ec420b879d2b41b2df1f88164ad9"
45
45
  }
package/src/index.ts CHANGED
@@ -1454,49 +1454,13 @@ class Auth extends AuthV1Compat {
1454
1454
  * @param params
1455
1455
  * @returns Promise<SignInRes>
1456
1456
  */
1457
- // async signInWithPhoneAuth({ phoneCode = '', useWxCloud = false }): Promise<SignInRes> {
1458
- async signInWithPhoneAuth({ phoneCode = '' }): Promise<SignInRes> {
1459
- // if (!adapterForWxMp.isMatch()) {
1460
- // return { data: {}, error: new AuthError({ message: 'wx api undefined' }) }
1461
- // }
1462
- // const wxInfo = wx.getAccountInfoSync().miniProgram
1463
- // const providerInfo = {
1464
- // provider_params: { provider_code_type: 'phone', code: phoneCode, appid: wxInfo.appId },
1465
- // provider_id: wxInfo.appId,
1466
- // }
1467
-
1468
- // const { code } = await wx.login()
1469
- // ;(providerInfo as any).provider_code = code
1470
-
1471
- // try {
1472
- // const providerToken = await this.oauthInstance.authApi.grantProviderToken(providerInfo, useWxCloud)
1473
- // if (providerToken.error_code) {
1474
- // throw providerToken
1475
- // }
1476
-
1477
- // const signInRes = await this.oauthInstance.authApi.signInWithProvider({
1478
- // provider_token: providerToken.provider_token,
1479
- // }, useWxCloud)
1480
-
1481
- // if ((signInRes as any)?.error_code) {
1482
- // throw signInRes
1483
- // }
1484
- // } catch (error) {
1485
- // return { data: {}, error: new AuthError(error) }
1486
- // }
1487
-
1488
- // const loginState = await this.createLoginState()
1489
-
1490
- // const { data: { session } = {} } = await this.getSession()
1491
-
1492
- // // loginState返回是为了兼容v2版本
1493
- // return { ...(loginState as any), data: { user: session.user, session }, error: null }
1457
+ async signInWithPhoneAuth({ phoneCode = '', useWxCloud = false }): Promise<SignInRes> {
1494
1458
  if (!adapterForWxMp.isMatch()) {
1495
1459
  return { data: {}, error: new AuthError({ message: 'wx api undefined' }) }
1496
1460
  }
1497
1461
  const wxInfo = wx.getAccountInfoSync().miniProgram
1498
1462
  const providerInfo = {
1499
- provider_params: { provider_code_type: 'phone' },
1463
+ provider_params: { provider_code_type: 'phone', code: phoneCode, appid: wxInfo.appId },
1500
1464
  provider_id: wxInfo.appId,
1501
1465
  }
1502
1466
 
@@ -1504,26 +1468,14 @@ class Auth extends AuthV1Compat {
1504
1468
  ;(providerInfo as any).provider_code = code
1505
1469
 
1506
1470
  try {
1507
- let providerToken = await this.oauthInstance.authApi.grantProviderToken(providerInfo)
1508
- if (providerToken.error_code) {
1509
- throw providerToken
1510
- }
1511
-
1512
- providerToken = await this.oauthInstance.authApi.patchProviderToken({
1513
- provider_token: providerToken.provider_token,
1514
- provider_id: wxInfo.appId,
1515
- provider_params: {
1516
- code: phoneCode,
1517
- provider_code_type: 'phone',
1518
- },
1519
- })
1471
+ const providerToken = await this.oauthInstance.authApi.grantProviderToken(providerInfo, useWxCloud)
1520
1472
  if (providerToken.error_code) {
1521
1473
  throw providerToken
1522
1474
  }
1523
1475
 
1524
1476
  const signInRes = await this.oauthInstance.authApi.signInWithProvider({
1525
1477
  provider_token: providerToken.provider_token,
1526
- })
1478
+ }, useWxCloud)
1527
1479
 
1528
1480
  if ((signInRes as any)?.error_code) {
1529
1481
  throw signInRes