@authing/native-js-ui-components 4.4.2 → 4.5.0-alpha.0

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.
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
5
- const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
6
- const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
7
- const ignoredFiles = require('react-dev-utils/ignoredFiles');
8
- const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
9
- const paths = require('./paths');
10
- const getHttpsConfig = require('./getHttpsConfig');
11
-
12
- const host = process.env.HOST || '0.0.0.0';
13
- const sockHost = process.env.WDS_SOCKET_HOST;
14
- const sockPath = process.env.WDS_SOCKET_PATH; // default: '/sockjs-node'
15
- const sockPort = process.env.WDS_SOCKET_PORT;
16
-
17
- module.exports = function (proxy, allowedHost) {
18
- return {
19
- // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
20
- // websites from potentially accessing local content through DNS rebinding:
21
- // https://github.com/webpack/webpack-dev-server/issues/887
22
- // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
23
- // However, it made several existing use cases such as development in cloud
24
- // environment or subdomains in development significantly more complicated:
25
- // https://github.com/facebook/create-react-app/issues/2271
26
- // https://github.com/facebook/create-react-app/issues/2233
27
- // While we're investigating better solutions, for now we will take a
28
- // compromise. Since our WDS configuration only serves files in the `public`
29
- // folder we won't consider accessing them a vulnerability. However, if you
30
- // use the `proxy` feature, it gets more dangerous because it can expose
31
- // remote code execution vulnerabilities in backends like Django and Rails.
32
- // So we will disable the host check normally, but enable it if you have
33
- // specified the `proxy` setting. Finally, we let you override it if you
34
- // really know what you're doing with a special environment variable.
35
- disableHostCheck:
36
- !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
37
- // Enable gzip compression of generated files.
38
- compress: true,
39
- // Silence WebpackDevServer's own logs since they're generally not useful.
40
- // It will still show compile warnings and errors with this setting.
41
- clientLogLevel: 'none',
42
- // By default WebpackDevServer serves physical files from current directory
43
- // in addition to all the virtual build products that it serves from memory.
44
- // This is confusing because those files won’t automatically be available in
45
- // production build folder unless we copy them. However, copying the whole
46
- // project directory is dangerous because we may expose sensitive files.
47
- // Instead, we establish a convention that only files in `public` directory
48
- // get served. Our build script will copy `public` into the `build` folder.
49
- // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
50
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
51
- // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
52
- // Note that we only recommend to use `public` folder as an escape hatch
53
- // for files like `favicon.ico`, `manifest.json`, and libraries that are
54
- // for some reason broken when imported through webpack. If you just want to
55
- // use an image, put it in `src` and `import` it from JavaScript instead.
56
- contentBase: paths.appPublic,
57
- contentBasePublicPath: paths.publicUrlOrPath,
58
- // By default files from `contentBase` will not trigger a page reload.
59
- watchContentBase: true,
60
- // Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
61
- // for the WebpackDevServer client so it can learn when the files were
62
- // updated. The WebpackDevServer client is included as an entry point
63
- // in the webpack development configuration. Note that only changes
64
- // to CSS are currently hot reloaded. JS changes will refresh the browser.
65
- hot: true,
66
- // Use 'ws' instead of 'sockjs-node' on server since we're using native
67
- // websockets in `webpackHotDevClient`.
68
- transportMode: 'ws',
69
- // Prevent a WS client from getting injected as we're already including
70
- // `webpackHotDevClient`.
71
- injectClient: false,
72
- // Enable custom sockjs pathname for websocket connection to hot reloading server.
73
- // Enable custom sockjs hostname, pathname and port for websocket connection
74
- // to hot reloading server.
75
- sockHost,
76
- sockPath,
77
- sockPort,
78
- // It is important to tell WebpackDevServer to use the same "publicPath" path as
79
- // we specified in the webpack config. When homepage is '.', default to serving
80
- // from the root.
81
- // remove last slash so user can land on `/test` instead of `/test/`
82
- publicPath: paths.publicUrlOrPath.slice(0, -1),
83
- // WebpackDevServer is noisy by default so we emit custom message instead
84
- // by listening to the compiler events with `compiler.hooks[...].tap` calls above.
85
- quiet: true,
86
- // Reportedly, this avoids CPU overload on some systems.
87
- // https://github.com/facebook/create-react-app/issues/293
88
- // src/node_modules is not ignored to support absolute imports
89
- // https://github.com/facebook/create-react-app/issues/1065
90
- watchOptions: {
91
- ignored: ignoredFiles(paths.appSrc),
92
- },
93
- https: getHttpsConfig(),
94
- host,
95
- overlay: false,
96
- historyApiFallback: {
97
- // Paths with dots should still use the history fallback.
98
- // See https://github.com/facebook/create-react-app/issues/387.
99
- disableDotRule: true,
100
- index: paths.publicUrlOrPath,
101
- },
102
- public: allowedHost,
103
- // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
104
- proxy,
105
- before(app, server) {
106
- // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
107
- // middlewares before `redirectServedPath` otherwise will not have any effect
108
- // This lets us fetch source contents from webpack for the error overlay
109
- app.use(evalSourceMapMiddleware(server));
110
- // This lets us open files from the runtime error overlay.
111
- app.use(errorOverlayMiddleware());
112
-
113
- if (fs.existsSync(paths.proxySetup)) {
114
- // This registers user provided middleware for proxy reasons
115
- require(paths.proxySetup)(app);
116
- }
117
- },
118
- after(app) {
119
- // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
120
- app.use(redirectServedPath(paths.publicUrlOrPath));
121
-
122
- // This service worker file is effectively a 'no-op' that will reset any
123
- // previous service worker registered for the same host:port combination.
124
- // We do this in development to avoid hitting the production cache if
125
- // it used the same host and port.
126
- // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
127
- app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
128
- },
129
- };
130
- };
package/lib/index.d.ts DELETED
@@ -1,73 +0,0 @@
1
- declare module '@authing/native-js-ui-components/App' {
2
- /// <reference types="react" />
3
- import "./App.css";
4
- function App(): JSX.Element;
5
- export default App;
6
-
7
- }
8
- declare module '@authing/native-js-ui-components/App.test' {
9
- export {};
10
-
11
- }
12
- declare module '@authing/native-js-ui-components/components/Guard/index' {
13
- import { AuthenticationClient, GuardEventsKebabToCamelType, GuardLocalConfig } from "@authing/react-ui-components";
14
- import "@authing/react-ui-components/lib/index.min.css";
15
- export interface NativeGuardProps {
16
- appId?: string;
17
- config?: Partial<GuardLocalConfig>;
18
- tenantId?: string;
19
- authClient?: AuthenticationClient;
20
- }
21
- export interface NativeGuardConstructor {
22
- (appId?: string | NativeGuardProps, config?: Partial<GuardLocalConfig>, tenantId?: string, authClient?: AuthenticationClient): void;
23
- (props: NativeGuardProps): void;
24
- }
25
- export type GuardEventListeners = {
26
- [key in keyof GuardEventsKebabToCamelType]: Exclude<Required<GuardEventsKebabToCamelType>[key], undefined>[];
27
- };
28
- export class Guard {
29
- appId?: string;
30
- config?: Partial<GuardLocalConfig>;
31
- tenantId?: string;
32
- authClient?: AuthenticationClient;
33
- visible?: boolean;
34
- constructor(props?: NativeGuardProps);
35
- constructor(appId?: string, config?: Partial<GuardLocalConfig>, tenantId?: string, authClient?: AuthenticationClient);
36
- static getGuardContainer(selector?: string | HTMLElement): Element | null;
37
- private eventListeners;
38
- render(): void;
39
- render(aliginOrCb: () => void): void;
40
- render(aliginOrCb: "none" | "center" | "left" | "right"): void;
41
- render(aliginOrCb: "none" | "center" | "left" | "right", callback: () => void): void;
42
- on<T extends keyof GuardEventsKebabToCamelType>(evt: T, handler: Exclude<GuardEventsKebabToCamelType[T], undefined>): void;
43
- show(): void;
44
- hide(): void;
45
- unmountComponent(): void;
46
- }
47
-
48
- }
49
- declare module '@authing/native-js-ui-components/components/index' {
50
- import { Guard } from "@authing/native-js-ui-components/components/Guard/index";
51
- import { User, GuardMode, GuardModuleType, LoginMethods, CommonMessage, RegisterMethods, AuthenticationClient, GuardEvents, GuardEventsKebabToCamelType, GuardEventsCamelToKebabMapping, GuardLocalConfig } from "@authing/react-ui-components";
52
- export { Guard, GuardMode, GuardModuleType, LoginMethods, RegisterMethods, GuardEventsCamelToKebabMapping };
53
- export type { GuardLocalConfig, GuardEvents, User, CommonMessage, AuthenticationClient, GuardEventsKebabToCamelType };
54
-
55
- }
56
- declare module '@authing/native-js-ui-components/index' {
57
- import './index.css';
58
-
59
- }
60
- declare module '@authing/native-js-ui-components/reportWebVitals' {
61
- import { ReportHandler } from 'web-vitals';
62
- const reportWebVitals: (onPerfEntry?: ReportHandler | undefined) => void;
63
- export default reportWebVitals;
64
-
65
- }
66
- declare module '@authing/native-js-ui-components/setupTests' {
67
- import '@testing-library/jest-dom';
68
-
69
- }
70
- declare module '@authing/native-js-ui-components' {
71
- import main = require('@authing/native-js-ui-components/components/index');
72
- export = main;
73
- }
Binary file
package/public/index.html DELETED
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta name="description" content="Web site created using create-react-app" />
9
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
10
- <!--
11
- manifest.json provides metadata used when your web app is installed on a
12
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
13
- -->
14
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
15
- <!--
16
- Notice the use of %PUBLIC_URL% in the tags above.
17
- It will be replaced with the URL of the `public` folder during the build.
18
- Only files inside the `public` folder can be referenced from the HTML.
19
-
20
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
21
- work correctly both with client-side routing and a non-root public URL.
22
- Learn how to configure a non-root public URL by running `npm run build`.
23
- -->
24
- <link rel="stylesheet" href="../lib/index.min.css" />
25
- <title>React App</title>
26
- </head>
27
- <body>
28
- <script src="../lib/index.min.js"></script>
29
- <noscript>You need to enable JavaScript to run this app.</noscript>
30
- <div id="root"></div>
31
-
32
- <script>
33
- window.onload = () => {
34
- const guard = new window.AuthingNativeJsUIComponents.Guard("5f6265c67ff6fdae64ec516e", {
35
- target: "#root",
36
-
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
- };
54
- </script>
55
- <!--
56
- This HTML file is a template.
57
- If you open it directly in the browser, you will see an empty page.
58
-
59
- You can add webfonts, meta tags, or analytics to this file.
60
- The build step will place the bundled scripts into the <body> tag.
61
-
62
- To begin the development, run `npm start` or `yarn start`.
63
- To create a production bundle, use `npm run build` or `yarn build`.
64
- -->
65
- </body>
66
- </html>
Binary file
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
package/public/robots.txt DELETED
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
package/scripts/build.js DELETED
@@ -1,212 +0,0 @@
1
- 'use strict';
2
-
3
- // Do this as the first thing so that any code reading it knows the right env.
4
- process.env.BABEL_ENV = 'production';
5
- process.env.NODE_ENV = 'production';
6
-
7
- // Makes the script crash on unhandled rejections instead of silently
8
- // ignoring them. In the future, promise rejections that are not handled will
9
- // terminate the Node.js process with a non-zero exit code.
10
- process.on('unhandledRejection', err => {
11
- throw err;
12
- });
13
-
14
- // Ensure environment variables are read.
15
- require('../config/env');
16
-
17
-
18
- const path = require('path');
19
- const chalk = require('react-dev-utils/chalk');
20
- const fs = require('fs-extra');
21
- const bfj = require('bfj');
22
- const webpack = require('webpack');
23
- const configFactory = require('../config/webpack.config');
24
- const paths = require('../config/paths');
25
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
26
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
27
- const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
28
- const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
29
- const printBuildError = require('react-dev-utils/printBuildError');
30
-
31
- const measureFileSizesBeforeBuild =
32
- FileSizeReporter.measureFileSizesBeforeBuild;
33
- const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
34
- const useYarn = fs.existsSync(paths.yarnLockFile);
35
-
36
- // These sizes are pretty large. We'll warn for bundles exceeding them.
37
- const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
38
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
39
-
40
- const isInteractive = process.stdout.isTTY;
41
-
42
- // Warn and crash if required files are missing
43
- if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
44
- process.exit(1);
45
- }
46
-
47
- const argv = process.argv.slice(2);
48
- const writeStatsJson = argv.indexOf('--stats') !== -1;
49
-
50
- // Generate configuration
51
- const config = configFactory('production');
52
-
53
- // We require that you explicitly set browsers and do not fall back to
54
- // browserslist defaults.
55
- const { checkBrowsers } = require('react-dev-utils/browsersHelper');
56
- checkBrowsers(paths.appPath, isInteractive)
57
- .then(() => {
58
- // First, read the current file sizes in build directory.
59
- // This lets us display how much they changed later.
60
- return measureFileSizesBeforeBuild(paths.appBuild);
61
- })
62
- .then(previousFileSizes => {
63
- // Remove all content but keep the directory so that
64
- // if you're in it, you don't end up in Trash
65
- fs.emptyDirSync(paths.appBuild);
66
- // Merge with the public folder
67
- copyPublicFolder();
68
- // Start the webpack build
69
- return build(previousFileSizes);
70
- })
71
- .then(
72
- ({ stats, previousFileSizes, warnings }) => {
73
- if (warnings.length) {
74
- console.log(chalk.yellow('Compiled with warnings.\n'));
75
- console.log(warnings.join('\n\n'));
76
- console.log(
77
- '\nSearch for the ' +
78
- chalk.underline(chalk.yellow('keywords')) +
79
- ' to learn more about each warning.'
80
- );
81
- console.log(
82
- 'To ignore, add ' +
83
- chalk.cyan('// eslint-disable-next-line') +
84
- ' to the line before.\n'
85
- );
86
- } else {
87
- console.log(chalk.green('Compiled successfully.\n'));
88
- }
89
-
90
- console.log('File sizes after gzip:\n');
91
- printFileSizesAfterBuild(
92
- stats,
93
- previousFileSizes,
94
- paths.appBuild,
95
- WARN_AFTER_BUNDLE_GZIP_SIZE,
96
- WARN_AFTER_CHUNK_GZIP_SIZE
97
- );
98
- console.log();
99
-
100
- const appPackage = require(paths.appPackageJson);
101
- const publicUrl = paths.publicUrlOrPath;
102
- const publicPath = config.output.publicPath;
103
- const buildFolder = path.relative(process.cwd(), paths.appBuild);
104
- printHostingInstructions(
105
- appPackage,
106
- publicUrl,
107
- publicPath,
108
- buildFolder,
109
- useYarn
110
- );
111
- },
112
- err => {
113
- const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
114
- if (tscCompileOnError) {
115
- console.log(
116
- chalk.yellow(
117
- 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
118
- )
119
- );
120
- printBuildError(err);
121
- } else {
122
- console.log(chalk.red('Failed to compile.\n'));
123
- printBuildError(err);
124
- process.exit(1);
125
- }
126
- }
127
- )
128
- .catch(err => {
129
- if (err && err.message) {
130
- console.log(err.message);
131
- }
132
- process.exit(1);
133
- });
134
-
135
- // Create the production build and print the deployment instructions.
136
- function build(previousFileSizes) {
137
- console.log('Creating an optimized production build...');
138
-
139
- const compiler = webpack(config);
140
- return new Promise((resolve, reject) => {
141
- compiler.run((err, stats) => {
142
- let messages;
143
- if (err) {
144
- if (!err.message) {
145
- return reject(err);
146
- }
147
-
148
- let errMessage = err.message;
149
-
150
- // Add additional information for postcss errors
151
- if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
152
- errMessage +=
153
- '\nCompileError: Begins at CSS selector ' +
154
- err['postcssNode'].selector;
155
- }
156
-
157
- messages = formatWebpackMessages({
158
- errors: [errMessage],
159
- warnings: [],
160
- });
161
- } else {
162
- messages = formatWebpackMessages(
163
- stats.toJson({ all: false, warnings: true, errors: true })
164
- );
165
- }
166
- if (messages.errors.length) {
167
- // Only keep the first error. Others are often indicative
168
- // of the same problem, but confuse the reader with noise.
169
- if (messages.errors.length > 1) {
170
- messages.errors.length = 1;
171
- }
172
- return reject(new Error(messages.errors.join('\n\n')));
173
- }
174
- if (
175
- process.env.CI &&
176
- (typeof process.env.CI !== 'string' ||
177
- process.env.CI.toLowerCase() !== 'false') &&
178
- messages.warnings.length
179
- ) {
180
- console.log(
181
- chalk.yellow(
182
- '\nTreating warnings as errors because process.env.CI = true.\n' +
183
- 'Most CI servers set it automatically.\n'
184
- )
185
- );
186
- return reject(new Error(messages.warnings.join('\n\n')));
187
- }
188
-
189
- const resolveArgs = {
190
- stats,
191
- previousFileSizes,
192
- warnings: messages.warnings,
193
- };
194
-
195
- if (writeStatsJson) {
196
- return bfj
197
- .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
198
- .then(() => resolve(resolveArgs))
199
- .catch(error => reject(new Error(error)));
200
- }
201
-
202
- return resolve(resolveArgs);
203
- });
204
- });
205
- }
206
-
207
- function copyPublicFolder() {
208
- fs.copySync(paths.appPublic, paths.appBuild, {
209
- dereference: true,
210
- filter: file => file !== paths.appHtml,
211
- });
212
- }