@pubinfo-pr/module-auth 0.203.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 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
- * @param id 唯一值
5
- * @param options 登录时需要传递的参数
6
- */
7
- export declare function signIn(id: ThirdParty, options?: Recordable): Promise<any>;
8
- /**
9
- * 生成二维码
10
- * @param id 第三方的唯一值
11
- * @param options 生成二维码需要传递的参数
12
- * @param options.id `getElementById`中指定的`id`
13
- */
14
- export declare function renderQRCode(id: ThirdParty, options: {
15
- id: string;
16
- } & Recordable): void;
17
- /**
18
- * 认证
19
- * @param id 第三方的唯一值
20
- */
21
- export declare function authenticate(id: ThirdParty): Promise<any>;
22
- /**
23
- * 重定向至统一登录页
24
- */
25
- export declare function redirect(): void;
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, ThirdParty } from './interface';
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
- import type { ModuleOptions } from 'pubinfo-pr';
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 { authenticate, redirect, renderQRCode, signIn, } from './core';
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;