@authing/native-js-ui-components 3.1.39-rc.2 → 4.0.0-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authing/native-js-ui-components",
3
- "version": "3.1.39-rc.2",
3
+ "version": "4.0.0-alpha.3",
4
4
  "framework": "Native",
5
5
  "private": false,
6
6
  "main": "lib/index.min.js",
@@ -165,7 +165,8 @@
165
165
  "workbox-webpack-plugin": "5.1.4"
166
166
  },
167
167
  "dependencies": {
168
- "@authing/react-ui-components": "^3.1.39",
169
- "authing-js-sdk": "4.23.30-alpha.3"
170
- }
171
- }
168
+ "@authing/react-ui-components": "^4.0.0-alpha.3",
169
+ "authing-js-sdk": "4.23.36-alpha.1"
170
+ },
171
+ "gitHead": "7d5996215b996fcd8ee63d3ea7627bef1f37b706"
172
+ }
package/public/index.html CHANGED
@@ -5,10 +5,7 @@
5
5
  <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
8
+ <meta name="description" content="Web site created using create-react-app" />
12
9
  <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
10
  <!--
14
11
  manifest.json provides metadata used when your web app is installed on a
@@ -34,30 +31,26 @@
34
31
 
35
32
  <script>
36
33
  window.onload = () => {
37
- const guard = new window.AuthingNativeJsUIComponents.AuthingGuard(
38
- '59f86b4832eb28071bdd9214',
39
- {
40
- target: '#root',
34
+ const guard = new window.AuthingNativeJsUIComponents.Guard("5f6265c67ff6fdae64ec516e", {
35
+ target: "#root",
41
36
 
42
- apiHost: 'http://console.authing.localhost:3000',
43
- // loginMethods: Object.values(LoginMethods),
44
- logo:
45
- 'https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png',
46
- title: 'Authing',
47
- defaultLoginMethod: 'password',
48
- // registerMethods: Object.values(RegisterMethods),
49
- // defaultRegisterMethod: RegisterMethods.Email,
50
- defaultScenes: 'login',
51
- // socialConnections: Object.values(SocialConnections),
52
- // enterpriseConnections: ["oidc1"],
53
- appId: '5fa5053e252697ad5302ce7e',
54
- // autoRegister: true,
55
- }
56
- )
57
- guard.on('load', (a) => {
58
- console.log('加载完成', a)
59
- })
60
- }
37
+ // apiHost: 'http://console.authing.localhost:3000',
38
+ // loginMethods: Object.values(LoginMethods),
39
+ logo: "https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png",
40
+ title: "Authing",
41
+ defaultLoginMethod: "password",
42
+ // registerMethods: Object.values(RegisterMethods),
43
+ // defaultRegisterMethod: RegisterMethods.Email,
44
+ defaultScenes: "login",
45
+ // socialConnections: Object.values(SocialConnections),
46
+ // enterpriseConnections: ["oidc1"],
47
+ appId: "5fa5053e252697ad5302ce7e",
48
+ // autoRegister: true,
49
+ });
50
+ guard.on("load", (a) => {
51
+ console.log("加载完成", a);
52
+ });
53
+ };
61
54
  </script>
62
55
  <!--
63
56
  This HTML file is a template.
package/src/App.tsx CHANGED
@@ -4,7 +4,6 @@ import { Guard, GuardEventsCamelToKebabMapping, GuardMode } from "./components";
4
4
 
5
5
  function App() {
6
6
  console.log(GuardEventsCamelToKebabMapping);
7
-
8
7
  useEffect(() => {
9
8
  const guard = new Guard("62cd66dc014378042b55154f", {
10
9
  target: ".App",
@@ -1,15 +1,17 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { Guard as ReactAuthingGuard } from '@authing/react-ui-components';
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
3
+ import { Guard as ReactAuthingGuard } from "@authing/react-ui-components";
4
4
  import {
5
5
  GuardMode,
6
6
  GuardEvents,
7
7
  AuthenticationClient,
8
8
  GuardEventsKebabToCamelType,
9
9
  GuardEventsCamelToKebabMapping,
10
- } from '@authing/react-ui-components';
11
- import '@authing/react-ui-components/lib/index.min.css';
12
- import { GuardComponentConfig, GuardLocalConfig } from '@authing/react-ui-components/components/Guard/config';
10
+ GuardLocalConfig,
11
+ GuardProps,
12
+ } from "@authing/react-ui-components";
13
+ import "@authing/react-ui-components/lib/index.min.css";
14
+ // import { GuardComponentConfig, GuardLocalConfig } from "@authing/react-ui-components/components/Guard/config";
13
15
 
14
16
  export interface NativeGuardProps {
15
17
  appId?: string;
@@ -49,7 +51,7 @@ export class Guard {
49
51
  tenantId?: string,
50
52
  authClient?: AuthenticationClient
51
53
  ) {
52
- if (appIdOrProps && typeof appIdOrProps !== 'string') {
54
+ if (appIdOrProps && typeof appIdOrProps !== "string") {
53
55
  const { appId, config: configProps, tenantId: tenantIdProps, authClient: authClientProps } = appIdOrProps;
54
56
  this.appId = appId;
55
57
  this.config = configProps;
@@ -68,12 +70,12 @@ export class Guard {
68
70
  }
69
71
 
70
72
  static getGuardContainer(selector?: string | HTMLElement) {
71
- const defaultId = 'authing_guard_container';
73
+ const defaultId = "authing_guard_container";
72
74
 
73
75
  if (!selector) {
74
76
  let container = document.querySelector(`#${defaultId}`);
75
77
  if (!container) {
76
- container = document.createElement('div');
78
+ container = document.createElement("div");
77
79
  container.id = defaultId;
78
80
  document.body.appendChild(container);
79
81
  }
@@ -81,7 +83,7 @@ export class Guard {
81
83
  return container;
82
84
  }
83
85
 
84
- if (typeof selector === 'string') {
86
+ if (typeof selector === "string") {
85
87
  return document.querySelector(selector);
86
88
  }
87
89
 
@@ -96,18 +98,18 @@ export class Guard {
96
98
 
97
99
  public render(): void;
98
100
  public render(aliginOrCb: () => void): void;
99
- public render(aliginOrCb: 'none' | 'center' | 'left' | 'right'): void;
100
- public render(aliginOrCb: 'none' | 'center' | 'left' | 'right', callback: () => void): void;
101
+ public render(aliginOrCb: "none" | "center" | "left" | "right"): void;
102
+ public render(aliginOrCb: "none" | "center" | "left" | "right", callback: () => void): void;
101
103
  public render(aliginOrCb?: any, cb?: any) {
102
104
  const l = arguments.length;
103
- let align: 'none' | 'center' | 'left' | 'right';
105
+ let align: "none" | "center" | "left" | "right";
104
106
 
105
107
  let callback: (() => void) | undefined;
106
108
  if (l === 0) {
107
- align = 'none';
109
+ align = "none";
108
110
  } else if (l === 1) {
109
- if (typeof aliginOrCb === 'function') {
110
- align = 'none';
111
+ if (typeof aliginOrCb === "function") {
112
+ align = "none";
111
113
  callback = aliginOrCb;
112
114
  } else {
113
115
  align = aliginOrCb;
@@ -116,7 +118,7 @@ export class Guard {
116
118
  align = aliginOrCb;
117
119
  callback = cb;
118
120
  } else {
119
- throw new Error('参数格式错误');
121
+ throw new Error("参数格式错误");
120
122
  }
121
123
 
122
124
  // 两个都有
@@ -133,7 +135,7 @@ export class Guard {
133
135
  const evts: GuardEvents = Object.entries(GuardEventsCamelToKebabMapping).reduce((acc, [reactEvt, nativeEvt]) => {
134
136
  return Object.assign({}, acc, {
135
137
  [reactEvt]: (...rest: any) => {
136
- if (nativeEvt === 'close') {
138
+ if (nativeEvt === "close") {
137
139
  this.hide();
138
140
  }
139
141
 
@@ -153,15 +155,15 @@ export class Guard {
153
155
  return ReactDOM.render(
154
156
  <div
155
157
  style={{
156
- display: 'flex',
157
- alignItems: 'center',
158
+ display: "flex",
159
+ alignItems: "center",
158
160
  justifyContent: align,
159
161
  }}
160
162
  >
161
163
  <ReactAuthingGuard
162
164
  {...(evts as GuardEvents)}
163
165
  appId={this.appId}
164
- config={this.config as GuardComponentConfig}
166
+ config={this.config as GuardProps["config"]}
165
167
  visible={this.visible}
166
168
  tenantId={this.tenantId}
167
169
  authClient={this.authClient}
@@ -1,51 +1,18 @@
1
- // export * from "./Guard";
2
1
  import { Guard } from "./Guard";
3
- import { AuthingGuard } from "./AuthingGuard";
4
2
 
5
3
  import {
6
4
  User,
7
5
  GuardMode,
8
- UserConfig,
9
- GuardScenes,
6
+ GuardModuleType,
10
7
  LoginMethods,
11
- getAuthClient,
12
8
  CommonMessage,
13
- initAuthClient,
14
9
  RegisterMethods,
15
- GuardModuleType,
16
- GuardEventsHandler,
17
10
  AuthenticationClient,
18
- GuardEventsHandlerKebab,
19
- GuardEventsCamelToKebabMap,
20
11
  GuardEvents,
21
12
  GuardEventsKebabToCamelType,
22
13
  GuardEventsCamelToKebabMapping,
23
- GuardConfig,
24
14
  GuardLocalConfig,
25
15
  } from "@authing/react-ui-components";
26
16
 
27
- export {
28
- Guard,
29
- AuthingGuard,
30
- GuardMode,
31
- GuardScenes,
32
- LoginMethods,
33
- getAuthClient,
34
- initAuthClient,
35
- RegisterMethods,
36
- GuardEventsCamelToKebabMap,
37
- GuardEventsCamelToKebabMapping,
38
- };
39
- export type {
40
- GuardConfig,
41
- GuardLocalConfig,
42
- GuardEvents,
43
- User,
44
- UserConfig,
45
- CommonMessage,
46
- GuardModuleType,
47
- GuardEventsHandler,
48
- AuthenticationClient,
49
- GuardEventsHandlerKebab,
50
- GuardEventsKebabToCamelType,
51
- };
17
+ export { Guard, GuardMode, GuardModuleType, LoginMethods, RegisterMethods, GuardEventsCamelToKebabMapping };
18
+ export type { GuardLocalConfig, GuardEvents, User, CommonMessage, AuthenticationClient, GuardEventsKebabToCamelType };
package/tsconfig.json CHANGED
@@ -3,11 +3,7 @@
3
3
  "baseUrl": ".",
4
4
  "outDir": "lib/",
5
5
  "target": "es5",
6
- "lib": [
7
- "dom",
8
- "dom.iterable",
9
- "esnext"
10
- ],
6
+ "lib": ["dom", "dom.iterable", "esnext"],
11
7
  "allowJs": true,
12
8
  "skipLibCheck": true,
13
9
  "esModuleInterop": true,
@@ -18,20 +14,11 @@
18
14
  "module": "esnext",
19
15
  "moduleResolution": "node",
20
16
  "resolveJsonModule": true,
21
- "isolatedModules": true,
22
17
  "declaration": true,
23
18
  "noEmit": false,
24
19
  "jsx": "react",
25
20
  "downlevelIteration": true
26
21
  },
27
- "include": [
28
- "src/**/*.ts",
29
- "src/**/*.tsx",
30
- "src/**/*.json"
31
- ],
32
- "exclude": [
33
- "node_modules",
34
- "lib",
35
- "build"
36
- ]
37
- }
22
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
23
+ "exclude": ["node_modules", "lib", "build"]
24
+ }
@@ -1,98 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import { AuthingGuard as ReactAuthingGuard } from "@authing/react-ui-components";
4
- import {
5
- GuardMode,
6
- UserConfig,
7
- GuardEventsHandler,
8
- GuardEventsHandlerKebab,
9
- GuardEventsCamelToKebabMap,
10
- } from "@authing/react-ui-components";
11
- import "@authing/react-ui-components/lib/index.min.css";
12
-
13
- export type EventListeners = {
14
- [key in keyof GuardEventsHandlerKebab]: Exclude<Required<GuardEventsHandlerKebab>[key], undefined>[];
15
- };
16
-
17
- export class AuthingGuard {
18
- constructor(private appId: string, private config?: UserConfig, private tenantId?: string) {
19
- this.render();
20
- }
21
-
22
- static getGuardContainer(selector?: string | HTMLElement) {
23
- const defaultId = "authing_guard_container";
24
-
25
- if (!selector) {
26
- let container = document.querySelector(`#${defaultId}`);
27
- if (!container) {
28
- container = document.createElement("div");
29
- container.id = defaultId;
30
- document.body.appendChild(container);
31
- }
32
-
33
- return container;
34
- }
35
-
36
- if (typeof selector === "string") {
37
- return document.querySelector(selector);
38
- }
39
-
40
- return selector;
41
- }
42
-
43
- private visible = this.config?.mode === GuardMode.Modal ? false : true;
44
-
45
- private eventListeners = Object.values(GuardEventsCamelToKebabMap).reduce((acc, evtName) => {
46
- return Object.assign({}, acc, {
47
- [evtName]: [],
48
- });
49
- }, {} as EventListeners);
50
-
51
- private render(cb?: () => void) {
52
- const evts: GuardEventsHandler = Object.entries(GuardEventsCamelToKebabMap).reduce((acc, [reactEvt, nativeEvt]) => {
53
- return Object.assign({}, acc, {
54
- [reactEvt]: (...rest: any) => {
55
- if (nativeEvt === "close") {
56
- this.hide();
57
- }
58
-
59
- // TODO 返回最后一个执行函数的值,实际应该只让监听一次
60
- return (
61
- this.eventListeners[nativeEvt]
62
- // @ts-ignore
63
- .map((item: any) => {
64
- return item(...rest);
65
- })
66
- .slice(-1)[0] ?? true
67
- );
68
- },
69
- });
70
- }, {} as GuardEventsHandler);
71
-
72
- return ReactDOM.render(
73
- <ReactAuthingGuard
74
- {...evts}
75
- appId={this.appId}
76
- tenantId={this.tenantId}
77
- config={this.config}
78
- visible={this.visible}
79
- />,
80
- AuthingGuard.getGuardContainer(this.config?.target),
81
- cb
82
- );
83
- }
84
-
85
- on<T extends keyof GuardEventsHandlerKebab>(evt: T, handler: Exclude<GuardEventsHandlerKebab[T], undefined>) {
86
- this.eventListeners[evt]!.push(handler as any);
87
- }
88
-
89
- show() {
90
- this.visible = true;
91
- this.render();
92
- }
93
-
94
- hide() {
95
- this.visible = false;
96
- this.render();
97
- }
98
- }