@authing/guard-shim-react18 5.0.8-alpha.1 → 5.0.8-alpha.3

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.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license React
3
+ * react-dom.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react.production.min.js
14
+ *
15
+ * Copyright (c) Facebook, Inc. and its affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * scheduler.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
@@ -0,0 +1,45 @@
1
+ import { GuardOptions, GuardEventsKebabToCamelType, StartWithRedirectOptions, AuthenticationClient, JwtTokenStatus, User, Lang } from './types';
2
+ import '@authing/react18-components/lib/index.min.css';
3
+ export * from './types';
4
+ export declare class Guard {
5
+ options: GuardOptions;
6
+ private visible;
7
+ private then;
8
+ private publicConfig?;
9
+ private root?;
10
+ constructor(options: GuardOptions);
11
+ private adaptOptions;
12
+ private getPublicConfig;
13
+ getAuthClient(): Promise<AuthenticationClient>;
14
+ static getGuardContainer(selector?: string | HTMLElement): Element | null;
15
+ private eventListeners;
16
+ /**
17
+ * 启动嵌入模式
18
+ * @param el String
19
+ * @returns Promise
20
+ */
21
+ start(el?: string): Promise<User>;
22
+ startRegister(): void;
23
+ checkLoginStatus(): Promise<JwtTokenStatus | undefined>;
24
+ changeLang(lang: Lang): void;
25
+ changeContentCSS(contentCSS: string): void;
26
+ /**
27
+ * 启动跳转模式
28
+ */
29
+ startWithRedirect(options?: StartWithRedirectOptions): Promise<void>;
30
+ handleRedirectCallback(): Promise<void>;
31
+ private getAccessTokenByCode;
32
+ private getCodeAndCodeChallenge;
33
+ private setStorageCache;
34
+ private parseUrlQuery;
35
+ /**
36
+ * 获取当前用户信息
37
+ */
38
+ trackSession(): Promise<User | null>;
39
+ logout(): Promise<void>;
40
+ render(): Promise<void>;
41
+ on<T extends keyof GuardEventsKebabToCamelType>(evt: T, handler: Exclude<GuardEventsKebabToCamelType[T], undefined>): void;
42
+ show(): void;
43
+ hide(): void;
44
+ unmount(): void;
45
+ }
@@ -0,0 +1,47 @@
1
+ import { GuardEventsKebabToCamelType, Lang, GuardProps, GuardLocalConfig, CodeAction, ApiCode, GuardModuleType, LoginMethods, OIDCConnectionMode, SocialConnectionProvider, Protocol, RegisterMethods, GuardMode, InputMethod, GuardPageSene, EmailScene, SceneType } from '@authing/react18-components';
2
+ export declare type ICodeAction = `${CodeAction}`;
3
+ export declare type IApiCode = `${ApiCode}`;
4
+ export declare type IGuardModuleType = `${GuardModuleType}`;
5
+ export declare type ILoginMethod = `${LoginMethods}`;
6
+ export declare type IOIDCConnectionMode = `${OIDCConnectionMode}`;
7
+ export declare type ISocialConnectionProvider = `${SocialConnectionProvider}`;
8
+ export declare type IProtocol = `${Protocol}`;
9
+ export declare type IRegisterMethod = `${RegisterMethods}`;
10
+ export declare type IGuardMode = `${GuardMode}`;
11
+ export declare type IInputMethod = `${InputMethod}`;
12
+ export declare type IGuardPageSene = `${GuardPageSene}`;
13
+ export declare type IEmailScene = `${EmailScene}`;
14
+ export declare type ISceneType = `${SceneType}`;
15
+ export declare type GuardEventListeners = {
16
+ [key in keyof GuardEventsKebabToCamelType]: Exclude<Required<GuardEventsKebabToCamelType>[key], undefined>[];
17
+ };
18
+ export declare type CodeChallengeMethod = 'S256' | 'plain';
19
+ export interface IGuardConfig extends GuardLocalConfig {
20
+ socialConnectionList?: ISocialConnectionProvider[];
21
+ loginMethod?: ILoginMethod;
22
+ loginMethodList: ILoginMethod[];
23
+ registerMethod?: IRegisterMethod;
24
+ registerMethodList?: IRegisterMethod[];
25
+ contentCSS?: string;
26
+ }
27
+ export interface GuardOptions extends GuardProps {
28
+ appId: string;
29
+ host?: string;
30
+ redirectUri?: string;
31
+ mode?: IGuardMode;
32
+ defaultScene?: IGuardModuleType;
33
+ tenantId?: string;
34
+ lang?: Lang;
35
+ isSSO?: boolean;
36
+ config?: Partial<IGuardConfig>;
37
+ }
38
+ export interface StartWithRedirectOptions {
39
+ codeChallengeMethod?: CodeChallengeMethod;
40
+ scope?: string;
41
+ redirectUri?: string;
42
+ state?: string;
43
+ responseType?: 'code' | 'code id_token token' | 'code id_token' | 'code token' | 'id_token token' | 'id_token' | 'none';
44
+ responseMode?: 'query' | 'fragment' | 'form_post';
45
+ nonce?: string;
46
+ }
47
+ export * from '@authing/react18-components';
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@authing/guard-shim-react18",
3
- "version": "5.0.8-alpha.1",
3
+ "version": "5.0.8-alpha.3",
4
4
  "description": "Guard shim for react18",
5
- "main": "src/index.tsx",
5
+ "module": "dist/esm/guard.min.js",
6
+ "types": "dist/typings/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
6
10
  "scripts": {
7
11
  "autoinstall": "npm ci",
8
- "build": "echo 'No need to build for @authing/guard-shim-react18'",
12
+ "build": "node scripts/build.js",
9
13
  "lint": "eslint --ext .ts,.tsx src/**",
10
14
  "lint:fix": "eslint --fix --ext .ts,.tsx src/**",
11
15
  "release:official": "npm publish --verbose --access public",
@@ -20,14 +24,11 @@
20
24
  "ts-loader": "^9.3.1",
21
25
  "webpack": "^5.72.0"
22
26
  },
23
- "peerDependencies": {
24
- "axios": "^0.27.2",
27
+ "dependencies": {
28
+ "@authing/react18-components": "^4.1.0-alpha.0",
25
29
  "react": "^18.0.0",
26
30
  "react-dom": "^18.0.0"
27
31
  },
28
- "dependencies": {
29
- "@authing/react18-components": "^4.1.0-alpha.0"
30
- },
31
32
  "author": "https://github.com/authing",
32
33
  "license": "MIT",
33
34
  "publishConfig": {
package/scripts/build.js DELETED
@@ -1,22 +0,0 @@
1
- const path = require('path')
2
- const rm = require('rimraf')
3
- const webpack = require('webpack')
4
- const webpackEsmBundlerConfig = require('./webpack.esm.config')
5
-
6
- try {
7
- rm.sync(path.resolve(__dirname, '../', 'dist'))
8
- } catch (e) {
9
- console.error('\n\n build guard, failed to delete dist directory, please operate manually \n\n')
10
- }
11
-
12
- readyGo()
13
-
14
- function readyGo () {
15
- webpack(webpackEsmBundlerConfig, (error, stats) => {
16
- if (error) {
17
- console.error('build guard-shim-react18 esm bundler error: ', error)
18
- } else {
19
- console.log(stats)
20
- }
21
- })
22
- }
@@ -1,42 +0,0 @@
1
- const path = require('path')
2
- const MiniCssExtractPlugin = require('mini-css-extract-plugin')
3
-
4
- function resolve (dir, file = '') {
5
- return path.resolve(__dirname, '../', dir, file)
6
- }
7
-
8
- module.exports = {
9
- mode: 'production',
10
- entry: resolve('src/index.tsx'),
11
- output: {
12
- filename: 'guard.min.js',
13
- path: resolve('dist/esm'),
14
- library: {
15
- type: 'module'
16
- }
17
- },
18
- experiments: {
19
- outputModule: true
20
- },
21
- resolve: {
22
- extensions: ['.ts', '.tsx', '.js']
23
- },
24
- module: {
25
- rules: [
26
- {
27
- test: /\.css$/,
28
- use: [MiniCssExtractPlugin.loader, 'css-loader']
29
- },
30
- {
31
- test: /\.tsx?$/,
32
- use: 'ts-loader',
33
- exclude: /node_modules/
34
- }
35
- ]
36
- },
37
- plugins: [
38
- new MiniCssExtractPlugin({
39
- filename: 'guard.min.css'
40
- })
41
- ]
42
- }