@deephaven/auth-plugins 0.37.1-auth-plugins.2 → 0.37.1-redux-peer-dep.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,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { CoreClient } from '@deephaven/jsapi-types';
2
3
  /**
3
4
  * Map from auth config keys to their values
4
5
  * E.g. Map { AuthHandlers → "io.deephaven.auth.AnonymousAuthenticationHandler" }
@@ -10,10 +11,12 @@ export type AuthConfigMap = Map<string, string>;
10
11
  export type AuthPluginProps = {
11
12
  /** Map from config keys to their values */
12
13
  authConfigValues: AuthConfigMap;
13
- /**
14
- * The children to render after authentication is completed.
15
- */
16
- children: React.ReactNode;
14
+ /** Client to check auth configuration on */
15
+ client: CoreClient;
16
+ /** Called when authentication is sucessful */
17
+ onSuccess(): void;
18
+ /** Called when authentication fails */
19
+ onFailure(error: unknown): void;
17
20
  };
18
21
  export type AuthPluginComponent = React.FunctionComponent<AuthPluginProps>;
19
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPlugin.d.ts","sourceRoot":"","sources":["../src/AuthPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2CAA2C;IAC3C,gBAAgB,EAAE,aAAa,CAAC;IAEhC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;AAEhF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,WAAW,EAAE,6BAA6B,CAAC;CAC5C,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,IAAI,UAAU,CAOnE"}
1
+ {"version":3,"file":"AuthPlugin.d.ts","sourceRoot":"","sources":["../src/AuthPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2CAA2C;IAC3C,gBAAgB,EAAE,aAAa,CAAC;IAEhC,4CAA4C;IAC5C,MAAM,EAAE,UAAU,CAAC;IAEnB,8CAA8C;IAC9C,SAAS,IAAI,IAAI,CAAC;IAElB,uCAAuC;IACvC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;AAEhF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,WAAW,EAAE,6BAA6B,CAAC;CAC5C,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,IAAI,UAAU,CAOnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPlugin.js","names":["isAuthPlugin","plugin","authPlugin","Component","undefined","isAvailable"],"sources":["../src/AuthPlugin.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * Map from auth config keys to their values\n * E.g. Map { AuthHandlers → \"io.deephaven.auth.AnonymousAuthenticationHandler\" }\n */\nexport type AuthConfigMap = Map<string, string>;\n\n/**\n * Props for the auth plugin component to render\n */\nexport type AuthPluginProps = {\n /** Map from config keys to their values */\n authConfigValues: AuthConfigMap;\n\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\nexport type AuthPluginComponent = React.FunctionComponent<AuthPluginProps>;\n\n/**\n * Whether the auth plugin is available given the current configuration\n */\nexport type AuthPluginIsAvailableFunction = (authHandlers: string[]) => boolean;\n\nexport type AuthPlugin = {\n Component: AuthPluginComponent;\n isAvailable: AuthPluginIsAvailableFunction;\n};\n\nexport function isAuthPlugin(plugin?: unknown): plugin is AuthPlugin {\n if (plugin == null) return false;\n const authPlugin = plugin as AuthPlugin;\n return (\n authPlugin.Component !== undefined &&\n typeof authPlugin.isAvailable === 'function'\n );\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAQA,OAAO,SAASA,YAAY,CAACC,MAAgB,EAAwB;EACnE,IAAIA,MAAM,IAAI,IAAI,EAAE,OAAO,KAAK;EAChC,IAAMC,UAAU,GAAGD,MAAoB;EACvC,OACEC,UAAU,CAACC,SAAS,KAAKC,SAAS,IAClC,OAAOF,UAAU,CAACG,WAAW,KAAK,UAAU;AAEhD"}
1
+ {"version":3,"file":"AuthPlugin.js","names":["isAuthPlugin","plugin","authPlugin","Component","undefined","isAvailable"],"sources":["../src/AuthPlugin.ts"],"sourcesContent":["import React from 'react';\nimport { CoreClient } from '@deephaven/jsapi-types';\n\n/**\n * Map from auth config keys to their values\n * E.g. Map { AuthHandlers → \"io.deephaven.auth.AnonymousAuthenticationHandler\" }\n */\nexport type AuthConfigMap = Map<string, string>;\n\n/**\n * Props for the auth plugin component to render\n */\nexport type AuthPluginProps = {\n /** Map from config keys to their values */\n authConfigValues: AuthConfigMap;\n\n /** Client to check auth configuration on */\n client: CoreClient;\n\n /** Called when authentication is sucessful */\n onSuccess(): void;\n\n /** Called when authentication fails */\n onFailure(error: unknown): void;\n};\n\nexport type AuthPluginComponent = React.FunctionComponent<AuthPluginProps>;\n\n/**\n * Whether the auth plugin is available given the current configuration\n */\nexport type AuthPluginIsAvailableFunction = (authHandlers: string[]) => boolean;\n\nexport type AuthPlugin = {\n Component: AuthPluginComponent;\n isAvailable: AuthPluginIsAvailableFunction;\n};\n\nexport function isAuthPlugin(plugin?: unknown): plugin is AuthPlugin {\n if (plugin == null) return false;\n const authPlugin = plugin as AuthPlugin;\n return (\n authPlugin.Component !== undefined &&\n typeof authPlugin.isAvailable === 'function'\n );\n}\n"],"mappings":"AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAQA,OAAO,SAASA,YAAY,CAACC,MAAgB,EAAwB;EACnE,IAAIA,MAAM,IAAI,IAAI,EAAE,OAAO,KAAK;EAChC,IAAMC,UAAU,GAAGD,MAAoB;EACvC,OACEC,UAAU,CAACC,SAAS,KAAKC,SAAS,IAClC,OAAOF,UAAU,CAACG,WAAW,KAAK,UAAU;AAEhD"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginAnonymous.d.ts","sourceRoot":"","sources":["../src/AuthPluginAnonymous.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAqB3D,QAAA,MAAM,mBAAmB,EAAE,UAI1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"AuthPluginAnonymous.d.ts","sourceRoot":"","sources":["../src/AuthPluginAnonymous.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAoD3D,QAAA,MAAM,mBAAmB,EAAE,UAI1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,25 +1,64 @@
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
- import React, { useCallback } from 'react';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { useApi } from '@deephaven/jsapi-bootstrap';
5
+ import Log from '@deephaven/log';
6
+ import { LoadingOverlay } from '@deephaven/components';
5
7
  import { AUTH_HANDLER_TYPE_ANONYMOUS } from "./AuthHandlerTypes.js";
6
- import AuthPluginBase from "./AuthPluginBase.js";
8
+ var log = Log.module('AuthPluginAnonymous');
9
+
7
10
  /**
8
11
  * AuthPlugin that tries to login anonymously. Fails if anonymous login fails
9
12
  */
10
13
  function Component(_ref) {
11
14
  var {
12
- children
15
+ client,
16
+ onSuccess,
17
+ onFailure
13
18
  } = _ref;
19
+ var [error, setError] = useState();
14
20
  var dh = useApi();
15
- var getLoginOptions = useCallback( /*#__PURE__*/_asyncToGenerator(function* () {
16
- return {
17
- type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS
21
+ useEffect(() => {
22
+ var isCanceled = false;
23
+ function login() {
24
+ return _login.apply(this, arguments);
25
+ }
26
+ function _login() {
27
+ _login = _asyncToGenerator(function* () {
28
+ try {
29
+ log.info('Logging in...');
30
+ yield client.login({
31
+ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS
32
+ });
33
+ if (isCanceled) {
34
+ log.info('Previous login result canceled');
35
+ return;
36
+ }
37
+ log.info('Logged in successfully.');
38
+ onSuccess();
39
+ } catch (e) {
40
+ if (isCanceled) {
41
+ log.info('Previous login failure canceled');
42
+ return;
43
+ }
44
+ log.error('Unable to login:', e);
45
+ setError(e);
46
+ onFailure(e);
47
+ }
48
+ });
49
+ return _login.apply(this, arguments);
50
+ }
51
+ login();
52
+ return () => {
53
+ isCanceled = true;
18
54
  };
19
- }), [dh]);
20
- return /*#__PURE__*/React.createElement(AuthPluginBase, {
21
- getLoginOptions: getLoginOptions
22
- }, children);
55
+ }, [client, dh, onFailure, onSuccess]);
56
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
57
+ "data-testid": "auth-anonymous-loading",
58
+ isLoading: true,
59
+ isLoaded: false,
60
+ errorMessage: error != null ? "".concat(error) : null
61
+ });
23
62
  }
24
63
  var AuthPluginAnonymous = {
25
64
  Component,
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginAnonymous.js","names":["React","useCallback","useApi","AUTH_HANDLER_TYPE_ANONYMOUS","AuthPluginBase","Component","children","dh","getLoginOptions","type","CoreClient","LOGIN_TYPE_ANONYMOUS","AuthPluginAnonymous","isAvailable","authHandlers","includes"],"sources":["../src/AuthPluginAnonymous.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { AUTH_HANDLER_TYPE_ANONYMOUS } from './AuthHandlerTypes';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\n/**\n * AuthPlugin that tries to login anonymously. Fails if anonymous login fails\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n const dh = useApi();\n\n const getLoginOptions = useCallback(\n async () => ({ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS }),\n [dh]\n );\n\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginAnonymous: AuthPlugin = {\n Component,\n isAvailable: authHandlers =>\n authHandlers.includes(AUTH_HANDLER_TYPE_ANONYMOUS),\n};\n\nexport default AuthPluginAnonymous;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,MAAM,QAAQ,4BAA4B;AAAC,SAC3CC,2BAA2B;AAAA,OAE7BC,cAAc;AAErB;AACA;AACA;AACA,SAASC,SAAS,OAA6C;EAAA,IAA5C;IAAEC;EAA0B,CAAC;EAC9C,IAAMC,EAAE,GAAGL,MAAM,EAAE;EAEnB,IAAMM,eAAe,GAAGP,WAAW,iCACjC;IAAA,OAAa;MAAEQ,IAAI,EAAEF,EAAE,CAACG,UAAU,CAACC;IAAqB,CAAC;EAAA,CAAC,GAC1D,CAACJ,EAAE,CAAC,CACL;EAED,oBACE,oBAAC,cAAc;IAAC,eAAe,EAAEC;EAAgB,GAC9CF,QAAQ,CACM;AAErB;AAEA,IAAMM,mBAA+B,GAAG;EACtCP,SAAS;EACTQ,WAAW,EAAEC,YAAY,IACvBA,YAAY,CAACC,QAAQ,CAACZ,2BAA2B;AACrD,CAAC;AAED,eAAeS,mBAAmB"}
1
+ {"version":3,"file":"AuthPluginAnonymous.js","names":["React","useEffect","useState","useApi","Log","LoadingOverlay","AUTH_HANDLER_TYPE_ANONYMOUS","log","module","Component","client","onSuccess","onFailure","error","setError","dh","isCanceled","login","info","type","CoreClient","LOGIN_TYPE_ANONYMOUS","e","AuthPluginAnonymous","isAvailable","authHandlers","includes"],"sources":["../src/AuthPluginAnonymous.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AUTH_HANDLER_TYPE_ANONYMOUS } from './AuthHandlerTypes';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginAnonymous');\n\n/**\n * AuthPlugin that tries to login anonymously. Fails if anonymous login fails\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const dh = useApi();\n\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n log.info('Logging in...');\n await client.login({ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, dh, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-anonymous-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginAnonymous: AuthPlugin = {\n Component,\n isAvailable: authHandlers =>\n authHandlers.includes(AUTH_HANDLER_TYPE_ANONYMOUS),\n};\n\nexport default AuthPluginAnonymous;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,MAAM,QAAQ,4BAA4B;AACnD,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,cAAc,QAAQ,uBAAuB;AAAC,SAC9CC,2BAA2B;AAGpC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,qBAAqB,CAAC;;AAE7C;AACA;AACA;AACA,SAASC,SAAS,OAIe;EAAA,IAJd;IACjBC,MAAM;IACNC,SAAS;IACTC;EACe,CAAC;EAChB,IAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,EAAW;EAC7C,IAAMa,EAAE,GAAGZ,MAAM,EAAE;EAEnBF,SAAS,CAAC,MAAM;IACd,IAAIe,UAAU,GAAG,KAAK;IAAC,SACRC,KAAK;MAAA;IAAA;IAAA;MAAA,2BAApB,aAAuB;QACrB,IAAI;UACFV,GAAG,CAACW,IAAI,CAAC,eAAe,CAAC;UACzB,MAAMR,MAAM,CAACO,KAAK,CAAC;YAAEE,IAAI,EAAEJ,EAAE,CAACK,UAAU,CAACC;UAAqB,CAAC,CAAC;UAChE,IAAIL,UAAU,EAAE;YACdT,GAAG,CAACW,IAAI,CAAC,gCAAgC,CAAC;YAC1C;UACF;UACAX,GAAG,CAACW,IAAI,CAAC,yBAAyB,CAAC;UACnCP,SAAS,EAAE;QACb,CAAC,CAAC,OAAOW,CAAC,EAAE;UACV,IAAIN,UAAU,EAAE;YACdT,GAAG,CAACW,IAAI,CAAC,iCAAiC,CAAC;YAC3C;UACF;UACAX,GAAG,CAACM,KAAK,CAAC,kBAAkB,EAAES,CAAC,CAAC;UAChCR,QAAQ,CAACQ,CAAC,CAAC;UACXV,SAAS,CAACU,CAAC,CAAC;QACd;MACF,CAAC;MAAA;IAAA;IACDL,KAAK,EAAE;IACP,OAAO,MAAM;MACXD,UAAU,GAAG,IAAI;IACnB,CAAC;EACH,CAAC,EAAE,CAACN,MAAM,EAAEK,EAAE,EAAEH,SAAS,EAAED,SAAS,CAAC,CAAC;EACtC,oBACE,oBAAC,cAAc;IACb,eAAY,wBAAwB;IACpC,SAAS;IACT,QAAQ,EAAE,KAAM;IAChB,YAAY,EAAEE,KAAK,IAAI,IAAI,aAAMA,KAAK,IAAK;EAAK,EAChD;AAEN;AAEA,IAAMU,mBAA+B,GAAG;EACtCd,SAAS;EACTe,WAAW,EAAEC,YAAY,IACvBA,YAAY,CAACC,QAAQ,CAACpB,2BAA2B;AACrD,CAAC;AAED,eAAeiB,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginParent.d.ts","sourceRoot":"","sources":["../src/AuthPluginParent.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAyB3D,QAAA,MAAM,gBAAgB,EAAE,UAIvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"AuthPluginParent.d.ts","sourceRoot":"","sources":["../src/AuthPluginParent.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AA8C3D,QAAA,MAAM,gBAAgB,EAAE,UAIvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,12 +1,10 @@
1
- import React from 'react';
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
+ 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
+ import React, { useEffect, useState } from 'react';
2
4
  import { LOGIN_OPTIONS_REQUEST, requestParentResponse } from '@deephaven/jsapi-utils';
3
5
  import Log from '@deephaven/log';
4
- import AuthPluginBase from "./AuthPluginBase.js";
6
+ import { LoadingOverlay } from '@deephaven/components';
5
7
  var log = Log.module('AuthPluginParent');
6
- function getLoginOptions() {
7
- log.info('Logging in by delegating to parent window...');
8
- return requestParentResponse(LOGIN_OPTIONS_REQUEST);
9
- }
10
8
  function getWindowAuthProvider() {
11
9
  var _URLSearchParams$get;
12
10
  return (_URLSearchParams$get = new URLSearchParams(window.location.search).get('authProvider')) !== null && _URLSearchParams$get !== void 0 ? _URLSearchParams$get : '';
@@ -17,11 +15,39 @@ function getWindowAuthProvider() {
17
15
  */
18
16
  function Component(_ref) {
19
17
  var {
20
- children
18
+ client,
19
+ onSuccess,
20
+ onFailure
21
21
  } = _ref;
22
- return /*#__PURE__*/React.createElement(AuthPluginBase, {
23
- getLoginOptions: getLoginOptions
24
- }, children);
22
+ var [error, setError] = useState();
23
+ useEffect(() => {
24
+ function login() {
25
+ return _login.apply(this, arguments);
26
+ }
27
+ function _login() {
28
+ _login = _asyncToGenerator(function* () {
29
+ try {
30
+ log.info('Logging in by delegating to parent window...');
31
+ var loginOptions = yield requestParentResponse(LOGIN_OPTIONS_REQUEST);
32
+ yield client.login(loginOptions);
33
+ log.info('Logged in successfully.');
34
+ onSuccess();
35
+ } catch (e) {
36
+ log.error('Unable to login:', e);
37
+ setError(e);
38
+ onFailure(e);
39
+ }
40
+ });
41
+ return _login.apply(this, arguments);
42
+ }
43
+ login();
44
+ }, [client, onFailure, onSuccess]);
45
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
46
+ "data-testid": "auth-parent-loading",
47
+ isLoading: true,
48
+ isLoaded: false,
49
+ errorMessage: error != null ? "".concat(error) : null
50
+ });
25
51
  }
26
52
  var AuthPluginParent = {
27
53
  Component,
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginParent.js","names":["React","LOGIN_OPTIONS_REQUEST","requestParentResponse","Log","AuthPluginBase","log","module","getLoginOptions","info","getWindowAuthProvider","URLSearchParams","window","location","search","get","Component","children","AuthPluginParent","isAvailable","opener"],"sources":["../src/AuthPluginParent.tsx"],"sourcesContent":["import React from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport {\n LOGIN_OPTIONS_REQUEST,\n requestParentResponse,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\nconst log = Log.module('AuthPluginParent');\n\nfunction getLoginOptions(): Promise<LoginOptions> {\n log.info('Logging in by delegating to parent window...');\n return requestParentResponse<LoginOptions>(LOGIN_OPTIONS_REQUEST);\n}\n\nfunction getWindowAuthProvider(): string {\n return new URLSearchParams(window.location.search).get('authProvider') ?? '';\n}\n\n/**\n * AuthPlugin that tries to delegate to the parent window for authentication. Fails if there is no parent window.\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginParent: AuthPlugin = {\n Component,\n isAvailable: () =>\n window.opener != null && getWindowAuthProvider() === 'parent',\n};\n\nexport default AuthPluginParent;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SACEC,qBAAqB,EACrBC,qBAAqB,QAChB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAE1BC,cAAc;AAErB,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,kBAAkB,CAAC;AAE1C,SAASC,eAAe,GAA0B;EAChDF,GAAG,CAACG,IAAI,CAAC,8CAA8C,CAAC;EACxD,OAAON,qBAAqB,CAAeD,qBAAqB,CAAC;AACnE;AAEA,SAASQ,qBAAqB,GAAW;EAAA;EACvC,+BAAO,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,cAAc,CAAC,uEAAI,EAAE;AAC9E;;AAEA;AACA;AACA;AACA,SAASC,SAAS,OAA6C;EAAA,IAA5C;IAAEC;EAA0B,CAAC;EAC9C,oBACE,oBAAC,cAAc;IAAC,eAAe,EAAET;EAAgB,GAC9CS,QAAQ,CACM;AAErB;AAEA,IAAMC,gBAA4B,GAAG;EACnCF,SAAS;EACTG,WAAW,EAAE,MACXP,MAAM,CAACQ,MAAM,IAAI,IAAI,IAAIV,qBAAqB,EAAE,KAAK;AACzD,CAAC;AAED,eAAeQ,gBAAgB"}
1
+ {"version":3,"file":"AuthPluginParent.js","names":["React","useEffect","useState","LOGIN_OPTIONS_REQUEST","requestParentResponse","Log","LoadingOverlay","log","module","getWindowAuthProvider","URLSearchParams","window","location","search","get","Component","client","onSuccess","onFailure","error","setError","login","info","loginOptions","e","AuthPluginParent","isAvailable","opener"],"sources":["../src/AuthPluginParent.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport {\n LOGIN_OPTIONS_REQUEST,\n requestParentResponse,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginParent');\n\nfunction getWindowAuthProvider(): string {\n return new URLSearchParams(window.location.search).get('authProvider') ?? '';\n}\n\n/**\n * AuthPlugin that tries to delegate to the parent window for authentication. Fails if there is no parent window.\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n useEffect(() => {\n async function login() {\n try {\n log.info('Logging in by delegating to parent window...');\n const loginOptions = await requestParentResponse<LoginOptions>(\n LOGIN_OPTIONS_REQUEST\n );\n\n await client.login(loginOptions);\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n }, [client, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-parent-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginParent: AuthPlugin = {\n Component,\n isAvailable: () =>\n window.opener != null && getWindowAuthProvider() === 'parent',\n};\n\nexport default AuthPluginParent;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAElD,SACEC,qBAAqB,EACrBC,qBAAqB,QAChB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,cAAc,QAAQ,uBAAuB;AAGtD,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,kBAAkB,CAAC;AAE1C,SAASC,qBAAqB,GAAW;EAAA;EACvC,+BAAO,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,cAAc,CAAC,uEAAI,EAAE;AAC9E;;AAEA;AACA;AACA;AACA,SAASC,SAAS,OAIe;EAAA,IAJd;IACjBC,MAAM;IACNC,SAAS;IACTC;EACe,CAAC;EAChB,IAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGlB,QAAQ,EAAW;EAC7CD,SAAS,CAAC,MAAM;IAAA,SACCoB,KAAK;MAAA;IAAA;IAAA;MAAA,2BAApB,aAAuB;QACrB,IAAI;UACFd,GAAG,CAACe,IAAI,CAAC,8CAA8C,CAAC;UACxD,IAAMC,YAAY,SAASnB,qBAAqB,CAC9CD,qBAAqB,CACtB;UAED,MAAMa,MAAM,CAACK,KAAK,CAACE,YAAY,CAAC;UAChChB,GAAG,CAACe,IAAI,CAAC,yBAAyB,CAAC;UACnCL,SAAS,EAAE;QACb,CAAC,CAAC,OAAOO,CAAC,EAAE;UACVjB,GAAG,CAACY,KAAK,CAAC,kBAAkB,EAAEK,CAAC,CAAC;UAChCJ,QAAQ,CAACI,CAAC,CAAC;UACXN,SAAS,CAACM,CAAC,CAAC;QACd;MACF,CAAC;MAAA;IAAA;IACDH,KAAK,EAAE;EACT,CAAC,EAAE,CAACL,MAAM,EAAEE,SAAS,EAAED,SAAS,CAAC,CAAC;EAClC,oBACE,oBAAC,cAAc;IACb,eAAY,qBAAqB;IACjC,SAAS;IACT,QAAQ,EAAE,KAAM;IAChB,YAAY,EAAEE,KAAK,IAAI,IAAI,aAAMA,KAAK,IAAK;EAAK,EAChD;AAEN;AAEA,IAAMM,gBAA4B,GAAG;EACnCV,SAAS;EACTW,WAAW,EAAE,MACXf,MAAM,CAACgB,MAAM,IAAI,IAAI,IAAIlB,qBAAqB,EAAE,KAAK;AACzD,CAAC;AAED,eAAegB,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginPsk.d.ts","sourceRoot":"","sources":["../src/AuthPluginPsk.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AA2B3D,QAAA,MAAM,aAAa,EAAE,UAGpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AuthPluginPsk.d.ts","sourceRoot":"","sources":["../src/AuthPluginPsk.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AA+D3D,QAAA,MAAM,aAAa,EAAE,UAGpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,36 +1,72 @@
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
- import React from 'react';
4
- import AuthPluginBase from "./AuthPluginBase.js";
3
+ import React, { useEffect, useState } from 'react';
4
+ import Log from '@deephaven/log';
5
+ import { LoadingOverlay } from '@deephaven/components';
6
+ var log = Log.module('AuthPluginPsk');
5
7
  var AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';
6
- function getLoginOptions() {
7
- return _getLoginOptions.apply(this, arguments);
8
+ function getWindowToken() {
9
+ var _URLSearchParams$get;
10
+ return (_URLSearchParams$get = new URLSearchParams(window.location.search).get('psk')) !== null && _URLSearchParams$get !== void 0 ? _URLSearchParams$get : '';
8
11
  }
12
+
9
13
  /**
10
14
  * AuthPlugin that tries to login using a pre-shared key.
11
15
  * Add the `psk=<token>` parameter to your URL string to set the token.
12
16
  */
13
- function _getLoginOptions() {
14
- _getLoginOptions = _asyncToGenerator(function* () {
15
- var _URLSearchParams$get;
16
- var token = (_URLSearchParams$get = new URLSearchParams(window.location.search).get('psk')) !== null && _URLSearchParams$get !== void 0 ? _URLSearchParams$get : '';
17
- if (!token) {
18
- throw new Error('No Pre-shared key token found. Add `psk=<token>` parameter to your URL');
19
- }
20
- return {
21
- type: AUTH_TYPE,
22
- token
23
- };
24
- });
25
- return _getLoginOptions.apply(this, arguments);
26
- }
27
17
  function Component(_ref) {
28
18
  var {
29
- children
19
+ client,
20
+ onSuccess,
21
+ onFailure
30
22
  } = _ref;
31
- return /*#__PURE__*/React.createElement(AuthPluginBase, {
32
- getLoginOptions: getLoginOptions
33
- }, children);
23
+ var [error, setError] = useState();
24
+ var [token] = useState(() => getWindowToken());
25
+ useEffect(() => {
26
+ var isCanceled = false;
27
+ function login() {
28
+ return _login.apply(this, arguments);
29
+ }
30
+ function _login() {
31
+ _login = _asyncToGenerator(function* () {
32
+ try {
33
+ if (!token) {
34
+ throw new Error('No Pre-shared key token found. Add `psk=<token>` parameter to your URL');
35
+ }
36
+ log.info('Logging in with found token...');
37
+ yield client.login({
38
+ type: AUTH_TYPE,
39
+ token
40
+ });
41
+ if (isCanceled) {
42
+ log.info('Previous login result canceled');
43
+ return;
44
+ }
45
+ log.info('Logged in successfully.');
46
+ onSuccess();
47
+ } catch (e) {
48
+ if (isCanceled) {
49
+ log.info('Previous login failure canceled');
50
+ return;
51
+ }
52
+ log.error('Unable to login:', e);
53
+ setError(e);
54
+ onFailure(e);
55
+ }
56
+ });
57
+ return _login.apply(this, arguments);
58
+ }
59
+ login();
60
+ return () => {
61
+ isCanceled = true;
62
+ };
63
+ }, [client, onFailure, onSuccess, token]);
64
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
65
+ "data-testid": "auth-psk-loading",
66
+ isLoading: true,
67
+ isLoaded: false,
68
+ errorMessage: error != null ? "".concat(error) : null
69
+ });
34
70
  }
35
71
  var AuthPluginPsk = {
36
72
  Component,
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPluginPsk.js","names":["React","AuthPluginBase","AUTH_TYPE","getLoginOptions","token","URLSearchParams","window","location","search","get","Error","type","Component","children","AuthPluginPsk","isAvailable","authHandlers","includes"],"sources":["../src/AuthPluginPsk.tsx"],"sourcesContent":["import React from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\nconst AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n\nasync function getLoginOptions(): Promise<LoginOptions> {\n const token = new URLSearchParams(window.location.search).get('psk') ?? '';\n if (!token) {\n throw new Error(\n 'No Pre-shared key token found. Add `psk=<token>` parameter to your URL'\n );\n }\n return { type: AUTH_TYPE, token };\n}\n\n/**\n * AuthPlugin that tries to login using a pre-shared key.\n * Add the `psk=<token>` parameter to your URL string to set the token.\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginPsk: AuthPlugin = {\n Component,\n isAvailable: authHandlers => authHandlers.includes(AUTH_TYPE),\n};\n\nexport default AuthPluginPsk;\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC,OAGnBC,cAAc;AAErB,IAAMC,SAAS,GAAG,0DAA0D;AAAC,SAE9DC,eAAe;EAAA;AAAA;AAU9B;AACA;AACA;AACA;AAHA;EAAA,qCAVA,aAAwD;IAAA;IACtD,IAAMC,KAAK,2BAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,KAAK,CAAC,uEAAI,EAAE;IAC1E,IAAI,CAACL,KAAK,EAAE;MACV,MAAM,IAAIM,KAAK,CACb,wEAAwE,CACzE;IACH;IACA,OAAO;MAAEC,IAAI,EAAET,SAAS;MAAEE;IAAM,CAAC;EACnC,CAAC;EAAA;AAAA;AAMD,SAASQ,SAAS,OAA6C;EAAA,IAA5C;IAAEC;EAA0B,CAAC;EAC9C,oBACE,oBAAC,cAAc;IAAC,eAAe,EAAEV;EAAgB,GAC9CU,QAAQ,CACM;AAErB;AAEA,IAAMC,aAAyB,GAAG;EAChCF,SAAS;EACTG,WAAW,EAAEC,YAAY,IAAIA,YAAY,CAACC,QAAQ,CAACf,SAAS;AAC9D,CAAC;AAED,eAAeY,aAAa"}
1
+ {"version":3,"file":"AuthPluginPsk.js","names":["React","useEffect","useState","Log","LoadingOverlay","log","module","AUTH_TYPE","getWindowToken","URLSearchParams","window","location","search","get","Component","client","onSuccess","onFailure","error","setError","token","isCanceled","login","Error","info","type","e","AuthPluginPsk","isAvailable","authHandlers","includes"],"sources":["../src/AuthPluginPsk.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginPsk');\n\nconst AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n\nfunction getWindowToken(): string {\n return new URLSearchParams(window.location.search).get('psk') ?? '';\n}\n\n/**\n * AuthPlugin that tries to login using a pre-shared key.\n * Add the `psk=<token>` parameter to your URL string to set the token.\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const [token] = useState(() => getWindowToken());\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n if (!token) {\n throw new Error(\n 'No Pre-shared key token found. Add `psk=<token>` parameter to your URL'\n );\n }\n log.info('Logging in with found token...');\n await client.login({ type: AUTH_TYPE, token });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, onFailure, onSuccess, token]);\n return (\n <LoadingOverlay\n data-testid=\"auth-psk-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginPsk: AuthPlugin = {\n Component,\n isAvailable: authHandlers => authHandlers.includes(AUTH_TYPE),\n};\n\nexport default AuthPluginPsk;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,cAAc,QAAQ,uBAAuB;AAGtD,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,eAAe,CAAC;AAEvC,IAAMC,SAAS,GAAG,0DAA0D;AAE5E,SAASC,cAAc,GAAW;EAAA;EAChC,+BAAO,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,KAAK,CAAC,uEAAI,EAAE;AACrE;;AAEA;AACA;AACA;AACA;AACA,SAASC,SAAS,OAIe;EAAA,IAJd;IACjBC,MAAM;IACNC,SAAS;IACTC;EACe,CAAC;EAChB,IAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGjB,QAAQ,EAAW;EAC7C,IAAM,CAACkB,KAAK,CAAC,GAAGlB,QAAQ,CAAC,MAAMM,cAAc,EAAE,CAAC;EAChDP,SAAS,CAAC,MAAM;IACd,IAAIoB,UAAU,GAAG,KAAK;IAAC,SACRC,KAAK;MAAA;IAAA;IAAA;MAAA,2BAApB,aAAuB;QACrB,IAAI;UACF,IAAI,CAACF,KAAK,EAAE;YACV,MAAM,IAAIG,KAAK,CACb,wEAAwE,CACzE;UACH;UACAlB,GAAG,CAACmB,IAAI,CAAC,gCAAgC,CAAC;UAC1C,MAAMT,MAAM,CAACO,KAAK,CAAC;YAAEG,IAAI,EAAElB,SAAS;YAAEa;UAAM,CAAC,CAAC;UAC9C,IAAIC,UAAU,EAAE;YACdhB,GAAG,CAACmB,IAAI,CAAC,gCAAgC,CAAC;YAC1C;UACF;UACAnB,GAAG,CAACmB,IAAI,CAAC,yBAAyB,CAAC;UACnCR,SAAS,EAAE;QACb,CAAC,CAAC,OAAOU,CAAC,EAAE;UACV,IAAIL,UAAU,EAAE;YACdhB,GAAG,CAACmB,IAAI,CAAC,iCAAiC,CAAC;YAC3C;UACF;UACAnB,GAAG,CAACa,KAAK,CAAC,kBAAkB,EAAEQ,CAAC,CAAC;UAChCP,QAAQ,CAACO,CAAC,CAAC;UACXT,SAAS,CAACS,CAAC,CAAC;QACd;MACF,CAAC;MAAA;IAAA;IACDJ,KAAK,EAAE;IACP,OAAO,MAAM;MACXD,UAAU,GAAG,IAAI;IACnB,CAAC;EACH,CAAC,EAAE,CAACN,MAAM,EAAEE,SAAS,EAAED,SAAS,EAAEI,KAAK,CAAC,CAAC;EACzC,oBACE,oBAAC,cAAc;IACb,eAAY,kBAAkB;IAC9B,SAAS;IACT,QAAQ,EAAE,KAAM;IAChB,YAAY,EAAEF,KAAK,IAAI,IAAI,aAAMA,KAAK,IAAK;EAAK,EAChD;AAEN;AAEA,IAAMS,aAAyB,GAAG;EAChCb,SAAS;EACTc,WAAW,EAAEC,YAAY,IAAIA,YAAY,CAACC,QAAQ,CAACvB,SAAS;AAC9D,CAAC;AAED,eAAeoB,aAAa"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './AuthPlugin';
2
2
  export * from './AuthHandlerTypes';
3
3
  export { default as AuthPluginAnonymous } from './AuthPluginAnonymous';
4
- export { default as AuthPluginBase } from './AuthPluginBase';
5
4
  export { default as AuthPluginParent } from './AuthPluginParent';
6
5
  export { default as AuthPluginPsk } from './AuthPluginPsk';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./AuthPlugin.js";
2
2
  export * from "./AuthHandlerTypes.js";
3
3
  export { default as AuthPluginAnonymous } from "./AuthPluginAnonymous.js";
4
- export { default as AuthPluginBase } from "./AuthPluginBase.js";
5
4
  export { default as AuthPluginParent } from "./AuthPluginParent.js";
6
5
  export { default as AuthPluginPsk } from "./AuthPluginPsk.js";
7
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","AuthPluginAnonymous","AuthPluginBase","AuthPluginParent","AuthPluginPsk"],"sources":["../src/index.ts"],"sourcesContent":["export * from './AuthPlugin';\nexport * from './AuthHandlerTypes';\nexport { default as AuthPluginAnonymous } from './AuthPluginAnonymous';\nexport { default as AuthPluginBase } from './AuthPluginBase';\nexport { default as AuthPluginParent } from './AuthPluginParent';\nexport { default as AuthPluginPsk } from './AuthPluginPsk';\n"],"mappings":";;SAESA,OAAO,IAAIC,mBAAmB;AAAA,SAC9BD,OAAO,IAAIE,cAAc;AAAA,SACzBF,OAAO,IAAIG,gBAAgB;AAAA,SAC3BH,OAAO,IAAII,aAAa"}
1
+ {"version":3,"file":"index.js","names":["default","AuthPluginAnonymous","AuthPluginParent","AuthPluginPsk"],"sources":["../src/index.ts"],"sourcesContent":["export * from './AuthPlugin';\nexport * from './AuthHandlerTypes';\nexport { default as AuthPluginAnonymous } from './AuthPluginAnonymous';\nexport { default as AuthPluginParent } from './AuthPluginParent';\nexport { default as AuthPluginPsk } from './AuthPluginPsk';\n"],"mappings":";;SAESA,OAAO,IAAIC,mBAAmB;AAAA,SAC9BD,OAAO,IAAIE,gBAAgB;AAAA,SAC3BF,OAAO,IAAIG,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/auth-plugins",
3
- "version": "0.37.1-auth-plugins.2+96728edb",
3
+ "version": "0.37.1-redux-peer-dep.0+aa02c0b7",
4
4
  "description": "Deephaven Auth Plugins",
5
5
  "keywords": [
6
6
  "Deephaven",
@@ -32,15 +32,14 @@
32
32
  "build:babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward"
33
33
  },
34
34
  "dependencies": {
35
- "@deephaven/components": "^0.37.1-auth-plugins.2+96728edb",
36
- "@deephaven/jsapi-bootstrap": "^0.37.1-auth-plugins.2+96728edb",
37
- "@deephaven/jsapi-types": "^0.37.1-auth-plugins.2+96728edb",
38
- "@deephaven/jsapi-utils": "^0.37.1-auth-plugins.2+96728edb",
39
- "@deephaven/log": "^0.37.1-auth-plugins.2+96728edb",
40
- "@deephaven/utils": "^0.37.1-auth-plugins.2+96728edb"
35
+ "@deephaven/components": "^0.37.1-redux-peer-dep.0+aa02c0b7",
36
+ "@deephaven/jsapi-bootstrap": "^0.37.1-redux-peer-dep.0+aa02c0b7",
37
+ "@deephaven/jsapi-types": "^0.37.1-redux-peer-dep.0+aa02c0b7",
38
+ "@deephaven/jsapi-utils": "^0.37.1-redux-peer-dep.0+aa02c0b7",
39
+ "@deephaven/log": "^0.37.1-redux-peer-dep.0+aa02c0b7"
41
40
  },
42
41
  "devDependencies": {
43
- "@deephaven/tsconfig": "^0.37.1-auth-plugins.2+96728edb",
42
+ "@deephaven/tsconfig": "^0.37.1-redux-peer-dep.0+aa02c0b7",
44
43
  "@types/react": "^17.0.2"
45
44
  },
46
45
  "peerDependencies": {
@@ -53,5 +52,5 @@
53
52
  "publishConfig": {
54
53
  "access": "public"
55
54
  },
56
- "gitHead": "96728edb7793223b015654e81e07b04505db0854"
55
+ "gitHead": "aa02c0b71ccbd7f204f478f6a98fefc2306b6ca2"
57
56
  }
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { LoginOptions } from '@deephaven/jsapi-types';
3
- export type AuthPluginBaseProps = {
4
- /**
5
- * The children to render after authentication is completed.
6
- */
7
- children: React.ReactNode;
8
- /**
9
- * Retrieve the login options for logging in to the client
10
- * @returns A promise for the login options
11
- */
12
- getLoginOptions: () => Promise<LoginOptions>;
13
- };
14
- /**
15
- * Base AuthPlugin that gets passed a function for retrieving the login options, and then attempting to login with them.
16
- * @param getLoginOptions Function that returns a promise for the login options
17
- */
18
- declare function AuthPluginBase({ children, getLoginOptions, }: AuthPluginBaseProps): JSX.Element;
19
- export default AuthPluginBase;
20
- //# sourceMappingURL=AuthPluginBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthPluginBase.d.ts","sourceRoot":"","sources":["../src/AuthPluginBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,iBAAS,cAAc,CAAC,EACtB,QAAQ,EACR,eAAe,GAChB,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAkDnC;AAED,eAAe,cAAc,CAAC"}
@@ -1,69 +0,0 @@
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
- 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
- import React, { useEffect, useState } from 'react';
4
- import { LoadingOverlay } from '@deephaven/components';
5
- import { useApi, useClient } from '@deephaven/jsapi-bootstrap';
6
- import Log from '@deephaven/log';
7
- import { CanceledPromiseError } from '@deephaven/utils';
8
- var log = Log.module('AuthPluginAnonymous');
9
- /**
10
- * Base AuthPlugin that gets passed a function for retrieving the login options, and then attempting to login with them.
11
- * @param getLoginOptions Function that returns a promise for the login options
12
- */
13
- function AuthPluginBase(_ref) {
14
- var {
15
- children,
16
- getLoginOptions
17
- } = _ref;
18
- var client = useClient();
19
- var dh = useApi();
20
- var [error, setError] = useState();
21
- var [isLoggedIn, setIsLoggedIn] = useState(false);
22
- useEffect(() => {
23
- var isCanceled = false;
24
- function verifyNotCanceled() {
25
- if (isCanceled) {
26
- throw new CanceledPromiseError('Login canceled.');
27
- }
28
- }
29
- function login() {
30
- return _login.apply(this, arguments);
31
- }
32
- function _login() {
33
- _login = _asyncToGenerator(function* () {
34
- try {
35
- var loginOptions = yield getLoginOptions();
36
- verifyNotCanceled();
37
- log.info('Logging in...');
38
- yield client.login(loginOptions);
39
- verifyNotCanceled();
40
- setIsLoggedIn(true);
41
- } catch (e) {
42
- if (!isCanceled) {
43
- log.error('Unable to login:', e);
44
- setError(e);
45
- setIsLoggedIn(false);
46
- }
47
- }
48
- });
49
- return _login.apply(this, arguments);
50
- }
51
- login();
52
- return () => {
53
- isCanceled = true;
54
- };
55
- }, [client, dh, getLoginOptions]);
56
- if (!isLoggedIn) {
57
- return /*#__PURE__*/React.createElement(LoadingOverlay, {
58
- "data-testid": "auth-base-loading",
59
- isLoading: error == null,
60
- isLoaded: false,
61
- errorMessage: error != null ? "".concat(error) : null
62
- });
63
- }
64
-
65
- // eslint-disable-next-line react/jsx-no-useless-fragment
66
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
67
- }
68
- export default AuthPluginBase;
69
- //# sourceMappingURL=AuthPluginBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthPluginBase.js","names":["React","useEffect","useState","LoadingOverlay","useApi","useClient","Log","CanceledPromiseError","log","module","AuthPluginBase","children","getLoginOptions","client","dh","error","setError","isLoggedIn","setIsLoggedIn","isCanceled","verifyNotCanceled","login","loginOptions","info","e"],"sources":["../src/AuthPluginBase.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi, useClient } from '@deephaven/jsapi-bootstrap';\nimport Log from '@deephaven/log';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport { CanceledPromiseError } from '@deephaven/utils';\n\nconst log = Log.module('AuthPluginAnonymous');\n\nexport type AuthPluginBaseProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n\n /**\n * Retrieve the login options for logging in to the client\n * @returns A promise for the login options\n */\n getLoginOptions: () => Promise<LoginOptions>;\n};\n\n/**\n * Base AuthPlugin that gets passed a function for retrieving the login options, and then attempting to login with them.\n * @param getLoginOptions Function that returns a promise for the login options\n */\nfunction AuthPluginBase({\n children,\n getLoginOptions,\n}: AuthPluginBaseProps): JSX.Element {\n const client = useClient();\n const dh = useApi();\n const [error, setError] = useState<unknown>();\n const [isLoggedIn, setIsLoggedIn] = useState(false);\n\n useEffect(() => {\n let isCanceled = false;\n function verifyNotCanceled() {\n if (isCanceled) {\n throw new CanceledPromiseError('Login canceled.');\n }\n }\n async function login() {\n try {\n const loginOptions = await getLoginOptions();\n verifyNotCanceled();\n\n log.info('Logging in...');\n await client.login(loginOptions);\n verifyNotCanceled();\n\n setIsLoggedIn(true);\n } catch (e) {\n if (!isCanceled) {\n log.error('Unable to login:', e);\n setError(e);\n setIsLoggedIn(false);\n }\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, dh, getLoginOptions]);\n\n if (!isLoggedIn) {\n return (\n <LoadingOverlay\n data-testid=\"auth-base-loading\"\n isLoading={error == null}\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default AuthPluginBase;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,MAAM,EAAEC,SAAS,QAAQ,4BAA4B;AAC9D,OAAOC,GAAG,MAAM,gBAAgB;AAEhC,SAASC,oBAAoB,QAAQ,kBAAkB;AAEvD,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,qBAAqB,CAAC;AAe7C;AACA;AACA;AACA;AACA,SAASC,cAAc,OAGc;EAAA,IAHb;IACtBC,QAAQ;IACRC;EACmB,CAAC;EACpB,IAAMC,MAAM,GAAGR,SAAS,EAAE;EAC1B,IAAMS,EAAE,GAAGV,MAAM,EAAE;EACnB,IAAM,CAACW,KAAK,EAAEC,QAAQ,CAAC,GAAGd,QAAQ,EAAW;EAC7C,IAAM,CAACe,UAAU,EAAEC,aAAa,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAEnDD,SAAS,CAAC,MAAM;IACd,IAAIkB,UAAU,GAAG,KAAK;IACtB,SAASC,iBAAiB,GAAG;MAC3B,IAAID,UAAU,EAAE;QACd,MAAM,IAAIZ,oBAAoB,CAAC,iBAAiB,CAAC;MACnD;IACF;IAAC,SACcc,KAAK;MAAA;IAAA;IAAA;MAAA,2BAApB,aAAuB;QACrB,IAAI;UACF,IAAMC,YAAY,SAASV,eAAe,EAAE;UAC5CQ,iBAAiB,EAAE;UAEnBZ,GAAG,CAACe,IAAI,CAAC,eAAe,CAAC;UACzB,MAAMV,MAAM,CAACQ,KAAK,CAACC,YAAY,CAAC;UAChCF,iBAAiB,EAAE;UAEnBF,aAAa,CAAC,IAAI,CAAC;QACrB,CAAC,CAAC,OAAOM,CAAC,EAAE;UACV,IAAI,CAACL,UAAU,EAAE;YACfX,GAAG,CAACO,KAAK,CAAC,kBAAkB,EAAES,CAAC,CAAC;YAChCR,QAAQ,CAACQ,CAAC,CAAC;YACXN,aAAa,CAAC,KAAK,CAAC;UACtB;QACF;MACF,CAAC;MAAA;IAAA;IACDG,KAAK,EAAE;IACP,OAAO,MAAM;MACXF,UAAU,GAAG,IAAI;IACnB,CAAC;EACH,CAAC,EAAE,CAACN,MAAM,EAAEC,EAAE,EAAEF,eAAe,CAAC,CAAC;EAEjC,IAAI,CAACK,UAAU,EAAE;IACf,oBACE,oBAAC,cAAc;MACb,eAAY,mBAAmB;MAC/B,SAAS,EAAEF,KAAK,IAAI,IAAK;MACzB,QAAQ,EAAE,KAAM;MAChB,YAAY,EAAEA,KAAK,IAAI,IAAI,aAAMA,KAAK,IAAK;IAAK,EAChD;EAEN;;EAEA;EACA,oBAAO,0CAAGJ,QAAQ,CAAI;AACxB;AAEA,eAAeD,cAAc"}