@pubinfo-pr/module-auth 0.200.1 → 0.203.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.
- package/dist/auth.d.ts +9 -0
- package/dist/core.d.ts +43 -25
- package/dist/helper.d.ts +1 -6
- package/dist/index.d.ts +20 -4
- package/dist/index.js +151 -101
- package/dist/interface.d.ts +17 -6
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/two-factor.d.ts +16 -0
- package/dist/plugins.js +27 -0
- package/dist/providers/default-credentials.d.ts +11 -0
- package/dist/providers/default-credentials.js +14 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +7 -0
- package/dist/providers.js +6 -0
- package/package.json +11 -3
- package/src/auth.ts +141 -0
- package/src/components/RedirectLogin/index.ts +3 -4
- package/src/core.ts +143 -64
- package/src/helper.ts +1 -15
- package/src/index.ts +23 -75
- package/src/interface.ts +19 -6
- package/src/plugins/index.ts +1 -0
- package/src/plugins/two-factor.ts +49 -0
- package/src/providers/default-credentials.ts +29 -0
- package/src/providers/index.ts +5 -0
- package/dist/context.d.ts +0 -2
- package/src/context.ts +0 -4
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModuleOptions } from 'pubinfo-pr';
|
|
2
|
+
import type { AuthClient as AuthClientInstance } from './core';
|
|
3
|
+
import type { AuthOptions, CreateAuthModule, PluginOptions } from './interface';
|
|
4
|
+
export declare const AuthClient: AuthClientInstance;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated 请使用 `createAuthModule` 和 `createAuth` 替换
|
|
7
|
+
*/
|
|
8
|
+
export declare function auth<Plugins extends PluginOptions[]>(options: AuthOptions<Plugins>): ModuleOptions;
|
|
9
|
+
export declare function createAuthModule(authClient: AuthClientInstance, options?: CreateAuthModule): ModuleOptions;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
|
-
import type { Recordable, ThirdParty } from './interface';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import type { PluginOptions, ProviderOptions, Recordable, ThirdParty } from './interface';
|
|
2
|
+
export interface CreateAuthOptions<Plugins extends PluginOptions[]> {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
providers?: ProviderOptions[];
|
|
5
|
+
plugins?: Plugins;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthClient {
|
|
8
|
+
/**
|
|
9
|
+
* 前往登录
|
|
10
|
+
* @param id 唯一值
|
|
11
|
+
* @param options 登录时需要传递的参数
|
|
12
|
+
*/
|
|
13
|
+
signIn: (id: ThirdParty, options?: Recordable) => Promise<any> | any;
|
|
14
|
+
/**
|
|
15
|
+
* 生成二维码
|
|
16
|
+
* @param id 第三方的唯一值
|
|
17
|
+
* @param options 生成二维码需要传递的参数
|
|
18
|
+
* @param options.id `getElementById`中指定的`id`
|
|
19
|
+
*/
|
|
20
|
+
renderQRCode: (id: ThirdParty, options: {
|
|
21
|
+
id: string;
|
|
22
|
+
} & Recordable) => void;
|
|
23
|
+
/**
|
|
24
|
+
* 认证
|
|
25
|
+
* @param id 第三方的唯一值
|
|
26
|
+
*/
|
|
27
|
+
authenticate: (id: ThirdParty) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* 重定向至统一登录页
|
|
30
|
+
*/
|
|
31
|
+
redirect: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* 获取指定的 `Provider`
|
|
34
|
+
* @param id
|
|
35
|
+
*/
|
|
36
|
+
getProvider: (id?: ThirdParty) => ProviderOptions;
|
|
37
|
+
}
|
|
38
|
+
type UnionToIntersection<U> = (U extends any ? (x: U) => any : never) extends (x: infer I) => any ? I : never;
|
|
39
|
+
type PluginExtend<P extends PluginOptions[]> = UnionToIntersection<{
|
|
40
|
+
[K in keyof P]: P[K] extends PluginOptions<infer E> ? E : never;
|
|
41
|
+
}[number]>;
|
|
42
|
+
export declare function createAuth<Plugins extends PluginOptions[]>(options: CreateAuthOptions<Plugins>): AuthClient & PluginExtend<Plugins>;
|
|
43
|
+
export {};
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { ProviderUserOptions, Recordable
|
|
2
|
-
/**
|
|
3
|
-
* 获取指定的 `Provider`
|
|
4
|
-
* @param id
|
|
5
|
-
*/
|
|
6
|
-
export declare function getProvider(id?: ThirdParty): import("./interface").ProviderOptions;
|
|
1
|
+
import type { ProviderUserOptions, Recordable } from './interface';
|
|
7
2
|
/**
|
|
8
3
|
* 构建第三方授权登录地址
|
|
9
4
|
* @param provider
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import type { AuthOptions } from './interface';
|
|
3
|
-
export declare function auth(options: AuthOptions): ModuleOptions;
|
|
1
|
+
export * from './auth';
|
|
4
2
|
export { LoginWithFourA } from './components/LoginWithFourA';
|
|
5
|
-
export {
|
|
3
|
+
export { createAuth } from './core';
|
|
6
4
|
export * from './interface';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated 认证, 请使用 `AuthClient.authenticate` 方法替代
|
|
7
|
+
*/
|
|
8
|
+
export declare const authenticate: (id: import("./interface").ThirdParty) => Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated 重定向至统一登录页, 请使用 `AuthClient.redirect` 方法替代
|
|
11
|
+
*/
|
|
12
|
+
export declare const redirect: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated 生成二维码, 请使用 `AuthClient.renderQRCode` 方法替代
|
|
15
|
+
*/
|
|
16
|
+
export declare const renderQRCode: (id: import("./interface").ThirdParty, options: {
|
|
17
|
+
id: string;
|
|
18
|
+
} & import("./interface").Recordable) => void;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated 前往登录, 请使用 `AuthClient.signIn` 方法替代
|
|
21
|
+
*/
|
|
22
|
+
export declare const signIn: (id: import("./interface").ThirdParty, options?: import("./interface").Recordable) => Promise<any> | any;
|