@backstage/plugin-app 0.1.2-next.1 → 0.1.2-next.2

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/defaultApis.esm.js.map +1 -1
  3. package/dist/extensions/App.esm.js.map +1 -1
  4. package/dist/extensions/AppLanguageApi.esm.js.map +1 -1
  5. package/dist/extensions/AppLayout.esm.js.map +1 -1
  6. package/dist/extensions/AppNav.esm.js.map +1 -1
  7. package/dist/extensions/AppRoot.esm.js.map +1 -1
  8. package/dist/extensions/AppRoutes.esm.js.map +1 -1
  9. package/dist/extensions/AppThemeApi.esm.js.map +1 -1
  10. package/dist/extensions/ComponentsApi.esm.js.map +1 -1
  11. package/dist/extensions/DefaultSignInPage.esm.js.map +1 -1
  12. package/dist/extensions/FeatureFlagsApi.esm.js.map +1 -1
  13. package/dist/extensions/IconsApi.esm.js.map +1 -1
  14. package/dist/extensions/TranslationsApi.esm.js.map +1 -1
  15. package/dist/extensions/components.esm.js.map +1 -1
  16. package/dist/extensions/elements.esm.js.map +1 -1
  17. package/dist/packages/app/src/components/Root/LogoFull.esm.js.map +1 -1
  18. package/dist/packages/app/src/components/Root/LogoIcon.esm.js.map +1 -1
  19. package/dist/packages/app-defaults/src/defaults/apis.esm.js.map +1 -1
  20. package/dist/packages/app-defaults/src/defaults/components.esm.js.map +1 -1
  21. package/dist/packages/app-defaults/src/defaults/icons.esm.js.map +1 -1
  22. package/dist/packages/core-app-api/src/apis/implementations/AlertApi/AlertApiForwarder.esm.js.map +1 -1
  23. package/dist/packages/core-app-api/src/apis/implementations/AnalyticsApi/NoOpAnalyticsApi.esm.js.map +1 -1
  24. package/dist/packages/core-app-api/src/apis/implementations/AppLanguageApi/AppLanguageSelector.esm.js.map +1 -1
  25. package/dist/packages/core-app-api/src/apis/implementations/AppThemeApi/AppThemeSelector.esm.js.map +1 -1
  26. package/dist/packages/core-app-api/src/apis/implementations/DiscoveryApi/UrlPatternDiscovery.esm.js.map +1 -1
  27. package/dist/packages/core-app-api/src/apis/implementations/ErrorApi/ErrorAlerter.esm.js.map +1 -1
  28. package/dist/packages/core-app-api/src/apis/implementations/ErrorApi/ErrorApiForwarder.esm.js.map +1 -1
  29. package/dist/packages/core-app-api/src/apis/implementations/ErrorApi/UnhandledErrorForwarder.esm.js.map +1 -1
  30. package/dist/packages/core-app-api/src/apis/implementations/FeatureFlagsApi/LocalStorageFeatureFlags.esm.js.map +1 -1
  31. package/dist/packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.esm.js.map +1 -1
  32. package/dist/packages/core-app-api/src/apis/implementations/FetchApi/IdentityAuthInjectorFetchMiddleware.esm.js.map +1 -1
  33. package/dist/packages/core-app-api/src/apis/implementations/FetchApi/PluginProtocolResolverFetchMiddleware.esm.js.map +1 -1
  34. package/dist/packages/core-app-api/src/apis/implementations/FetchApi/createFetchApi.esm.js.map +1 -1
  35. package/dist/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthPendingRequests.esm.js.map +1 -1
  36. package/dist/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthRequestManager.esm.js.map +1 -1
  37. package/dist/packages/core-app-api/src/apis/implementations/StorageApi/WebStorage.esm.js.map +1 -1
  38. package/dist/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.esm.js.map +1 -1
  39. package/dist/packages/core-app-api/src/apis/implementations/auth/atlassian/AtlassianAuth.esm.js.map +1 -1
  40. package/dist/packages/core-app-api/src/apis/implementations/auth/bitbucket/BitbucketAuth.esm.js.map +1 -1
  41. package/dist/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.esm.js.map +1 -1
  42. package/dist/packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.esm.js.map +1 -1
  43. package/dist/packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.esm.js.map +1 -1
  44. package/dist/packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.esm.js.map +1 -1
  45. package/dist/packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.esm.js.map +1 -1
  46. package/dist/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.esm.js.map +1 -1
  47. package/dist/packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.esm.js.map +1 -1
  48. package/dist/packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.esm.js.map +1 -1
  49. package/dist/packages/core-app-api/src/apis/implementations/auth/saml/types.esm.js.map +1 -1
  50. package/dist/packages/core-app-api/src/apis/implementations/auth/vmwareCloud/VMwareCloudAuth.esm.js.map +1 -1
  51. package/dist/packages/core-app-api/src/apis/system/ApiAggregator.esm.js.map +1 -1
  52. package/dist/packages/core-app-api/src/apis/system/ApiProvider.esm.js.map +1 -1
  53. package/dist/packages/core-app-api/src/app/AppRouter.esm.js.map +1 -1
  54. package/dist/packages/core-app-api/src/app/AppThemeProvider.esm.js.map +1 -1
  55. package/dist/packages/core-app-api/src/app/isProtectedApp.esm.js.map +1 -1
  56. package/dist/packages/core-app-api/src/app/isReactRouterBeta.esm.js.map +1 -1
  57. package/dist/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.esm.js.map +1 -1
  58. package/dist/packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.esm.js.map +1 -1
  59. package/dist/packages/core-app-api/src/lib/AuthSessionManager/SessionStateTracker.esm.js.map +1 -1
  60. package/dist/packages/core-app-api/src/lib/AuthSessionManager/common.esm.js.map +1 -1
  61. package/dist/packages/core-app-api/src/lib/loginPopup.esm.js.map +1 -1
  62. package/dist/packages/core-app-api/src/lib/subjects.esm.js.map +1 -1
  63. package/dist/packages/core-app-api/src/routing/FeatureFlagged.esm.js.map +1 -1
  64. package/dist/packages/core-app-api/src/routing/FlatRoutes.esm.js.map +1 -1
  65. package/dist/packages/core-app-api/src/routing/RouteTracker.esm.js.map +1 -1
  66. package/dist/packages/core-app-api/src/routing/RoutingProvider.esm.js.map +1 -1
  67. package/dist/packages/core-app-api/src/routing/types.esm.js.map +1 -1
  68. package/dist/packages/core-plugin-api/src/translation/TranslationRef.esm.js.map +1 -1
  69. package/dist/packages/core-plugin-api/src/translation/TranslationResource.esm.js.map +1 -1
  70. package/dist/packages/frontend-app-api/src/apis/implementations/ComponentsApi/DefaultComponentsApi.esm.js.map +1 -1
  71. package/dist/packages/frontend-app-api/src/apis/implementations/IconsApi/DefaultIconsApi.esm.js.map +1 -1
  72. package/dist/packages/frontend-app-api/src/routing/RouteTracker.esm.js.map +1 -1
  73. package/dist/packages/frontend-app-api/src/routing/getBasePath.esm.js.map +1 -1
  74. package/dist/plugin.esm.js.map +1 -1
  75. package/package.json +13 -6
@@ -1 +1 @@
1
- {"version":3,"file":"GithubAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { githubAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'github',\n title: 'GitHub',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to GitHub products.\n *\n * @public\n */\nexport default class GithubAuth {\n static create(options: OAuthApiCreateOptions): typeof githubAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['read:user'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAOA,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAA,GAAgB,CAAC,WAAW,CAAA;AAAA,KAC1B,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"GithubAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { githubAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'github',\n title: 'GitHub',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to GitHub products.\n *\n * @public\n */\nexport default class GithubAuth {\n static create(options: OAuthApiCreateOptions): typeof githubAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['read:user'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAOA,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAA,GAAgB,CAAC,WAAW;AAAA,KAC1B,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"GitlabAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { gitlabAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'gitlab',\n title: 'GitLab',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to GitLab products.\n *\n * @public\n */\nexport default class GitlabAuth {\n static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['read_user'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAOA,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAA,GAAgB,CAAC,WAAW,CAAA;AAAA,KAC1B,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"GitlabAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { gitlabAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'gitlab',\n title: 'GitLab',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to GitLab products.\n *\n * @public\n */\nexport default class GitlabAuth {\n static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['read_user'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAOA,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAA,GAAgB,CAAC,WAAW;AAAA,KAC1B,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { googleAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'google',\n title: 'Google',\n icon: () => null,\n};\n\nconst SCOPE_PREFIX = 'https://www.googleapis.com/auth/';\n\n/**\n * Implements the OAuth flow to Google products.\n *\n * @public\n */\nexport default class GoogleAuth {\n static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n defaultScopes = [\n 'openid',\n `${SCOPE_PREFIX}userinfo.email`,\n `${SCOPE_PREFIX}userinfo.profile`,\n ],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n scopeTransform(scopes: string[]) {\n return scopes.map(scope => {\n if (scope === 'openid') {\n return scope;\n }\n\n if (scope === 'profile' || scope === 'email') {\n return `${SCOPE_PREFIX}userinfo.${scope}`;\n }\n\n if (scope.startsWith(SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAEA,MAAM,YAAe,GAAA,kCAAA,CAAA;AAOrB,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,aAAgB,GAAA;AAAA,QACd,QAAA;AAAA,QACA,GAAG,YAAY,CAAA,cAAA,CAAA;AAAA,QACf,GAAG,YAAY,CAAA,gBAAA,CAAA;AAAA,OACjB;AAAA,KACE,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA,eAAe,MAAkB,EAAA;AAC/B,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAA,IAAI,UAAU,QAAU,EAAA;AACtB,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAI,IAAA,KAAA,KAAU,SAAa,IAAA,KAAA,KAAU,OAAS,EAAA;AAC5C,YAAO,OAAA,CAAA,EAAG,YAAY,CAAA,SAAA,EAAY,KAAK,CAAA,CAAA,CAAA;AAAA,WACzC;AAEA,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,YAAY,CAAG,EAAA;AAClC,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAO,OAAA,CAAA,EAAG,YAAY,CAAA,EAAG,KAAK,CAAA,CAAA,CAAA;AAAA,SAC/B,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"GoogleAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { googleAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'google',\n title: 'Google',\n icon: () => null,\n};\n\nconst SCOPE_PREFIX = 'https://www.googleapis.com/auth/';\n\n/**\n * Implements the OAuth flow to Google products.\n *\n * @public\n */\nexport default class GoogleAuth {\n static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n defaultScopes = [\n 'openid',\n `${SCOPE_PREFIX}userinfo.email`,\n `${SCOPE_PREFIX}userinfo.profile`,\n ],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n scopeTransform(scopes: string[]) {\n return scopes.map(scope => {\n if (scope === 'openid') {\n return scope;\n }\n\n if (scope === 'profile' || scope === 'email') {\n return `${SCOPE_PREFIX}userinfo.${scope}`;\n }\n\n if (scope.startsWith(SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAEA,MAAM,YAAe,GAAA,kCAAA;AAOrB,MAAqB,UAAW,CAAA;AAAA,EAC9B,OAAO,OAAO,OAA2D,EAAA;AACvE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,aAAgB,GAAA;AAAA,QACd,QAAA;AAAA,QACA,GAAG,YAAY,CAAA,cAAA,CAAA;AAAA,QACf,GAAG,YAAY,CAAA,gBAAA;AAAA;AACjB,KACE,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA,eAAe,MAAkB,EAAA;AAC/B,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAA,IAAI,UAAU,QAAU,EAAA;AACtB,YAAO,OAAA,KAAA;AAAA;AAGT,UAAI,IAAA,KAAA,KAAU,SAAa,IAAA,KAAA,KAAU,OAAS,EAAA;AAC5C,YAAO,OAAA,CAAA,EAAG,YAAY,CAAA,SAAA,EAAY,KAAK,CAAA,CAAA;AAAA;AAGzC,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,YAAY,CAAG,EAAA;AAClC,YAAO,OAAA,KAAA;AAAA;AAGT,UAAO,OAAA,CAAA,EAAG,YAAY,CAAA,EAAG,KAAK,CAAA,CAAA;AAAA,SAC/B,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MicrosoftAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n microsoftAuthApiRef,\n AuthRequestOptions,\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n} from '@backstage/core-plugin-api';\nimport { OAuth2, OAuth2CreateOptions } from '../oauth2';\n\nconst DEFAULT_PROVIDER = {\n id: 'microsoft',\n title: 'Microsoft',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to Microsoft products.\n *\n * @public\n */\nexport default class MicrosoftAuth {\n private oauth2: { [aud: string]: OAuth2 };\n private configApi: ConfigApi | undefined;\n private environment: string;\n private provider: AuthProviderInfo;\n private oauthRequestApi: OAuthRequestApi;\n private discoveryApi: DiscoveryApi;\n private scopeTransform: (scopes: string[]) => string[];\n\n private static MicrosoftGraphID = '00000003-0000-0000-c000-000000000000';\n\n static create(options: OAuth2CreateOptions): typeof microsoftAuthApiRef.T {\n return new MicrosoftAuth(options);\n }\n private constructor(options: OAuth2CreateOptions) {\n const {\n configApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n discoveryApi,\n defaultScopes = [\n 'openid',\n 'offline_access',\n 'profile',\n 'email',\n 'User.Read',\n ],\n scopeTransform = scopes => scopes.concat('offline_access'),\n } = options;\n\n this.configApi = configApi;\n this.environment = environment;\n this.provider = provider;\n this.oauthRequestApi = oauthRequestApi;\n this.discoveryApi = discoveryApi;\n this.scopeTransform = scopeTransform;\n\n this.oauth2 = {\n [MicrosoftAuth.MicrosoftGraphID]: OAuth2.create({\n configApi: this.configApi,\n discoveryApi: this.discoveryApi,\n oauthRequestApi: this.oauthRequestApi,\n provider: this.provider,\n environment: this.environment,\n scopeTransform: this.scopeTransform,\n defaultScopes,\n }),\n };\n }\n\n private microsoftGraph(): OAuth2 {\n return this.oauth2[MicrosoftAuth.MicrosoftGraphID];\n }\n\n private static resourceForScopes(scope: string): Promise<string> {\n const audiences = [\n ...new Set(\n scope\n .split(' ')\n .map(MicrosoftAuth.resourceForScope)\n .filter(aud => aud !== 'openid'),\n ),\n ];\n\n if (audiences.length > 1) {\n return Promise.reject(\n new Error(\n `Requested access token with scopes from multiple Azure resources: ${audiences.join(\n ', ',\n )}. Access tokens can only have a single audience.`,\n ),\n );\n }\n const audience = audiences[0] ?? MicrosoftAuth.MicrosoftGraphID;\n return Promise.resolve(audience);\n }\n\n private static resourceForScope(scope: string): string {\n const groups = scope.match(/^(?<resourceURI>.*)\\/(?<scp>[^\\/]*)$/)?.groups;\n if (groups) {\n const { resourceURI } = groups;\n const aud = resourceURI.replace(/^api:\\/\\//, '');\n return aud;\n }\n switch (scope) {\n case 'email':\n case 'openid':\n case 'offline_access':\n case 'profile': {\n return 'openid';\n }\n default:\n return MicrosoftAuth.MicrosoftGraphID;\n }\n }\n\n async getAccessToken(\n scope?: string | string[],\n options?: AuthRequestOptions,\n ): Promise<string> {\n const aud =\n scope === undefined\n ? MicrosoftAuth.MicrosoftGraphID\n : await MicrosoftAuth.resourceForScopes(\n Array.isArray(scope) ? scope.join(' ') : scope,\n );\n if (!(aud in this.oauth2)) {\n this.oauth2[aud] = OAuth2.create({\n configApi: this.configApi,\n discoveryApi: this.discoveryApi,\n oauthRequestApi: this.oauthRequestApi,\n provider: this.provider,\n environment: this.environment,\n scopeTransform: this.scopeTransform,\n });\n }\n return this.oauth2[aud].getAccessToken(scope, options);\n }\n\n getIdToken(options?: AuthRequestOptions) {\n return this.microsoftGraph().getIdToken(options);\n }\n\n getProfile(options?: AuthRequestOptions) {\n return this.microsoftGraph().getProfile(options);\n }\n\n getBackstageIdentity(options?: AuthRequestOptions) {\n return this.microsoftGraph().getBackstageIdentity(options);\n }\n\n signIn() {\n return this.microsoftGraph().signIn();\n }\n\n signOut() {\n return this.microsoftGraph().signOut();\n }\n\n sessionState$() {\n return this.microsoftG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AAA,GACvD;AAAA,EAEA,WAAW,OAA8B,EAAA;AACvC,IAAA,OAAO,IAAK,CAAA,cAAA,EAAiB,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,WAAW,OAA8B,EAAA;AACvC,IAAA,OAAO,IAAK,CAAA,cAAA,EAAiB,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,qBAAqB,OAA8B,EAAA;AACjD,IAAA,OAAO,IAAK,CAAA,cAAA,EAAiB,CAAA,oBAAA,CAAqB,OAAO,CAAA,CAAA;AAAA,GAC3D;AAAA,EAEA,MAAS,GAAA;AACP,IAAO,OAAA,IAAA,CAAK,cAAe,EAAA,CAAE,MAAO,EAAA,CAAA;AAAA,GACtC;AAAA,EAEA,OAAU,GAAA;AACR,IAAO,OAAA,IAAA,CAAK,cAAe,EAAA,CAAE,OAAQ,EAAA,CAAA;AAAA,GACvC;AAAA,EAEA,aAAgB,GAAA;AACd,IAAO,OAAA,IAAA,CAAK,cAAe,EAAA,CAAE,aAAc,EAAA,CAAA;AAAA,GAC7C;AACF;;;;"}
1
+ {"version":3,"file":"MicrosoftAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n microsoftAuthApiRef,\n AuthRequestOptions,\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n} from '@backstage/core-plugin-api';\nimport { OAuth2, OAuth2CreateOptions } from '../oauth2';\n\nconst DEFAULT_PROVIDER = {\n id: 'microsoft',\n title: 'Microsoft',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow to Microsoft products.\n *\n * @public\n */\nexport default class MicrosoftAuth {\n private oauth2: { [aud: string]: OAuth2 };\n private configApi: ConfigApi | undefined;\n private environment: string;\n private provider: AuthProviderInfo;\n private oauthRequestApi: OAuthRequestApi;\n private discoveryApi: DiscoveryApi;\n private scopeTransform: (scopes: string[]) => string[];\n\n private static MicrosoftGraphID = '00000003-0000-0000-c000-000000000000';\n\n static create(options: OAuth2CreateOptions): typeof microsoftAuthApiRef.T {\n return new MicrosoftAuth(options);\n }\n private constructor(options: OAuth2CreateOptions) {\n const {\n configApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n discoveryApi,\n defaultScopes = [\n 'openid',\n 'offline_access',\n 'profile',\n 'email',\n 'User.Read',\n ],\n scopeTransform = scopes => scopes.concat('offline_access'),\n } = options;\n\n this.configApi = configApi;\n this.environment = environment;\n this.provider = provider;\n this.oauthRequestApi = oauthRequestApi;\n this.discoveryApi = discoveryApi;\n this.scopeTransform = scopeTransform;\n\n this.oauth2 = {\n [MicrosoftAuth.MicrosoftGraphID]: OAuth2.create({\n configApi: this.configApi,\n discoveryApi: this.discoveryApi,\n oauthRequestApi: this.oauthRequestApi,\n provider: this.provider,\n environment: this.environment,\n scopeTransform: this.scopeTransform,\n defaultScopes,\n }),\n };\n }\n\n private microsoftGraph(): OAuth2 {\n return this.oauth2[MicrosoftAuth.MicrosoftGraphID];\n }\n\n private static resourceForScopes(scope: string): Promise<string> {\n const audiences = [\n ...new Set(\n scope\n .split(' ')\n .map(MicrosoftAuth.resourceForScope)\n .filter(aud => aud !== 'openid'),\n ),\n ];\n\n if (audiences.length > 1) {\n return Promise.reject(\n new Error(\n `Requested access token with scopes from multiple Azure resources: ${audiences.join(\n ', ',\n )}. Access tokens can only have a single audience.`,\n ),\n );\n }\n const audience = audiences[0] ?? MicrosoftAuth.MicrosoftGraphID;\n return Promise.resolve(audience);\n }\n\n private static resourceForScope(scope: string): string {\n const groups = scope.match(/^(?<resourceURI>.*)\\/(?<scp>[^\\/]*)$/)?.groups;\n if (groups) {\n const { resourceURI } = groups;\n const aud = resourceURI.replace(/^api:\\/\\//, '');\n return aud;\n }\n switch (scope) {\n case 'email':\n case 'openid':\n case 'offline_access':\n case 'profile': {\n return 'openid';\n }\n default:\n return MicrosoftAuth.MicrosoftGraphID;\n }\n }\n\n async getAccessToken(\n scope?: string | string[],\n options?: AuthRequestOptions,\n ): Promise<string> {\n const aud =\n scope === undefined\n ? MicrosoftAuth.MicrosoftGraphID\n : await MicrosoftAuth.resourceForScopes(\n Array.isArray(scope) ? scope.join(' ') : scope,\n );\n if (!(aud in this.oauth2)) {\n this.oauth2[aud] = OAuth2.create({\n configApi: this.configApi,\n discoveryApi: this.discoveryApi,\n oauthRequestApi: this.oauthRequestApi,\n provider: this.provider,\n environment: this.environment,\n scopeTransform: this.scopeTransform,\n });\n }\n return this.oauth2[aud].getAccessToken(scope, options);\n }\n\n getIdToken(options?: AuthRequestOptions) {\n return this.microsoftGraph().getIdToken(options);\n }\n\n getProfile(options?: AuthRequestOptions) {\n return this.microsoftGraph().getProfile(options);\n }\n\n getBackstageIdentity(options?: AuthRequestOptions) {\n return this.microsoftGraph().getBackstageIdentity(options);\n }\n\n signIn() {\n return this.microsoftGraph().signIn();\n }\n\n signOut() {\n return this.microsoftGraph().signOut();\n }\n\n sessionState$() {\n return this.microsoftGraph().sessionState$();\n }\n}\n"],"names":[],"mappings":";;AA0BA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,WAAA;AAAA,EACJ,KAAO,EAAA,WAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAOA,MAAqB,aAAc,CAAA;AAAA,EACzB,MAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,Y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;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"OAuth2.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DefaultAuthConnector,\n PopupOptions,\n} from '../../../../lib/AuthConnector';\nimport { RefreshingAuthSessionManager } from '../../../../lib/AuthSessionManager';\nimport { SessionManager } from '../../../../lib/AuthSessionManager/types';\nimport {\n AuthRequestOptions,\n BackstageIdentityResponse,\n OAuthApi,\n OpenIdConnectApi,\n ProfileInfo,\n ProfileInfoApi,\n SessionState,\n SessionApi,\n BackstageIdentityApi,\n BackstageUserIdentity,\n} from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\nimport { OAuth2Session } from './types';\nimport { OAuthApiCreateOptions } from '../types';\n\n/**\n * OAuth2 create options.\n * @public\n */\nexport type OAuth2CreateOptions = OAuthApiCreateOptions & {\n scopeTransform?: (scopes: string[]) => string[];\n popupOptions?: PopupOptions;\n};\n\nexport type OAuth2Response = {\n providerInfo: {\n accessToken: string;\n idToken: string;\n scope: string;\n expiresInSeconds?: number;\n };\n profile: ProfileInfo;\n backstageIdentity: {\n token: string;\n expiresInSeconds?: number;\n identity: BackstageUserIdentity;\n };\n};\n\nconst DEFAULT_PROVIDER = {\n id: 'oauth2',\n title: 'Your Identity Provider',\n icon: () => null,\n};\n\n/**\n * Implements a generic OAuth2 flow for auth.\n *\n * @public\n */\nexport default class OAuth2\n implements\n OAuthApi,\n OpenIdConnectApi,\n ProfileInfoApi,\n BackstageIdentityApi,\n SessionApi\n{\n static create(options: OAuth2CreateOptions) {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = [],\n scopeTransform = x => x,\n popupOptions,\n } = options;\n\n const connector = new DefaultAuthConnector({\n configApi,\n discoveryApi,\n environment,\n provider,\n oauthRequestApi: oauthRequestApi,\n sessionTransform({\n backstageIdentity,\n ...res\n }: OAuth2Response): OAuth2Session {\n const session: OAuth2Session = {\n ...res,\n providerInfo: {\n idToken: res.providerInfo.idToken,\n accessToken: res.providerInfo.accessToken,\n scopes: OAuth2.normalizeScopes(\n scopeTransform,\n res.providerInfo.scope,\n ),\n expiresAt: res.providerInfo.expiresInSeconds\n ? new Date(Date.now() + res.providerInfo.expiresInSeconds * 1000)\n : undefined,\n },\n };\n if (backstageIdentity) {\n session.backstageIdentity = {\n token: backstageIdentity.token,\n identity: backstageIdentity.identity,\n expiresAt: backstageIdentity.expiresInSeconds\n ? new Date(Date.now() + backstageIdentity.expiresInSeconds * 1000)\n : undefined,\n };\n }\n return session;\n },\n popupOptions,\n });\n\n const sessionManager = new RefreshingAuthSessionManager({\n connector,\n defaultScopes: new Set(defaultScopes),\n sessionScopes: (session: OAuth2Session) => session.providerInfo.scopes,\n sessionShouldRefresh: (session: OAuth2Session) => {\n // TODO(Rugvip): Optimize to use separate checks for provider vs backstage session expiration\n let min = Infinity;\n if (session.providerInfo?.expiresAt) {\n min = Math.min(\n min,\n (session.providerInfo.expiresAt.getTime() - Date.now()) / 1000,\n );\n }\n if (session.backstageIdentity?.expiresAt) {\n min = Math.min(\n min,\n (session.backstageIdentity.expiresAt.getTime() - Date.now()) / 1000,\n );\n }\n return min < 60 * 5;\n },\n });\n\n return new OAuth2({ sessionManager, scopeTransform });\n }\n\n private readonly sessionManager: SessionManager<OAuth2Session>;\n private readonly scopeTransform: (scopes: string[]) => string[];\n\n private constructor(options: {\n sessionManager: SessionManager<OAuth2Session>;\n scopeTransform: (scopes: string[]) => string[];\n }) {\n this.sessionManager = options.sessionManager;\n this.scopeTransform = options.scopeTransform;\n }\n\n async signIn() {\n await this.getAccessToken();\n }\n\n async signOut() {\n await this.sessionManager.removeSession();\n }\n\n sessionState$(): Observable<SessionState> {\n return this.sessionManager.sessionState$();\n }\n\n async getAccessToken(\n scope?: string | string[],\n options?: AuthRequestOptions,\n ) {\n const normalizedScopes = OAuth2.normalizeScopes(this.scopeTransform, scope);\n const session = await this.sessionManager.getSession({\n ...options,\n scopes: normalizedScopes,\n });\n return session?.providerInfo.accessToken ?? '';\n }\n\n async getIdToken(options: AuthRequestOptions = {}) {\n const session = await this.sessionManager.getSession({\n ...options,\n scopes: new Set(['openid']),\n });\n return session?.providerInfo.idToken ?? '';\n }\n\n async getBackstageIdentity(\n options: AuthRequestOptions = {},\n ): Promise<BackstageIdentityResponse | undefined> {\n const session = await this.sessionManager.getSession(options);\n return session?.backstageIdentity;\n }\n\n async getProfile(options: AuthRequestOptions = {}) {\n const session = await this.sessionManager.getSession(options);\n return session?.profile;\n }\n\n private static normalizeScopes(\n scopeTransform: (scopes: string[]) => string[],\n scopes?: string | string[],\n ): Set<string> {\n if (!scopes) {\n return new Set();\n }\n\n const scopeList = Array.isArray(scopes)\n ? scopes\n : scopes.split(/[\\s|,]/).filter(Boolean);\n\n return new Set(scopeTransform(scopeList));\n }\n}\n"],"names":[],"mappings":";;;;;AA8DA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,wBAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAOA,MAAqB,MAOrB,CAAA;AAAA,EACE,OAAO,OAAO,OAA8B,EAAA;AAC1C,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,gBAAgB,EAAC;AAAA,M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AAe,eACb,CAAA,cAAA,EACA,MACa,EAAA;AACb,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAA,2BAAW,GAAI,EAAA,CAAA;AAAA,KACjB;AAEA,IAAM,MAAA,SAAA,GAAY,KAAM,CAAA,OAAA,CAAQ,MAAM,CAAA,GAClC,MACA,GAAA,MAAA,CAAO,KAAM,CAAA,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAEzC,IAAA,OAAO,IAAI,GAAA,CAAI,cAAe,CAAA,SAAS,CAAC,CAAA,CAAA;AAAA,GAC1C;AACF;;;;"}
1
+ {"version":3,"file":"OAuth2.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DefaultAuthConnector,\n PopupOptions,\n} from '../../../../lib/AuthConnector';\nimport { RefreshingAuthSessionManager } from '../../../../lib/AuthSessionManager';\nimport { SessionManager } from '../../../../lib/AuthSessionManager/types';\nimport {\n AuthRequestOptions,\n BackstageIdentityResponse,\n OAuthApi,\n OpenIdConnectApi,\n ProfileInfo,\n ProfileInfoApi,\n SessionState,\n SessionApi,\n BackstageIdentityApi,\n BackstageUserIdentity,\n} from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\nimport { OAuth2Session } from './types';\nimport { OAuthApiCreateOptions } from '../types';\n\n/**\n * OAuth2 create options.\n * @public\n */\nexport type OAuth2CreateOptions = OAuthApiCreateOptions & {\n scopeTransform?: (scopes: string[]) => string[];\n popupOptions?: PopupOptions;\n};\n\nexport type OAuth2Response = {\n providerInfo: {\n accessToken: string;\n idToken: string;\n scope: string;\n expiresInSeconds?: number;\n };\n profile: ProfileInfo;\n backstageIdentity: {\n token: string;\n expiresInSeconds?: number;\n identity: BackstageUserIdentity;\n };\n};\n\nconst DEFAULT_PROVIDER = {\n id: 'oauth2',\n title: 'Your Identity Provider',\n icon: () => null,\n};\n\n/**\n * Implements a generic OAuth2 flow for auth.\n *\n * @public\n */\nexport default class OAuth2\n implements\n OAuthApi,\n OpenIdConnectApi,\n ProfileInfoApi,\n BackstageIdentityApi,\n SessionApi\n{\n static create(options: OAuth2CreateOptions) {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = [],\n scopeTransform = x => x,\n popupOptions,\n } = options;\n\n const connector = new DefaultAuthConnector({\n configApi,\n discoveryApi,\n environment,\n provider,\n oauthRequestApi: oauthRequestApi,\n sessionTransform({\n backstageIdentity,\n ...res\n }: OAuth2Response): OAuth2Session {\n const session: OAuth2Session = {\n ...res,\n providerInfo: {\n idToken: res.providerInfo.idToken,\n accessToken: res.providerInfo.accessToken,\n scopes: OAuth2.normalizeScopes(\n scopeTransform,\n res.providerInfo.scope,\n ),\n expiresAt: res.providerInfo.expiresInSeconds\n ? new Date(Date.now() + res.providerInfo.expiresInSeconds * 1000)\n : undefined,\n },\n };\n if (backstageIdentity) {\n session.backstageIdentity = {\n token: backstageIdentity.token,\n identity: backstageIdentity.identity,\n expiresAt: backstageIdentity.expiresInSeconds\n ? new Date(Date.now() + backstageIdentity.expiresInSeconds * 1000)\n : undefined,\n };\n }\n return session;\n },\n popupOptions,\n });\n\n const sessionManager = new RefreshingAuthSessionManager({\n connector,\n defaultScopes: new Set(defaultScopes),\n sessionScopes: (session: OAuth2Session) => session.providerInfo.scopes,\n sessionShouldRefresh: (session: OAuth2Session) => {\n // TODO(Rugvip): Optimize to use separate checks for provider vs backstage session expiration\n let min = Infinity;\n if (session.providerInfo?.expiresAt) {\n min = Math.min(\n min,\n (session.providerInfo.expiresAt.getTime() - Date.now()) / 1000,\n );\n }\n if (session.backstageIdentity?.expiresAt) {\n min = Math.min(\n min,\n (session.backstageIdentity.expiresAt.getTime() - Date.now()) / 1000,\n );\n }\n return min < 60 * 5;\n },\n });\n\n return new OAuth2({ sessionManager, scopeTransform });\n }\n\n private readonly sessionManager: SessionManager<OAuth2Session>;\n private readonly scopeTransform: (scopes: string[]) => string[];\n\n private constructor(options: {\n sessionManager: SessionManager<OAuth2Session>;\n scopeTransform: (scopes: string[]) => string[];\n }) {\n this.sessionManager = options.sessionManager;\n this.scopeTransform = options.scopeTransform;\n }\n\n async signIn() {\n await this.getAccessToken();\n }\n\n async signOut() {\n await this.sessionManager.removeSession();\n }\n\n sessionState$(): Observable<SessionState> {\n return this.sessionManager.sessionState$();\n }\n\n async getAccessToken(\n scope?: string | string[],\n options?: AuthRequestOptions,\n ) {\n const normalizedScopes = OAuth2.normalizeScopes(this.scopeTransform, scope);\n const session = await this.sessionManager.getSession({\n ...options,\n scopes: normalizedScopes,\n });\n return session?.providerInfo.accessToken ?? '';\n }\n\n async getIdToken(options: AuthRequestOptions = {}) {\n const session = await this.sessionManager.getSession({\n ...options,\n scopes: new Set(['openid']),\n });\n return session?.providerInfo.idToken ?? '';\n }\n\n async getBackstageIdentity(\n options: AuthRequestOptions = {},\n ): Promise<BackstageIdentityResponse | undefined> {\n const session = await this.sessionManager.getSession(options);\n return session?.backstageIdentity;\n }\n\n async getProfile(options: AuthRequestOptions = {}) {\n const session = await this.sessionManager.getSession(options);\n return session?.profile;\n }\n\n private static normalizeScopes(\n scopeTransform: (scopes: string[]) => string[],\n scopes?: string | string[],\n ): Set<string> {\n if (!scopes) {\n return new Set();\n }\n\n const scopeList = Array.isArray(scopes)\n ? scopes\n : scopes.split(/[\\s|,]/).filter(Boolean);\n\n return new Set(scopeTransform(scopeList));\n }\n}\n"],"names":[],"mappings":";;;;;AA8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OAAO,OAAS,EAAA,OAAA;AAAA;AAClB,EAEA,OAAe,eACb,CAAA,cAAA,EACA,MACa,EAAA;AACb,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAA,2BAAW,GAAI,EAAA;AAAA;AAGjB,IAAM,MAAA,SAAA,GAAY,KAAM,CAAA,OAAA,CAAQ,MAAM,CAAA,GAClC,MACA,GAAA,MAAA,CAAO,KAAM,CAAA,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAEzC,IAAA,OAAO,IAAI,GAAA,CAAI,cAAe,CAAA,SAAS,CAAC,CAAA;AAAA;AAE5C;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"OktaAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { oktaAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'okta',\n title: 'Okta',\n icon: () => null,\n};\n\nconst OKTA_OIDC_SCOPES: Set<String> = new Set([\n 'openid',\n 'profile',\n 'email',\n 'phone',\n 'address',\n 'groups',\n 'offline_access',\n]);\n\nconst OKTA_SCOPE_PREFIX: string = 'okta.';\n\n/**\n * Implements the OAuth flow to Okta products.\n *\n * @public\n */\nexport default class OktaAuth {\n static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['openid', 'email', 'profile', 'offline_access'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n scopeTransform(scopes) {\n return scopes.map(scope => {\n if (OKTA_OIDC_SCOPES.has(scope)) {\n return scope;\n }\n\n if (scope.startsWith(OKTA_SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${OKTA_SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,MAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAEA,MAAM,gBAAA,uBAAoC,GAAI,CAAA;AAAA,EAC5C,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AACF,CAAC,CAAA,CAAA;AAED,MAAM,iBAA4B,GAAA,OAAA,CAAA;AAOlC,MAAqB,QAAS,CAAA;AAAA,EAC5B,OAAO,OAAO,OAAyD,EAAA;AACrE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAgB,GAAA,CAAC,QAAU,EAAA,OAAA,EAAS,WAAW,gBAAgB,CAAA;AAAA,KAC7D,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA,eAAe,MAAQ,EAAA;AACrB,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAI,IAAA,gBAAA,CAAiB,GAAI,CAAA,KAAK,CAAG,EAAA;AAC/B,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,iBAAiB,CAAG,EAAA;AACvC,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAO,OAAA,CAAA,EAAG,iBAAiB,CAAA,EAAG,KAAK,CAAA,CAAA,CAAA;AAAA,SACpC,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"OktaAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { oktaAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'okta',\n title: 'Okta',\n icon: () => null,\n};\n\nconst OKTA_OIDC_SCOPES: Set<String> = new Set([\n 'openid',\n 'profile',\n 'email',\n 'phone',\n 'address',\n 'groups',\n 'offline_access',\n]);\n\nconst OKTA_SCOPE_PREFIX: string = 'okta.';\n\n/**\n * Implements the OAuth flow to Okta products.\n *\n * @public\n */\nexport default class OktaAuth {\n static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n defaultScopes = ['openid', 'email', 'profile', 'offline_access'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n scopeTransform(scopes) {\n return scopes.map(scope => {\n if (OKTA_OIDC_SCOPES.has(scope)) {\n return scope;\n }\n\n if (scope.startsWith(OKTA_SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${OKTA_SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,MAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAEA,MAAM,gBAAA,uBAAoC,GAAI,CAAA;AAAA,EAC5C,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,MAAM,iBAA4B,GAAA,OAAA;AAOlC,MAAqB,QAAS,CAAA;AAAA,EAC5B,OAAO,OAAO,OAAyD,EAAA;AACrE,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,MACA,aAAgB,GAAA,CAAC,QAAU,EAAA,OAAA,EAAS,WAAW,gBAAgB;AAAA,KAC7D,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA,eAAe,MAAQ,EAAA;AACrB,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAI,IAAA,gBAAA,CAAiB,GAAI,CAAA,KAAK,CAAG,EAAA;AAC/B,YAAO,OAAA,KAAA;AAAA;AAGT,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,iBAAiB,CAAG,EAAA;AACvC,YAAO,OAAA,KAAA;AAAA;AAGT,UAAO,OAAA,CAAA,EAAG,iBAAiB,CAAA,EAAG,KAAK,CAAA,CAAA;AAAA,SACpC,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"OneLoginAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n oneloginAuthApiRef,\n OAuthRequestApi,\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n} from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\n\n/**\n * OneLogin auth provider create options.\n * @public\n */\nexport type OneLoginAuthCreateOptions = {\n configApi?: ConfigApi;\n discoveryApi: DiscoveryApi;\n oauthRequestApi: OAuthRequestApi;\n environment?: string;\n provider?: AuthProviderInfo;\n};\n\nconst DEFAULT_PROVIDER = {\n id: 'onelogin',\n title: 'onelogin',\n icon: () => null,\n};\n\nconst OIDC_SCOPES: Set<String> = new Set([\n 'openid',\n 'profile',\n 'email',\n 'phone',\n 'address',\n 'groups',\n 'offline_access',\n]);\n\nconst SCOPE_PREFIX: string = 'onelogin.';\n\n/**\n * Implements a OneLogin OAuth flow.\n *\n * @public\n */\nexport default class OneLoginAuth {\n static create(\n options: OneLoginAuthCreateOptions,\n ): typeof oneloginAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes: ['openid', 'email', 'profile', 'offline_access'],\n scopeTransform(scopes) {\n return scopes.map(scope => {\n if (OIDC_SCOPES.has(scope)) {\n return scope;\n }\n\n if (scope.startsWith(SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAqCA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,UAAA;AAAA,EACJ,KAAO,EAAA,UAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAEA,MAAM,WAAA,uBAA+B,GAAI,CAAA;AAAA,EACvC,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AACF,CAAC,CAAA,CAAA;AAED,MAAM,YAAuB,GAAA,WAAA,CAAA;AAO7B,MAAqB,YAAa,CAAA;AAAA,EAChC,OAAO,OACL,OAC6B,EAAA;AAC7B,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,eAAA;AAAA,KACE,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAe,EAAA,CAAC,QAAU,EAAA,OAAA,EAAS,WAAW,gBAAgB,CAAA;AAAA,MAC9D,eAAe,MAAQ,EAAA;AACrB,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAI,IAAA,WAAA,CAAY,GAAI,CAAA,KAAK,CAAG,EAAA;AAC1B,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,YAAY,CAAG,EAAA;AAClC,YAAO,OAAA,KAAA,CAAA;AAAA,WACT;AAEA,UAAO,OAAA,CAAA,EAAG,YAAY,CAAA,EAAG,KAAK,CAAA,CAAA,CAAA;AAAA,SAC/B,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"OneLoginAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n oneloginAuthApiRef,\n OAuthRequestApi,\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n} from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\n\n/**\n * OneLogin auth provider create options.\n * @public\n */\nexport type OneLoginAuthCreateOptions = {\n configApi?: ConfigApi;\n discoveryApi: DiscoveryApi;\n oauthRequestApi: OAuthRequestApi;\n environment?: string;\n provider?: AuthProviderInfo;\n};\n\nconst DEFAULT_PROVIDER = {\n id: 'onelogin',\n title: 'onelogin',\n icon: () => null,\n};\n\nconst OIDC_SCOPES: Set<String> = new Set([\n 'openid',\n 'profile',\n 'email',\n 'phone',\n 'address',\n 'groups',\n 'offline_access',\n]);\n\nconst SCOPE_PREFIX: string = 'onelogin.';\n\n/**\n * Implements a OneLogin OAuth flow.\n *\n * @public\n */\nexport default class OneLoginAuth {\n static create(\n options: OneLoginAuthCreateOptions,\n ): typeof oneloginAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n oauthRequestApi,\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes: ['openid', 'email', 'profile', 'offline_access'],\n scopeTransform(scopes) {\n return scopes.map(scope => {\n if (OIDC_SCOPES.has(scope)) {\n return scope;\n }\n\n if (scope.startsWith(SCOPE_PREFIX)) {\n return scope;\n }\n\n return `${SCOPE_PREFIX}${scope}`;\n });\n },\n });\n }\n}\n"],"names":[],"mappings":";;AAqCA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,UAAA;AAAA,EACJ,KAAO,EAAA,UAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAEA,MAAM,WAAA,uBAA+B,GAAI,CAAA;AAAA,EACvC,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,MAAM,YAAuB,GAAA,WAAA;AAO7B,MAAqB,YAAa,CAAA;AAAA,EAChC,OAAO,OACL,OAC6B,EAAA;AAC7B,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX;AAAA,KACE,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAe,EAAA,CAAC,QAAU,EAAA,OAAA,EAAS,WAAW,gBAAgB,CAAA;AAAA,MAC9D,eAAe,MAAQ,EAAA;AACrB,QAAO,OAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA;AACzB,UAAI,IAAA,WAAA,CAAY,GAAI,CAAA,KAAK,CAAG,EAAA;AAC1B,YAAO,OAAA,KAAA;AAAA;AAGT,UAAI,IAAA,KAAA,CAAM,UAAW,CAAA,YAAY,CAAG,EAAA;AAClC,YAAO,OAAA,KAAA;AAAA;AAGT,UAAO,OAAA,CAAA,EAAG,YAAY,CAAA,EAAG,KAAK,CAAA,CAAA;AAAA,SAC/B,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/saml/types.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackstageIdentityResponse,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport { z } from 'zod';\n\n/** @internal */\nexport type SamlSession = {\n profile: ProfileInfo;\n backstageIdentity: BackstageIdentityResponse;\n};\n\n/** @internal */\nexport const samlSessionSchema: z.ZodSchema<SamlSession> = z.object({\n profile: z.object({\n email: z.string().optional(),\n displayName: z.string().optional(),\n picture: z.string().optional(),\n }),\n backstageIdentity: z.object({\n token: z.string(),\n identity: z.object({\n type: z.literal('user'),\n userEntityRef: z.string(),\n ownershipEntityRefs: z.array(z.string()),\n }),\n }),\n});\n"],"names":[],"mappings":";;AA6B2D,EAAE,MAAO,CAAA;AAAA,EAClE,OAAA,EAAS,EAAE,MAAO,CAAA;AAAA,IAChB,KAAO,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,IACjC,OAAS,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,GAC9B,CAAA;AAAA,EACD,iBAAA,EAAmB,EAAE,MAAO,CAAA;AAAA,IAC1B,KAAA,EAAO,EAAE,MAAO,EAAA;AAAA,IAChB,QAAA,EAAU,EAAE,MAAO,CAAA;AAAA,MACjB,IAAA,EAAM,CAAE,CAAA,OAAA,CAAQ,MAAM,CAAA;AAAA,MACtB,aAAA,EAAe,EAAE,MAAO,EAAA;AAAA,MACxB,mBAAqB,EAAA,CAAA,CAAE,KAAM,CAAA,CAAA,CAAE,QAAQ,CAAA;AAAA,KACxC,CAAA;AAAA,GACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"types.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/saml/types.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackstageIdentityResponse,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport { z } from 'zod';\n\n/** @internal */\nexport type SamlSession = {\n profile: ProfileInfo;\n backstageIdentity: BackstageIdentityResponse;\n};\n\n/** @internal */\nexport const samlSessionSchema: z.ZodSchema<SamlSession> = z.object({\n profile: z.object({\n email: z.string().optional(),\n displayName: z.string().optional(),\n picture: z.string().optional(),\n }),\n backstageIdentity: z.object({\n token: z.string(),\n identity: z.object({\n type: z.literal('user'),\n userEntityRef: z.string(),\n ownershipEntityRefs: z.array(z.string()),\n }),\n }),\n});\n"],"names":[],"mappings":";;AA6B2D,EAAE,MAAO,CAAA;AAAA,EAClE,OAAA,EAAS,EAAE,MAAO,CAAA;AAAA,IAChB,KAAO,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,IACjC,OAAS,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS;AAAA,GAC9B,CAAA;AAAA,EACD,iBAAA,EAAmB,EAAE,MAAO,CAAA;AAAA,IAC1B,KAAA,EAAO,EAAE,MAAO,EAAA;AAAA,IAChB,QAAA,EAAU,EAAE,MAAO,CAAA;AAAA,MACjB,IAAA,EAAM,CAAE,CAAA,OAAA,CAAQ,MAAM,CAAA;AAAA,MACtB,aAAA,EAAe,EAAE,MAAO,EAAA;AAAA,MACxB,mBAAqB,EAAA,CAAA,CAAE,KAAM,CAAA,CAAA,CAAE,QAAQ;AAAA,KACxC;AAAA,GACF;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"VMwareCloudAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/vmwareCloud/VMwareCloudAuth.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { vmwareCloudAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'vmwareCloudServices',\n title: 'VMware Cloud',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow for VMware Cloud Services\n *\n * @public\n */\nexport default class VMwareCloudAuth {\n static create(\n options: OAuthApiCreateOptions,\n ): typeof vmwareCloudAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n defaultScopes = ['openid'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAmBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,qBAAA;AAAA,EACJ,KAAO,EAAA,cAAA;AAAA,EACP,MAAM,MAAM,IAAA;AACd,CAAA,CAAA;AAOA,MAAqB,eAAgB,CAAA;AAAA,EACnC,OAAO,OACL,OACgC,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,aAAA,GAAgB,CAAC,QAAQ,CAAA;AAAA,KACvB,GAAA,OAAA,CAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"VMwareCloudAuth.esm.js","sources":["../../../../../../../../../../packages/core-app-api/src/apis/implementations/auth/vmwareCloud/VMwareCloudAuth.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { vmwareCloudAuthApiRef } from '@backstage/core-plugin-api';\nimport { OAuth2 } from '../oauth2';\nimport { OAuthApiCreateOptions } from '../types';\n\nconst DEFAULT_PROVIDER = {\n id: 'vmwareCloudServices',\n title: 'VMware Cloud',\n icon: () => null,\n};\n\n/**\n * Implements the OAuth flow for VMware Cloud Services\n *\n * @public\n */\nexport default class VMwareCloudAuth {\n static create(\n options: OAuthApiCreateOptions,\n ): typeof vmwareCloudAuthApiRef.T {\n const {\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment = 'development',\n provider = DEFAULT_PROVIDER,\n defaultScopes = ['openid'],\n } = options;\n\n return OAuth2.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n provider,\n environment,\n defaultScopes,\n });\n }\n}\n"],"names":[],"mappings":";;AAmBA,MAAM,gBAAmB,GAAA;AAAA,EACvB,EAAI,EAAA,qBAAA;AAAA,EACJ,KAAO,EAAA,cAAA;AAAA,EACP,MAAM,MAAM;AACd,CAAA;AAOA,MAAqB,eAAgB,CAAA;AAAA,EACnC,OAAO,OACL,OACgC,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAc,GAAA,aAAA;AAAA,MACd,QAAW,GAAA,gBAAA;AAAA,MACX,aAAA,GAAgB,CAAC,QAAQ;AAAA,KACvB,GAAA,OAAA;AAEJ,IAAA,OAAO,OAAO,MAAO,CAAA;AAAA,MACnB,SAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ApiAggregator.esm.js","sources":["../../../../../../../../packages/core-app-api/src/apis/system/ApiAggregator.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiRef, ApiHolder } from '@backstage/core-plugin-api';\n\n/**\n * An ApiHolder that queries multiple other holders from for\n * an Api implementation, returning the first one encountered..\n */\nexport class ApiAggregator implements ApiHolder {\n private readonly holders: ApiHolder[];\n\n constructor(...holders: ApiHolder[]) {\n this.holders = holders;\n }\n\n get<T>(apiRef: ApiRef<T>): T | undefined {\n for (const holder of this.holders) {\n const api = holder.get(apiRef);\n if (api) {\n return api;\n }\n }\n return undefined;\n }\n}\n"],"names":[],"mappings":"AAsBO,MAAM,aAAmC,CAAA;AAAA,EAC7B,OAAA,CAAA;AAAA,EAEjB,eAAe,OAAsB,EAAA;AACnC,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AAAA,GACjB;AAAA,EAEA,IAAO,MAAkC,EAAA;AACvC,IAAW,KAAA,MAAA,MAAA,IAAU,KAAK,OAAS,EAAA;AACjC,MAAM,MAAA,GAAA,GAAM,MAAO,CAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAC7B,MAAA,IAAI,GAAK,EAAA;AACP,QAAO,OAAA,GAAA,CAAA;AAAA,OACT;AAAA,KACF;AACA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}
1
+ {"version":3,"file":"ApiAggregator.esm.js","sources":["../../../../../../../../packages/core-app-api/src/apis/system/ApiAggregator.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiRef, ApiHolder } from '@backstage/core-plugin-api';\n\n/**\n * An ApiHolder that queries multiple other holders from for\n * an Api implementation, returning the first one encountered..\n */\nexport class ApiAggregator implements ApiHolder {\n private readonly holders: ApiHolder[];\n\n constructor(...holders: ApiHolder[]) {\n this.holders = holders;\n }\n\n get<T>(apiRef: ApiRef<T>): T | undefined {\n for (const holder of this.holders) {\n const api = holder.get(apiRef);\n if (api) {\n return api;\n }\n }\n return undefined;\n }\n}\n"],"names":[],"mappings":"AAsBO,MAAM,aAAmC,CAAA;AAAA,EAC7B,OAAA;AAAA,EAEjB,eAAe,OAAsB,EAAA;AACnC,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA;AAAA;AACjB,EAEA,IAAO,MAAkC,EAAA;AACvC,IAAW,KAAA,MAAA,MAAA,IAAU,KAAK,OAAS,EAAA;AACjC,MAAM,MAAA,GAAA,GAAM,MAAO,CAAA,GAAA,CAAI,MAAM,CAAA;AAC7B,MAAA,IAAI,GAAK,EAAA;AACP,QAAO,OAAA,GAAA;AAAA;AACT;AAEF,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ApiProvider.esm.js","sources":["../../../../../../../../packages/core-app-api/src/apis/system/ApiProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useContext, ReactNode, PropsWithChildren } from 'react';\nimport PropTypes from 'prop-types';\nimport { ApiHolder } from '@backstage/core-plugin-api';\nimport { ApiAggregator } from './ApiAggregator';\nimport {\n createVersionedValueMap,\n createVersionedContext,\n} from '@backstage/version-bridge';\n\n/**\n * Prop types for the ApiProvider component.\n * @public\n */\nexport type ApiProviderProps = {\n apis: ApiHolder;\n children: ReactNode;\n};\n\nconst ApiContext = createVersionedContext<{ 1: ApiHolder }>('api-context');\n\n/**\n * Provides an {@link @backstage/core-plugin-api#ApiHolder} for consumption in\n * the React tree.\n *\n * @public\n */\nexport const ApiProvider = (props: PropsWithChildren<ApiProviderProps>) => {\n const { apis, children } = props;\n const parentHolder = useContext(ApiContext)?.atVersion(1);\n const holder = parentHolder ? new ApiAggregator(apis, parentHolder) : apis;\n\n return (\n <ApiContext.Provider\n value={createVersionedValueMap({ 1: holder })}\n children={children}\n />\n );\n};\n\nApiProvider.propTypes = {\n apis: PropTypes.shape({ get: PropTypes.func.isRequired }).isRequired,\n children: PropTypes.node,\n};\n"],"names":[],"mappings":";;;;;AAkCA,MAAM,UAAA,GAAa,uBAAyC,aAAa,CAAA,CAAA;AAQ5D,MAAA,WAAA,GAAc,CAAC,KAA+C,KAAA;AACzE,EAAM,MAAA,EAAE,IAAM,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AAC3B,EAAA,MAAM,YAAe,GAAA,UAAA,CAAW,UAAU,CAAA,EAAG,UAAU,CAAC,CAAA,CAAA;AACxD,EAAA,MAAM,SAAS,YAAe,GAAA,IAAI,aAAc,CAAA,IAAA,EAAM,YAAY,CAAI,GAAA,IAAA,CAAA;AAEtE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAW,CAAA,QAAA;AAAA,IAAX;AAAA,MACC,KAAO,EAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,QAAQ,CAAA;AAAA,MAC5C,QAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ,EAAA;AAEA,WAAA,CAAY,SAAY,GAAA;AAAA,EACtB,IAAA,EAAM,UAAU,KAAM,CAAA,EAAE,KAAK,SAAU,CAAA,IAAA,CAAK,UAAW,EAAC,CAAE,CAAA,UAAA;AAAA,EAC1D,UAAU,SAAU,CAAA,IAAA;AACtB,CAAA;;;;"}
1
+ {"version":3,"file":"ApiProvider.esm.js","sources":["../../../../../../../../packages/core-app-api/src/apis/system/ApiProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useContext, ReactNode, PropsWithChildren } from 'react';\nimport PropTypes from 'prop-types';\nimport { ApiHolder } from '@backstage/core-plugin-api';\nimport { ApiAggregator } from './ApiAggregator';\nimport {\n createVersionedValueMap,\n createVersionedContext,\n} from '@backstage/version-bridge';\n\n/**\n * Prop types for the ApiProvider component.\n * @public\n */\nexport type ApiProviderProps = {\n apis: ApiHolder;\n children: ReactNode;\n};\n\nconst ApiContext = createVersionedContext<{ 1: ApiHolder }>('api-context');\n\n/**\n * Provides an {@link @backstage/core-plugin-api#ApiHolder} for consumption in\n * the React tree.\n *\n * @public\n */\nexport const ApiProvider = (props: PropsWithChildren<ApiProviderProps>) => {\n const { apis, children } = props;\n const parentHolder = useContext(ApiContext)?.atVersion(1);\n const holder = parentHolder ? new ApiAggregator(apis, parentHolder) : apis;\n\n return (\n <ApiContext.Provider\n value={createVersionedValueMap({ 1: holder })}\n children={children}\n />\n );\n};\n\nApiProvider.propTypes = {\n apis: PropTypes.shape({ get: PropTypes.func.isRequired }).isRequired,\n children: PropTypes.node,\n};\n"],"names":[],"mappings":";;;;;AAkCA,MAAM,UAAA,GAAa,uBAAyC,aAAa,CAAA;AAQ5D,MAAA,WAAA,GAAc,CAAC,KAA+C,KAAA;AACzE,EAAM,MAAA,EAAE,IAAM,EAAA,QAAA,EAAa,GAAA,KAAA;AAC3B,EAAA,MAAM,YAAe,GAAA,UAAA,CAAW,UAAU,CAAA,EAAG,UAAU,CAAC,CAAA;AACxD,EAAA,MAAM,SAAS,YAAe,GAAA,IAAI,aAAc,CAAA,IAAA,EAAM,YAAY,CAAI,GAAA,IAAA;AAEtE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAW,CAAA,QAAA;AAAA,IAAX;AAAA,MACC,KAAO,EAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,QAAQ,CAAA;AAAA,MAC5C;AAAA;AAAA,GACF;AAEJ;AAEA,WAAA,CAAY,SAAY,GAAA;AAAA,EACtB,IAAA,EAAM,UAAU,KAAM,CAAA,EAAE,KAAK,SAAU,CAAA,IAAA,CAAK,UAAW,EAAC,CAAE,CAAA,UAAA;AAAA,EAC1D,UAAU,SAAU,CAAA;AACtB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/AppRouter.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useContext, ReactNode, ComponentType, useState } from 'react';\nimport {\n attachComponentData,\n ConfigApi,\n configApiRef,\n IdentityApi,\n SignInPageProps,\n useApi,\n useApp,\n} from '@backstage/core-plugin-api';\nimport { InternalAppContext } from './InternalAppContext';\nimport { isReactRouterBeta } from './isReactRouterBeta';\nimport { RouteTracker } from '../routing/RouteTracker';\nimport { Route, Routes } from 'react-router-dom';\nimport { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';\n\n/**\n * Get the app base path from the configured app baseUrl.\n *\n * The returned path does not have a trailing slash.\n */\nexport function getBasePath(configApi: ConfigApi) {\n if (!isReactRouterBeta()) {\n // When using rr v6 stable the base path is handled through the\n // basename prop on the router component instead.\n return '';\n }\n\n return readBasePath(configApi);\n}\n\n/**\n * Read the configured base path.\n *\n * The returned path does not have a trailing slash.\n */\nfunction readBasePath(configApi: ConfigApi) {\n let { pathname } = new URL(\n configApi.getOptionalString('app.baseUrl') ?? '/',\n 'http://sample.dev', // baseUrl can be specified as just a path\n );\n pathname = pathname.replace(/\\/*$/, '');\n return pathname;\n}\n\n// This wraps the sign-in page and waits for sign-in to be completed before rendering the app\nfunction SignInPageWrapper({\n component: Component,\n appIdentityProxy,\n children,\n}: {\n component: ComponentType<SignInPageProps>;\n appIdentityProxy: AppIdentityProxy;\n children: ReactNode;\n}) {\n const [identityApi, setIdentityApi] = useState<IdentityApi>();\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n\n if (!identityApi) {\n return <Component onSignInSuccess={setIdentityApi} />;\n }\n\n appIdentityProxy.setTarget(identityApi, {\n signOutTargetUrl: basePath || '/',\n });\n return <>{children}</>;\n}\n\n/**\n * Props for the {@link AppRouter} component.\n * @public\n */\nexport interface AppRouterProps {\n children?: ReactNode;\n}\n\n/**\n * App router and sign-in page wrapper.\n *\n * @public\n * @remarks\n *\n * The AppRouter provides the routing context and renders the sign-in page.\n * Until the user has successfully signed in, this component will render\n * the sign-in page. Once the user has signed-in, it will instead render\n * the app, while providing routing and route tracking for the app.\n */\nexport function AppRouter(props: AppRouterProps) {\n const { Router: RouterComponent, SignInPage: SignInPageComponent } =\n useApp().getComponents();\n\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n const mountPath = `${basePath}/*`;\n const internalAppContext = useContext(InternalAppContext);\n if (!internalAppContext) {\n throw new Error('AppRouter must be rendered within the AppProvider');\n }\n const { routeObjects, appIdentityProxy } = internalAppContext;\n\n // If the app hasn't configured a sign-in page, we just continue as guest.\n if (!SignInPageComponent) {\n appIdentityProxy.setTarget(\n {\n getUserId: () => 'guest',\n getIdToken: async () => undefined,\n getProfile: () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getProfileInfo: async () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getBackstageIdentity: async () => ({\n type: 'user',\n userEntityRef: 'user:default/guest',\n ownershipEntityRefs: ['user:default/guest'],\n }),\n getCredentials: async () => ({}),\n signOut: async () => {},\n },\n { signOutTargetUrl: basePath || '/' },\n );\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n {props.children}\n </RouterComponent>\n );\n }\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </SignInPageWrapper>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n {props.children}\n </SignInPageWrapper>\n </RouterComponent>\n );\n}\n\nattachComponentData(AppRouter, 'core.type', 'AppRouter');\n"],"names":[],"mappings":";;;;;;;AAoDA,SAAS,aAAa,SAAsB,EAAA;AAC1C,EAAI,IAAA,EAAE,QAAS,EAAA,GAAI,IAAI,GAA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B,YAAa,EAAA,EAAA,YAAA,EAA4B,CACzC,EAAA,KAAA,CAAM,QACT,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,IAAI,mBAAqB,EAAA;AACvB,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,cAA4B,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,mBAAA;AAAA,QACX,gBAAA;AAAA,OAAA;AAAA,sBAEA,KAAA,CAAA,aAAA,CAAC,MACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,IAAA,EAAM,SAAW,EAAA,OAAA,kBAAY,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,KAAA,CAAM,QAAS,CAAA,EAAK,CAC1D,CAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,2CACG,eAAgB,EAAA,EAAA,QAAA,EAAU,4BACxB,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,cAA4B,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,mBAAA;AAAA,MACX,gBAAA;AAAA,KAAA;AAAA,IAEC,KAAM,CAAA,QAAA;AAAA,GAEX,CAAA,CAAA;AAEJ,CAAA;AAEA,mBAAoB,CAAA,SAAA,EAAW,aAAa,WAAW,CAAA;;;;"}
1
+ {"version":3,"file":"AppRouter.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/AppRouter.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useContext, ReactNode, ComponentType, useState } from 'react';\nimport {\n attachComponentData,\n ConfigApi,\n configApiRef,\n IdentityApi,\n SignInPageProps,\n useApi,\n useApp,\n} from '@backstage/core-plugin-api';\nimport { InternalAppContext } from './InternalAppContext';\nimport { isReactRouterBeta } from './isReactRouterBeta';\nimport { RouteTracker } from '../routing/RouteTracker';\nimport { Route, Routes } from 'react-router-dom';\nimport { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';\n\n/**\n * Get the app base path from the configured app baseUrl.\n *\n * The returned path does not have a trailing slash.\n */\nexport function getBasePath(configApi: ConfigApi) {\n if (!isReactRouterBeta()) {\n // When using rr v6 stable the base path is handled through the\n // basename prop on the router component instead.\n return '';\n }\n\n return readBasePath(configApi);\n}\n\n/**\n * Read the configured base path.\n *\n * The returned path does not have a trailing slash.\n */\nfunction readBasePath(configApi: ConfigApi) {\n let { pathname } = new URL(\n configApi.getOptionalString('app.baseUrl') ?? '/',\n 'http://sample.dev', // baseUrl can be specified as just a path\n );\n pathname = pathname.replace(/\\/*$/, '');\n return pathname;\n}\n\n// This wraps the sign-in page and waits for sign-in to be completed before rendering the app\nfunction SignInPageWrapper({\n component: Component,\n appIdentityProxy,\n children,\n}: {\n component: ComponentType<SignInPageProps>;\n appIdentityProxy: AppIdentityProxy;\n children: ReactNode;\n}) {\n const [identityApi, setIdentityApi] = useState<IdentityApi>();\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n\n if (!identityApi) {\n return <Component onSignInSuccess={setIdentityApi} />;\n }\n\n appIdentityProxy.setTarget(identityApi, {\n signOutTargetUrl: basePath || '/',\n });\n return <>{children}</>;\n}\n\n/**\n * Props for the {@link AppRouter} component.\n * @public\n */\nexport interface AppRouterProps {\n children?: ReactNode;\n}\n\n/**\n * App router and sign-in page wrapper.\n *\n * @public\n * @remarks\n *\n * The AppRouter provides the routing context and renders the sign-in page.\n * Until the user has successfully signed in, this component will render\n * the sign-in page. Once the user has signed-in, it will instead render\n * the app, while providing routing and route tracking for the app.\n */\nexport function AppRouter(props: AppRouterProps) {\n const { Router: RouterComponent, SignInPage: SignInPageComponent } =\n useApp().getComponents();\n\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n const mountPath = `${basePath}/*`;\n const internalAppContext = useContext(InternalAppContext);\n if (!internalAppContext) {\n throw new Error('AppRouter must be rendered within the AppProvider');\n }\n const { routeObjects, appIdentityProxy } = internalAppContext;\n\n // If the app hasn't configured a sign-in page, we just continue as guest.\n if (!SignInPageComponent) {\n appIdentityProxy.setTarget(\n {\n getUserId: () => 'guest',\n getIdToken: async () => undefined,\n getProfile: () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getProfileInfo: async () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getBackstageIdentity: async () => ({\n type: 'user',\n userEntityRef: 'user:default/guest',\n ownershipEntityRefs: ['user:default/guest'],\n }),\n getCredentials: async () => ({}),\n signOut: async () => {},\n },\n { signOutTargetUrl: basePath || '/' },\n );\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n {props.children}\n </RouterComponent>\n );\n }\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </SignInPageWrapper>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n {props.children}\n </SignInPageWrapper>\n </RouterComponent>\n );\n}\n\nattachComponentData(AppRouter, 'core.type', 'AppRouter');\n"],"names":[],"mappings":";;;;;;;AAoDA,SAAS,aAAa,SAAsB,EAAA;AAC1C,EAAI,IAAA,EAAE,QAAS,EAAA,GAAI,IAAI,GAAA;AAAA,IACrB,SAAA,CAAU,iBAAkB,CAAA,aAAa,CAAK,IAAA,GAAA;AAAA,IAC9C;AAAA;AAAA,GACF;AACA,EAAW,QAAA,GAAA,QAAA,CAAS,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAA;AACtC,EAAO,OAAA,QAAA;AACT;AAGA,SAAS,iBAAkB,CAAA;AAAA,EACzB,SAAW,EAAA,SAAA;AAAA,EACX,gBAAA;AAAA,EACA;AACF,CAIG,EAAA;AACD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAsB,EAAA;AAC5D,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAM,MAAA,QAAA,GAAW,aAAa,SAAS,CAAA;AAEvC,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,eAAA,EAAiB,cAAgB,EAAA,CAAA;AAAA;AAGrD,EAAA,gBAAA,CAAiB,UAAU,WAAa,EAAA;AAAA,IACtC,kBAAkB,QAAY,IAAA;AAAA,GAC/B,CAAA;AACD,EAAA,iEAAU,QAAS,CAAA;AACrB;AAqBO,SAAS,UAAU,KAAuB,EAAA;AAC/C,EAAM,MAAA,EAAE,QAAQ,eAAiB,EAAA,UAAA,EAAY,qBAC3C,GAAA,MAAA,GAAS,aAAc,EAAA;AAEzB,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAM,MAAA,QAAA,GAAW,aAAa,SAAS,CAAA;AACvC,E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AIJ,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,mBAAgB,QAAU,EAAA,QAAA,EAAA,sCACxB,YAAa,EAAA,EAAA,YAAA,EAA4B,CACzC,EAAA,KAAA,CAAM,QACT,CAAA;AAAA;AAIJ,EAAA,IAAI,mBAAqB,EAAA;AACvB,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,cAA4B,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,mBAAA;AAAA,QACX;AAAA,OAAA;AAAA,sBAEA,KAAA,CAAA,aAAA,CAAC,MACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,IAAA,EAAM,SAAW,EAAA,OAAA,kBAAY,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,KAAA,CAAM,QAAS,CAAA,EAAK,CAC1D;AAAA,KAEJ,CAAA;AAAA;AAIJ,EAAA,2CACG,eAAgB,EAAA,EAAA,QAAA,EAAU,4BACxB,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,cAA4B,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,mBAAA;AAAA,MACX;AAAA,KAAA;AAAA,IAEC,KAAM,CAAA;AAAA,GAEX,CAAA;AAEJ;AAEA,mBAAoB,CAAA,SAAA,EAAW,aAAa,WAAW,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AppThemeProvider.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/AppThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo, useEffect, useState, PropsWithChildren } from 'react';\nimport { useApi, appThemeApiRef, AppTheme } from '@backstage/core-plugin-api';\nimport useObservable from 'react-use/esm/useObservable';\n\n// This tries to find the most accurate match, but also falls back to less\n// accurate results in order to avoid errors.\nfunction resolveTheme(\n themeId: string | undefined,\n shouldPreferDark: boolean,\n themes: AppTheme[],\n) {\n if (themeId !== undefined) {\n const selectedTheme = themes.find(theme => theme.id === themeId);\n if (selectedTheme) {\n return selectedTheme;\n }\n }\n\n if (shouldPreferDark) {\n const darkTheme = themes.find(theme => theme.variant === 'dark');\n if (darkTheme) {\n return darkTheme;\n }\n }\n\n const lightTheme = themes.find(theme => theme.variant === 'light');\n if (lightTheme) {\n return lightTheme;\n }\n\n return themes[0];\n}\n\nconst useShouldPreferDarkTheme = () => {\n const mediaQuery = useMemo(\n () => window.matchMedia('(prefers-color-scheme: dark)'),\n [],\n );\n const [shouldPreferDark, setPrefersDark] = useState(mediaQuery.matches);\n\n useEffect(() => {\n const listener = (event: MediaQueryListEvent) => {\n setPrefersDark(event.matches);\n };\n mediaQuery.addListener(listener);\n return () => {\n mediaQuery.removeListener(listener);\n };\n }, [mediaQuery]);\n\n return shouldPreferDark;\n};\n\nexport function AppThemeProvider({ children }: PropsWithChildren<{}>) {\n const appThemeApi = useApi(appThemeApiRef);\n const themeId = useObservable(\n appThemeApi.activeThemeId$(),\n appThemeApi.getActiveThemeId(),\n );\n\n // Browser feature detection won't change over time, so ignore lint rule\n const shouldPreferDark = Boolean(window.matchMedia)\n ? useShouldPreferDarkTheme() // eslint-disable-line react-hooks/rules-of-hooks\n : false;\n\n const appTheme = resolveTheme(\n themeId,\n shouldPreferDark,\n appThemeApi.getInstalledThemes(),\n );\n if (!appTheme) {\n throw new Error('App has no themes');\n }\n\n return <appTheme.Provider children={children} />;\n}\n"],"names":[],"mappings":";;;;AAsBA,SAAS,YAAA,CACP,OACA,EAAA,gBAAA,EACA,MACA,EAAA;AACA,EAAA,IAAI,YAAY,KAAW,CAAA,EAAA;AACzB,IAAA,MAAM,gBAAgB,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,OAAO,OAAO,CAAA,CAAA;AAC/D,IAAA,IAAI,aAAe,EAAA;AACjB,MAAO,OAAA,aAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAA,IAAI,gBAAkB,EAAA;AACpB,IAAA,MAAM,YAAY,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,YAAY,MAAM,CAAA,CAAA;AAC/D,IAAA,IAAI,SAAW,EAAA;AACb,MAAO,OAAA,SAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,YAAY,OAAO,CAAA,CAAA;AACjE,EAAA,IAAI,UAAY,EAAA;AACd,IAAO,OAAA,UAAA,CAAA;AAAA,GACT;AAEA,EAAA,OAAO,OAAO,CAAC,CAAA,CAAA;AACjB,CAAA;AAEA,MAAM,2BAA2B,MAAM;AACrC,EAAA,MAAM,UAAa,GAAA,OAAA;AAAA,IACjB,MAAM,MAAO,CAAA,UAAA,CAAW,8BAA8B,CAAA;AAAA,IACtD,EAAC;AAAA,GACH,CAAA;AACA,EAAA,MAAM,CAAC,gBAAkB,EAAA,cAAc,CAAI,GAAA,QAAA,CAAS,WAAW,OAAO,CAAA,CAAA;AAEtE,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,QAAA,GAAW,CAAC,KAA+B,KAAA;AAC/C,MAAA,cAAA,CAAe,MAAM,OAAO,CAAA,CAAA;AAAA,KAC9B,CAAA;AACA,IAAA,UAAA,CAAW,YAAY,QAAQ,CAAA,CAAA;AAC/B,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,CAAW,eAAe,QAAQ,CAAA,CAAA;AAAA,KACpC,CAAA;AAAA,GACF,EAAG,CAAC,UAAU,CAAC,CAAA,CAAA;AAEf,EAAO,OAAA,gBAAA,CAAA;AACT,CAAA,CAAA;AAEgB,SAAA,gBAAA,CAAiB,EAAE,QAAA,EAAmC,EAAA;AACpE,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,OAAU,GAAA,aAAA;AAAA,IACd,YAAY,cAAe,EAAA;AAAA,IAC3B,YAAY,gBAAiB,EAAA;AAAA,GAC/B,CAAA;AAGA,EAAA,MAAM,mBAAmB,OAAQ,CAAA,MAAA,CAAO,UAAU,CAAA,GAC9C,0BACA,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,QAAW,GAAA,YAAA;AAAA,IACf,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAY,kBAAmB,EAAA;AAAA,GACjC,CAAA;AACA,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,mBAAmB,CAAA,CAAA;AAAA,GACrC;AAEA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,QAAA,CAAS,QAAT,EAAA,EAAkB,QAAoB,EAAA,CAAA,CAAA;AAChD;;;;"}
1
+ {"version":3,"file":"AppThemeProvider.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/AppThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo, useEffect, useState, PropsWithChildren } from 'react';\nimport { useApi, appThemeApiRef, AppTheme } from '@backstage/core-plugin-api';\nimport useObservable from 'react-use/esm/useObservable';\n\n// This tries to find the most accurate match, but also falls back to less\n// accurate results in order to avoid errors.\nfunction resolveTheme(\n themeId: string | undefined,\n shouldPreferDark: boolean,\n themes: AppTheme[],\n) {\n if (themeId !== undefined) {\n const selectedTheme = themes.find(theme => theme.id === themeId);\n if (selectedTheme) {\n return selectedTheme;\n }\n }\n\n if (shouldPreferDark) {\n const darkTheme = themes.find(theme => theme.variant === 'dark');\n if (darkTheme) {\n return darkTheme;\n }\n }\n\n const lightTheme = themes.find(theme => theme.variant === 'light');\n if (lightTheme) {\n return lightTheme;\n }\n\n return themes[0];\n}\n\nconst useShouldPreferDarkTheme = () => {\n const mediaQuery = useMemo(\n () => window.matchMedia('(prefers-color-scheme: dark)'),\n [],\n );\n const [shouldPreferDark, setPrefersDark] = useState(mediaQuery.matches);\n\n useEffect(() => {\n const listener = (event: MediaQueryListEvent) => {\n setPrefersDark(event.matches);\n };\n mediaQuery.addListener(listener);\n return () => {\n mediaQuery.removeListener(listener);\n };\n }, [mediaQuery]);\n\n return shouldPreferDark;\n};\n\nexport function AppThemeProvider({ children }: PropsWithChildren<{}>) {\n const appThemeApi = useApi(appThemeApiRef);\n const themeId = useObservable(\n appThemeApi.activeThemeId$(),\n appThemeApi.getActiveThemeId(),\n );\n\n // Browser feature detection won't change over time, so ignore lint rule\n const shouldPreferDark = Boolean(window.matchMedia)\n ? useShouldPreferDarkTheme() // eslint-disable-line react-hooks/rules-of-hooks\n : false;\n\n const appTheme = resolveTheme(\n themeId,\n shouldPreferDark,\n appThemeApi.getInstalledThemes(),\n );\n if (!appTheme) {\n throw new Error('App has no themes');\n }\n\n return <appTheme.Provider children={children} />;\n}\n"],"names":[],"mappings":";;;;AAsBA,SAAS,YAAA,CACP,OACA,EAAA,gBAAA,EACA,MACA,EAAA;AACA,EA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c,OAAO,cAAc,CAAA;AACzC,EAAA,MAAM,OAAU,GAAA,aAAA;AAAA,IACd,YAAY,cAAe,EAAA;AAAA,IAC3B,YAAY,gBAAiB;AAAA,GAC/B;AAGA,EAAA,MAAM,mBAAmB,OAAQ,CAAA,MAAA,CAAO,UAAU,CAAA,GAC9C,0BACA,GAAA,KAAA;AAEJ,EAAA,MAAM,QAAW,GAAA,YAAA;AAAA,IACf,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAY,kBAAmB;AAAA,GACjC;AACA,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,mBAAmB,CAAA;AAAA;AAGrC,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,QAAA,CAAS,QAAT,EAAA,EAAkB,QAAoB,EAAA,CAAA;AAChD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isProtectedApp.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/isProtectedApp.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function isProtectedApp() {\n const element = document.querySelector('meta[name=\"backstage-app-mode\"]');\n const appMode = element?.getAttribute('content') ?? 'public';\n return appMode === 'protected';\n}\n"],"names":[],"mappings":"AAgBO,SAAS,cAAiB,GAAA;AAC/B,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,iCAAiC,CAAA,CAAA;AACxE,EAAA,MAAM,OAAU,GAAA,OAAA,EAAS,YAAa,CAAA,SAAS,CAAK,IAAA,QAAA,CAAA;AACpD,EAAA,OAAO,OAAY,KAAA,WAAA,CAAA;AACrB;;;;"}
1
+ {"version":3,"file":"isProtectedApp.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/isProtectedApp.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function isProtectedApp() {\n const element = document.querySelector('meta[name=\"backstage-app-mode\"]');\n const appMode = element?.getAttribute('content') ?? 'public';\n return appMode === 'protected';\n}\n"],"names":[],"mappings":"AAgBO,SAAS,cAAiB,GAAA;AAC/B,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,iCAAiC,CAAA;AACxE,EAAA,MAAM,OAAU,GAAA,OAAA,EAAS,YAAa,CAAA,SAAS,CAAK,IAAA,QAAA;AACpD,EAAA,OAAO,OAAY,KAAA,WAAA;AACrB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isReactRouterBeta.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/isReactRouterBeta.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { createRoutesFromChildren, Route } from 'react-router-dom';\n\nexport function isReactRouterBeta(): boolean {\n const [obj] = createRoutesFromChildren(<Route index element={<div />} />);\n return !obj.index;\n}\n"],"names":[],"mappings":";;;AAmBO,SAAS,iBAA6B,GAAA;AAC3C,EAAA,MAAM,CAAC,GAAG,CAAI,GAAA,wBAAA,iBAA0B,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,KAAK,EAAA,IAAA,EAAC,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAI,EAAA,IAAA,CAAA,EAAI,CAAE,CAAA,CAAA;AACxE,EAAA,OAAO,CAAC,GAAI,CAAA,KAAA,CAAA;AACd;;;;"}
1
+ {"version":3,"file":"isReactRouterBeta.esm.js","sources":["../../../../../../../packages/core-app-api/src/app/isReactRouterBeta.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { createRoutesFromChildren, Route } from 'react-router-dom';\n\nexport function isReactRouterBeta(): boolean {\n const [obj] = createRoutesFromChildren(<Route index element={<div />} />);\n return !obj.index;\n}\n"],"names":[],"mappings":";;;AAmBO,SAAS,iBAA6B,GAAA;AAC3C,EAAA,MAAM,CAAC,GAAG,CAAI,GAAA,wBAAA,iBAA0B,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,KAAK,EAAA,IAAA,EAAC,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAI,EAAA,IAAA,CAAA,EAAI,CAAE,CAAA;AACxE,EAAA,OAAO,CAAC,GAAI,CAAA,KAAA;AACd;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultAuthConnector.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n OAuthRequester,\n} from '@backstage/core-plugin-api';\nimport { showLoginPopup } from '../loginPopup';\nimport { AuthConnector, CreateSessionOptions, PopupOptions } from './types';\n\nlet warned = false;\n\ntype Options<AuthSession> = {\n /**\n * DiscoveryApi instance used to locate the auth backend endpoint.\n */\n discoveryApi: DiscoveryApi;\n /**\n * Environment hint passed on to auth backend, for example 'production' or 'development'\n */\n environment: string;\n /**\n * Information about the auth provider to be shown to the user.\n * The ID Must match the backend auth plugin configuration, for example 'google'.\n */\n provider: AuthProviderInfo;\n /**\n * API used to instantiate an auth requester.\n */\n oauthRequestApi: OAuthRequestApi;\n /**\n * Function used to join together a set of scopes, defaults to joining with a space character.\n */\n joinScopes?: (scopes: Set<string>) => string;\n /**\n * Function used to transform an auth response into the session type.\n */\n sessionTransform?(response: any): AuthSession | Promise<AuthSession>;\n /**\n * ConfigApi instance used to configure authentication flow of pop-up or redirect.\n */\n configApi?: ConfigApi;\n /**\n * Options used to configure auth popup\n */\n popupOptions?: PopupOptions;\n};\n\nfunction defaultJoinScopes(scopes: Set<string>) {\n return [...scopes].join(' ');\n}\n\n/**\n * DefaultAuthConnector is the default auth connector in Backstage. It talks to the\n * backend auth plugin through the standardized API, and requests user permission\n * via the OAuthRequestApi.\n */\nexport class DefaultAuthConnector<AuthSession>\n implements AuthConnector<AuthSession>\n{\n private readonly discoveryApi: DiscoveryApi;\n private readonly environment: string;\n private readonly provider: AuthProviderInfo;\n private readonly joinScopesFunc: (scopes: Set<string>) => string;\n private readonly authRequester: OAuthRequester<AuthSession>;\n private readonly sessionTransform: (response: any) => Promise<AuthSession>;\n private readonly enableExperimentalRedirectFlow: boolean;\n private readonly popupOptions: PopupOptions | undefined;\n constructor(options: Options<AuthSession>) {\n const {\n configApi,\n discoveryApi,\n environment,\n provider,\n joinScopes = defaultJoinScopes,\n oauthRequestApi,\n sessionTransform = id => id,\n popupOptions,\n } = options;\n\n if (!warned && !configApi) {\n // eslint-disable-next-line no-console\n console.warn(\n 'DEPRECATION WARNING: Authentication providers require a configApi instance to configure the authentication flow. Please provide one to the authentication provider constructor.',\n );\n warned = true;\n }\n\n this.enableExperimentalRedirectFlow = configApi\n ? configApi.getOptionalBoolean('enableExperimentalRedirectFlow') ?? false\n : false;\n\n this.authRequester = oauthRequestApi.createAuthRequester({\n provider,\n onAuthRequest: async scopes => {\n if (!this.enableExperimentalRedirectFlow) {\n return this.showPopup(scopes);\n }\n return this.executeRedirect(scopes);\n },\n });\n\n this.discoveryApi = discoveryApi;\n this.environment = environment;\n this.provider = provider;\n this.joinScopesFunc = joinScopes;\n this.sessionTransform = sessionTransform;\n this.popupOptions = popupOptions;\n }\n\n async createSession(options: CreateSessionOptions): Promise<AuthSession> {\n if (options.instantPopup) {\n if (this.enableExperimentalRedirectFlow) {\n return this.executeRedirect(options.scopes);\n }\n return this.showPopup(options.scopes);\n }\n return this.authRequester(options.scopes);\n }\n\n async refreshSession(scopes?: Set<string>): Promise<any> {\n const res = await fetch(\n await this.buildUrl('/refresh', {\n optional: true,\n ...(scopes && { scope: this.joinScopesFunc(scopes) }),\n }),\n {\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n },\n ).catch(error => {\n throw new Error(`Auth refresh request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(\n `Auth refresh request failed, ${res.statusText}`,\n );\n error.status = res.status;\n throw error;\n }\n\n const authInfo = await res.json();\n\n if (authInfo.error) {\n const error = new Error(authInfo.error.message);\n if (authInfo.error.name) {\n error.name = authInfo.error.name;\n }\n throw error;\n }\n return await this.sessionTransform(authInfo);\n }\n\n async removeSession(): Promise<void> {\n const res = await fetch(await this.buildUrl('/logout'), {\n method: 'POST',\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n }).catch(error => {\n throw new Error(`Logout request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(`Logout request failed, ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n }\n\n private async showPopup(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n const popupUrl = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n flow: 'popup',\n });\n\n const width = this.popupOptions?.size?.fullscreen\n ? window.screen.width\n : this.popupOptions?.size?.width || 450;\n\n const height = this.popupOptions?.size?.fullscreen\n ? window.screen.height\n : this.popupOptions?.size?.height || 730;\n\n const payload = await showLoginPopup({\n url: popupUrl,\n name: `${this.provider.title} Login`,\n origin: new URL(popupUrl).origin,\n width,\n height,\n });\n\n return await this.sessionTransform(payload);\n }\n\n private async executeRedirect(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n // redirect to auth api\n window.location.href = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n redirectUrl: window.location.href,\n flow: 'redirect',\n });\n // return a promise that never resolves\n return new Promise(() => {});\n }\n\n private async buildUrl(\n path: string,\n query?: { [key: string]: string | boolean | undefined },\n ): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('auth');\n const queryString = this.buildQueryString({\n ...query,\n env: this.environment,\n });\n\n return `${baseUrl}/${this.provider.id}${path}${queryString}`;\n }\n\n private buildQueryString(query?: {\n [key: string]: string | boolean | undefined;\n }): string {\n if (!query) {\n return '';\n }\n\n const queryString = Object.entries<string | boolean | undefined>(query)\n .map(([key, value]) => {\n if (typeof value === 'string') {\n return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n } else if (value) {\n return encodeURIComponent(key);\n }\n return undefined;\n })\n .filter(Boolean)\n .join('&');\n\n if (!queryString) {\n return '';\n }\n return `?${queryString}`;\n }\n}\n"],"names":[],"mappings":";;AAyBA,IAAI,MAAS,GAAA,KAAA,CAAA;AAsCb,SAAS,kBAAkB,MAAqB,EAAA;AAC9C,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,GAAG,CAAA,CAAA;AAC7B,CAAA;AAOO,MAAM,oBAEb,CAAA;AAAA,EACmB,YAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EACA,cAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,gBAAA,CAAA;AAAA,EACA,8BAAA,CAAA;AAAA,EACA,YAAA,CAAA;AAAA,EACjB,YAAY,OAA+B,EAAA;AACzC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAa,GAAA,iBAAA;AAAA,MACb,eAAA;AAAA,MACA,mBAAmB,CAAM,EAAA,KAAA,EAAA;AAAA,MACzB,YAAA;AAAA,KACE,GAAA,OAAA,CAAA;AAEJ,IAAI,IAAA,CAAC,MAAU,IAAA,CAAC,SAAW,EAAA;AAEzB,MAAQ,OAAA,CAAA,IAAA;AAAA,QACN,iLAAA;AAAA,OACF,CAAA;AACA,MAAS,MAAA,GAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAA,IAAA,CAAK,iCAAiC,SAClC,GAAA,SAAA,CAAU,kBAAmB,CAAA,gCAAgC,KAAK,KAClE,GAAA,KAAA,CAAA;AAEJ,IAAK,IAAA,CAAA,aAAA,GAAgB,gBAAgB,mBAAoB,CAAA;AAAA,MACvD,QAAA;AAAA,MACA,aAAA,EAAe,OAAM,MAAU,KAAA;AAC7B,QAAI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GAAG,CAAC,CAAI,CAAA,EAAA,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA,CAAA;AAAA,iBACrD,KAAO,EAAA;AAChB,QAAA,OAAO,mBAAmB,GAAG,CAAA,CAAA;AAAA,OAC/B;AACA,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACR,CACA,CAAA,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA,CAAA;AAEX,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAO,OAAA,EAAA,CAAA;AAAA,KACT;AACA,IAAA,OAAO,IAAI,WAAW,CAAA,CAAA,CAAA;AAAA,GACxB;AACF;;;;"}
1
+ {"version":3,"file":"DefaultAuthConnector.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n OAuthRequester,\n} from '@backstage/core-plugin-api';\nimport { showLoginPopup } from '../loginPopup';\nimport { AuthConnector, CreateSessionOptions, PopupOptions } from './types';\n\nlet warned = false;\n\ntype Options<AuthSession> = {\n /**\n * DiscoveryApi instance used to locate the auth backend endpoint.\n */\n discoveryApi: DiscoveryApi;\n /**\n * Environment hint passed on to auth backend, for example 'production' or 'development'\n */\n environment: string;\n /**\n * Information about the auth provider to be shown to the user.\n * The ID Must match the backend auth plugin configuration, for example 'google'.\n */\n provider: AuthProviderInfo;\n /**\n * API used to instantiate an auth requester.\n */\n oauthRequestApi: OAuthRequestApi;\n /**\n * Function used to join together a set of scopes, defaults to joining with a space character.\n */\n joinScopes?: (scopes: Set<string>) => string;\n /**\n * Function used to transform an auth response into the session type.\n */\n sessionTransform?(response: any): AuthSession | Promise<AuthSession>;\n /**\n * ConfigApi instance used to configure authentication flow of pop-up or redirect.\n */\n configApi?: ConfigApi;\n /**\n * Options used to configure auth popup\n */\n popupOptions?: PopupOptions;\n};\n\nfunction defaultJoinScopes(scopes: Set<string>) {\n return [...scopes].join(' ');\n}\n\n/**\n * DefaultAuthConnector is the default auth connector in Backstage. It talks to the\n * backend auth plugin through the standardized API, and requests user permission\n * via the OAuthRequestApi.\n */\nexport class DefaultAuthConnector<AuthSession>\n implements AuthConnector<AuthSession>\n{\n private readonly discoveryApi: DiscoveryApi;\n private readonly environment: string;\n private readonly provider: AuthProviderInfo;\n private readonly joinScopesFunc: (scopes: Set<string>) => string;\n private readonly authRequester: OAuthRequester<AuthSession>;\n private readonly sessionTransform: (response: any) => Promise<AuthSession>;\n private readonly enableExperimentalRedirectFlow: boolean;\n private readonly popupOptions: PopupOptions | undefined;\n constructor(options: Options<AuthSession>) {\n const {\n configApi,\n discoveryApi,\n environment,\n provider,\n joinScopes = defaultJoinScopes,\n oauthRequestApi,\n sessionTransform = id => id,\n popupOptions,\n } = options;\n\n if (!warned && !configApi) {\n // eslint-disable-next-line no-console\n console.warn(\n 'DEPRECATION WARNING: Authentication providers require a configApi instance to configure the authentication flow. Please provide one to the authentication provider constructor.',\n );\n warned = true;\n }\n\n this.enableExperimentalRedirectFlow = configApi\n ? configApi.getOptionalBoolean('enableExperimentalRedirectFlow') ?? false\n : false;\n\n this.authRequester = oauthRequestApi.createAuthRequester({\n provider,\n onAuthRequest: async scopes => {\n if (!this.enableExperimentalRedirectFlow) {\n return this.showPopup(scopes);\n }\n return this.executeRedirect(scopes);\n },\n });\n\n this.discoveryApi = discoveryApi;\n this.environment = environment;\n this.provider = provider;\n this.joinScopesFunc = joinScopes;\n this.sessionTransform = sessionTransform;\n this.popupOptions = popupOptions;\n }\n\n async createSession(options: CreateSessionOptions): Promise<AuthSession> {\n if (options.instantPopup) {\n if (this.enableExperimentalRedirectFlow) {\n return this.executeRedirect(options.scopes);\n }\n return this.showPopup(options.scopes);\n }\n return this.authRequester(options.scopes);\n }\n\n async refreshSession(scopes?: Set<string>): Promise<any> {\n const res = await fetch(\n await this.buildUrl('/refresh', {\n optional: true,\n ...(scopes && { scope: this.joinScopesFunc(scopes) }),\n }),\n {\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n },\n ).catch(error => {\n throw new Error(`Auth refresh request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(\n `Auth refresh request failed, ${res.statusText}`,\n );\n error.status = res.status;\n throw error;\n }\n\n const authInfo = await res.json();\n\n if (authInfo.error) {\n const error = new Error(authInfo.error.message);\n if (authInfo.error.name) {\n error.name = authInfo.error.name;\n }\n throw error;\n }\n return await this.sessionTransform(authInfo);\n }\n\n async removeSession(): Promise<void> {\n const res = await fetch(await this.buildUrl('/logout'), {\n method: 'POST',\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n }).catch(error => {\n throw new Error(`Logout request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(`Logout request failed, ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n }\n\n private async showPopup(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n const popupUrl = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n flow: 'popup',\n });\n\n const width = this.popupOptions?.size?.fullscreen\n ? window.screen.width\n : this.popupOptions?.size?.width || 450;\n\n const height = this.popupOptions?.size?.fullscreen\n ? window.screen.height\n : this.popupOptions?.size?.height || 730;\n\n const payload = await showLoginPopup({\n url: popupUrl,\n name: `${this.provider.title} Login`,\n origin: new URL(popupUrl).origin,\n width,\n height,\n });\n\n return await this.sessionTransform(payload);\n }\n\n private async executeRedirect(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n // redirect to auth api\n window.location.href = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n redirectUrl: window.location.href,\n flow: 'redirect',\n });\n // return a promise that never resolves\n return new Promise(() => {});\n }\n\n private async buildUrl(\n path: string,\n query?: { [key: string]: string | boolean | undefined },\n ): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('auth');\n const queryString = this.buildQueryString({\n ...query,\n env: this.environment,\n });\n\n return `${baseUrl}/${this.provider.id}${path}${queryString}`;\n }\n\n private buildQueryString(query?: {\n [key: string]: string | boolean | undefined;\n }): string {\n if (!query) {\n return '';\n }\n\n const queryString = Object.entries<string | boolean | undefined>(query)\n .map(([key, value]) => {\n if (typeof value === 'string') {\n return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n } else if (value) {\n return encodeURIComponent(key);\n }\n return undefined;\n })\n .filter(Boolean)\n .join('&');\n\n if (!queryString) {\n return '';\n }\n return `?${queryString}`;\n }\n}\n"],"names":[],"mappings":";;AAyBA,IAAI,MAAS,GAAA,KAAA;AAsCb,SAAS,kBAAkB,MAAqB,EAAA;AAC9C,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,GAAG,CAAA;AAC7B;AAOO,MAAM,oBAEb,CAAA;AAAA,EACmB,YAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,8BAAA;AAAA,EACA,YAAA;AAAA,EACjB,YAAY,OAA+B,EAAA;AACzC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAa,GAAA,iBAAA;AAAA,MACb,eAAA;AAAA,MACA,mBAAmB,CAAM,EAAA,KAAA,EAAA;AAAA,MACzB;AAAA,KACE,GAAA,OAAA;AAEJ,IAAI,IAAA,CAAC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AmB,KAAK,CAAC,CAAA,CAAA;AAAA,iBACrD,KAAO,EAAA;AAChB,QAAA,OAAO,mBAAmB,GAAG,CAAA;AAAA;AAE/B,MAAO,OAAA,KAAA,CAAA;AAAA,KACR,CACA,CAAA,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAO,OAAA,EAAA;AAAA;AAET,IAAA,OAAO,IAAI,WAAW,CAAA,CAAA;AAAA;AAE1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshingAuthSessionManager.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SessionManager,\n SessionScopesFunc,\n SessionShouldRefreshFunc,\n GetSessionOptions,\n} from './types';\nimport { AuthConnector } from '../AuthConnector';\nimport { SessionScopeHelper, hasScopes } from './common';\nimport { SessionStateTracker } from './SessionStateTracker';\n\ntype Options<T> = {\n /** The connector used for acting on the auth session */\n connector: AuthConnector<T>;\n /** Used to get the scope of the session */\n sessionScopes: SessionScopesFunc<T>;\n /** Used to check if the session needs to be refreshed */\n sessionShouldRefresh: SessionShouldRefreshFunc<T>;\n /** The default scopes that should always be present in a session, defaults to none. */\n defaultScopes?: Set<string>;\n};\n\n/**\n * RefreshingAuthSessionManager manages an underlying session that has\n * and expiration time and needs to be refreshed periodically.\n */\nexport class RefreshingAuthSessionManager<T> implements SessionManager<T> {\n private readonly connector: AuthConnector<T>;\n private readonly helper: SessionScopeHelper<T>;\n private readonly sessionScopesFunc: SessionScopesFunc<T>;\n private readonly sessionShouldRefreshFunc: SessionShouldRefreshFunc<T>;\n private readonly stateTracker = new SessionStateTracker();\n\n private refreshPromise?: Promise<T>;\n private currentSession: T | undefined;\n\n constructor(options: Options<T>) {\n const {\n connector,\n defaultScopes = new Set(),\n sessionScopes,\n sessionShouldRefresh,\n } = options;\n\n this.connector = connector;\n this.sessionScopesFunc = sessionScopes;\n this.sessionShouldRefreshFunc = sessionShouldRefresh;\n this.helper = new SessionScopeHelper({ sessionScopes, defaultScopes });\n }\n\n async getSession(options: GetSessionOptions): Promise<T | undefined> {\n if (\n this.helper.sessionExistsAndHasScope(this.currentSession, options.scopes)\n ) {\n const shouldRefresh = this.sessionShouldRefreshFunc(this.currentSession!);\n if (!shouldRefresh) {\n return this.currentSession!;\n }\n\n try {\n const refreshedSession = await this.collapsedSessionRefresh(\n options.scopes,\n );\n const currentScopes = this.sessionScopesFunc(this.currentSession!);\n const refreshedScopes = this.sessionScopesFunc(refreshedSession);\n if (hasScopes(refreshedScopes, currentScopes)) {\n this.currentSession = refreshedSession;\n }\n return refreshedSession;\n } catch (error) {\n if (options.optional) {\n return undefined;\n }\n throw error;\n }\n }\n\n // The user may still have a valid refresh token in their cookies. Attempt to\n // initiate a fresh session through the backend using that refresh token.\n //\n // We skip this check if an instant login popup is requested, as we need to\n // stay in a synchronous call stack from the user interaction. The downside\n // is that the user will sometimes be requested to log in even if they\n // already had an existing session.\n if (!this.currentSession && !options.instantPopup) {\n try {\n const newSession = await this.collapsedSessionRefresh(options.scopes);\n this.currentSession = newSession;\n // The session might not have the scopes requested so go back and check again\n return this.getSession(options);\n } catch {\n // If the refresh attempt fails we assume we don't have a session, so continue to create one.\n }\n }\n\n // If we continue here we will show a popup, so exit if this is an optional session request.\n if (options.optional) {\n return undefined;\n }\n\n // We can call authRequester multiple times, the returned session will contain all requested scopes.\n this.currentSession = await this.connector.createSession({\n ...options,\n scopes: this.helper.getExtendedScope(this.currentSession, options.scopes),\n });\n this.stateTracker.setIsSignedIn(true);\n return this.currentSession;\n }\n\n async removeSession() {\n this.currentSession = undefined;\n await this.connector.removeSession();\n this.stateTracker.setIsSignedIn(false);\n }\n\n sessionState$() {\n return this.stateTracker.sessionState$();\n }\n\n private async collapsedSessionRefresh(scopes?: Set<string>): Promise<T> {\n if (this.refreshPromise) {\n return this.refreshPromise;\n }\n\n this.refreshPromise = this.connector.refreshSession(\n this.helper.getExtendedScope(this.currentSession, scopes),\n );\n\n try {\n const session = await this.refreshPromise;\n this.stateTracker.setIsSignedIn(true);\n return session;\n } finally {\n delete this.refreshPromise;\n }\n }\n}\n"],"names":[],"mappings":";;;AAyCO,MAAM,4BAA6D,CAAA;AAAA,EACvD,SAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,iBAAA,CAAA;AAAA,EACA,wBAAA,CAAA;AAAA,EACA,YAAA,GAAe,IAAI,mBAAoB,EAAA,CAAA;AAAA,EAEhD,cAAA,CAAA;AAAA,EACA,cAAA,CAAA;AAAA,EAER,YAAY,OAAqB,EAAA;AAC/B,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,aAAA,uBAAoB,GAAI,EAAA;AAAA,MACxB,aAAA;AAAA,MACA,oBAAA;AAAA,KACE,GAAA,OAAA,CAAA;AAEJ,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAA;AACjB,IAAA,IAAA,CAAK,iBAAoB,GAAA,aAAA,CAAA;AACzB,IAAA,IAAA,CAAK,wBAA2B,GAAA,oBAAA,CAAA;AAChC,IAAA,IAAA,CAAK,SAAS,IAAI,kBAAA,CAAmB,EAAE,aAAA,EAAe,eAAe,CAAA,CAAA;AAAA,GACvE;AAAA,EAEA,MAAM,WAAW,OAAoD,EAAA;AACnE,IAAA,IACE,KAAK,MAAO,CAAA,wBAAA,CAAyB,KAAK,cAAgB,EAAA,OAAA,CAAQ,MAAM,CACxE,EAAA;AACA,MAAA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A,SAAA,CAAU,aAAc,CAAA;AAAA,MACvD,GAAG,OAAA;AAAA,MACH,QAAQ,IAAK,CAAA,MAAA,CAAO,iBAAiB,IAAK,CAAA,cAAA,EAAgB,QAAQ,MAAM,CAAA;AAAA,KACzE,CAAA,CAAA;AACD,IAAK,IAAA,CAAA,YAAA,CAAa,cAAc,IAAI,CAAA,CAAA;AACpC,IAAA,OAAO,IAAK,CAAA,cAAA,CAAA;AAAA,GACd;AAAA,EAEA,MAAM,aAAgB,GAAA;AACpB,IAAA,IAAA,CAAK,cAAiB,GAAA,KAAA,CAAA,CAAA;AACtB,IAAM,MAAA,IAAA,CAAK,UAAU,aAAc,EAAA,CAAA;AACnC,IAAK,IAAA,CAAA,YAAA,CAAa,cAAc,KAAK,CAAA,CAAA;AAAA,GACvC;AAAA,EAEA,aAAgB,GAAA;AACd,IAAO,OAAA,IAAA,CAAK,aAAa,aAAc,EAAA,CAAA;AAAA,GACzC;AAAA,EAEA,MAAc,wBAAwB,MAAkC,EAAA;AACtE,IAAA,IAAI,KAAK,cAAgB,EAAA;AACvB,MAAA,OAAO,IAAK,CAAA,cAAA,CAAA;AAAA,KACd;AAEA,IAAK,IAAA,CAAA,cAAA,GAAiB,KAAK,SAAU,CAAA,cAAA;AAAA,MACnC,IAAK,CAAA,MAAA,CAAO,gBAAiB,CAAA,IAAA,CAAK,gBAAgB,MAAM,CAAA;AAAA,KAC1D,CAAA;AAEA,IAAI,IAAA;AACF,MAAM,MAAA,OAAA,GAAU,MAAM,IAAK,CAAA,cAAA,CAAA;AAC3B,MAAK,IAAA,CAAA,YAAA,CAAa,cAAc,IAAI,CAAA,CAAA;AACpC,MAAO,OAAA,OAAA,CAAA;AAAA,KACP,SAAA;AACA,MAAA,OAAO,IAAK,CAAA,cAAA,CAAA;AAAA,KACd;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"RefreshingAuthSessionManager.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SessionManager,\n SessionScopesFunc,\n SessionShouldRefreshFunc,\n GetSessionOptions,\n} from './types';\nimport { AuthConnector } from '../AuthConnector';\nimport { SessionScopeHelper, hasScopes } from './common';\nimport { SessionStateTracker } from './SessionStateTracker';\n\ntype Options<T> = {\n /** The connector used for acting on the auth session */\n connector: AuthConnector<T>;\n /** Used to get the scope of the session */\n sessionScopes: SessionScopesFunc<T>;\n /** Used to check if the session needs to be refreshed */\n sessionShouldRefresh: SessionShouldRefreshFunc<T>;\n /** The default scopes that should always be present in a session, defaults to none. */\n defaultScopes?: Set<string>;\n};\n\n/**\n * RefreshingAuthSessionManager manages an underlying session that has\n * and expiration time and needs to be refreshed periodically.\n */\nexport class RefreshingAuthSessionManager<T> implements SessionManager<T> {\n private readonly connector: AuthConnector<T>;\n private readonly helper: SessionScopeHelper<T>;\n private readonly sessionScopesFunc: SessionScopesFunc<T>;\n private readonly sessionShouldRefreshFunc: SessionShouldRefreshFunc<T>;\n private readonly stateTracker = new SessionStateTracker();\n\n private refreshPromise?: Promise<T>;\n private currentSession: T | undefined;\n\n constructor(options: Options<T>) {\n const {\n connector,\n defaultScopes = new Set(),\n sessionScopes,\n sessionShouldRefresh,\n } = options;\n\n this.connector = connector;\n this.sessionScopesFunc = sessionScopes;\n this.sessionShouldRefreshFunc = sessionShouldRefresh;\n this.helper = new SessionScopeHelper({ sessionScopes, defaultScopes });\n }\n\n async getSession(options: GetSessionOptions): Promise<T | undefined> {\n if (\n this.helper.sessionExistsAndHasScope(this.currentSession, options.scopes)\n ) {\n const shouldRefresh = this.sessionShouldRefreshFunc(this.currentSession!);\n if (!shouldRefresh) {\n return this.currentSession!;\n }\n\n try {\n const refreshedSession = await this.collapsedSessionRefresh(\n options.scopes,\n );\n const currentScopes = this.sessionScopesFunc(this.currentSession!);\n const refreshedScopes = this.sessionScopesFunc(refreshedSession);\n if (hasScopes(refreshedScopes, currentScopes)) {\n this.currentSession = refreshedSession;\n }\n return refreshedSession;\n } catch (error) {\n if (options.optional) {\n return undefined;\n }\n throw error;\n }\n }\n\n // The user may still have a valid refresh token in their cookies. Attempt to\n // initiate a fresh session through the backend using that refresh token.\n //\n // We skip this check if an instant login popup is requested, as we need to\n // stay in a synchronous call stack from the user interaction. The downside\n // is that the user will sometimes be requested to log in even if they\n // already had an existing session.\n if (!this.currentSession && !options.instantPopup) {\n try {\n const newSession = await this.collapsedSessionRefresh(options.scopes);\n this.currentSession = newSession;\n // The session might not have the scopes requested so go back and check again\n return this.getSession(options);\n } catch {\n // If the refresh attempt fails we assume we don't have a session, so continue to create one.\n }\n }\n\n // If we continue here we will show a popup, so exit if this is an optional session request.\n if (options.optional) {\n return undefined;\n }\n\n // We can call authRequester multiple times, the returned session will contain all requested scopes.\n this.currentSession = await this.connector.createSession({\n ...options,\n scopes: this.helper.getExtendedScope(this.currentSession, options.scopes),\n });\n this.stateTracker.setIsSignedIn(true);\n return this.currentSession;\n }\n\n async removeSession() {\n this.currentSession = undefined;\n await this.connector.removeSession();\n this.stateTracker.setIsSignedIn(false);\n }\n\n sessionState$() {\n return this.stateTracker.sessionState$();\n }\n\n private async collapsedSessionRefresh(scopes?: Set<string>): Promise<T> {\n if (this.refreshPromise) {\n return this.refreshPromise;\n }\n\n this.refreshPromise = this.connector.refreshSession(\n this.helper.getExtendedScope(this.currentSession, scopes),\n );\n\n try {\n const session = await this.refreshPromise;\n this.stateTracker.setIsSignedIn(true);\n return session;\n } finally {\n delete this.refreshPromise;\n }\n }\n}\n"],"names":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,IAAK,IAAA,CAAA,cAAA,GAAiB,KAAK,SAAU,CAAA,cAAA;AAAA,MACnC,IAAK,CAAA,MAAA,CAAO,gBAAiB,CAAA,IAAA,CAAK,gBAAgB,MAAM;AAAA,KAC1D;AAEA,IAAI,IAAA;AACF,MAAM,MAAA,OAAA,GAAU,MAAM,IAAK,CAAA,cAAA;AAC3B,MAAK,IAAA,CAAA,YAAA,CAAa,cAAc,IAAI,CAAA;AACpC,MAAO,OAAA,OAAA;AAAA,KACP,SAAA;AACA,MAAA,OAAO,IAAK,CAAA,cAAA;AAAA;AACd;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionStateTracker.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/SessionStateTracker.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BehaviorSubject } from '../subjects';\nimport { SessionState } from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\n\nexport class SessionStateTracker {\n private readonly subject = new BehaviorSubject<SessionState>(\n SessionState.SignedOut,\n );\n\n private signedIn: boolean = false;\n\n setIsSignedIn(isSignedIn: boolean) {\n if (this.signedIn !== isSignedIn) {\n this.signedIn = isSignedIn;\n this.subject.next(\n this.signedIn ? SessionState.SignedIn : SessionState.SignedOut,\n );\n }\n }\n\n sessionState$(): Observable<SessionState> {\n return this.subject;\n }\n}\n"],"names":[],"mappings":";;;AAoBO,MAAM,mBAAoB,CAAA;AAAA,EACd,UAAU,IAAI,eAAA;AAAA,IAC7B,YAAa,CAAA,SAAA;AAAA,GACf,CAAA;AAAA,EAEQ,QAAoB,GAAA,KAAA,CAAA;AAAA,EAE5B,cAAc,UAAqB,EAAA;AACjC,IAAI,IAAA,IAAA,CAAK,aAAa,UAAY,EAAA;AAChC,MAAA,IAAA,CAAK,QAAW,GAAA,UAAA,CAAA;AAChB,MAAA,IAAA,CAAK,OAAQ,CAAA,IAAA;AAAA,QACX,IAAK,CAAA,QAAA,GAAW,YAAa,CAAA,QAAA,GAAW,YAAa,CAAA,SAAA;AAAA,OACvD,CAAA;AAAA,KACF;AAAA,GACF;AAAA,EAEA,aAA0C,GAAA;AACxC,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GACd;AACF;;;;"}
1
+ {"version":3,"file":"SessionStateTracker.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/SessionStateTracker.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BehaviorSubject } from '../subjects';\nimport { SessionState } from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\n\nexport class SessionStateTracker {\n private readonly subject = new BehaviorSubject<SessionState>(\n SessionState.SignedOut,\n );\n\n private signedIn: boolean = false;\n\n setIsSignedIn(isSignedIn: boolean) {\n if (this.signedIn !== isSignedIn) {\n this.signedIn = isSignedIn;\n this.subject.next(\n this.signedIn ? SessionState.SignedIn : SessionState.SignedOut,\n );\n }\n }\n\n sessionState$(): Observable<SessionState> {\n return this.subject;\n }\n}\n"],"names":[],"mappings":";;;AAoBO,MAAM,mBAAoB,CAAA;AAAA,EACd,UAAU,IAAI,eAAA;AAAA,IAC7B,YAAa,CAAA;AAAA,GACf;AAAA,EAEQ,QAAoB,GAAA,KAAA;AAAA,EAE5B,cAAc,UAAqB,EAAA;AACjC,IAAI,IAAA,IAAA,CAAK,aAAa,UAAY,EAAA;AAChC,MAAA,IAAA,CAAK,QAAW,GAAA,UAAA;AAChB,MAAA,IAAA,CAAK,OAAQ,CAAA,IAAA;AAAA,QACX,IAAK,CAAA,QAAA,GAAW,YAAa,CAAA,QAAA,GAAW,YAAa,CAAA;AAAA,OACvD;AAAA;AACF;AACF,EAEA,aAA0C,GAAA;AACxC,IAAA,OAAO,IAAK,CAAA,OAAA;AAAA;AAEhB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/common.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionScopesFunc } from './types';\n\nexport function hasScopes(\n searched: Set<string>,\n searchFor: Set<string>,\n): boolean {\n for (const scope of searchFor) {\n if (!searched.has(scope)) {\n return false;\n }\n }\n return true;\n}\n\ntype ScopeHelperOptions<T> = {\n sessionScopes: SessionScopesFunc<T> | undefined;\n defaultScopes?: Set<string>;\n};\n\nexport class SessionScopeHelper<T> {\n constructor(private readonly options: ScopeHelperOptions<T>) {}\n\n sessionExistsAndHasScope(\n session: T | undefined,\n scopes?: Set<string>,\n ): boolean {\n if (!session) {\n return false;\n }\n if (!scopes) {\n return true;\n }\n if (this.options.sessionScopes === undefined) {\n return true;\n }\n const sessionScopes = this.options.sessionScopes(session);\n return hasScopes(sessionScopes, scopes);\n }\n\n getExtendedScope(session: T | undefined, scopes?: Set<string>) {\n const newScope = new Set(this.options.defaultScopes);\n if (session && this.options.sessionScopes !== undefined) {\n const sessionScopes = this.options.sessionScopes(session);\n for (const scope of sessionScopes) {\n newScope.add(scope);\n }\n }\n if (scopes) {\n for (const scope of scopes) {\n newScope.add(scope);\n }\n }\n return newScope;\n }\n}\n"],"names":[],"mappings":"AAkBgB,SAAA,SAAA,CACd,UACA,SACS,EAAA;AACT,EAAA,KAAA,MAAW,SAAS,SAAW,EAAA;AAC7B,IAAA,IAAI,CAAC,QAAA,CAAS,GAAI,CAAA,KAAK,CAAG,EAAA;AACxB,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,GACF;AACA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAOO,MAAM,kBAAsB,CAAA;AAAA,EACjC,YAA6B,OAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA,CAAA;AAAA,GAAiC;AAAA,EAE9D,wBAAA,CACE,SACA,MACS,EAAA;AACT,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AACA,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AACA,IAAI,IAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AAC5C,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AACA,IAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,CAAc,OAAO,CAAA,CAAA;AACxD,IAAO,OAAA,SAAA,CAAU,eAAe,MAAM,CAAA,CAAA;AAAA,GACxC;AAAA,EAEA,gBAAA,CAAiB,SAAwB,MAAsB,EAAA;AAC7D,IAAA,MAAM,QAAW,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,QAAQ,aAAa,CAAA,CAAA;AACnD,IAAA,IAAI,OAAW,IAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AACvD,MAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,CAAc,OAAO,CAAA,CAAA;AACxD,MAAA,KAAA,MAAW,SAAS,aAAe,EAAA;AACjC,QAAA,QAAA,CAAS,IAAI,KAAK,CAAA,CAAA;AAAA,OACpB;AAAA,KACF;AACA,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,KAAA,MAAW,SAAS,MAAQ,EAAA;AAC1B,QAAA,QAAA,CAAS,IAAI,KAAK,CAAA,CAAA;AAAA,OACpB;AAAA,KACF;AACA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AACF;;;;"}
1
+ {"version":3,"file":"common.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthSessionManager/common.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionScopesFunc } from './types';\n\nexport function hasScopes(\n searched: Set<string>,\n searchFor: Set<string>,\n): boolean {\n for (const scope of searchFor) {\n if (!searched.has(scope)) {\n return false;\n }\n }\n return true;\n}\n\ntype ScopeHelperOptions<T> = {\n sessionScopes: SessionScopesFunc<T> | undefined;\n defaultScopes?: Set<string>;\n};\n\nexport class SessionScopeHelper<T> {\n constructor(private readonly options: ScopeHelperOptions<T>) {}\n\n sessionExistsAndHasScope(\n session: T | undefined,\n scopes?: Set<string>,\n ): boolean {\n if (!session) {\n return false;\n }\n if (!scopes) {\n return true;\n }\n if (this.options.sessionScopes === undefined) {\n return true;\n }\n const sessionScopes = this.options.sessionScopes(session);\n return hasScopes(sessionScopes, scopes);\n }\n\n getExtendedScope(session: T | undefined, scopes?: Set<string>) {\n const newScope = new Set(this.options.defaultScopes);\n if (session && this.options.sessionScopes !== undefined) {\n const sessionScopes = this.options.sessionScopes(session);\n for (const scope of sessionScopes) {\n newScope.add(scope);\n }\n }\n if (scopes) {\n for (const scope of scopes) {\n newScope.add(scope);\n }\n }\n return newScope;\n }\n}\n"],"names":[],"mappings":"AAkBgB,SAAA,SAAA,CACd,UACA,SACS,EAAA;AACT,EAAA,KAAA,MAAW,SAAS,SAAW,EAAA;AAC7B,IAAA,IAAI,CAAC,QAAA,CAAS,GAAI,CAAA,KAAK,CAAG,EAAA;AACxB,MAAO,OAAA,KAAA;AAAA;AACT;AAEF,EAAO,OAAA,IAAA;AACT;AAOO,MAAM,kBAAsB,CAAA;AAAA,EACjC,YAA6B,OAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAAiC,EAE9D,wBAAA,CACE,SACA,MACS,EAAA;AACT,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAO,OAAA,KAAA;AAAA;AAET,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAO,OAAA,IAAA;AAAA;AAET,IAAI,IAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AAC5C,MAAO,OAAA,IAAA;AAAA;AAET,IAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,CAAc,OAAO,CAAA;AACxD,IAAO,OAAA,SAAA,CAAU,eAAe,MAAM,CAAA;AAAA;AACxC,EAEA,gBAAA,CAAiB,SAAwB,MAAsB,EAAA;AAC7D,IAAA,MAAM,QAAW,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,QAAQ,aAAa,CAAA;AACnD,IAAA,IAAI,OAAW,IAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AACvD,MAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,OAAQ,CAAA,aAAA,CAAc,OAAO,CAAA;AACxD,MAAA,KAAA,MAAW,SAAS,aAAe,EAAA;AACjC,QAAA,QAAA,CAAS,IAAI,KAAK,CAAA;AAAA;AACpB;AAEF,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,KAAA,MAAW,SAAS,MAAQ,EAAA;AAC1B,QAAA,QAAA,CAAS,IAAI,KAAK,CAAA;AAAA;AACpB;AAEF,IAAO,OAAA,QAAA;AAAA;AAEX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"loginPopup.esm.js","sources":["../../../../../../../packages/core-app-api/src/lib/loginPopup.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options used to open a login popup.\n */\nexport type LoginPopupOptions = {\n /**\n * The URL that the auth popup should point to\n */\n url: string;\n\n /**\n * The name of the popup, as in second argument to window.open\n */\n name: string;\n\n /**\n * The origin of the final popup page that will post a message to this window.\n */\n origin: string;\n\n /**\n * The width of the popup in pixels, defaults to 500\n */\n width?: number;\n\n /**\n * The height of the popup in pixels, defaults to 700\n */\n height?: number;\n};\n\ntype AuthResult =\n | {\n type: 'authorization_response';\n response: unknown;\n }\n | {\n type: 'authorization_response';\n error: {\n name: string;\n message: string;\n };\n };\n\n/**\n * Show a popup pointing to a URL that starts an auth flow. Implementing the receiving\n * end of the postMessage mechanism outlined in https://tools.ietf.org/html/draft-sakimura-oauth-wmrm-00\n *\n * The redirect handler of the flow should use postMessage to communicate back\n * to the app window. The message posted to the app must match the AuthResult type.\n *\n * The returned promise resolves to the response of the message that was posted from the auth popup.\n */\nexport function showLoginPopup(options: LoginPopupOptions): Promise<any> {\n return new Promise((resolve, reject) => {\n const width = options.width || 500;\n const height = options.height || 700;\n const left = window.screen.width / 2 - width / 2;\n const top = window.screen.height / 2 - height / 2;\n\n const popup = window.open(\n options.url,\n options.name,\n `menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${width},height=${height},top=${top},left=${left}`,\n );\n\n let targetOrigin = '';\n\n if (!popup || typeof popup.closed === 'undefined' || popup.closed) {\n const error = new Error('Failed to open auth popup.');\n error.name = 'PopupRejectedError';\n reject(error);\n return;\n }\n\n const messageListener = (event: MessageEvent) => {\n if (event.source !== popup) {\n return;\n }\n if (event.origin !== options.origin) {\n return;\n }\n const { data } = event;\n\n if (data.type === 'config_info') {\n targetOrigin = data.targetOrigin;\n return;\n }\n\n if (data.type !== 'authorization_response') {\n return;\n }\n const authResult = data as AuthResult;\n\n if ('error' in authResult) {\n const error = new Error(authResult.error.message);\n error.name = authResult.error.name;\n // TODO: proper error type\n // error.extra = authResult.error.extra;\n reject(error);\n } else {\n resolve(authResult.response);\n }\n done();\n };\n\n const intervalId = setInterval(() => {\n if (popup.closed) {\n const errMessage = `Login failed, ${\n targetOrigin && targetOrigin !== window.location.origin\n ? `Incorrect app origin, expected ${targetOrigin}`\n : 'popup was closed'\n }`;\n const error = new Error(errMessage);\n error.name = 'PopupClosedError';\n reject(error);\n done();\n }\n }, 100);\n\n function done() {\n window.removeEventListener('message', messageListener);\n clearInterval(intervalId);\n }\n\n window.addEventListener('message', messageListener);\n });\n}\n"],"names":[],"mappings":"AAoEO,SAAS,eAAe,OAA0C,EAAA;AACvE,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,EAAS,MAAW,KAAA;AACtC,IAAM,MAAA,KAAA,GAAQ,QAAQ,KAAS,IAAA,GAAA,CAAA;AAC/B,IAAM,MAAA,MAAA,GAAS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/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options used to open a login popup.\n */\nexport type LoginPopupOptions = {\n /**\n * The URL that the auth popup should point to\n */\n url: string;\n\n /**\n * The name of the popup, as in second argument to window.open\n */\n name: string;\n\n /**\n * The origin of the final popup page that will post a message to this window.\n */\n origin: string;\n\n /**\n * The width of the popup in pixels, defaults to 500\n */\n width?: number;\n\n /**\n * The height of the popup in pixels, defaults to 700\n */\n height?: number;\n};\n\ntype AuthResult =\n | {\n type: 'authorization_response';\n response: unknown;\n }\n | {\n type: 'authorization_response';\n error: {\n name: string;\n message: string;\n };\n };\n\n/**\n * Show a popup pointing to a URL that starts an auth flow. Implementing the receiving\n * end of the postMessage mechanism outlined in https://tools.ietf.org/html/draft-sakimura-oauth-wmrm-00\n *\n * The redirect handler of the flow should use postMessage to communicate back\n * to the app window. The message posted to the app must match the AuthResult type.\n *\n * The returned promise resolves to the response of the message that was posted from the auth popup.\n */\nexport function showLoginPopup(options: LoginPopupOptions): Promise<any> {\n return new Promise((resolve, reject) => {\n const width = options.width || 500;\n const height = options.height || 700;\n const left = window.screen.width / 2 - width / 2;\n const top = window.screen.height / 2 - height / 2;\n\n const popup = window.open(\n options.url,\n options.name,\n `menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${width},height=${height},top=${top},left=${left}`,\n );\n\n let targetOrigin = '';\n\n if (!popup || typeof popup.closed === 'undefined' || popup.closed) {\n const error = new Error('Failed to open auth popup.');\n error.name = 'PopupRejectedError';\n reject(error);\n return;\n }\n\n const messageListener = (event: MessageEvent) => {\n if (event.source !== popup) {\n return;\n }\n if (event.origin !== options.origin) {\n return;\n }\n const { data } = event;\n\n if (data.type === 'config_info') {\n targetOrigin = data.targetOrigin;\n return;\n }\n\n if (data.type !== 'authorization_response') {\n return;\n }\n const authResult = data as AuthResult;\n\n if ('error' in authResult) {\n const error = new Error(authResult.error.message);\n error.name = authResult.error.name;\n // TODO: proper error type\n // error.extra = authResult.error.extra;\n reject(error);\n } else {\n resolve(authResult.response);\n }\n done();\n };\n\n const intervalId = setInterval(() => {\n if (popup.closed) {\n const errMessage = `Login failed, ${\n targetOrigin && targetOrigin !== window.location.origin\n ? `Incorrect app origin, expected ${targetOrigin}`\n : 'popup was closed'\n }`;\n const error = new Error(errMessage);\n error.name = 'PopupClosedError';\n reject(error);\n done();\n }\n }, 100);\n\n function done() {\n window.removeEventListener('message', messageListener);\n clearInterval(intervalId);\n }\n\n window.addEventListener('message', messageListener);\n });\n}\n"],"names":[],"mappings":"AAoEO,SAAS,eAAe,OAA0C,EAAA;AACvE,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,EAAS,MAAW,KAAA;AACtC,IAAM,MAAA,KAAA,GAAQ,QAAQ,KAAS,IAAA,GAAA;AAC/B,IAAM,MAAA,MAAA,GAAS,QAAQ,MAAU,IAAA,GAAA;AACjC,IAAA,MAAM,IAAO,GAAA,MAAA,CAAO,MAAO,CAAA,KAAA,GAAQ,IAAI,KAAQ,GAAA,CAAA;AAC/C,IAAA,MAAM,GAAM,GAAA,MAAA,CAAO,MAAO,CAAA,MAAA,GAAS,IAAI,MAAS,GAAA,CAAA;AAEhD,IAAA,MAAM,QAAQ,MAAO,CAAA,IAAA;AAAA,MACnB,OAAQ,CAAA,GAAA;AAAA,MACR,OAAQ,CAAA,IAAA;AAAA,MACR,qEAAqE,KAAK,CAAA,QAAA,EAAW,MAAM,CAAQ,KAAA,EAAA,GAAG,SAAS,IAAI,CAAA;AAAA,KACrH;AAEA,IAAA,IAAI,YAAe,GAAA,EAAA;AAEnB,IAAA,I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