@cloudbase/oauth 2.5.38-beta.0 → 2.5.40-beta.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/oauth",
3
- "version": "2.5.38-beta.0",
3
+ "version": "2.5.40-beta.0",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -21,5 +21,5 @@
21
21
  "encryptlong": "^3.1.4"
22
22
  },
23
23
  "license": "Apache-2.0",
24
- "gitHead": "4ed39f8929f3b129f4a25cefdbe9dfcbf4bd523f"
24
+ "gitHead": "fdd47542ba93aa05a9a917b2b3cee8e6d5d04c66"
25
25
  }
package/src/auth/apis.ts CHANGED
@@ -43,6 +43,7 @@ import {
43
43
  WithSudoRequest,
44
44
  PublicKey,
45
45
  EncryptParams,
46
+ ProviderSubType,
46
47
  } from './models'
47
48
  import { SimpleStorage, RequestFunction } from '../oauth2client/interface'
48
49
  import { OAuth2Client, defaultStorage } from '../oauth2client/oauth2client'
@@ -758,4 +759,17 @@ export class Auth {
758
759
  public_key_thumbprint,
759
760
  }
760
761
  }
762
+
763
+ /**
764
+ * get provider sub type
765
+ * @returns
766
+ */
767
+ public async getProviderSubType(): Promise<ProviderSubType> {
768
+ return this.config.request<ProviderSubType>(ApiUrls.GET_PROVIDER_TYPE, {
769
+ method: 'POST',
770
+ body: {
771
+ provider_id: 'weda',
772
+ },
773
+ })
774
+ }
761
775
  }
@@ -24,7 +24,8 @@ export enum ApiUrls {
24
24
  AUTH_RESET_PASSWORD = '/auth/v1/reset',
25
25
  AUTH_GET_DEVICE_CODE = '/auth/v1/device/code',
26
26
  CHECK_USERNAME = '/auth/v1/checkUsername',
27
- CHECK_IF_USER_EXIST = '/auth/v1/checkIfUserExist'
27
+ CHECK_IF_USER_EXIST = '/auth/v1/checkIfUserExist',
28
+ GET_PROVIDER_TYPE = '/auth/v1/mgr/provider/providerSubType'
28
29
  }
29
30
 
30
31
  export enum ApiUrlsV2 {
@@ -464,3 +464,8 @@ export interface EncryptParams {
464
464
  public_key_thumbprint?: string; // 加密的公钥指纹
465
465
  params?: string; // 加密的数据
466
466
  }
467
+
468
+ export interface ProviderSubType {
469
+ id: string;
470
+ provider_sub_type: 'NO_AUTH_LOGIN' | ''; // NO_AUTH_LOGIN-免密登录
471
+ }
@@ -1,6 +1,6 @@
1
- import JSEncrypt from 'encryptlong'
2
- import HmacSHA256 from 'crypto-js/hmac-sha256'
3
- import WordArray from 'crypto-js/lib-typedarrays'
1
+ import JSEncrypt from './encryptlong'
2
+ // import HmacSHA256 from 'crypto-js/hmac-sha256'
3
+ // import WordArray from 'crypto-js/lib-typedarrays'
4
4
  import { deepClone } from '.'
5
5
 
6
6
  /**
@@ -19,17 +19,17 @@ export const getEncryptInfo = ({ publicKey = '', payload = {} } = {}) => {
19
19
  // 设置公钥
20
20
  rsaInstance.setPublicKey(publicKey)
21
21
  // 生成时间戳
22
- params.timestamp = +new Date()
22
+ // params.timestamp = +new Date()
23
23
  // 确定签名算法
24
- const signMethod = 'HmacSHA256'
24
+ // const signMethod = 'HmacSHA256'
25
25
  // 生成随机数
26
- const nonce = WordArray.random(16).toString()
26
+ // const nonce = WordArray.random(16).toString()
27
27
  // 生成签名:基本参数、时间戳 + 随机数
28
- const signature = HmacSHA256(JSON.stringify(params), nonce).toString()
28
+ // const signature = HmacSHA256(JSON.stringify(params), nonce).toString()
29
29
  // 将签名放入参数中
30
- params.signature = signature
31
- params.nonce = nonce
32
- params.signMethod = signMethod
30
+ // params.signature = signature
31
+ // params.nonce = nonce
32
+ // params.signMethod = signMethod
33
33
  // rsa公钥加密
34
34
  const encrypted = rsaInstance.encryptLong(JSON.stringify(params))
35
35