[
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n**/Properties/launchSettings.json\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk \n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# JetBrains Rider\n.idea/\n*.sln.iml\n\n# CodeRush\n.cr/\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output \nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder \n.mfractor/\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018 Jan Škoruba\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "![Logo](docs/Images/Skoruba-Logo-ReadMe.png)\n\n# React-oidc-client-js\n\n> OpenID Connect (OIDC) client with React and typescript\n\n- This is sample application that contains [oidc-client-js](https://github.com/IdentityModel/oidc-client-js) and `React` with `Typescript`.\n\n- The application is based on `create-react-app` - [Create React App](https://github.com/facebook/create-react-app)\n\n## ℹ️ Project status: Not maintained\n\nThis project is no longer maintained.\n\nIt demonstrates a legacy approach where access tokens are stored in\n`localStorage` / `sessionStorage`, which is **no longer considered secure**\nfor modern SPA applications.\n\n👉 **Current recommendation:**  \nUse the **Backend for Frontend (BFF) pattern**, where tokens are handled\nserver-side and never exposed to the browser.\n\n# Installation\n\n## Cloning app\n\n- `git clone https://github.com/skoruba/react-oidc-client-js.git`\n- `cd src/`\n\n## Install dependecies\n\n- Install dependecies - `yarn install`\n\n## Running app\n\n- `yarn start` - start the web server that is running on [http://localhost:4200](http://localhost:4200)\n\n- The application is connected to `OpenID Connect Provider` that is running on [https://demo.identityserver.io/](https://demo.identityserver.io/)\n- This STS has configured a SPA client to run on http://localhost:4200, therefore a sample application will be running on this port `4200`.\n\n## App preview\n\n![Logo](docs/Images/react-oidc-client-screenshot.png)\n"
  },
  {
    "path": "appveyor.yml",
    "content": "environment:\n  matrix:\n    - nodejs_version: '12'\n    - nodejs_version: '10'\n    - nodejs_version: '8'\ninstall:\n  - ps: Install-Product node $env:nodejs_version\n  - npm install --global npm@latest\n  - set PATH=%APPDATA%\\npm;%PATH%\n  - npm install -g create-react-app\n  - npm install\nmatrix:\n  fast_finish: true\nbuild: off\nshallow_clone: true\ntest_script:\n  - node --version\n  - npm --version\n  - cd src/\n  - npm install -g create-react-app\n  - npm install\n  - npm test\ncache:\n  - '%APPDATA%\\npm-cache'\n"
  },
  {
    "path": "docs/README.md",
    "content": "![Logo](Images/Skoruba-Logo-ReadMe.png)\n\n# react-oidc-client-js docs\n"
  },
  {
    "path": "src/.gitignore",
    "content": "# See https://help.github.com/ignore-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n\n# testing\n/coverage\n\n# production\n/build\n\n# misc\n.DS_Store\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n"
  },
  {
    "path": "src/package.json",
    "content": "{\n  \"name\": \"react-oidc-client-js\",\n  \"description\": \"OpenID Connect (OIDC) javascript client with React\",\n  \"version\": \"3.0.0\",\n  \"dependencies\": {\n    \"axios\": \"0.19.2\",\n    \"core-js\": \"3.6.5\",\n    \"bootstrap\": \"4.5.0\",\n    \"enzyme\": \"3.11.0\",\n    \"enzyme-adapter-react-16\": \"1.15.2\",\n    \"oidc-client\": \"1.10.1\",\n    \"ramda\": \"0.27.0\",\n    \"react\": \"16.13.1\",\n    \"react-dom\": \"16.13.1\",\n    \"react-json-tree\": \"0.11.2\",\n    \"react-scripts\": \"3.4.1\",\n    \"react-test-renderer\": \"16.13.1\",\n    \"react-app-polyfill\": \"1.0.6\",\n    \"react-toastify\": \"6.0.8\"\n  },\n  \"scripts\": {\n    \"start\": \"set PORT=4200 && react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"test\": \"react-scripts test --env=jsdom\",\n    \"eject\": \"react-scripts eject\"\n  },\n  \"devDependencies\": {\n    \"@types/axios\": \"0.14.0\",\n    \"@types/enzyme\": \"3.10.5\",\n    \"@types/enzyme-adapter-react-16\": \"1.0.6\",\n    \"@types/jest\": \"26.0.4\",\n    \"@types/node\": \"14.0.23\",\n    \"@types/ramda\": \"0.27.11\",\n    \"@types/react\": \"16.9.43\",\n    \"@types/react-dom\": \"16.9.8\",\n    \"@types/react-json-tree\": \"0.6.11\",\n    \"@types/react-test-renderer\": \"16.9.2\",\n    \"@types/toastr\": \"2.1.38\",\n    \"typescript\": \"3.9.6\"\n  },\n  \"browserslist\": {\n    \"production\": [\n      \">0.2%\",\n      \"not dead\",\n      \"not op_mini all\"\n    ],\n    \"development\": [\n      \"last 1 chrome version\",\n      \"last 1 firefox version\",\n      \"last 1 safari version\",\n      \"ie 11\"\n    ]\n  }\n}\n"
  },
  {
    "path": "src/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n    <meta name=\"theme-color\" content=\"#000000\">\n    <!--\n      manifest.json provides metadata used when your web app is added to the\n      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/\n    -->\n    <link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\">\n    <link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\">\n    <!--\n      Notice the use of %PUBLIC_URL% in the tags above.\n      It will be replaced with the URL of the `public` folder during the build.\n      Only files inside the `public` folder can be referenced from the HTML.\n\n      Unlike \"/favicon.ico\" or \"favicon.ico\", \"%PUBLIC_URL%/favicon.ico\" will\n      work correctly both with client-side routing and a non-root public URL.\n      Learn how to configure a non-root public URL by running `npm run build`.\n    -->\n    <title>React App</title>\n  </head>\n  <body>\n    <noscript>\n      You need to enable JavaScript to run this app.\n    </noscript>\n    <div id=\"root\"></div>\n    <!--\n      This HTML file is a template.\n      If you open it directly in the browser, you will see an empty page.\n\n      You can add webfonts, meta tags, or analytics to this file.\n      The build step will place the bundled scripts into the <body> tag.\n\n      To begin the development, run `npm start` or `yarn start`.\n      To create a production bundle, use `npm run build` or `yarn build`.\n    -->\n  </body>\n</html>\n"
  },
  {
    "path": "src/public/manifest.json",
    "content": "{\n  \"short_name\": \"React App\",\n  \"name\": \"Create React App Sample\",\n  \"icons\": [\n    {\n      \"src\": \"favicon.ico\",\n      \"sizes\": \"64x64 32x32 24x24 16x16\",\n      \"type\": \"image/x-icon\"\n    }\n  ],\n  \"start_url\": \"./index.html\",\n  \"display\": \"standalone\",\n  \"theme_color\": \"#000000\",\n  \"background_color\": \"#ffffff\"\n}\n"
  },
  {
    "path": "src/public/signin-callback.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <title>Authentification callback processing..</title>\n</head>\n\n<body>\n    <noscript>\n        You need to enable JavaScript to run this app.\n    </noscript>\n\n    <h1>Authentification callback processing...</h1>\n\n    <script src=\"oidc-client.min.js\"></script>\n    <script>\n        new Oidc.UserManager({ response_mode: \"query\" }).signinRedirectCallback().then(function () {\n            window.location = \"index.html\";\n        }).catch(function (e) {\n            console.error(e);\n        });\n    </script>\n\n</body>\n\n</html>"
  },
  {
    "path": "src/public/silent-renew.html",
    "content": "<script src=\"oidc-client.min.js\"></script>\n<script>\n    var mgr = new Oidc.UserManager();\n    mgr.signinSilentCallback().catch(function (error) {\n        console.error(error);\n    });\n</script>"
  },
  {
    "path": "src/src/components/AppContent.tsx",
    "content": "import * as React from 'react';\n\nimport { ToastContainer, toast } from 'react-toastify';\nimport { ApiService } from '../services/ApiService';\nimport { AuthService } from '../services/AuthService';\n\nimport AuthContent from './AuthContent';\nimport Buttons from './Buttons';\n\nexport default class AppContent extends React.Component<any, any> {\n  public authService: AuthService;\n  public apiService: ApiService;\n  private shouldCancel: boolean;\n\n  constructor(props: any) {\n    super(props);\n\n    this.authService = new AuthService();\n    this.apiService = new ApiService();\n    this.state = { user: {}, api: {} };\n    this.shouldCancel = false;\n  }\n\n  public componentDidMount() {\n    this.getUser();\n  }\n\n  public login = () => {\n    this.authService.login();\n  };\n\n  public callApi = () => {\n    this.apiService\n      .callApi()\n      .then(data => {\n        this.setState({ api: data.data });\n        toast.success('Api return successfully data, check in section - Api response');\n      })\n      .catch(error => {\n        toast.error(error);\n      });\n  };\n\n  public componentWillUnmount() {\n    this.shouldCancel = true;\n  }\n\n  public renewToken = () => {\n    this.authService\n      .renewToken()\n      .then(user => {\n        toast.success('Token has been sucessfully renewed. :-)');\n        this.getUser();\n      })\n      .catch(error => {\n        toast.error(error);\n      });\n  };\n\n  public logout = () => {\n    this.authService.logout();\n  };\n\n  public getUser = () => {\n    this.authService.getUser().then(user => {\n      if (user) {\n        toast.success('User has been successfully loaded from store.');\n      } else {\n        toast.info('You are not logged in.');\n      }\n\n      if (!this.shouldCancel) {\n        this.setState({ user });\n      }\n    });\n  };\n\n  public render() {\n    return (\n      <>\n        <ToastContainer />\n\n        <Buttons\n          login={this.login}\n          logout={this.logout}\n          renewToken={this.renewToken}\n          getUser={this.getUser}\n          callApi={this.callApi}\n        />\n\n        <AuthContent api={this.state.api} user={this.state.user} />\n      </>\n    );\n  }\n}\n"
  },
  {
    "path": "src/src/components/AuthContent.tsx",
    "content": "import * as React from 'react';\nimport JsonTreeViewer from './JsonTreeViewer';\n\nexport interface IAuthContentProps {\n  api: any;\n  user: any;\n}\n\nexport default class AuthContent extends React.Component<IAuthContentProps, any> {\n  public shouldExpandNode = (keyPath: Array<string | number>, data: [any] | {}, level: number) => {\n    return true;\n  };\n\n  public render() {\n    return (\n      <div className=\"row\">\n        <div className=\"col-md-6\">\n          <JsonTreeViewer data={this.props.user} title=\"User Profile\" shouldExpandNode={this.shouldExpandNode} />\n        </div>\n        <div className=\"col-md-6\">\n          <JsonTreeViewer data={this.props.api} title=\"Api Response\" shouldExpandNode={this.shouldExpandNode} />\n        </div>\n      </div>\n    );\n  }\n}\n"
  },
  {
    "path": "src/src/components/Buttons.test.tsx",
    "content": "import { shallow } from 'enzyme';\nimport * as React from 'react';\nimport * as renderer from 'react-test-renderer';\n\nimport Buttons from './Buttons';\n\ndescribe(Buttons, () => {\n  const mockLogin = jest.fn();\n  const mockLogout = jest.fn();\n  const mockRenewToken = jest.fn();\n  const mockCallApi = jest.fn();\n  const mockGetUser = jest.fn();\n\n  const component = shallow(\n    <Buttons\n      login={mockLogin}\n      logout={mockLogout}\n      renewToken={mockRenewToken}\n      callApi={mockCallApi}\n      getUser={mockGetUser}\n    />\n  );\n\n  it('renders and matches our snapshot', () => {\n    const buttonComponent = renderer.create(\n      <Buttons\n        login={mockLogin}\n        logout={mockLogout}\n        renewToken={mockRenewToken}\n        callApi={mockCallApi}\n        getUser={mockGetUser}\n      />\n    );\n    const tree = buttonComponent.toJSON();\n    expect(tree).toMatchSnapshot();\n  });\n\n  it('contains the image and h1', () => {\n    expect(component.find('button')).toHaveLength(5);\n  });\n\n  it('try to click on login button', () => {\n    component.find('button.btn-login').simulate('click');\n    expect(mockLogin).toBeCalled();\n  });\n\n  it('try to click on logout button', () => {\n    component.find('button.btn-logout').simulate('click');\n    expect(mockLogout).toBeCalled();\n  });\n});\n"
  },
  {
    "path": "src/src/components/Buttons.tsx",
    "content": "import * as React from 'react';\n\ninterface IButtonsProps {\n  login: () => void;\n  getUser: () => void;\n  callApi: () => void;\n  renewToken: () => void;\n  logout: () => void;\n}\n\nconst Buttons: React.SFC<IButtonsProps> = props => {\n  return (\n    <div className=\"row\">\n      <div className=\"col-md-12 text-center\" style={{ marginTop: '30px' }}>\n        <button className=\"btn btn-primary btn-login\" style={{ margin: '10px' }} onClick={props.login}>\n          Login\n        </button>\n        <button className=\"btn btn-secondary btn-getuser\" style={{ margin: '10px' }} onClick={props.getUser}>\n          Get User info\n        </button>\n        <button className=\"btn btn-warning btn-getapi\" style={{ margin: '10px' }} onClick={props.callApi}>\n          Call API\n        </button>\n        <button className=\"btn btn-success btn-renewtoken\" style={{ margin: '10px' }} onClick={props.renewToken}>\n          Renew Token\n        </button>\n        <button className=\"btn btn-dark btn-logout\" style={{ margin: '10px' }} onClick={props.logout}>\n          Logout\n        </button>\n      </div>\n    </div>\n  );\n};\n\nexport default Buttons;\n"
  },
  {
    "path": "src/src/components/Header.test.tsx",
    "content": "import { shallow } from 'enzyme';\nimport * as React from 'react';\nimport * as renderer from 'react-test-renderer';\n\nimport logo from '../logo.svg';\nimport Header from './Header';\n\ndescribe(Header, () => {\n  const pageTitle = 'React app with oidc-client-js';\n\n  const component = shallow(<Header pageTitle={pageTitle} logoSrc={logo} />);\n\n  it('renders and matches our snapshot', () => {\n    const headerComponent = renderer.create(<Header pageTitle={pageTitle} logoSrc={logo} />);\n    const tree = headerComponent.toJSON();\n    expect(tree).toMatchSnapshot();\n  });\n\n  it('contains the image and h1', () => {\n    expect(component.find('img')).toHaveLength(1);\n    expect(component.find('h1')).toHaveLength(1);\n  });\n\n  it('h1 contains correct title', () => {\n    expect(component.find('h1').text()).toEqual(pageTitle);\n    expect(component.contains(pageTitle)).toEqual(true);\n  });\n});\n"
  },
  {
    "path": "src/src/components/Header.tsx",
    "content": "import * as React from 'react';\n\nexport interface IHeaderProps {\n  pageTitle: string;\n  logoSrc: any;\n}\n\nexport default function Header(props: IHeaderProps) {\n  return (\n    <header className=\"App-header\">\n      <img src={props.logoSrc} className=\"App-logo\" alt=\"logo\" />\n      <h1 className=\"App-title\">{props.pageTitle}</h1>\n    </header>\n  );\n}\n"
  },
  {
    "path": "src/src/components/JsonTreeViewer.tsx",
    "content": "import * as R from 'ramda';\nimport * as React from 'react';\nimport JSONTree from 'react-json-tree';\n\nexport interface IJsonTreeViewer {\n  data: any;\n  title: string;\n  shouldExpandNode?: (keyPath: Array<string | number>, data: [any] | {}, level: number) => boolean;\n}\n\nexport default class JsonTreeViewer extends React.Component<IJsonTreeViewer, any> {\n  public renderJsonData() {\n    return R.not(R.isEmpty(this.props.data)) && R.not(R.isNil(this.props.data)) ? (\n      <>\n        <h1>{this.props.title}</h1>\n        <JSONTree data={this.props.data} theme=\"bright\" shouldExpandNode={this.props.shouldExpandNode} />\n      </>\n    ) : null;\n  }\n\n  public render() {\n    return this.renderJsonData();\n  }\n}\n"
  },
  {
    "path": "src/src/components/__snapshots__/Buttons.test.tsx.snap",
    "content": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`Buttons renders and matches our snapshot 1`] = `\n<div\n  className=\"row\"\n>\n  <div\n    className=\"col-md-12 text-center\"\n    style={\n      Object {\n        \"marginTop\": \"30px\",\n      }\n    }\n  >\n    <button\n      className=\"btn btn-primary btn-login\"\n      onClick={[MockFunction]}\n      style={\n        Object {\n          \"margin\": \"10px\",\n        }\n      }\n    >\n      Login\n    </button>\n    <button\n      className=\"btn btn-secondary btn-getuser\"\n      onClick={[MockFunction]}\n      style={\n        Object {\n          \"margin\": \"10px\",\n        }\n      }\n    >\n      Get User info\n    </button>\n    <button\n      className=\"btn btn-warning btn-getapi\"\n      onClick={[MockFunction]}\n      style={\n        Object {\n          \"margin\": \"10px\",\n        }\n      }\n    >\n      Call API\n    </button>\n    <button\n      className=\"btn btn-success btn-renewtoken\"\n      onClick={[MockFunction]}\n      style={\n        Object {\n          \"margin\": \"10px\",\n        }\n      }\n    >\n      Renew Token\n    </button>\n    <button\n      className=\"btn btn-dark btn-logout\"\n      onClick={[MockFunction]}\n      style={\n        Object {\n          \"margin\": \"10px\",\n        }\n      }\n    >\n      Logout\n    </button>\n  </div>\n</div>\n`;\n"
  },
  {
    "path": "src/src/components/__snapshots__/Header.test.tsx.snap",
    "content": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`Header renders and matches our snapshot 1`] = `\n<header\n  className=\"App-header\"\n>\n  <img\n    alt=\"logo\"\n    className=\"App-logo\"\n    src=\"logo.svg\"\n  />\n  <h1\n    className=\"App-title\"\n  >\n    React app with oidc-client-js\n  </h1>\n</header>\n`;\n"
  },
  {
    "path": "src/src/containers/App.css",
    "content": ".App-logo {\n  animation: App-logo-spin infinite 20s linear;\n  height: 80px;\n}\n\n.App-header {\n  background-color: #222;\n  height: 150px;\n  padding: 20px;\n  color: white;\n  text-align: center;\n}\n\n.App-title {\n  font-size: 1.5em;\n}\n\n.App-intro {\n  font-size: large;\n}\n\n@keyframes App-logo-spin {\n  from {\n    transform: rotate(0deg);\n  }\n  to {\n    transform: rotate(360deg);\n  }\n}\n\n#toast-container > div {\n  opacity: 1;\n}\n"
  },
  {
    "path": "src/src/containers/App.test.tsx",
    "content": "import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport App from './App';\n\nconst storageMock = {\n  clear: jest.fn(),\n  getItem: jest.fn(),\n  setItem: jest.fn()\n};\n\n(global as any).sessionStorage = storageMock;\n(global as any).localStorage = storageMock;\n\nit('renders without crashing', () => {\n  const div = document.createElement('div');\n  ReactDOM.render(<App />, div);\n  ReactDOM.unmountComponentAtNode(div);\n});\n"
  },
  {
    "path": "src/src/containers/App.tsx",
    "content": "import * as React from 'react';\nimport AppContent from '../components/AppContent';\nimport Header from '../components/Header';\nimport logo from '../logo.svg';\nimport './App.css';\n\nclass App extends React.Component {\n  public render() {\n    return (\n      <div className=\"App\">\n        <Header pageTitle=\"Welcome to React and oidc-client-js\" logoSrc={logo} />\n        <div className=\"container-fluid\">\n          <div className=\"row\">\n            <div className=\"col\">\n              <AppContent />\n            </div>\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n\nexport default App;\n"
  },
  {
    "path": "src/src/helpers/Constants.ts",
    "content": "export class Constants {\n  public static stsAuthority = 'https://demo.identityserver.io/';\n  public static clientId = 'interactive.public';\n  public static clientRoot = 'http://localhost:4200/';\n  public static clientScope = 'openid profile email api';\n\n  public static apiRoot = 'https://demo.identityserver.io/api/';\n}\n"
  },
  {
    "path": "src/src/index.css",
    "content": "body {\n  margin: 0;\n  padding: 0;\n  font-family: sans-serif;\n}\n"
  },
  {
    "path": "src/src/index.tsx",
    "content": "import 'bootstrap/dist/css/bootstrap.min.css';\nimport 'react-toastify/dist/ReactToastify.css';\n\nimport 'react-app-polyfill/ie11';\nimport 'core-js';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport App from './containers/App';\nimport './index.css';\nimport registerServiceWorker from './registerServiceWorker';\n\nReactDOM.render(<App />, document.getElementById('root') as HTMLElement);\nregisterServiceWorker();\n"
  },
  {
    "path": "src/src/react-app-env.d.ts",
    "content": "/// <reference types=\"react-scripts\" />\n"
  },
  {
    "path": "src/src/registerServiceWorker.ts",
    "content": "// tslint:disable:no-console\n// In production, we register a service worker to serve assets from local cache.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on the 'N+1' visit to a page, since previously\n// cached resources are updated in the background.\n\n// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.\n// This link also includes instructions on opting out of this behavior.\n\nconst isLocalhost = Boolean(\n  window.location.hostname === 'localhost' ||\n    // [::1] is the IPv6 localhost address.\n    window.location.hostname === '[::1]' ||\n    // 127.0.0.1/8 is considered localhost for IPv4.\n    window.location.hostname.match(\n      /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n    )\n);\n\nexport default function register() {\n  if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n    // The URL constructor is available in all browsers that support SW.\n    const publicUrl = new URL(\n      process.env.PUBLIC_URL!,\n      window.location.toString()\n    );\n    if (publicUrl.origin !== window.location.origin) {\n      // Our service worker won't work if PUBLIC_URL is on a different origin\n      // from what our page is served on. This might happen if a CDN is used to\n      // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374\n      return;\n    }\n\n    window.addEventListener('load', () => {\n      const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n      if (isLocalhost) {\n        // This is running on localhost. Lets check if a service worker still exists or not.\n        checkValidServiceWorker(swUrl);\n\n        // Add some additional logging to localhost, pointing developers to the\n        // service worker/PWA documentation.\n        navigator.serviceWorker.ready.then(() => {\n          console.log(\n            'This web app is being served cache-first by a service ' +\n              'worker. To learn more, visit https://goo.gl/SC7cgQ'\n          );\n        });\n      } else {\n        // Is not local host. Just register service worker\n        registerValidSW(swUrl);\n      }\n    });\n  }\n}\n\nfunction registerValidSW(swUrl: string) {\n  navigator.serviceWorker\n    .register(swUrl)\n    .then(registration => {\n      registration.onupdatefound = () => {\n        const installingWorker = registration.installing;\n        if (installingWorker) {\n          installingWorker.onstatechange = () => {\n            if (installingWorker.state === 'installed') {\n              if (navigator.serviceWorker.controller) {\n                // At this point, the old content will have been purged and\n                // the fresh content will have been added to the cache.\n                // It's the perfect time to display a 'New content is\n                // available; please refresh.' message in your web app.\n                console.log('New content is available; please refresh.');\n              } else {\n                // At this point, everything has been precached.\n                // It's the perfect time to display a\n                // 'Content is cached for offline use.' message.\n                console.log('Content is cached for offline use.');\n              }\n            }\n          };\n        }\n      };\n    })\n    .catch(error => {\n      console.error('Error during service worker registration:', error);\n    });\n}\n\nfunction checkValidServiceWorker(swUrl: string) {\n  // Check if the service worker can be found. If it can't reload the page.\n  fetch(swUrl)\n    .then(response => {\n      // Ensure service worker exists, and that we really are getting a JS file.\n      if (\n        response.status === 404 ||\n        response.headers.get('content-type')!.indexOf('javascript') === -1\n      ) {\n        // No service worker found. Probably a different app. Reload the page.\n        navigator.serviceWorker.ready.then(registration => {\n          registration.unregister().then(() => {\n            window.location.reload();\n          });\n        });\n      } else {\n        // Service worker found. Proceed as normal.\n        registerValidSW(swUrl);\n      }\n    })\n    .catch(() => {\n      console.log(\n        'No internet connection found. App is running in offline mode.'\n      );\n    });\n}\n\nexport function unregister() {\n  if ('serviceWorker' in navigator) {\n    navigator.serviceWorker.ready.then(registration => {\n      registration.unregister();\n    });\n  }\n}\n"
  },
  {
    "path": "src/src/services/ApiService.ts",
    "content": "import axios from 'axios';\nimport { Constants } from '../helpers/Constants';\nimport { AuthService } from './AuthService';\n\nexport class ApiService {\n  private authService: AuthService;\n\n  constructor() {\n    this.authService = new AuthService();\n  }\n\n  public callApi(): Promise<any> {\n    return this.authService.getUser().then(user => {\n      if (user && user.access_token) {\n        return this._callApi(user.access_token).catch(error => {\n          if (error.response.status === 401) {\n            return this.authService.renewToken().then(renewedUser => {\n              return this._callApi(renewedUser.access_token);\n            });\n          }\n          throw error;\n        });\n      } else if (user) {\n        return this.authService.renewToken().then(renewedUser => {\n          return this._callApi(renewedUser.access_token);\n        });\n      } else {\n        throw new Error('user is not logged in');\n      }\n    });\n  }\n\n  private _callApi(token: string) {\n    const headers = {\n      Accept: 'application/json',\n      Authorization: 'Bearer ' + token\n    };\n\n    return axios.get(Constants.apiRoot + 'test', { headers });\n  }\n}\n"
  },
  {
    "path": "src/src/services/AuthService.ts",
    "content": "import { Log, User, UserManager } from 'oidc-client';\n\nimport { Constants } from '../helpers/Constants';\n\nexport class AuthService {\n  public userManager: UserManager;\n\n  constructor() {\n    const settings = {\n      authority: Constants.stsAuthority,\n      client_id: Constants.clientId,\n      redirect_uri: `${Constants.clientRoot}signin-callback.html`,\n      silent_redirect_uri: `${Constants.clientRoot}silent-renew.html`,\n      // tslint:disable-next-line:object-literal-sort-keys\n      post_logout_redirect_uri: `${Constants.clientRoot}`,\n      response_type: 'code',\n      scope: Constants.clientScope\n    };\n    this.userManager = new UserManager(settings);\n\n    Log.logger = console;\n    Log.level = Log.INFO;\n  }\n\n  public getUser(): Promise<User | null> {\n    return this.userManager.getUser();\n  }\n\n  public login(): Promise<void> {\n    return this.userManager.signinRedirect();\n  }\n\n  public renewToken(): Promise<User> {\n    return this.userManager.signinSilent();\n  }\n\n  public logout(): Promise<void> {\n    return this.userManager.signoutRedirect();\n  }\n}\n"
  },
  {
    "path": "src/src/setupTests.ts",
    "content": "import Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\n\nEnzyme.configure({ adapter: new Adapter() });\n"
  },
  {
    "path": "src/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\",\n    \"lib\": [\n      \"dom\",\n      \"dom.iterable\",\n      \"esnext\"\n    ],\n    \"allowJs\": true,\n    \"skipLibCheck\": true,\n    \"esModuleInterop\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"noEmit\": true,\n    \"jsx\": \"preserve\"\n  },\n  \"include\": [\n    \"src\"\n  ]\n}\n"
  },
  {
    "path": "src/tslint.json",
    "content": "{\n  \"extends\": [\"tslint:recommended\", \"tslint-react\", \"tslint-config-prettier\"],\n  \"linterOptions\": {\n    \"exclude\": [\n      \"config/**/*.js\",\n      \"node_modules/**/*.ts\"\n    ]\n  }\n}\n"
  }
]