@deephaven/app-utils 0.46.2-dynamic-import.0 → 0.47.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.
- package/dist/components/AuthBootstrap.d.ts.map +1 -1
- package/dist/components/AuthBootstrap.js +7 -1
- package/dist/components/AuthBootstrap.js.map +1 -1
- package/dist/plugins/PluginUtils.d.ts +6 -14
- package/dist/plugins/PluginUtils.d.ts.map +1 -1
- package/dist/plugins/PluginUtils.js +35 -73
- package/dist/plugins/PluginUtils.js.map +1 -1
- package/package.json +12 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/AuthBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAcxE,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/AuthBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAcxE,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAeF;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,eA6D7D;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -12,7 +12,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
/** Core auth plugins that are always loaded */
|
|
15
|
-
var CORE_AUTH_PLUGINS = new Map([['@deephaven/auth-plugins.AuthPluginParent',
|
|
15
|
+
var CORE_AUTH_PLUGINS = new Map([['@deephaven/auth-plugins.AuthPluginParent', {
|
|
16
|
+
AuthPlugin: AuthPluginParent
|
|
17
|
+
}], ['@deephaven/auth-plugins.AuthPluginPsk', {
|
|
18
|
+
AuthPlugin: AuthPluginPsk
|
|
19
|
+
}], ['@deephaven/auth-plugins.AuthPluginAnonymous', {
|
|
20
|
+
AuthPlugin: AuthPluginAnonymous
|
|
21
|
+
}]]);
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* AuthBootstrap component. Handles displaying the auth plugin and authenticating.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthBootstrap.js","names":["React","useContext","useEffect","useMemo","useState","AuthPluginAnonymous","AuthPluginParent","AuthPluginPsk","LoadingOverlay","useClient","getErrorMessage","PluginsContext","getAuthPluginComponent","LoginNotifier","CORE_AUTH_PLUGINS","Map","AuthBootstrap","children","client","plugins","authConfig","setAuthConfig","error","setError","initAuthConfigValues","isCanceled","loadAuthConfigValues","newAuthConfigValues","getAuthConfigValues","e","AuthComponent","undefined","isLoading"],"sources":["../../src/components/AuthBootstrap.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AuthConfigMap,\n AuthPluginAnonymous,\n AuthPluginParent,\n AuthPluginPsk,\n} from '@deephaven/auth-plugins';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useClient } from '@deephaven/jsapi-bootstrap';\nimport { getErrorMessage } from '@deephaven/utils';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\nimport LoginNotifier from './LoginNotifier';\n\nexport type AuthBootstrapProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\n/** Core auth plugins that are always loaded */\nconst CORE_AUTH_PLUGINS = new Map([\n ['@deephaven/auth-plugins.AuthPluginParent'
|
|
1
|
+
{"version":3,"file":"AuthBootstrap.js","names":["React","useContext","useEffect","useMemo","useState","AuthPluginAnonymous","AuthPluginParent","AuthPluginPsk","LoadingOverlay","useClient","getErrorMessage","PluginsContext","getAuthPluginComponent","LoginNotifier","CORE_AUTH_PLUGINS","Map","AuthPlugin","AuthBootstrap","children","client","plugins","authConfig","setAuthConfig","error","setError","initAuthConfigValues","isCanceled","loadAuthConfigValues","newAuthConfigValues","getAuthConfigValues","e","AuthComponent","undefined","isLoading"],"sources":["../../src/components/AuthBootstrap.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AuthConfigMap,\n AuthPluginAnonymous,\n AuthPluginParent,\n AuthPluginPsk,\n} from '@deephaven/auth-plugins';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useClient } from '@deephaven/jsapi-bootstrap';\nimport { getErrorMessage } from '@deephaven/utils';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\nimport LoginNotifier from './LoginNotifier';\n\nexport type AuthBootstrapProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\n/** Core auth plugins that are always loaded */\nconst CORE_AUTH_PLUGINS = new Map([\n [\n '@deephaven/auth-plugins.AuthPluginParent',\n { AuthPlugin: AuthPluginParent },\n ],\n ['@deephaven/auth-plugins.AuthPluginPsk', { AuthPlugin: AuthPluginPsk }],\n [\n '@deephaven/auth-plugins.AuthPluginAnonymous',\n { AuthPlugin: AuthPluginAnonymous },\n ],\n]);\n\n/**\n * AuthBootstrap component. Handles displaying the auth plugin and authenticating.\n */\nexport function AuthBootstrap({ children }: AuthBootstrapProps) {\n const client = useClient();\n // `useContext` instead of `usePlugins` so that we don't have to wait for the plugins to load\n // We want to load the auth config values in parallel with the plugins\n const plugins = useContext(PluginsContext);\n const [authConfig, setAuthConfig] = useState<AuthConfigMap>();\n const [error, setError] = useState<unknown>();\n\n useEffect(\n function initAuthConfigValues() {\n let isCanceled = false;\n async function loadAuthConfigValues() {\n try {\n const newAuthConfigValues = await client.getAuthConfigValues();\n if (!isCanceled) {\n setAuthConfig(new Map(newAuthConfigValues));\n }\n } catch (e) {\n if (!isCanceled) {\n setError(e);\n }\n }\n }\n loadAuthConfigValues();\n return () => {\n isCanceled = true;\n };\n },\n [client]\n );\n\n const AuthComponent = useMemo(() => {\n if (plugins == null || authConfig == null) {\n return undefined;\n }\n\n try {\n return getAuthPluginComponent(plugins, authConfig, CORE_AUTH_PLUGINS);\n } catch (e) {\n setError(e);\n }\n }, [authConfig, plugins]);\n\n const isLoading = AuthComponent == null || authConfig == null;\n\n if (isLoading || error != null) {\n return (\n <LoadingOverlay\n isLoading={isLoading && error == null}\n errorMessage={getErrorMessage(error)}\n />\n );\n }\n return (\n <AuthComponent authConfigValues={authConfig}>\n <>\n <LoginNotifier />\n {children}\n </>\n </AuthComponent>\n );\n}\n\nexport default AuthBootstrap;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAEEC,mBAAmB,EACnBC,gBAAgB,EAChBC,aAAa,QACR,yBAAyB;AAChC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,eAAe,QAAQ,kBAAkB;AAAC,SAC1CC,cAAc;AAAA,SACdC,sBAAsB;AAAA,OACxBC,aAAa;AAAA;AAAA;AAAA;AASpB;AACA,IAAMC,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAChC,CACE,0CAA0C,EAC1C;EAAEC,UAAU,EAAEV;AAAiB,CAAC,CACjC,EACD,CAAC,uCAAuC,EAAE;EAAEU,UAAU,EAAET;AAAc,CAAC,CAAC,EACxE,CACE,6CAA6C,EAC7C;EAAES,UAAU,EAAEX;AAAoB,CAAC,CACpC,CACF,CAAC;;AAEF;AACA;AACA;AACA,OAAO,SAASY,aAAa,OAAmC;EAAA,IAAlC;IAAEC;EAA6B,CAAC;EAC5D,IAAMC,MAAM,GAAGV,SAAS,EAAE;EAC1B;EACA;EACA,IAAMW,OAAO,GAA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IAAI,IAAK;MACtC,YAAY,EAAEb,eAAe,CAACa,KAAK;IAAE,EACrC;EAEN;EACA,oBACE,KAAC,aAAa;IAAC,gBAAgB,EAAEF,UAAW;IAAA,uBAC1C;MAAA,wBACE,KAAC,aAAa,KAAG,EAChBH,QAAQ;IAAA;EACR,EACW;AAEpB;AAEA,eAAeD,aAAa"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AuthPlugin, AuthPluginComponent } from '@deephaven/auth-plugins';
|
|
3
|
-
export interface PluginModule {
|
|
4
|
-
}
|
|
1
|
+
import { type PluginModule, type AuthPlugin, type AuthPluginComponent, LegacyAuthPlugin, LegacyPlugin, Plugin } from '@deephaven/plugin';
|
|
5
2
|
export type PluginModuleMap = Map<string, PluginModule>;
|
|
6
3
|
export type PluginManifestPluginInfo = {
|
|
7
4
|
name: string;
|
|
@@ -11,19 +8,14 @@ export type PluginManifestPluginInfo = {
|
|
|
11
8
|
export type PluginManifest = {
|
|
12
9
|
plugins: PluginManifestPluginInfo[];
|
|
13
10
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Load a component plugin from the server.
|
|
16
|
-
* @param baseURL Base URL of the plugin server
|
|
17
|
-
* @param pluginName Name of the component plugin to load
|
|
18
|
-
* @returns A lazily loaded JSX.Element from the plugin
|
|
19
|
-
*/
|
|
20
|
-
export declare function loadComponentPlugin(baseURL: URL, pluginName: string): ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
21
11
|
/**
|
|
22
12
|
* Imports a commonjs plugin module from the provided URL
|
|
23
13
|
* @param pluginUrl The URL of the plugin to load
|
|
24
14
|
* @returns The loaded module
|
|
25
15
|
*/
|
|
26
|
-
export declare function loadModulePlugin(pluginUrl: string): Promise<
|
|
16
|
+
export declare function loadModulePlugin(pluginUrl: string): Promise<LegacyPlugin | {
|
|
17
|
+
default: Plugin;
|
|
18
|
+
}>;
|
|
27
19
|
/**
|
|
28
20
|
* Loads a JSON file and returns the JSON object
|
|
29
21
|
* @param jsonUrl The URL of the JSON file to load
|
|
@@ -31,7 +23,7 @@ export declare function loadModulePlugin(pluginUrl: string): Promise<PluginModul
|
|
|
31
23
|
*/
|
|
32
24
|
export declare function loadJson(jsonUrl: string): Promise<PluginManifest>;
|
|
33
25
|
/**
|
|
34
|
-
* Load all plugin modules available
|
|
26
|
+
* Load all plugin modules available based on the manifest file at the provided base URL
|
|
35
27
|
* @param modulePluginsUrl The base URL of the module plugins to load
|
|
36
28
|
* @returns A map from the name of the plugin to the plugin module that was loaded
|
|
37
29
|
*/
|
|
@@ -46,5 +38,5 @@ export declare function getAuthHandlers(authConfigValues: Map<string, string>):
|
|
|
46
38
|
* @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins
|
|
47
39
|
* @returns The auth plugin component to render
|
|
48
40
|
*/
|
|
49
|
-
export declare function getAuthPluginComponent(pluginMap: PluginModuleMap, authConfigValues: Map<string, string>, corePlugins?: Map<string, AuthPlugin>): AuthPluginComponent;
|
|
41
|
+
export declare function getAuthPluginComponent(pluginMap: PluginModuleMap, authConfigValues: Map<string, string>, corePlugins?: Map<string, LegacyAuthPlugin | AuthPlugin>): AuthPluginComponent;
|
|
50
42
|
//# sourceMappingURL=PluginUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginUtils.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginUtils.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginUtils.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginUtils.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,gBAAgB,EAChB,YAAY,EACZ,MAAM,EAIP,MAAM,mBAAmB,CAAC;AAK3B,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,wBAAwB,EAAE,CAAA;CAAE,CAAC;AAErE;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAG7C;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAUvE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,eAAe,CAAC,CAsC1B;AAED,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,EAAE,CAEV;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,eAAe,EAC1B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,WAAW,6CAAmD,GAC7D,mBAAmB,CAwCrB"}
|
|
@@ -1,58 +1,9 @@
|
|
|
1
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
2
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
7
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { isAuthPlugin } from '@deephaven/auth-plugins';
|
|
10
3
|
import Log from '@deephaven/log';
|
|
11
|
-
import
|
|
4
|
+
import { isAuthPlugin, PluginType, isLegacyAuthPlugin, isLegacyPlugin } from '@deephaven/plugin';
|
|
12
5
|
import loadRemoteModule from "./loadRemoteModule.js";
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
6
|
var log = Log.module('@deephaven/app-utils.PluginUtils');
|
|
15
|
-
|
|
16
|
-
// A PluginModule. This interface should have new fields added to it from different levels of plugins.
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Load a component plugin from the server.
|
|
21
|
-
* @param baseURL Base URL of the plugin server
|
|
22
|
-
* @param pluginName Name of the component plugin to load
|
|
23
|
-
* @returns A lazily loaded JSX.Element from the plugin
|
|
24
|
-
*/
|
|
25
|
-
export function loadComponentPlugin(baseURL, pluginName) {
|
|
26
|
-
var pluginUrl = new URL("".concat(pluginName, ".js"), baseURL);
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
var Plugin = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/_jsx(RemoteComponent, {
|
|
29
|
-
url: pluginUrl.href
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
,
|
|
32
|
-
render: _ref => {
|
|
33
|
-
var {
|
|
34
|
-
err,
|
|
35
|
-
Component
|
|
36
|
-
} = _ref;
|
|
37
|
-
if (err != null && err !== '') {
|
|
38
|
-
var errorMessage = "Error loading plugin ".concat(pluginName, " from ").concat(pluginUrl, " due to ").concat(err);
|
|
39
|
-
log.error(errorMessage);
|
|
40
|
-
return /*#__PURE__*/_jsx("div", {
|
|
41
|
-
className: "error-message",
|
|
42
|
-
children: "".concat(errorMessage)
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
46
|
-
return /*#__PURE__*/_jsx(Component, _objectSpread({
|
|
47
|
-
ref: ref
|
|
48
|
-
}, props));
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
Plugin.pluginName = pluginName;
|
|
52
|
-
Plugin.displayName = 'Plugin';
|
|
53
|
-
return Plugin;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
7
|
/**
|
|
57
8
|
* Imports a commonjs plugin module from the provided URL
|
|
58
9
|
* @param pluginUrl The URL of the plugin to load
|
|
@@ -79,7 +30,7 @@ export function loadJson(_x2) {
|
|
|
79
30
|
}
|
|
80
31
|
|
|
81
32
|
/**
|
|
82
|
-
* Load all plugin modules available
|
|
33
|
+
* Load all plugin modules available based on the manifest file at the provided base URL
|
|
83
34
|
* @param modulePluginsUrl The base URL of the module plugins to load
|
|
84
35
|
* @returns A map from the name of the plugin to the plugin module that was loaded
|
|
85
36
|
*/
|
|
@@ -126,7 +77,7 @@ function _loadModulePlugins() {
|
|
|
126
77
|
name: _name
|
|
127
78
|
} = manifest.plugins[_i];
|
|
128
79
|
if (module.status === 'fulfilled') {
|
|
129
|
-
pluginMap.set(_name, module.value);
|
|
80
|
+
pluginMap.set(_name, isLegacyPlugin(module.value) ? module.value : module.value.default);
|
|
130
81
|
} else {
|
|
131
82
|
log.error("Unable to load plugin ".concat(_name), module.reason);
|
|
132
83
|
}
|
|
@@ -154,37 +105,48 @@ export function getAuthHandlers(authConfigValues) {
|
|
|
154
105
|
* @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins
|
|
155
106
|
* @returns The auth plugin component to render
|
|
156
107
|
*/
|
|
157
|
-
export function getAuthPluginComponent(pluginMap, authConfigValues
|
|
108
|
+
export function getAuthPluginComponent(pluginMap, authConfigValues) {
|
|
109
|
+
var corePlugins = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Map();
|
|
158
110
|
var authHandlers = getAuthHandlers(authConfigValues);
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
111
|
+
// User plugins take priority over core plugins
|
|
112
|
+
var authPlugins = [...pluginMap.entries(), ...corePlugins.entries()].filter(_ref => {
|
|
113
|
+
var [, plugin] = _ref;
|
|
114
|
+
return isAuthPlugin(plugin) || isLegacyAuthPlugin(plugin);
|
|
115
|
+
}).map(_ref2 => {
|
|
116
|
+
var [name, plugin] = _ref2;
|
|
117
|
+
if (isLegacyAuthPlugin(plugin)) {
|
|
118
|
+
return {
|
|
119
|
+
type: PluginType.AUTH_PLUGIN,
|
|
120
|
+
name,
|
|
121
|
+
component: plugin.AuthPlugin.Component,
|
|
122
|
+
isAvailable: plugin.AuthPlugin.isAvailable
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return plugin;
|
|
167
126
|
});
|
|
168
127
|
|
|
169
|
-
// Add all the core plugins in priority
|
|
170
|
-
authPlugins.push(...(corePlugins !== null && corePlugins !== void 0 ? corePlugins : []));
|
|
171
|
-
|
|
172
128
|
// Filter the available auth plugins
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
129
|
+
var availableAuthPlugins = authPlugins.filter(_ref3 => {
|
|
130
|
+
var {
|
|
131
|
+
isAvailable
|
|
132
|
+
} = _ref3;
|
|
133
|
+
return isAvailable(authHandlers, authConfigValues);
|
|
177
134
|
});
|
|
178
135
|
if (availableAuthPlugins.length === 0) {
|
|
179
136
|
throw new Error("No login plugins found, please register a login plugin for auth handlers: ".concat(authHandlers));
|
|
180
137
|
} else if (availableAuthPlugins.length > 1) {
|
|
181
|
-
log.warn('More than one login plugin available, will use the first one: ', availableAuthPlugins.map(
|
|
182
|
-
var
|
|
138
|
+
log.warn('More than one login plugin available, will use the first one: ', availableAuthPlugins.map(_ref4 => {
|
|
139
|
+
var {
|
|
140
|
+
name
|
|
141
|
+
} = _ref4;
|
|
183
142
|
return name;
|
|
184
143
|
}).join(', '));
|
|
185
144
|
}
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
145
|
+
var {
|
|
146
|
+
name,
|
|
147
|
+
component
|
|
148
|
+
} = availableAuthPlugins[0];
|
|
149
|
+
log.info('Using LoginPlugin', name);
|
|
150
|
+
return component;
|
|
189
151
|
}
|
|
190
152
|
//# sourceMappingURL=PluginUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginUtils.js","names":["React","isAuthPlugin","Log","RemoteComponent","loadRemoteModule","log","module","loadComponentPlugin","baseURL","pluginName","pluginUrl","URL","Plugin","forwardRef","props","ref","href","err","Component","errorMessage","error","displayName","loadModulePlugin","myModule","loadJson","jsonUrl","res","fetch","ok","Error","statusText","json","loadModulePlugins","modulePluginsUrl","debug","manifest","Array","isArray","plugins","pluginPromises","i","length","name","main","pluginMainUrl","push","pluginModules","Promise","allSettled","pluginMap","Map","status","set","value","reason","info","e","getAuthHandlers","authConfigValues","get","split","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","entries","filter","plugin","AuthPlugin","map","availableAuthPlugins","authPlugin","isAvailable","warn","join","loginPluginName","NewLoginPlugin"],"sources":["../../src/plugins/PluginUtils.tsx"],"sourcesContent":["import React, { ForwardRefExoticComponent } from 'react';\nimport {\n AuthPlugin,\n AuthPluginComponent,\n isAuthPlugin,\n} from '@deephaven/auth-plugins';\nimport Log from '@deephaven/log';\nimport RemoteComponent from './RemoteComponent';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\n\n// A PluginModule. This interface should have new fields added to it from different levels of plugins.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PluginModule {}\n\nexport type PluginModuleMap = Map<string, PluginModule>;\n\nexport type PluginManifestPluginInfo = {\n name: string;\n main: string;\n version: string;\n};\n\nexport type PluginManifest = { plugins: PluginManifestPluginInfo[] };\n\n/**\n * Load a component plugin from the server.\n * @param baseURL Base URL of the plugin server\n * @param pluginName Name of the component plugin to load\n * @returns A lazily loaded JSX.Element from the plugin\n */\nexport function loadComponentPlugin(\n baseURL: URL,\n pluginName: string\n): ForwardRefExoticComponent<React.RefAttributes<unknown>> {\n const pluginUrl = new URL(`${pluginName}.js`, baseURL);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Plugin: any = React.forwardRef((props, ref) => (\n <RemoteComponent\n url={pluginUrl.href}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n render={({ err, Component }: { err: unknown; Component: any }) => {\n if (err != null && err !== '') {\n const errorMessage = `Error loading plugin ${pluginName} from ${pluginUrl} due to ${err}`;\n log.error(errorMessage);\n return <div className=\"error-message\">{`${errorMessage}`}</div>;\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <Component ref={ref} {...props} />;\n }}\n />\n ));\n Plugin.pluginName = pluginName;\n Plugin.displayName = 'Plugin';\n return Plugin;\n}\n\n/**\n * Imports a commonjs plugin module from the provided URL\n * @param pluginUrl The URL of the plugin to load\n * @returns The loaded module\n */\nexport async function loadModulePlugin(\n pluginUrl: string\n): Promise<PluginModule> {\n const myModule = await loadRemoteModule(pluginUrl);\n return myModule;\n}\n\n/**\n * Loads a JSON file and returns the JSON object\n * @param jsonUrl The URL of the JSON file to load\n * @returns The JSON object of the manifest file\n */\nexport async function loadJson(jsonUrl: string): Promise<PluginManifest> {\n const res = await fetch(jsonUrl);\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n try {\n return await res.json();\n } catch {\n throw new Error('Could not be parsed as JSON');\n }\n}\n\n/**\n * Load all plugin modules available.\n * @param modulePluginsUrl The base URL of the module plugins to load\n * @returns A map from the name of the plugin to the plugin module that was loaded\n */\nexport async function loadModulePlugins(\n modulePluginsUrl: string\n): Promise<PluginModuleMap> {\n log.debug('Loading plugins...');\n try {\n const manifest = await loadJson(`${modulePluginsUrl}/manifest.json`);\n\n if (!Array.isArray(manifest.plugins)) {\n throw new Error('Plugin manifest JSON does not contain plugins array');\n }\n\n log.debug('Plugin manifest loaded:', manifest);\n const pluginPromises: Promise<PluginModule>[] = [];\n for (let i = 0; i < manifest.plugins.length; i += 1) {\n const { name, main } = manifest.plugins[i];\n const pluginMainUrl = `${modulePluginsUrl}/${name}/${main}`;\n pluginPromises.push(loadModulePlugin(pluginMainUrl));\n }\n const pluginModules = await Promise.allSettled(pluginPromises);\n\n const pluginMap: PluginModuleMap = new Map();\n for (let i = 0; i < pluginModules.length; i += 1) {\n const module = pluginModules[i];\n const { name } = manifest.plugins[i];\n if (module.status === 'fulfilled') {\n pluginMap.set(name, module.value);\n } else {\n log.error(`Unable to load plugin ${name}`, module.reason);\n }\n }\n log.info('Plugins loaded:', pluginMap);\n\n return pluginMap;\n } catch (e) {\n log.error('Unable to load plugins:', e);\n return new Map();\n }\n}\n\nexport function getAuthHandlers(\n authConfigValues: Map<string, string>\n): string[] {\n return authConfigValues.get('AuthHandlers')?.split(',') ?? [];\n}\n\n/**\n * Get the auth plugin component from the plugin map and current configuration\n * Throws if no auth plugin is available\n *\n * @param pluginMap Map of plugins loaded from the server\n * @param authConfigValues Auth config values from the server\n * @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins\n * @returns The auth plugin component to render\n */\nexport function getAuthPluginComponent(\n pluginMap: PluginModuleMap,\n authConfigValues: Map<string, string>,\n corePlugins?: Map<string, AuthPlugin>\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // Filter out all the plugins that are auth plugins, and then map them to [pluginName, AuthPlugin] pairs\n // Uses some pretty disgusting casting, because TypeScript wants to treat it as an (string | AuthPlugin)[] array instead\n const authPlugins = (\n [...pluginMap.entries()].filter(\n ([, plugin]: [string, { AuthPlugin?: AuthPlugin }]) =>\n isAuthPlugin(plugin.AuthPlugin)\n ) as [string, { AuthPlugin: AuthPlugin }][]\n ).map(([name, plugin]) => [name, plugin.AuthPlugin]) as [\n string,\n AuthPlugin,\n ][];\n\n // Add all the core plugins in priority\n authPlugins.push(...(corePlugins ?? []));\n\n // Filter the available auth plugins\n\n const availableAuthPlugins = authPlugins.filter(([name, authPlugin]) =>\n authPlugin.isAvailable(authHandlers, authConfigValues)\n );\n\n if (availableAuthPlugins.length === 0) {\n throw new Error(\n `No login plugins found, please register a login plugin for auth handlers: ${authHandlers}`\n );\n } else if (availableAuthPlugins.length > 1) {\n log.warn(\n 'More than one login plugin available, will use the first one: ',\n availableAuthPlugins.map(([name]) => name).join(', ')\n );\n }\n\n const [loginPluginName, NewLoginPlugin] = availableAuthPlugins[0];\n log.info('Using LoginPlugin', loginPluginName);\n\n return NewLoginPlugin.Component;\n}\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAqC,OAAO;AACxD,SAGEC,YAAY,QACP,yBAAyB;AAChC,O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AAY,CAACkE,MAAM,CAACC,UAAU,CAAC;EAAA,EAClC,CACDC,GAAG,CAAC;IAAA,IAAC,CAAC3B,IAAI,EAAEyB,MAAM,CAAC;IAAA,OAAK,CAACzB,IAAI,EAAEyB,MAAM,CAACC,UAAU,CAAC;EAAA,EAGhD;;EAEH;EACAJ,WAAW,CAACnB,IAAI,CAAC,IAAIiB,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI,EAAE,CAAC,CAAC;;EAExC;;EAEA,IAAMQ,oBAAoB,GAAGN,WAAW,CAACE,MAAM,CAAC;IAAA,IAAC,CAACxB,IAAI,EAAE6B,UAAU,CAAC;IAAA,OACjEA,UAAU,CAACC,WAAW,CAACT,YAAY,EAAEL,gBAAgB,CAAC;EAAA,EACvD;EAED,IAAIY,oBAAoB,CAAC7B,MAAM,KAAK,CAAC,EAAE;IACrC,MAAM,IAAIZ,KAAK,qFACgEkC,YAAY,EAC1F;EACH,CAAC,MAAM,IAAIO,oBAAoB,CAAC7B,MAAM,GAAG,CAAC,EAAE;IAC1CpC,GAAG,CAACoE,IAAI,CACN,gEAAgE,EAChEH,oBAAoB,CAACD,GAAG,CAAC;MAAA,IAAC,CAAC3B,IAAI,CAAC;MAAA,OAAKA,IAAI;IAAA,EAAC,CAACgC,IAAI,CAAC,IAAI,CAAC,CACtD;EACH;EAEA,IAAM,CAACC,eAAe,EAAEC,cAAc,CAAC,GAAGN,oBAAoB,CAAC,CAAC,CAAC;EACjEjE,GAAG,CAACkD,IAAI,CAAC,mBAAmB,EAAEoB,eAAe,CAAC;EAE9C,OAAOC,cAAc,CAAC1D,SAAS;AACjC"}
|
|
1
|
+
{"version":3,"file":"PluginUtils.js","names":["Log","isAuthPlugin","PluginType","isLegacyAuthPlugin","isLegacyPlugin","loadRemoteModule","log","module","loadModulePlugin","pluginUrl","myModule","loadJson","jsonUrl","res","fetch","ok","Error","statusText","json","loadModulePlugins","modulePluginsUrl","debug","manifest","Array","isArray","plugins","pluginPromises","i","length","name","main","pluginMainUrl","push","pluginModules","Promise","allSettled","pluginMap","Map","status","set","value","default","error","reason","info","e","getAuthHandlers","authConfigValues","get","split","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","entries","filter","plugin","map","type","AUTH_PLUGIN","component","AuthPlugin","Component","isAvailable","availableAuthPlugins","warn","join"],"sources":["../../src/plugins/PluginUtils.tsx"],"sourcesContent":["import Log from '@deephaven/log';\nimport {\n type PluginModule,\n type AuthPlugin,\n type AuthPluginComponent,\n isAuthPlugin,\n LegacyAuthPlugin,\n LegacyPlugin,\n Plugin,\n PluginType,\n isLegacyAuthPlugin,\n isLegacyPlugin,\n} from '@deephaven/plugin';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\n\nexport type PluginModuleMap = Map<string, PluginModule>;\n\nexport type PluginManifestPluginInfo = {\n name: string;\n main: string;\n version: string;\n};\n\nexport type PluginManifest = { plugins: PluginManifestPluginInfo[] };\n\n/**\n * Imports a commonjs plugin module from the provided URL\n * @param pluginUrl The URL of the plugin to load\n * @returns The loaded module\n */\nexport async function loadModulePlugin(\n pluginUrl: string\n): Promise<LegacyPlugin | { default: Plugin }> {\n const myModule = await loadRemoteModule(pluginUrl);\n return myModule;\n}\n\n/**\n * Loads a JSON file and returns the JSON object\n * @param jsonUrl The URL of the JSON file to load\n * @returns The JSON object of the manifest file\n */\nexport async function loadJson(jsonUrl: string): Promise<PluginManifest> {\n const res = await fetch(jsonUrl);\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n try {\n return await res.json();\n } catch {\n throw new Error('Could not be parsed as JSON');\n }\n}\n\n/**\n * Load all plugin modules available based on the manifest file at the provided base URL\n * @param modulePluginsUrl The base URL of the module plugins to load\n * @returns A map from the name of the plugin to the plugin module that was loaded\n */\nexport async function loadModulePlugins(\n modulePluginsUrl: string\n): Promise<PluginModuleMap> {\n log.debug('Loading plugins...');\n try {\n const manifest = await loadJson(`${modulePluginsUrl}/manifest.json`);\n\n if (!Array.isArray(manifest.plugins)) {\n throw new Error('Plugin manifest JSON does not contain plugins array');\n }\n\n log.debug('Plugin manifest loaded:', manifest);\n const pluginPromises: Promise<LegacyPlugin | { default: Plugin }>[] = [];\n for (let i = 0; i < manifest.plugins.length; i += 1) {\n const { name, main } = manifest.plugins[i];\n const pluginMainUrl = `${modulePluginsUrl}/${name}/${main}`;\n pluginPromises.push(loadModulePlugin(pluginMainUrl));\n }\n const pluginModules = await Promise.allSettled(pluginPromises);\n\n const pluginMap: PluginModuleMap = new Map();\n for (let i = 0; i < pluginModules.length; i += 1) {\n const module = pluginModules[i];\n const { name } = manifest.plugins[i];\n if (module.status === 'fulfilled') {\n pluginMap.set(\n name,\n isLegacyPlugin(module.value) ? module.value : module.value.default\n );\n } else {\n log.error(`Unable to load plugin ${name}`, module.reason);\n }\n }\n log.info('Plugins loaded:', pluginMap);\n\n return pluginMap;\n } catch (e) {\n log.error('Unable to load plugins:', e);\n return new Map();\n }\n}\n\nexport function getAuthHandlers(\n authConfigValues: Map<string, string>\n): string[] {\n return authConfigValues.get('AuthHandlers')?.split(',') ?? [];\n}\n\n/**\n * Get the auth plugin component from the plugin map and current configuration\n * Throws if no auth plugin is available\n *\n * @param pluginMap Map of plugins loaded from the server\n * @param authConfigValues Auth config values from the server\n * @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins\n * @returns The auth plugin component to render\n */\nexport function getAuthPluginComponent(\n pluginMap: PluginModuleMap,\n authConfigValues: Map<string, string>,\n corePlugins = new Map<string, AuthPlugin | LegacyAuthPlugin>()\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // User plugins take priority over core plugins\n const authPlugins = (\n [...pluginMap.entries(), ...corePlugins.entries()].filter(\n ([, plugin]) => isAuthPlugin(plugin) || isLegacyAuthPlugin(plugin)\n ) as [string, AuthPlugin | LegacyAuthPlugin][]\n ).map(([name, plugin]) => {\n if (isLegacyAuthPlugin(plugin)) {\n return {\n type: PluginType.AUTH_PLUGIN,\n name,\n component: plugin.AuthPlugin.Component,\n isAvailable: plugin.AuthPlugin.isAvailable,\n };\n }\n\n return plugin;\n });\n\n // Filter the available auth plugins\n const availableAuthPlugins = authPlugins.filter(({ isAvailable }) =>\n isAvailable(authHandlers, authConfigValues)\n );\n\n if (availableAuthPlugins.length === 0) {\n throw new Error(\n `No login plugins found, please register a login plugin for auth handlers: ${authHandlers}`\n );\n } else if (availableAuthPlugins.length > 1) {\n log.warn(\n 'More than one login plugin available, will use the first one: ',\n availableAuthPlugins.map(({ name }) => name).join(', ')\n );\n }\n\n const { name, component } = availableAuthPlugins[0];\n log.info('Using LoginPlugin', name);\n\n return component;\n}\n"],"mappings":";;AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAIEC,YAAY,EAIZC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,QACT,mBAAmB;AAAC,OACpBC,gBAAgB;AAEvB,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,CAAC,kCAAkC,CAAC;AAY1D;AACA;AACA;AACA;AACA;AACA,gBAAsBC,gBAAgB;EAAA;AAAA;;AAOtC;AACA;AACA;AACA;AACA;AAJA;EAAA,sCAPO,WACLC,SAAiB,EAC4B;IAC7C,IAAMC,QAAQ,SAASL,gBAAgB,CAACI,SAAS,CAAC;IAClD,OAAOC,QAAQ;EACjB,CAAC;EAAA;AAAA;AAOD,gBAAsBC,QAAQ;EAAA;AAAA;;AAY9B;AACA;AACA;AACA;AACA;AAJA;EAAA,8BAZO,WAAwBC,OAAe,EAA2B;IACvE,IAAMC,GAAG,SAASC,KAAK,CAACF,OAAO,CAAC;IAChC,IAAI,CAACC,GAAG,CAACE,EAAE,EAAE;MACX,MAAM,IAAIC,KAAK,CAACH,GAAG,CAACI,UAAU,CAAC;IACjC;IACA,IAAI;MACF,aAAaJ,GAAG,CAACK,IAAI,EAAE;IACzB,CAAC,CAAC,gBAAM;MACN,MAAM,IAAIF,KAAK,CAAC,6BAA6B,CAAC;IAChD;EACF,CAAC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UAAU,CAACyD,WAAW;QAC5B9B,IAAI;QACJ+B,SAAS,EAAEJ,MAAM,CAACK,UAAU,CAACC,SAAS;QACtCC,WAAW,EAAEP,MAAM,CAACK,UAAU,CAACE;MACjC,CAAC;IACH;IAEA,OAAOP,MAAM;EACf,CAAC,CAAC;;EAEF;EACA,IAAMQ,oBAAoB,GAAGX,WAAW,CAACE,MAAM,CAAC;IAAA,IAAC;MAAEQ;IAAY,CAAC;IAAA,OAC9DA,WAAW,CAACX,YAAY,EAAEL,gBAAgB,CAAC;EAAA,EAC5C;EAED,IAAIiB,oBAAoB,CAACpC,MAAM,KAAK,CAAC,EAAE;IACrC,MAAM,IAAIZ,KAAK,qFACgEoC,YAAY,EAC1F;EACH,CAAC,MAAM,IAAIY,oBAAoB,CAACpC,MAAM,GAAG,CAAC,EAAE;IAC1CtB,GAAG,CAAC2D,IAAI,CACN,gEAAgE,EAChED,oBAAoB,CAACP,GAAG,CAAC;MAAA,IAAC;QAAE5B;MAAK,CAAC;MAAA,OAAKA,IAAI;IAAA,EAAC,CAACqC,IAAI,CAAC,IAAI,CAAC,CACxD;EACH;EAEA,IAAM;IAAErC,IAAI;IAAE+B;EAAU,CAAC,GAAGI,oBAAoB,CAAC,CAAC,CAAC;EACnD1D,GAAG,CAACsC,IAAI,CAAC,mBAAmB,EAAEf,IAAI,CAAC;EAEnC,OAAO+B,SAAS;AAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/app-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Deephaven App Utils",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,15 +28,16 @@
|
|
|
28
28
|
"redux": "^4.x"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@deephaven/auth-plugins": "^0.
|
|
32
|
-
"@deephaven/components": "^0.
|
|
33
|
-
"@deephaven/jsapi-bootstrap": "^0.
|
|
34
|
-
"@deephaven/jsapi-components": "^0.
|
|
35
|
-
"@deephaven/jsapi-types": "^0.
|
|
36
|
-
"@deephaven/jsapi-utils": "^0.
|
|
37
|
-
"@deephaven/log": "^0.
|
|
38
|
-
"@deephaven/
|
|
39
|
-
"@deephaven/
|
|
31
|
+
"@deephaven/auth-plugins": "^0.47.0",
|
|
32
|
+
"@deephaven/components": "^0.47.0",
|
|
33
|
+
"@deephaven/jsapi-bootstrap": "^0.47.0",
|
|
34
|
+
"@deephaven/jsapi-components": "^0.47.0",
|
|
35
|
+
"@deephaven/jsapi-types": "^0.47.0",
|
|
36
|
+
"@deephaven/jsapi-utils": "^0.47.0",
|
|
37
|
+
"@deephaven/log": "^0.47.0",
|
|
38
|
+
"@deephaven/plugin": "^0.47.0",
|
|
39
|
+
"@deephaven/react-hooks": "^0.47.0",
|
|
40
|
+
"@deephaven/utils": "^0.47.0",
|
|
40
41
|
"@paciolan/remote-component": "2.13.0",
|
|
41
42
|
"@paciolan/remote-module-loader": "^3.0.2",
|
|
42
43
|
"fira": "mozilla/fira#4.202"
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "8d890b724d6c8bdb73eb03463f9c850ca57094bd"
|
|
60
61
|
}
|