@looker/extension-utils 0.1.17 → 0.1.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ### [0.1.19](https://www.github.com/looker-open-source/sdk-codegen/compare/extension-utils-v0.1.18...extension-utils-v0.1.19) (2022-12-09)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @looker/extension-sdk bumped from ^22.20.0 to ^22.20.1
11
+ * @looker/extension-sdk-react bumped from ^22.20.0 to ^22.20.1
12
+ * @looker/sdk-rtl bumped from ^21.4.0 to ^21.5.0
13
+ * @looker/code-editor bumped from ^0.1.26 to ^0.1.27
14
+
15
+ ### [0.1.18](https://www.github.com/looker-open-source/sdk-codegen/compare/extension-utils-v0.1.17...extension-utils-v0.1.18) (2022-11-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * oauth support in APIX when embedded in another app ([#1198](https://www.github.com/looker-open-source/sdk-codegen/issues/1198)) ([c464d2f](https://www.github.com/looker-open-source/sdk-codegen/commit/c464d2f24c7f8e7d282208efd00feaaba216fe3e))
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @looker/extension-sdk bumped from ^22.18.0 to ^22.20.0
28
+ * @looker/extension-sdk-react bumped from ^22.18.0 to ^22.20.0
29
+ * @looker/code-editor bumped from ^0.1.25 to ^0.1.26
30
+
3
31
  ### [0.1.17](https://www.github.com/looker-open-source/sdk-codegen/compare/extension-utils-v0.1.16...extension-utils-v0.1.17) (2022-10-17)
4
32
 
5
33
 
package/lib/OAuthScene.js CHANGED
@@ -11,6 +11,8 @@ var _components = require("@looker/components");
11
11
 
12
12
  var _reactRouter = require("react-router");
13
13
 
14
+ var _reactRouterDom = require("react-router-dom");
15
+
14
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
17
 
16
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -20,18 +22,31 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
20
22
  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); }); }; }
21
23
 
22
24
  var OAuthScene = _ref => {
25
+ var _authSession$returnUr;
26
+
23
27
  var {
24
28
  adaptor
25
29
  } = _ref;
26
30
  var history = (0, _reactRouter.useHistory)();
31
+ var location = (0, _reactRouterDom.useLocation)();
32
+ var reactPath = location.pathname;
33
+ var fullPath = window.location.pathname;
34
+ var extraPath = fullPath.substr(0, fullPath.indexOf(reactPath));
27
35
  var authSession = adaptor.sdk.authSession;
28
- var oldUrl = authSession.returnUrl || "/";
36
+ var retPath = (_authSession$returnUr = authSession.returnUrl) !== null && _authSession$returnUr !== void 0 ? _authSession$returnUr : '/';
37
+ var oldUrl = retPath.replace(extraPath, '');
29
38
  (0, _react.useEffect)(() => {
30
39
  var maybeLogin = function () {
31
40
  var _ref2 = _asyncToGenerator(function* () {
32
41
  var token = yield adaptor.login();
33
42
 
34
43
  if (token) {
44
+ console.error({
45
+ push: oldUrl,
46
+ retPath,
47
+ extraPath,
48
+ location
49
+ });
35
50
  history.push(oldUrl);
36
51
  }
37
52
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/OAuthScene.tsx"],"names":["OAuthScene","adaptor","history","authSession","sdk","oldUrl","returnUrl","maybeLogin","token","login","push","themeOverrides","loadGoogleFonts","themeCustomizations"],"mappings":";;;;;;;AA2BA;;AAEA;;AAOA;;;;;;;;;;AAYO,IAAMA,UAA+B,GAAG,QAAiB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,MAAMC,OAAO,GAAG,8BAAhB;AACA,MAAMC,WAAW,GAAGF,OAAO,CAACG,GAAR,CAAYD,WAAhC;AACA,MAAME,MAAM,GAAGF,WAAW,CAACG,SAAZ,OAAf;AAEA,wBAAU,MAAM;AACd,QAAMC,UAAU;AAAA,oCAAG,aAAY;AAC7B,YAAMC,KAAK,SAASP,OAAO,CAACQ,KAAR,EAApB;;AACA,YAAID,KAAJ,EAAW;AACTN,UAAAA,OAAO,CAACQ,IAAR,CAAaL,MAAb;AACD;AACF,OALe;;AAAA,sBAAVE,UAAU;AAAA;AAAA;AAAA,OAAhB;;AAMAA,IAAAA,UAAU;AACX,GARD,EAQG,EARH;AAUA,MAAMI,cAAc,GAAGV,OAAO,CAACU,cAAR,EAAvB;AACA,SACE,6BAAC,8BAAD;AACE,IAAA,eAAe,EAAEA,cAAc,CAACC,eADlC;AAEE,IAAA,mBAAmB,EAAED,cAAc,CAACE;AAFtC,KAIE,6BAAC,gBAAD;AAAM,IAAA,aAAa,EAAC,QAApB;AAA6B,IAAA,cAAc,EAAC,QAA5C;AAAqD,IAAA,EAAE,EAAC;AAAxD,KACE,6BAAC,oBAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACE,6BAAC,4BAAD;AAAkB,IAAA,IAAI,EAAC;AAAvB,IADF,CADF,EAIE,6BAAC,oBAAD;AAAU,IAAA,EAAE,EAAC,OAAb;AAAqB,IAAA,SAAS,EAAC;AAA/B,KACE,6BAAC,mBAAD;AAAS,IAAA,KAAK,EAAC,KAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,4BACmBR,MADnB,4BADF,CAJF,CAJF,CADF;AAiBD,CAjCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react'\nimport React, { useEffect } from 'react'\nimport type { BrowserSession } from '@looker/sdk-rtl'\nimport {\n ComponentsProvider,\n Flex,\n FlexItem,\n Heading,\n ProgressCircular,\n} from '@looker/components'\nimport { useHistory } from 'react-router'\n\nimport type { IEnvironmentAdaptor } from './adaptorUtils'\n\ninterface OAuthSceneProps {\n adaptor: IEnvironmentAdaptor\n}\n\n/**\n * OAuth scene for sdk session handling and redirection to OAuth flow initiation\n * route\n */\nexport const OAuthScene: FC<OAuthSceneProps> = ({ adaptor }) => {\n const history = useHistory()\n const authSession = adaptor.sdk.authSession as BrowserSession\n const oldUrl = authSession.returnUrl || `/`\n\n useEffect(() => {\n const maybeLogin = async () => {\n const token = await adaptor.login()\n if (token) {\n history.push(oldUrl)\n }\n }\n maybeLogin()\n }, [])\n\n const themeOverrides = adaptor.themeOverrides()\n return (\n <ComponentsProvider\n loadGoogleFonts={themeOverrides.loadGoogleFonts}\n themeCustomizations={themeOverrides.themeCustomizations}\n >\n <Flex flexDirection=\"column\" justifyContent=\"center\" mt=\"25%\">\n <FlexItem alignSelf=\"center\">\n <ProgressCircular size=\"large\" />\n </FlexItem>\n <FlexItem mt=\"large\" alignSelf=\"center\">\n <Heading color=\"key\" as=\"h2\">\n {`Returning to ${oldUrl} after OAuth login ...`}\n </Heading>\n </FlexItem>\n </Flex>\n </ComponentsProvider>\n )\n}\n"],"file":"OAuthScene.js"}
1
+ {"version":3,"sources":["../src/OAuthScene.tsx"],"names":["OAuthScene","adaptor","history","location","reactPath","pathname","fullPath","window","extraPath","substr","indexOf","authSession","sdk","retPath","returnUrl","oldUrl","replace","maybeLogin","token","login","console","error","push","themeOverrides","loadGoogleFonts","themeCustomizations"],"mappings":";;;;;;;AA2BA;;AAEA;;AAOA;;AACA;;;;;;;;;;AAWO,IAAMA,UAA+B,GAAG,QAAiB;AAAA;;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,MAAMC,OAAO,GAAG,8BAAhB;AACA,MAAMC,QAAQ,GAAG,kCAAjB;AACA,MAAMC,SAAS,GAAGD,QAAQ,CAACE,QAA3B;AACA,MAAMC,QAAQ,GAAIC,MAAD,CAAgBJ,QAAhB,CAAyBE,QAA1C;AACA,MAAMG,SAAS,GAAGF,QAAQ,CAACG,MAAT,CAAgB,CAAhB,EAAmBH,QAAQ,CAACI,OAAT,CAAiBN,SAA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CADF;AAiBD,CAxCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react'\nimport React, { useEffect } from 'react'\nimport type { BrowserSession } from '@looker/sdk-rtl'\nimport {\n ComponentsProvider,\n Flex,\n FlexItem,\n Heading,\n ProgressCircular,\n} from '@looker/components'\nimport { useHistory } from 'react-router'\nimport { useLocation } from 'react-router-dom'\nimport type { IEnvironmentAdaptor } from './adaptorUtils'\n\ninterface OAuthSceneProps {\n adaptor: IEnvironmentAdaptor\n}\n\n/**\n * OAuth scene for sdk session handling and redirection to OAuth flow initiation\n * route\n */\nexport const OAuthScene: FC<OAuthSceneProps> = ({ adaptor }) => {\n const history = useHistory()\n const location = useLocation()\n const reactPath = location.pathname\n const fullPath = (window as any).location.pathname\n const extraPath = fullPath.substr(0, fullPath.indexOf(reactPath))\n const authSession = adaptor.sdk.authSession as BrowserSession\n const retPath = authSession.returnUrl ?? '/'\n /** If this is a nested React app, remove extraPath to prevent recursive return pathing */\n const oldUrl = retPath.replace(extraPath, '')\n\n useEffect(() => {\n const maybeLogin = async () => {\n const token = await adaptor.login()\n if (token) {\n console.error({ push: oldUrl, retPath, extraPath, location })\n history.push(oldUrl)\n }\n }\n maybeLogin()\n }, [])\n\n const themeOverrides = adaptor.themeOverrides()\n return (\n <ComponentsProvider\n loadGoogleFonts={themeOverrides.loadGoogleFonts}\n themeCustomizations={themeOverrides.themeCustomizations}\n >\n <Flex flexDirection=\"column\" justifyContent=\"center\" mt=\"25%\">\n <FlexItem alignSelf=\"center\">\n <ProgressCircular size=\"large\" />\n </FlexItem>\n <FlexItem mt=\"large\" alignSelf=\"center\">\n <Heading color=\"key\" as=\"h2\">\n {`Returning to ${oldUrl} after OAuth login ...`}\n </Heading>\n </FlexItem>\n </Flex>\n </ComponentsProvider>\n )\n}\n"],"file":"OAuthScene.js"}
@@ -1,5 +1,6 @@
1
1
  import type { ThemeCustomizations } from '@looker/design-tokens';
2
2
  import type { IAPIMethods } from '@looker/sdk-rtl';
3
+ import type { Location as HLocation } from 'history';
3
4
  export interface IAuthAdaptor {
4
5
  get sdk(): IAPIMethods;
5
6
  login(): Promise<boolean>;
@@ -27,3 +28,4 @@ export declare const registerEnvAdaptor: <T extends IEnvironmentAdaptor>(adaptor
27
28
  export declare const unregisterEnvAdaptor: () => void;
28
29
  export declare const getEnvAdaptor: () => IEnvironmentAdaptor;
29
30
  export declare const registerTestEnvAdaptor: <T extends IEnvironmentAdaptor>(adaptor?: T | undefined) => void;
31
+ export declare const appPath: (location: HLocation, newPath: string) => string;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.registerTestEnvAdaptor = exports.getEnvAdaptor = exports.unregisterEnvAdaptor = exports.registerEnvAdaptor = exports.getThemeOverrides = exports.hostedInternally = void 0;
6
+ exports.appPath = exports.registerTestEnvAdaptor = exports.getEnvAdaptor = exports.unregisterEnvAdaptor = exports.registerEnvAdaptor = exports.getThemeOverrides = exports.hostedInternally = void 0;
7
7
 
8
8
  var _browserAdaptor = require("./browserAdaptor");
9
9
 
@@ -60,4 +60,15 @@ var registerTestEnvAdaptor = adaptor => {
60
60
  };
61
61
 
62
62
  exports.registerTestEnvAdaptor = registerTestEnvAdaptor;
63
+
64
+ var appPath = (location, newPath) => {
65
+ var reactPath = location.pathname;
66
+ var wloc = window.location;
67
+ var base = wloc.origin;
68
+ var wpath = wloc.pathname;
69
+ var result = "".concat(base).concat(wpath.substring(0, wpath.indexOf(reactPath))).concat(newPath);
70
+ return result;
71
+ };
72
+
73
+ exports.appPath = appPath;
63
74
  //# sourceMappingURL=adaptorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adaptorUtils.ts"],"names":["hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk","BrowserAdaptor"],"mappings":";;;;;;;AA4BA;;AAoDO,IAAMA,gBAAgB,GAAIC,QAAD,IAC9BA,QAAQ,CAACC,QAAT,CAAkB,aAAlB,KACAD,QAAQ,CAACC,QAAT,CAAkB,aAAlB,CADA,IAEAD,QAAQ,KAAK,WAFb,IAMCA,QAAQ,CAACE,UAAT,CAAoB,yBAApB,KACCF,QAAQ,CAACC,QAAT,CAAkB,UAAlB,CARG;;;;AAcA,IAAME,iBAAiB,GAAIC,eAAD,IAC/BA,eAAe,GACX;AACEC,EAAAA,eAAe,EAAE,IADnB;AAEEC,EAAAA,mBAAmB,EAAE;AACnBC,IAAAA,YAAY,EAAE;AAAEC,MAAAA,KAAK,EAAE;AAAT,KADK;AAEnBC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AAFW;AAFvB,CADW,GAQX;AACEJ,EAAAA,mBAAmB,EAAE;AACnBG,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AADW;AADvB,CATC;;;AAeP,IAAIC,gBAAJ;;AAMO,IAAMC,kBAAkB,GAC7BC,OADgC,IAE7B;AACHF,EAAAA,gBAAgB,GAAGE,OAAnB;AACD,CAJM;;;;AASA,IAAMC,oBAAoB,GAAG,MAAM;AACxCH,EAAAA,gBAAgB,GAAGI,SAAnB;AACD,CAFM;;;;AAOA,IAAMC,aAAa,GAAG,MAAM;AACjC,MAAI,CAACL,gBAAL,EAAuB;AACrB,UAAM,IAAIM,KAAJ,CAAU,sCAAV,CAAN;AACD;;AACD,SAAON,gBAAP;AACD,CALM;;;;AAWA,IAAMO,sBAAsB,GACjCL,OADoC,IAEjC;AACH,MAAMM,OAAO,GAAG,EAAhB;AACAP,EAAAA,kBAAkB,CAACC,OAAO,IAAI,IAAIO,8BAAJ,CAAmBD,OAAnB,CAAZ,CAAlB;AACD,CALM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n"],"file":"adaptorUtils.js"}
1
+ {"version":3,"sources":["../src/adaptorUtils.ts"],"names":["hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk","BrowserAdaptor","appPath","location","newPath","reactPath","pathname","wloc","window","base","origin","wpath","result","substring","indexOf"],"mappings":";;;;;;;AA6BA;;AAoDO,IAAMA,gBAAgB,GAAIC,QAAD,IAC9BA,QAAQ,CAACC,QAAT,CAAkB,aAAlB,KACAD,QAAQ,CAACC,QAAT,CAAkB,aAAlB,C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IAAI,CAACD,QAAnB;AACA,MAAMM,MAAM,aAAMH,IAAN,SAAaE,KAAK,CAACE,SAAN,CACvB,CADuB,EAEvBF,KAAK,CAACG,OAAN,CAAcT,SAAd,CAFuB,CAAb,SAGRD,OAHQ,CAAZ;AAIA,SAAOQ,MAAP;AACD,CAVM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type { Location as HLocation } from 'history'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n\n/**\n * Get new application-level base path for react application\n * This function compares the react-based location with the browser window location\n * pathname to ensure that the newPath variable is assigned at the root of the\n * React app path rather than potentially recursive nesting\n *\n * @param location which is usually from useLocation()\n * @param newPath new path to assign, like `/oauth`\n */\nexport const appPath = (location: HLocation, newPath: string) => {\n const reactPath = location.pathname\n const wloc = (window as any).location\n const base = wloc.origin\n const wpath = wloc.pathname\n const result = `${base}${wpath.substring(\n 0,\n wpath.indexOf(reactPath)\n )}${newPath}`\n return result\n}\n"],"file":"adaptorUtils.js"}
@@ -13,6 +13,8 @@ export declare class OAuthConfigProvider extends ApiSettings {
13
13
  getStoredConfig(): {
14
14
  base_url: string;
15
15
  looker_url: string;
16
+ client_id: string;
17
+ redirect_uri: string;
16
18
  };
17
19
  authIsConfigured(): boolean;
18
20
  readConfig(_section?: string): IApiSection;
package/lib/authUtils.js CHANGED
@@ -53,7 +53,9 @@ class OAuthConfigProvider extends _sdkRtl.ApiSettings {
53
53
  var storage = this.getStorage(this.configKey);
54
54
  var config = {
55
55
  base_url: '',
56
- looker_url: ''
56
+ looker_url: '',
57
+ client_id: '',
58
+ redirect_uri: ''
57
59
  };
58
60
 
59
61
  if (storage.value) {
@@ -76,20 +78,24 @@ class OAuthConfigProvider extends _sdkRtl.ApiSettings {
76
78
  var authServer = "".concat(url.protocol, "//").concat(url.hostname);
77
79
  config = {
78
80
  base_url: this.base_url,
79
- looker_url: "".concat(authServer, ":9999")
81
+ looker_url: "".concat(authServer, ":9999"),
82
+ client_id: 'looker.api-explorer',
83
+ redirect_uri: "".concat(window.location.origin, "/oauth")
80
84
  };
81
85
  }
82
86
 
83
87
  var {
84
88
  base_url,
85
- looker_url
89
+ looker_url,
90
+ client_id,
91
+ redirect_uri
86
92
  } = config;
87
93
  this.base_url = base_url;
88
94
  return _objectSpread(_objectSpread({}, super.readConfig(_section)), {
89
95
  base_url,
90
96
  looker_url,
91
- client_id: 'looker.api-explorer',
92
- redirect_uri: "".concat(window.location.origin, "/oauth")
97
+ client_id,
98
+ redirect_uri
93
99
  });
94
100
  }
95
101
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/authUtils.ts"],"names":["OAuthConfigProvider","ApiSettings","constructor","settings","configKey","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","protocol","hostname","client_id","redirect_uri","window","origin"],"mappings":";;;;;;;AA0BA;;;;;;;;AAeO,MAAMA,mBAAN,SAAkCC,mBAAlC,CAA8C;AACnDC,EAAAA,WAAW,CACTC,QADS,EAEQC,SAFR,EAGT;AACA,UAAMD,QAAN;AADA,SADiBC,SACjB,GADiBA,SACjB;AAED;;AAEOC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AAChE,QAAIC,KAAK,GAAGC,cAAc,CAACC,OAAf,CAAuBJ,GAAvB,CAAZ;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,SADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACDA,IAAAA,KAAK,GAAGI,YAAY,CAACF,OAAb,CAAqBJ,GAArB,CAAR;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAA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B,CADL,GAEK;AACDN,MAAAA,QADC;AAEDC,MAAAA,UAFC;AAGDW,MAAAA,SAAS,EAAE,qBAHV;AAIDC,MAAAA,YAAY,YAAKC,MAAM,CAACpB,QAAP,CAAgBqB,MAArB;AAJX,KAFL;AASD;;AAzEkD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n constructor(\n settings: Partial<IApiSettings>,\n private readonly configKey: string\n ) {\n super(settings)\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = { base_url: '', looker_url: '' }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n }\n }\n\n const { base_url, looker_url } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id: 'looker.api-explorer',\n redirect_uri: `${window.location.origin}/oauth`,\n },\n }\n }\n}\n"],"file":"authUtils.js"}
1
+ {"version":3,"sources":["../src/authUtils.ts"],"names":["OAuthConfigProvider","ApiSettings","constructor","settings","configKey","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","client_id","redirect_uri","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","protocol","hostname","window","origin"],"mappings":";;;;;;;AA0BA;;;;;;;;AAeO,MAAMA,mBAAN,SAAkCC,mBAAlC,CAA8C;AACnDC,EAAAA,WAAW,CACTC,QADS,EAEQC,SAFR,EAGT;AACA,UAAMD,QAAN;AADA,SADiBC,SACjB,GADiBA,SACjB;AAED;;AAEOC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AAChE,QAAIC,KAAK,GAAGC,cAAc,CAACC,OAAf,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QAAV,eAAuBH,GAAG,CAACI,QAA3B,CAAhB;AACAd,MAAAA,MAAM,GAAG;AACPC,QAAAA,QAAQ,EAAE,KAAKA,QADR;AAEPC,QAAAA,UAAU,YAAKU,UAAL,UAFH;AAGPT,QAAAA,SAAS,EAAE,qBAHJ;AAIPC,QAAAA,YAAY,YAAKW,MAAM,CAACpB,QAAP,CAAgBqB,MAArB;AAJL,OAAT;AAMD;;AAED,QAAM;AAAEf,MAAAA,QAAF;AAAYC,MAAAA,UAAZ;AAAwBC,MAAAA,SAAxB;AAAmCC,MAAAA;AAAnC,QAAoDJ,MAA1D;AAEA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,2CACK,MAAMO,UAAN,CAAiBC,QAAjB,CADL,GAEK;AACDR,MAAAA,QADC;AAEDC,MAAAA,UAFC;AAGDC,MAAAA,SAHC;AAIDC,MAAAA;AAJC,KAFL;AASD;;AAhFkD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n constructor(\n settings: Partial<IApiSettings>,\n private readonly configKey: string\n ) {\n super(settings)\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = {\n base_url: '',\n looker_url: '',\n client_id: '',\n redirect_uri: '',\n }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n client_id: 'looker.api-explorer',\n redirect_uri: `${window.location.origin}/oauth`,\n }\n }\n\n const { base_url, looker_url, client_id, redirect_uri } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id,\n redirect_uri,\n },\n }\n }\n}\n"],"file":"authUtils.js"}
@@ -5,19 +5,33 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
5
5
  import React, { useEffect } from 'react';
6
6
  import { ComponentsProvider, Flex, FlexItem, Heading, ProgressCircular } from '@looker/components';
7
7
  import { useHistory } from 'react-router';
8
+ import { useLocation } from 'react-router-dom';
8
9
  export var OAuthScene = _ref => {
10
+ var _authSession$returnUr;
11
+
9
12
  var {
10
13
  adaptor
11
14
  } = _ref;
12
15
  var history = useHistory();
16
+ var location = useLocation();
17
+ var reactPath = location.pathname;
18
+ var fullPath = window.location.pathname;
19
+ var extraPath = fullPath.substr(0, fullPath.indexOf(reactPath));
13
20
  var authSession = adaptor.sdk.authSession;
14
- var oldUrl = authSession.returnUrl || "/";
21
+ var retPath = (_authSession$returnUr = authSession.returnUrl) !== null && _authSession$returnUr !== void 0 ? _authSession$returnUr : '/';
22
+ var oldUrl = retPath.replace(extraPath, '');
15
23
  useEffect(() => {
16
24
  var maybeLogin = function () {
17
25
  var _ref2 = _asyncToGenerator(function* () {
18
26
  var token = yield adaptor.login();
19
27
 
20
28
  if (token) {
29
+ console.error({
30
+ push: oldUrl,
31
+ retPath,
32
+ extraPath,
33
+ location
34
+ });
21
35
  history.push(oldUrl);
22
36
  }
23
37
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/OAuthScene.tsx"],"names":["React","useEffect","ComponentsProvider","Flex","FlexItem","Heading","ProgressCircular","useHistory","OAuthScene","adaptor","history","authSession","sdk","oldUrl","returnUrl","maybeLogin","token","login","push","themeOverrides","loadGoogleFonts","themeCustomizations"],"mappings":";;;;AA2BA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AAEA,SACEC,kBADF,EAEEC,IAFF,EAGEC,QAHF,EAIEC,OAJF,EAKEC,gBALF,QAMO,oBANP;AAOA,SAASC,UAAT,QAA2B,cAA3B;AAYA,OAAO,IAAMC,UAA+B,GAAG,QAAiB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,MAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,MAAMI,WAAW,GAAGF,OAAO,CAACG,GAAR,CAAYD,WAAhC;AACA,MAAME,MAAM,GAAGF,WAAW,CAACG,SAAZ,OAAf;AAEAb,EAAAA,SAAS,CAAC,MAAM;AACd,QAAMc,UAAU;AAAA,oCAAG,aAAY;AAC7B,YAAMC,KAAK,SAASP,OAAO,CAACQ,KAAR,EAApB;;AACA,YAAID,KAAJ,EAAW;AACTN,UAAAA,OAAO,CAACQ,IAAR,CAAaL,MAAb;AACD;AACF,OALe;;AAAA,sBAAVE,UAAU;AAAA;AAAA;AAAA,OAAhB;;AAMAA,IAAAA,UAAU;AACX,GARQ,EAQN,EARM,CAAT;AAUA,MAAMI,cAAc,GAAGV,OAAO,CAACU,cAAR,EAAvB;AACA,SACE,oBAAC,kBAAD;AACE,IAAA,eAAe,EAAEA,cAAc,CAACC,eADlC;AAEE,IAAA,mBAAmB,EAAED,cAAc,CAACE;AAFtC,KAIE,oBAAC,IAAD;AAAM,IAAA,aAAa,EAAC,QAApB;AAA6B,IAAA,cAAc,EAAC,QAA5C;AAAqD,IAAA,EAAE,EAAC;AAAxD,KACE,oBAAC,QAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACE,oBAAC,gBAAD;AAAkB,IAAA,IAAI,EAAC;AAAvB,IADF,CADF,EAIE,oBAAC,QAAD;AAAU,IAAA,EAAE,EAAC,OAAb;AAAqB,IAAA,SAAS,EAAC;AAA/B,KACE,oBAAC,OAAD;AAAS,IAAA,KAAK,EAAC,KAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,4BACmBR,MADnB,4BADF,CAJF,CAJF,CADF;AAiBD,CAjCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react'\nimport React, { useEffect } from 'react'\nimport type { BrowserSession } from '@looker/sdk-rtl'\nimport {\n ComponentsProvider,\n Flex,\n FlexItem,\n Heading,\n ProgressCircular,\n} from '@looker/components'\nimport { useHistory } from 'react-router'\n\nimport type { IEnvironmentAdaptor } from './adaptorUtils'\n\ninterface OAuthSceneProps {\n adaptor: IEnvironmentAdaptor\n}\n\n/**\n * OAuth scene for sdk session handling and redirection to OAuth flow initiation\n * route\n */\nexport const OAuthScene: FC<OAuthSceneProps> = ({ adaptor }) => {\n const history = useHistory()\n const authSession = adaptor.sdk.authSession as BrowserSession\n const oldUrl = authSession.returnUrl || `/`\n\n useEffect(() => {\n const maybeLogin = async () => {\n const token = await adaptor.login()\n if (token) {\n history.push(oldUrl)\n }\n }\n maybeLogin()\n }, [])\n\n const themeOverrides = adaptor.themeOverrides()\n return (\n <ComponentsProvider\n loadGoogleFonts={themeOverrides.loadGoogleFonts}\n themeCustomizations={themeOverrides.themeCustomizations}\n >\n <Flex flexDirection=\"column\" justifyContent=\"center\" mt=\"25%\">\n <FlexItem alignSelf=\"center\">\n <ProgressCircular size=\"large\" />\n </FlexItem>\n <FlexItem mt=\"large\" alignSelf=\"center\">\n <Heading color=\"key\" as=\"h2\">\n {`Returning to ${oldUrl} after OAuth login ...`}\n </Heading>\n </FlexItem>\n </Flex>\n </ComponentsProvider>\n )\n}\n"],"file":"OAuthScene.js"}
1
+ {"version":3,"sources":["../../src/OAuthScene.tsx"],"names":["React","useEffect","ComponentsProvider","Flex","FlexItem","Heading","ProgressCircular","useHistory","useLocation","OAuthScene","adaptor","history","location","reactPath","pathname","fullPath","window","extraPath","substr","indexOf","authSession","sdk","retPath","returnUrl","oldUrl","replace","maybeLogin","token","login","console","error","push","themeOverrides","loadGoogleFonts","themeCustomizations"],"mappings":";;;;AA2BA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AAEA,SACEC,kBADF,EAEEC,IAFF,EAGEC,QAHF,EAIEC,OAJF,EAKEC,gBALF,QAMO,oBANP;AAOA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,WAAT,QAA4B,kBAA5B;AAWA,OAAO,IAAMC,UAA+B,GAAG,QAAiB;AAAA;;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,MAAMC,OAAO,GAAGJ,UAAU,EAA1B;AACA,MAAMK,QAAQ,GAAGJ,WAAW,EAA5B;AACA,MAAMK,SAAS,GAAGD,QAAQ,CAACE,QAA3B;AACA,MAAMC,QAAQ,GAAIC,MAAD,CAAgBJ,QAAhB,CAAyBE,QAA1C;AACA,MAAMG,SAAS,GAAGF,QAAQ,CAACG,MAAT,CAAgB,CAAhB,EAAmBH,QAAQ,CAACI,OAAT,CAAiBN,SAAjB,CAAnB,CAAlB;AACA,MAAMO,WAAW,GAAGV,OAAO,CAACW,GAAR,CAAYD,WAAhC;AACA,MAAME,OAAO,4BAAGF,WAAW,CAACG,SAAf,yEAA4B,GAAzC;AAEA,MAAMC,MAAM,GAAGF,OAAO,CAACG,OAAR,CAAgBR,SAAhB,EAA2B,EAA3B,CAAf;AAEAhB,EAAAA,SAAS,CAAC,MAAM;AACd,QAAMyB,UAAU;AAAA,oCAAG,aAAY;AAC7B,YAAMC,KAAK,SAASjB,OAAO,CAACkB,KAAR,EAApB;;AACA,YAAID,KAAJ,EAAW;AACTE,UAAAA,OAAO,CAACC,KAAR,CAAc;AAAEC,YAAAA,IAAI,EAAEP,MAAR;AAAgBF,YAAAA,OAAhB;AAAyBL,YAAAA,SAAzB;AAAoCL,YAAAA;AAApC,WAAd;AACAD,UAAAA,OAAO,CAACoB,IAAR,CAAaP,MAAb;AACD;AACF,OANe;;AAAA,sBAAVE,UAAU;AAAA;AAAA;AAAA,OAAhB;;AAOAA,IAAAA,UAAU;AACX,GATQ,EASN,EATM,CAAT;AAWA,MAAMM,cAAc,GAAGtB,OAAO,CAACsB,cAAR,EAAvB;AACA,SACE,oBAAC,kBAAD;AACE,IAAA,eAAe,EAAEA,cAAc,CAACC,eADlC;AAEE,IAAA,mBAAmB,EAAED,cAAc,CAACE;AAFtC,KAIE,oBAAC,IAAD;AAAM,IAAA,aAAa,EAAC,QAApB;AAA6B,IAAA,cAAc,EAAC,QAA5C;AAAqD,IAAA,EAAE,EAAC;AAAxD,KACE,oBAAC,QAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACE,oBAAC,gBAAD;AAAkB,IAAA,IAAI,EAAC;AAAvB,IADF,CADF,EAIE,oBAAC,QAAD;AAAU,IAAA,EAAE,EAAC,OAAb;AAAqB,IAAA,SAAS,EAAC;AAA/B,KACE,oBAAC,OAAD;AAAS,IAAA,KAAK,EAAC,KAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,4BACmBV,MADnB,4BADF,CAJF,CAJF,CADF;AAiBD,CAxCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react'\nimport React, { useEffect } from 'react'\nimport type { BrowserSession } from '@looker/sdk-rtl'\nimport {\n ComponentsProvider,\n Flex,\n FlexItem,\n Heading,\n ProgressCircular,\n} from '@looker/components'\nimport { useHistory } from 'react-router'\nimport { useLocation } from 'react-router-dom'\nimport type { IEnvironmentAdaptor } from './adaptorUtils'\n\ninterface OAuthSceneProps {\n adaptor: IEnvironmentAdaptor\n}\n\n/**\n * OAuth scene for sdk session handling and redirection to OAuth flow initiation\n * route\n */\nexport const OAuthScene: FC<OAuthSceneProps> = ({ adaptor }) => {\n const history = useHistory()\n const location = useLocation()\n const reactPath = location.pathname\n const fullPath = (window as any).location.pathname\n const extraPath = fullPath.substr(0, fullPath.indexOf(reactPath))\n const authSession = adaptor.sdk.authSession as BrowserSession\n const retPath = authSession.returnUrl ?? '/'\n /** If this is a nested React app, remove extraPath to prevent recursive return pathing */\n const oldUrl = retPath.replace(extraPath, '')\n\n useEffect(() => {\n const maybeLogin = async () => {\n const token = await adaptor.login()\n if (token) {\n console.error({ push: oldUrl, retPath, extraPath, location })\n history.push(oldUrl)\n }\n }\n maybeLogin()\n }, [])\n\n const themeOverrides = adaptor.themeOverrides()\n return (\n <ComponentsProvider\n loadGoogleFonts={themeOverrides.loadGoogleFonts}\n themeCustomizations={themeOverrides.themeCustomizations}\n >\n <Flex flexDirection=\"column\" justifyContent=\"center\" mt=\"25%\">\n <FlexItem alignSelf=\"center\">\n <ProgressCircular size=\"large\" />\n </FlexItem>\n <FlexItem mt=\"large\" alignSelf=\"center\">\n <Heading color=\"key\" as=\"h2\">\n {`Returning to ${oldUrl} after OAuth login ...`}\n </Heading>\n </FlexItem>\n </Flex>\n </ComponentsProvider>\n )\n}\n"],"file":"OAuthScene.js"}
@@ -35,4 +35,12 @@ export var registerTestEnvAdaptor = adaptor => {
35
35
  var mockSdk = {};
36
36
  registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk));
37
37
  };
38
+ export var appPath = (location, newPath) => {
39
+ var reactPath = location.pathname;
40
+ var wloc = window.location;
41
+ var base = wloc.origin;
42
+ var wpath = wloc.pathname;
43
+ var result = "".concat(base).concat(wpath.substring(0, wpath.indexOf(reactPath))).concat(newPath);
44
+ return result;
45
+ };
38
46
  //# sourceMappingURL=adaptorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adaptorUtils.ts"],"names":["BrowserAdaptor","hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk"],"mappings":"AA4BA,SAASA,cAAT,QAA+B,kBAA/B;AAoDA,OAAO,IAAMC,gBAAgB,GAAIC,QAAD,IAC9BA,QAAQ,CAACC,QAAT,CAAkB,aAAlB,KACAD,QAAQ,CAACC,QAAT,CAAkB,aAAlB,CADA,IAEAD,QAAQ,KAAK,WAFb,IAMCA,QAAQ,CAACE,UAAT,CAAoB,yBAApB,KACCF,QAAQ,CAACC,QAAT,CAAkB,UAAlB,CARG;AAcP,OAAO,IAAME,iBAAiB,GAAIC,eAAD,IAC/BA,eAAe,GACX;AACEC,EAAAA,eAAe,EAAE,IADnB;AAEEC,EAAAA,mBAAmB,EAAE;AACnBC,IAAAA,YAAY,EAAE;AAAEC,MAAAA,KAAK,EAAE;AAAT,KADK;AAEnBC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AAFW;AAFvB,CADW,GAQX;AACEJ,EAAAA,mBAAmB,EAAE;AACnBG,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AADW;AADvB,CATC;AAeP,IAAIC,gBAAJ;AAMA,OAAO,IAAMC,kBAAkB,GAC7BC,OADgC,IAE7B;AACHF,EAAAA,gBAAgB,GAAGE,OAAnB;AACD,CAJM;AASP,OAAO,IAAMC,oBAAoB,GAAG,MAAM;AACxCH,EAAAA,gBAAgB,GAAGI,SAAnB;AACD,CAFM;AAOP,OAAO,IAAMC,aAAa,GAAG,MAAM;AACjC,MAAI,CAACL,gBAAL,EAAuB;AACrB,UAAM,IAAIM,KAAJ,CAAU,sCAAV,CAAN;AACD;;AACD,SAAON,gBAAP;AACD,CALM;AAWP,OAAO,IAAMO,sBAAsB,GACjCL,OADoC,IAEjC;AACH,MAAMM,OAAO,GAAG,EAAhB;AACAP,EAAAA,kBAAkB,CAACC,OAAO,IAAI,IAAIf,cAAJ,CAAmBqB,OAAnB,CAAZ,CAAlB;AACD,CALM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n"],"file":"adaptorUtils.js"}
1
+ {"version":3,"sources":["../../src/adaptorUtils.ts"],"names":["BrowserAdaptor","hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk","appPath","location","newPath","reactPath","pathname","w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OAAO,GAAG,CAACC,QAAD,EAAsBC,OAAtB,KAA0C;AAC/D,MAAMC,SAAS,GAAGF,QAAQ,CAACG,QAA3B;AACA,MAAMC,IAAI,GAAIC,MAAD,CAAgBL,QAA7B;AACA,MAAMM,IAAI,GAAGF,IAAI,CAACG,MAAlB;AACA,MAAMC,KAAK,GAAGJ,IAAI,CAACD,QAAnB;AACA,MAAMM,MAAM,aAAMH,IAAN,SAAaE,KAAK,CAACE,SAAN,CACvB,CADuB,EAEvBF,KAAK,CAACG,OAAN,CAAcT,SAAd,CAFuB,CAAb,SAGRD,OAHQ,CAAZ;AAIA,SAAOQ,MAAP;AACD,CAVM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type { Location as HLocation } from 'history'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n\n/**\n * Get new application-level base path for react application\n * This function compares the react-based location with the browser window location\n * pathname to ensure that the newPath variable is assigned at the root of the\n * React app path rather than potentially recursive nesting\n *\n * @param location which is usually from useLocation()\n * @param newPath new path to assign, like `/oauth`\n */\nexport const appPath = (location: HLocation, newPath: string) => {\n const reactPath = location.pathname\n const wloc = (window as any).location\n const base = wloc.origin\n const wpath = wloc.pathname\n const result = `${base}${wpath.substring(\n 0,\n wpath.indexOf(reactPath)\n )}${newPath}`\n return result\n}\n"],"file":"adaptorUtils.js"}
@@ -45,7 +45,9 @@ export class OAuthConfigProvider extends ApiSettings {
45
45
  var storage = this.getStorage(this.configKey);
46
46
  var config = {
47
47
  base_url: '',
48
- looker_url: ''
48
+ looker_url: '',
49
+ client_id: '',
50
+ redirect_uri: ''
49
51
  };
50
52
 
51
53
  if (storage.value) {
@@ -68,20 +70,24 @@ export class OAuthConfigProvider extends ApiSettings {
68
70
  var authServer = "".concat(url.protocol, "//").concat(url.hostname);
69
71
  config = {
70
72
  base_url: this.base_url,
71
- looker_url: "".concat(authServer, ":9999")
73
+ looker_url: "".concat(authServer, ":9999"),
74
+ client_id: 'looker.api-explorer',
75
+ redirect_uri: "".concat(window.location.origin, "/oauth")
72
76
  };
73
77
  }
74
78
 
75
79
  var {
76
80
  base_url,
77
- looker_url
81
+ looker_url,
82
+ client_id,
83
+ redirect_uri
78
84
  } = config;
79
85
  this.base_url = base_url;
80
86
  return _objectSpread(_objectSpread({}, super.readConfig(_section)), {
81
87
  base_url,
82
88
  looker_url,
83
- client_id: 'looker.api-explorer',
84
- redirect_uri: "".concat(window.location.origin, "/oauth")
89
+ client_id,
90
+ redirect_uri
85
91
  });
86
92
  }
87
93
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/authUtils.ts"],"names":["ApiSettings","OAuthConfigProvider","constructor","settings","configKey","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","protocol","hostname","client_id","redirect_uri","window","origin"],"mappings":";;;;;;AA0BA,SAASA,WAAT,QAA4B,iBAA5B;AAeA,OAAO,MAAMC,mBAAN,SAAkCD,WAAlC,CAA8C;AACnDE,EAAAA,WAAW,CACTC,QADS,EAEQC,SAFR,EAGT;AACA,UAAMD,QAAN;AADA,SADiBC,SACjB,GADiBA,SACjB;AAED;;AAEOC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AAChE,QAAIC,KAAK,GAAGC,cAAc,CAACC,OAAf,CAAuBJ,GAAvB,CAAZ;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,SADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACDA,IAAAA,KAAK,GAAGI,YAAY,CAACF,OAAb,CAAqBJ,GAArB,CAAR;;AACA,QAAIE,KAAJ,EAAW;AACT,aA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CAAiBC,QAAjB,CADL,GAEK;AACDN,MAAAA,QADC;AAEDC,MAAAA,UAFC;AAGDW,MAAAA,SAAS,EAAE,qBAHV;AAIDC,MAAAA,YAAY,YAAKC,MAAM,CAACpB,QAAP,CAAgBqB,MAArB;AAJX,KAFL;AASD;;AAzEkD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n constructor(\n settings: Partial<IApiSettings>,\n private readonly configKey: string\n ) {\n super(settings)\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = { base_url: '', looker_url: '' }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n }\n }\n\n const { base_url, looker_url } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id: 'looker.api-explorer',\n redirect_uri: `${window.location.origin}/oauth`,\n },\n }\n }\n}\n"],"file":"authUtils.js"}
1
+ {"version":3,"sources":["../../src/authUtils.ts"],"names":["ApiSettings","OAuthConfigProvider","constructor","settings","configKey","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","client_id","redirect_uri","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","protocol","hostname","window","origin"],"mappings":";;;;;;AA0BA,SAASA,WAAT,QAA4B,iBAA5B;AAeA,OAAO,MAAMC,mBAAN,SAAkCD,WAAlC,CAA8C;AACnDE,EAAAA,WAAW,CACTC,QADS,EAEQC,SAFR,EAGT;AACA,UAAMD,QAAN;AADA,SADiBC,SACjB,GADiBA,SACjB;AAED;;AAEOC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AAChE,Q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AACA,UAAMW,UAAU,aAAMF,GAAG,CAACG,QAAV,eAAuBH,GAAG,CAACI,QAA3B,CAAhB;AACAd,MAAAA,MAAM,GAAG;AACPC,QAAAA,QAAQ,EAAE,KAAKA,QADR;AAEPC,QAAAA,UAAU,YAAKU,UAAL,UAFH;AAGPT,QAAAA,SAAS,EAAE,qBAHJ;AAIPC,QAAAA,YAAY,YAAKW,MAAM,CAACpB,QAAP,CAAgBqB,MAArB;AAJL,OAAT;AAMD;;AAED,QAAM;AAAEf,MAAAA,QAAF;AAAYC,MAAAA,UAAZ;AAAwBC,MAAAA,SAAxB;AAAmCC,MAAAA;AAAnC,QAAoDJ,MAA1D;AAEA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,2CACK,MAAMO,UAAN,CAAiBC,QAAjB,CADL,GAEK;AACDR,MAAAA,QADC;AAEDC,MAAAA,UAFC;AAGDC,MAAAA,SAHC;AAIDC,MAAAA;AAJC,KAFL;AASD;;AAhFkD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n constructor(\n settings: Partial<IApiSettings>,\n private readonly configKey: string\n ) {\n super(settings)\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = {\n base_url: '',\n looker_url: '',\n client_id: '',\n redirect_uri: '',\n }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n client_id: 'looker.api-explorer',\n redirect_uri: `${window.location.origin}/oauth`,\n }\n }\n\n const { base_url, looker_url, client_id, redirect_uri } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id,\n redirect_uri,\n },\n }\n }\n}\n"],"file":"authUtils.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/extension-utils",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "Looker Extension Utilities",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -25,22 +25,23 @@
25
25
  "watch": "yarn lerna exec --scope @looker/extension-utils --stream 'BABEL_ENV=build babel src --root-mode upward --out-dir lib/esm --source-maps --extensions .ts,.tsx --no-comments --watch'"
26
26
  },
27
27
  "dependencies": {
28
- "@looker/code-editor": "^0.1.25",
28
+ "@looker/code-editor": "^0.1.27",
29
29
  "@looker/components": "^3.0.8",
30
- "@looker/extension-sdk": "^22.18.0",
31
- "@looker/extension-sdk-react": "^22.18.0",
32
- "@looker/sdk-rtl": "^21.4.0",
30
+ "@looker/extension-sdk": "^22.20.1",
31
+ "@looker/extension-sdk-react": "^22.20.1",
32
+ "@looker/sdk-rtl": "^21.5.0",
33
33
  "react": "^16.13.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@looker/components-test-utils": "^1.5.26",
37
37
  "@testing-library/react": "^12.1.5",
38
38
  "@types/react-router": "^5.1.18",
39
+ "@types/react-router-dom": "^5.3.3",
39
40
  "@types/redux": "^3.6.0",
40
41
  "webpack-bundle-analyzer": "^4.2.0",
41
42
  "webpack-cli": "^4.6.0",
42
43
  "webpack-dev-server": "^3.11.2",
43
44
  "webpack-merge": "^5.7.3"
44
45
  },
45
- "gitHead": "051cf862cf3b422bf9bc0a38dcf2d7606f7500d1"
46
+ "gitHead": "5545803533abe44ccef1f1b87e99d9f3e5bdc316"
46
47
  }