@cloudbase/oauth 2.5.39-beta.0 → 2.5.41-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.39-beta.0",
3
+ "version": "2.5.41-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": "3b38f0f9222b02585f8918b150a82f5c230e9b49"
24
+ "gitHead": "e8513caf4d4c69629977296f3a977e831bddd314"
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'
@@ -56,6 +57,7 @@ export interface AuthOptions {
56
57
  clientId: string;
57
58
  credentialsClient?: OAuth2Client;
58
59
  request?: RequestFunction;
60
+ baseRequest?: RequestFunction;
59
61
  storage?: SimpleStorage;
60
62
  anonymousSignInFunc?: (Credentials) => Promise<Credentials | void>;
61
63
  }
@@ -758,4 +760,17 @@ export class Auth {
758
760
  public_key_thumbprint,
759
761
  }
760
762
  }
763
+
764
+ /**
765
+ * get provider sub type
766
+ * @returns
767
+ */
768
+ public async getProviderSubType(): Promise<ProviderSubType> {
769
+ return this.config.request<ProviderSubType>(ApiUrls.GET_PROVIDER_TYPE, {
770
+ method: 'POST',
771
+ body: {
772
+ provider_id: 'weda',
773
+ },
774
+ })
775
+ }
761
776
  }
@@ -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
+ }
package/src/index.ts CHANGED
@@ -33,12 +33,12 @@ export class CloudbaseOAuth {
33
33
  public authApi: Auth
34
34
 
35
35
  constructor(authOptions: AuthOptions) {
36
- const { apiOrigin, clientId, storage, request, anonymousSignInFunc } = authOptions
36
+ const { apiOrigin, clientId, storage, request, baseRequest, anonymousSignInFunc } = authOptions
37
37
  this.oauth2client = new OAuth2Client({
38
38
  apiOrigin,
39
39
  clientId,
40
40
  storage,
41
- baseRequest: request,
41
+ baseRequest: baseRequest || request,
42
42
  anonymousSignInFunc,
43
43
  })
44
44
 
@@ -1,4 +1,4 @@
1
- import JSEncrypt from 'encryptlong'
1
+ import JSEncrypt from './encryptlong'
2
2
  // import HmacSHA256 from 'crypto-js/hmac-sha256'
3
3
  // import WordArray from 'crypto-js/lib-typedarrays'
4
4
  import { deepClone } from '.'