@cloudbase/oauth 2.22.1 → 2.22.2

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.
Files changed (48) hide show
  1. package/dist/cjs/auth/apis.js +1 -1
  2. package/dist/cjs/captcha/captcha.js +1 -1
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/oauth2client/oauth2client.js +1 -1
  5. package/dist/cjs/utils/index.js +1 -1
  6. package/dist/cjs/utils/urlSearchParams.js +1 -1
  7. package/package.json +4 -4
  8. package/src/auth/apis.ts +8 -0
  9. package/src/captcha/captcha.ts +1 -0
  10. package/src/index.ts +1 -0
  11. package/src/oauth2client/oauth2client.ts +1 -0
  12. package/src/utils/index.ts +1 -0
  13. package/src/utils/urlSearchParams.ts +2 -0
  14. package/tsconfig.json +3 -1
  15. package/dist/esm/auth/apis.d.ts +0 -123
  16. package/dist/esm/auth/consts.d.ts +0 -110
  17. package/dist/esm/auth/models.d.ts +0 -542
  18. package/dist/esm/captcha/captcha.d.ts +0 -40
  19. package/dist/esm/index.d.ts +0 -13
  20. package/dist/esm/oauth2client/consts.d.ts +0 -20
  21. package/dist/esm/oauth2client/interface.d.ts +0 -15
  22. package/dist/esm/oauth2client/models.d.ts +0 -60
  23. package/dist/esm/oauth2client/oauth2client.d.ts +0 -71
  24. package/dist/esm/utils/base64.d.ts +0 -4
  25. package/dist/esm/utils/encrypt.d.ts +0 -4
  26. package/dist/esm/utils/encryptlong/index.d.ts +0 -546
  27. package/dist/esm/utils/function/single-promise.d.ts +0 -6
  28. package/dist/esm/utils/index.d.ts +0 -2
  29. package/dist/esm/utils/mp.d.ts +0 -2
  30. package/dist/esm/utils/urlSearchParams.d.ts +0 -13
  31. package/dist/esm/utils/uuid.d.ts +0 -1
  32. /package/dist/{cjs → types}/auth/apis.d.ts +0 -0
  33. /package/dist/{cjs → types}/auth/consts.d.ts +0 -0
  34. /package/dist/{cjs → types}/auth/models.d.ts +0 -0
  35. /package/dist/{cjs → types}/captcha/captcha.d.ts +0 -0
  36. /package/dist/{cjs → types}/index.d.ts +0 -0
  37. /package/dist/{cjs → types}/oauth2client/consts.d.ts +0 -0
  38. /package/dist/{cjs → types}/oauth2client/interface.d.ts +0 -0
  39. /package/dist/{cjs → types}/oauth2client/models.d.ts +0 -0
  40. /package/dist/{cjs → types}/oauth2client/oauth2client.d.ts +0 -0
  41. /package/dist/{cjs → types}/utils/base64.d.ts +0 -0
  42. /package/dist/{cjs → types}/utils/encrypt.d.ts +0 -0
  43. /package/dist/{cjs → types}/utils/encryptlong/index.d.ts +0 -0
  44. /package/dist/{cjs → types}/utils/function/single-promise.d.ts +0 -0
  45. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  46. /package/dist/{cjs → types}/utils/mp.d.ts +0 -0
  47. /package/dist/{cjs → types}/utils/urlSearchParams.d.ts +0 -0
  48. /package/dist/{cjs → types}/utils/uuid.d.ts +0 -0
@@ -1,20 +0,0 @@
1
- export { ErrorType } from '../auth/consts';
2
- export declare enum Syntax {
3
- CLIENT_ID = "client_id",
4
- CLIENT_SECRET = "client_secret",
5
- RESPONSE_TYPE = "response_type",
6
- SCOPE = "scope",
7
- STATE = "state",
8
- REDIRECT_URI = "redirect_uri",
9
- ERROR = "error",
10
- ERROR_DESCRIPTION = "error_description",
11
- ERROR_URI = "error_uri",
12
- GRANT_TYPE = "grant_type",
13
- CODE = "code",
14
- ACCESS_TOKEN = "access_token",
15
- TOKEN_TYPE = "token_type",
16
- EXPIRES_IN = "expires_in",
17
- USERNAME = "username",
18
- PASSWORD = "password",
19
- REFRESH_TOKEN = "refresh_token"
20
- }
@@ -1,15 +0,0 @@
1
- import { Credentials, AuthClientRequestOptions } from './models';
2
- export declare abstract class AuthClient {
3
- abstract request: RequestFunction;
4
- abstract setCredentials(credentials?: Credentials): void;
5
- abstract getAccessToken(): Promise<string>;
6
- }
7
- export type RequestFunction = <T>(url: string, options?: AuthClientRequestOptions) => Promise<T>;
8
- export interface SimpleStorage {
9
- getItem: (key: string) => Promise<string | null>;
10
- removeItem: (key: string) => Promise<void>;
11
- setItem: (key: string, value: string) => Promise<void>;
12
- getItemSync: (key: string) => string | null;
13
- removeItemSync: (key: string) => void;
14
- setItemSync: (key: string, value: string) => void;
15
- }
@@ -1,60 +0,0 @@
1
- import { SimpleStorage } from './interface';
2
- import { ErrorType } from './consts';
3
- import { AuthOptions } from '../auth/apis';
4
- import { ICloudbaseConfig } from '@cloudbase/types';
5
- export interface Credentials {
6
- token_type?: string | null;
7
- access_token?: string | null;
8
- refresh_token?: string | null;
9
- scope?: string | null;
10
- expires_in?: number | null;
11
- expires_at?: Date | null;
12
- sub?: string | null;
13
- groups?: string[] | null;
14
- version?: string;
15
- }
16
- export interface ResponseError {
17
- error: ErrorType;
18
- error_description?: string | null;
19
- error_uri?: string | null;
20
- details?: any | null;
21
- }
22
- export interface RequestOptions {
23
- body?: any | null;
24
- headers?: any | null;
25
- method?: string;
26
- [key: string]: any;
27
- }
28
- export type RequestFunction = <T>(url: string, options?: RequestOptions) => Promise<T>;
29
- export interface AuthClientRequestOptions extends RequestOptions {
30
- headers?: {
31
- 'x-request-id'?: string;
32
- [key: string]: any;
33
- } | null;
34
- withCredentials?: boolean;
35
- withBasicAuth?: boolean;
36
- retry?: number;
37
- useWxCloud?: boolean;
38
- [key: string]: any;
39
- }
40
- export interface OAuth2ClientOptions {
41
- devMode?: boolean;
42
- apiOrigin: string;
43
- apiPath?: string;
44
- clientId: string;
45
- env: string;
46
- retry?: number;
47
- baseRequest?: <T>(url: string, options?: RequestOptions) => Promise<T>;
48
- storage?: SimpleStorage;
49
- clientSecret?: string;
50
- refreshTokenFunc?: (refreshToken?: string) => Promise<Credentials>;
51
- tokenInURL?: boolean;
52
- headers?: {
53
- [key: string]: string;
54
- };
55
- anonymousSignInFunc?: (Credentials: any) => Promise<Credentials | void>;
56
- wxCloud?: any;
57
- onCredentialsError?: AuthOptions['onCredentialsError'];
58
- i18n?: ICloudbaseConfig['i18n'];
59
- useWxCloud?: boolean;
60
- }
@@ -1,71 +0,0 @@
1
- import { ErrorType } from './consts';
2
- import { AuthClient, SimpleStorage } from './interface';
3
- import { Credentials, ResponseError, RequestOptions, RequestFunction, OAuth2ClientOptions, AuthClientRequestOptions } from './models';
4
- export interface ToResponseErrorOptions {
5
- error?: ErrorType;
6
- error_description?: string | null;
7
- error_uri?: string | null;
8
- details?: any | null;
9
- }
10
- export declare const defaultRequest: RequestFunction;
11
- export declare const toResponseError: (error: ResponseError | Error, options?: ToResponseErrorOptions) => ResponseError;
12
- export declare function generateRequestId(): string;
13
- declare class DefaultStorage implements SimpleStorage {
14
- private readonly _env;
15
- constructor(opts?: {
16
- env: string;
17
- });
18
- getItem(key: string): Promise<string | null>;
19
- removeItem(key: string): Promise<void>;
20
- setItem(key: string, value: string): Promise<void>;
21
- getItemSync(key: string): string | null;
22
- removeItemSync(key: string): void;
23
- setItemSync(key: string, value: string): void;
24
- }
25
- export declare const defaultStorage: DefaultStorage;
26
- export declare class OAuth2Client implements AuthClient {
27
- private static defaultRetry;
28
- private static minRetry;
29
- private static maxRetry;
30
- private static retryInterval;
31
- private apiOrigin;
32
- private apiPath;
33
- private clientId;
34
- private i18n;
35
- private retry;
36
- private clientSecret?;
37
- private baseRequest;
38
- private localCredentials;
39
- private storage;
40
- private deviceID?;
41
- private tokenInURL?;
42
- private refreshTokenFunc;
43
- private headers?;
44
- private singlePromise;
45
- private anonymousSignInFunc;
46
- private wxCloud;
47
- private useWxCloud;
48
- private basicAuth;
49
- private onCredentialsError;
50
- constructor(options: OAuth2ClientOptions);
51
- setCredentials(credentials?: Credentials): Promise<void>;
52
- setAccessKeyCredentials(credentials?: Credentials): void;
53
- getAccessToken(): Promise<string>;
54
- request<T>(url: string, options?: AuthClientRequestOptions): Promise<T>;
55
- wxCloudCallFunction<T>(url: string, options?: RequestOptions): Promise<T>;
56
- getCredentials(): Promise<Credentials | null>;
57
- getCredentialsSync(): Credentials | null;
58
- getCredentialsAsync(): Promise<Credentials | null>;
59
- getScope(): Promise<string>;
60
- getGroups(): Promise<string[]>;
61
- refreshToken(credentials: Credentials): Promise<Credentials>;
62
- private anonymousLogin;
63
- private checkRetry;
64
- private formatRetry;
65
- private sleep;
66
- private anonymousSignIn;
67
- private defaultRefreshTokenFunc;
68
- private getDeviceId;
69
- private unAuthenticatedError;
70
- }
71
- export {};
@@ -1,4 +0,0 @@
1
- export declare function weBtoa(string: string): string;
2
- export declare const weAtob: (string: string) => string;
3
- export declare function base64_url_decode(str: string): string;
4
- export declare function weappJwtDecode(token: string, options?: any): any;
@@ -1,4 +0,0 @@
1
- export declare const getEncryptInfo: ({ publicKey, payload }?: {
2
- publicKey?: string;
3
- payload?: any;
4
- }) => any;