{"_id":"@asemirsk/oidc","_rev":"18-f767c68321fdc9d9171aee8e19363bf0","time":{"created":"2022-04-04T11:44:51.882Z","1.0.0-alpha-3.9.0":"2022-03-15T12:56:34.846Z","modified":"2022-05-25T09:17:48.412Z","1.0.0-alpha-3.1.0":"2022-03-15T13:54:13.143Z","1.0.0-beta.2":"2022-03-15T14:25:08.382Z","1.0.0-beta.3":"2022-03-15T14:37:37.784Z","1.0.0":"2022-03-15T14:40:35.406Z","1.0.1-beta.0":"2022-03-15T14:44:43.175Z","1.0.0-alpha-5.3.0":"2022-03-15T16:03:36.252Z","1.0.0-alpha.0":"2022-04-04T11:44:52.055Z","1.0.0-beta.5":"2022-04-04T13:57:35.217Z","1.0.0-beta.6":"2022-04-08T20:00:48.587Z","1.0.1-beta.6":"2022-04-08T20:05:00.064Z","1.0.1":"2022-04-08T20:09:41.465Z","1.0.2-beta.0":"2022-04-08T20:19:07.512Z","1.0.2":"2022-04-08T20:22:19.563Z","1.1.0":"2022-04-19T15:07:07.816Z","1.0.0-canary-24-22.0":"2022-05-25T08:46:19.159Z","1.0.0-canary-24-23.0":"2022-05-25T09:07:52.812Z","1.0.0-canary-24-24.0":"2022-05-25T09:17:48.273Z"},"name":"@asemirsk/oidc","dist-tags":{"alpha":"1.0.0-alpha.0","latest":"1.1.0","next":"1.0.2-beta.0","canary-24":"1.0.0-canary-24-24.0"},"versions":{"1.0.0-alpha.0":{"name":"@asemirsk/oidc","version":"1.0.0-alpha.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"28ce15a6b1c49e6f984d59ff1db29bac050fe78d","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-alpha.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-iID8eM5O9/OykHPZbLh/JUte5VIfGCjI4sD7tVN5t9HUD5sI64nRTJoTdQs9hobROdNH990jKrntJm3aBOufGw==","shasum":"7522aa03e8f9b80ea4e00edd226ba2d746e33ea8","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-alpha.0.tgz","fileCount":4,"unpackedSize":26056,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFVOXGJQGAltW7WCIGCxKoecjh64N3tzBIFE4AOG8DD+AiBOfUHmG+jCHacrGDYppKHCNOYk58KNIFRv9PMc9IGlBg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiSto0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqo2w//algxDkOc3AiatAzfftMp3F3sy/fAuBwKCSIsuHHByPhndS17\r\nIiS5nmkpK4usBd0rzLfzz8KnPSBZfoVRj6NfyJzryHBni7Oc9PHjk+1tlo4Z\r\nJN4xZCtkHbNzGxhGvhIeBlsqyBn3pzNuQMr0tLviHSxhWcyrsezwMzlukJ0K\r\nHdLve88maPcrE3EzUXWY3ZO6gq3slAnNKbwQTiJ9P0nEUzPS7Qnqf/y2KrBC\r\n/LpVxECkscm+i/1j5z7+yZ3D4Hpbb6QYWiJK+GOhvKZStx82rRhMKpM+5QFN\r\n1Wp6u8WUDSdZ4LA3QIfJkqDrEpip3Z+C6EO2CAwB8qjehEppQs4DiZdh7hBx\r\nMletJpcurUI9SjBFttLEip1DdC+JxYDuVqdcHe+x7FrJzsKixmg6btLrosqF\r\nTXhLsxIWGu0NwAXVfamwgLk5bdsgvWdTBLxuUwuFXcZLHOZfRSRa6zNoapfk\r\nrGYem4/7lEk0B2E0zFJ0FzO1Ywd9MFaJkAolBCXABJnfeYwJMLr1MubjYg2L\r\nYd0vQF0ueu30ZLMty59PVwecW/LuyrY2ki3vnX5EkQ+fvEbTdRFK9Tvxm12N\r\nWHdzTfouQ57+AhBOmkXLJBUz2KHBxvllkR+iu8kp7t3gbFWyrJaGbhIaGHM2\r\n0mc+PyQYdix10WxtoAJN+pk8rlTqe7jVZq4=\r\n=R/RQ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-alpha.0_1649072691934_0.44800981762055336"},"_hasShrinkwrap":false},"1.0.0-beta.5":{"name":"@asemirsk/oidc","version":"1.0.0-beta.5","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"e6beb3c3e2c8fcff324e0e741ec5746fc55ec312","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@bodiless/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@bodiless/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@bodiless/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@bodiless/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@bodiless/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { AuthCallback } from '@bodiless/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-beta.5","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-8OTNxHn1AjPgfTOTaO/rNItqee+XEnLJfte6iPa1kZtJANxBP85Z7jBbcVYuE1JVTpiZdmb8AymWXRjnhBsQbg==","shasum":"63287b2c58781a0433e6c31df1f86f205ee57507","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-beta.5.tgz","fileCount":4,"unpackedSize":26047,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5CIQ4wDlAUjHkSeAbfdZNhuFw1SCfQxHdwddhvel6ZAIhAIY9C9p2XuwCcR6us6GRMWKDoMAonMhMq9IuLZRrSe98"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiSvlPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqhPw//fw1/GFeIwGoAWygS5RSQ3/pOfQmE8ZHVL7w9OwJyKoMRQXJV\r\nTP5q1WZPGA1ZiO0Ci/oRF6LHDRVebkb66wXkwiSUqCGl3RLgmRTKTzbKxf0F\r\nImHXLQ5XnzQt+uF5WotjHOyttpH25fIvNTy+7SLAdyCbWmuL0hZsAi5a2u3W\r\nwd16kFOO95Jqe0kUGhD5zko0bjvZl5OwW5Fy8ES2btGtRtLT3RhoW7yO2coA\r\nSogd/Mbok0S0rsVZioq1FeXk/Ou2ldsj1/M6kozm3g+KC39IS/1vd8gvQC9D\r\nTJ+vDKhuvQC7oRRA+yNrAwAOIuncedEhRU2B4KlLIxdtASKNrSylm6BiLOD/\r\nmdBrn46DFmhRaODEbTWq4kY1lvt42Xl2GMu9TUcZ4/KokHV3FKK70IHYOXTb\r\nExrGMEqoty91iCy6RDRWEGvtn1Q4KKy8FkAWTy1zy6qUYVSRF40GApGUjDWf\r\nvgFoPfcge2u9unsvAt7TvdBrQT1jtJ/Q8qxm/Asg9Zbpd7bIEKAFmd2jG97t\r\nwV4qo0cswiD+5ljhSOQFIWekGEEhzB6KNv+45O+lqGIHNZ5R4jr6pvLM4ojQ\r\n8xWSMsDESVUSRXImhrWWDLyiJGejDRuWX+VrUrgsUJr6nI4Qi1+0y9tHNyn0\r\nGIF8BheOt+49pycUy/jJqWlIv75cKcHJ3xs=\r\n=lrZe\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-beta.5_1649080655032_0.2760041171301342"},"_hasShrinkwrap":false},"1.0.0-beta.6":{"name":"@asemirsk/oidc","version":"1.0.0-beta.6","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.0.0-beta.6","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"cbd97725152f2362bb86e6d4bba02043e3c4570e","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@bodiless/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@bodiless/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@bodiless/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@bodiless/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@bodiless/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { AuthCallback } from '@bodiless/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-beta.6","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-IX/iEivaunXo1Yv/Wh2B0BnB9uK3yY/NfCAN5auUj8rG7jarfaRHElxKnb4kO1drJdOYMxKDYfldSKfTIKD2ZA==","shasum":"6cd8c9f1884c73e0fbf8a27eac837d957485fda9","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-beta.6.tgz","fileCount":4,"unpackedSize":26085,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCt9KEH+WlSTrtPaS5euOb7kcxo5CF10DKNJ38b3BHpawIgGqwEPk/aDrSZtv0RHJRaG1DA+pX9vHBsz91pR4wYvKM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUJRwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr08Q//VUyjbSK4sJMAFmLwO4RmO3/aJ4KT76iu/AK0WNSFKIzR7McC\r\nDYgB7T3TpQKaJt9weRFlnDRfwWBn9iD+JUoUa1RfGJjZQ8SFmPK9Vb1ajAYa\r\nUWx8KEHEe81nVDo9oTqOPj3FRbqP1xUE6qx5fWu9/TbVkbeRKKRoqwd3t5yw\r\npaHQIPY7ZqpTSXRfz8ZYXgSpzKU5t50tVpNlWq6/IEobXtFuA72PB6Vra82R\r\n4DXESN2DfqfEoySQegmpzBvjNHSpw1WHVrTCGyvazmXsVgX2yQ8FUq6myRXC\r\n9TYRqZqdD4mvEG2kxf6LexUTU2qVcc+GBtnBlpoks5cr81pHhlHWvg5rkDuj\r\nLpXvlTBPydVGBo4OESMPD4e24MEfPRdq3raEaoS92xFr1xswWeAfursJhkng\r\nreo12kGp1JOqO8Pl2tzZGjpgaxmu3X6uXD91PXEsMR8BQmrTSw3rDFqBxn25\r\nHVSj4KMeK8W32HHyyiAiBxSruXg8BkuW4AIvv9wz6JUrdnCfcYPql941XYH4\r\ndtrPi6BotJXT9pO8wUDuIL8LfHoizPIsLmbxmvWulMISiSyYMzNIMMx/HRkC\r\nIZJqGHaBKgzNPgEoEywaWUzW+QiNtZRixSDwgqtl5oltmPMgju5n0dh4JJyW\r\n742jhxRI7TGmiHxfflPyk9YJqLkRZAn8HrE=\r\n=CrJv\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-beta.6_1649448048423_0.8147039130689162"},"_hasShrinkwrap":false},"1.0.1-beta.6":{"name":"@asemirsk/oidc","version":"1.0.1-beta.6","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.0.1-beta.6","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"dfbcb3dab592c76bd48c138c275c1e27fbd9ca1d","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@bodiless/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@bodiless/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@bodiless/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@bodiless/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@bodiless/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { AuthCallback } from '@bodiless/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.1-beta.6","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-b1PHa17I0UGN4ov6oW/JMXMKl0nTDe+mv/QrnEPoXIOF2Jwu6Ws/qb0UTN1RVaNJN2S9iCL4aOr+yo8kvfFz1A==","shasum":"98172447b34411f6a458322b0577a3983599c722","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.1-beta.6.tgz","fileCount":4,"unpackedSize":26085,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAP4/ccE2BwNwlnJN48gm2sUhefVYYzZcqWWjP7cauQfAiBJaaHgn9RLQmZyZphzNfN+nz73tiitxn12mEf3cd0Z5g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUJVsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmplAA//Zr2/qdZbxPV/4V80Qyt35jExaRn/zpNnZ6wkynHZcV6M1JXK\r\ndCWOkmlWdsz88BcUNgF58kRwstbnFFMUfjHCqwzsjLWt7xHZncH9cKMlAhNb\r\nqRSFNx6bS8edVGvSw4Pc4UKRA6CeWd+N4zSlPien2ywxwUbE7mSPzCZqAFY9\r\nyOenUQ3kpSUESSyYJPKfT2W+e1lxvN6+7N/CdSyEU2uEabuBn1L8MMPip6pJ\r\nrIlhzQZdSUHiFUnRj59cQp64eQbE/JIPrco1D4EVNZND6n4hKyekmia1jF3+\r\nvD2JFrnzoFitLpncyQHJO89MGYegJfoCtIMkINA1nj3VSJr1ISJDCvFDhTET\r\nFWKavK0GT/A0d2wc1ispeQHJ6xxcaFM6ws25gf3lbjdpyxx6WXpQTiNixSoN\r\n7ZF2cqc/t5K9t6wjJHYF6+Iu1L06fi9T92plggDb21Kz8P24QPgPRWDf9jbs\r\nuZaZNkbhLnNJuTv+WK29wxhcdC0WDtyWMfkhMYNAEB1bhl+Jc6g2reTua8kc\r\nLzhF1qQm9TsGpNBfQZ3IHcSz2RZh4xxdtJb5Wpp7oE7lYjaGbN6oomlaqT0b\r\n9SbacruKfuhv4PDI/eGojI+9GWm2Ls8fCKWxiBFThTZDOPvSDsTax4F6bg8t\r\nW9Z5bzj3FpYPNHHnFh5mF5rpqc5CQyoscJ4=\r\n=jnRm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.1-beta.6_1649448299844_0.9263890015993792"},"_hasShrinkwrap":false},"1.0.1":{"name":"@asemirsk/oidc","version":"1.0.1","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.0.1","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"b943f745d8dc223a872b770f79f3e0db78f43486","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.1","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-MWW+iqs42VmvKk+yHAuc3/TWB/RXUgPOlhO3EsBpADS8IvaIv/rIC4RwEYLcSB2tGfnapgWGHq/pZ75wtx/rJg==","shasum":"e9ae6424818790fdfd19d62739a450c13141640e","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.1.tgz","fileCount":4,"unpackedSize":26071,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCHS4bButjseHt9p/b9pBK2lOS+i3KoCKab/W7zjnZJbAIgfRajFASYYmO9cDwqQUDhYBVbNBIe34haGUsD4qFB8/I="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUJaFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrGwg//SHlOGRzHDXq1z6Co1006FWSMcO+f1Z4BCtk/aJOuEEbdiRvc\r\n/WRjiu/Keg76qC7dhSfTpDthJ3xSEepOMOeLW4Y1N0xvqNhcre6z85cNL8sm\r\nWaaaMsUe3a8VMEXxw8u11KwaWfq24qfWsf8IDieFV+L4jHGEhvV/VGVVByJZ\r\nFuJS98yde1l7j3Qan2w2gi+Az5WL6kPaNJvYA/q7bN8m0KZVeTPWreEjoZ1n\r\noL3E7dcu21MQPW/SrlRNVnMqB0SYBShV3KwHpHn3Vb7PtbPgdGNhv0D/mdTm\r\nX9SJaPcdi7Ev6XW+TklrBpeGUsA/3WrM9H+fXHSXZCB9MFTHY1rx9WN+Ccwu\r\n3rvdxO4lPfr4UWWb4qewSox5Uq4FEQZ65/OzzEhq0ZpPlEAUETXVn/uOCG42\r\nF1TlP+0GlY56M+cgbGwYRolqu8GCNO7xK5OO0F6xKxVmeFXDeb/yV0xYI9ne\r\nEaf8Ow9hxU2Sz/aXjd1DAH6/qLzLox2Yv8vS6N8OI7wmL4476X50ZjrjEohE\r\nTwTwY1mfuGSRTZYLa+GIf/mRzo+fvMm0ezVOcnJshVzEGgnnw2KEq93MjqSN\r\nyIFyhoUlP5HGZ780hkJfRBVmLmMqmqS8yNNscCYlHfIDFE7esxenLMbWnBje\r\nIvy6y1NoX91LXMkD2ufDIInOmpslgElaZNo=\r\n=lTTZ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.1_1649448581293_0.31305802649268966"},"_hasShrinkwrap":false},"1.0.2-beta.0":{"name":"@asemirsk/oidc","version":"1.0.2-beta.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.0.2-beta.0","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"da62659a8fb42aa89cdc8cae2f148c8dd8db5dcb","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@bodiless/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@bodiless/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@bodiless/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@bodiless/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@bodiless/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { AuthCallback } from '@bodiless/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.2-beta.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-ifJk6z5jm05HyKB9mLSXbRHIzfsO2JjzTL+p7NQ4WpjCTqC/1Zk0hiGeGzvH0gK8MEsrsUGJBO2Bm1fT6UcaVg==","shasum":"8728fd7bb810b61f3607f2b14b5a5ca723c65b37","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.2-beta.0.tgz","fileCount":4,"unpackedSize":26085,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBuFzqZhYtNr+rk3oUOR/+13SQlWX4mQSXVIyw8P+jvJAiB3xTcoUYiOMIstuVlQ+3fTCQ1AV3+/NF2RsGqPrlY3AQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUJi7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq+uw//fVk/yUkJVIrplfx3shWDeCILjjT5TL/5vKakUn5/6T9UyelA\r\nVmbx3RyYP8mz1okiNCJI+R6Wcmb9pBEiSdnzAdbANZHXtNVDk2lzRkWMus18\r\n2rldH9olN7oN4orZLY4fJwRKc3pYeHTOW04oPXHmfOJh26qXp9BpJ9SdXk/6\r\nIZzqfSvqGIsnDHB6zfvrDdiS3NjWBLAJJ9W9CfQ/tGMI5KhHibwInUKa+YuL\r\niai31IN+yQjxFvRagTJcfjEJgvr1z5YPfvmQYcmVt6KtSyOwAggqQqsZ1SgY\r\nMSBzvM9VfZ4yr4p8qn44HP+1NjrbOMqSLvwAHxNYmEAmnbl5uUvnWHEy202Z\r\nD+z2prlq87Rs8bRzhxDfDO+3KsCeFApmfTGNcKzGORcZxdGaxEHE3BruYn0v\r\n/pJ+9kYJSuzp7sB0WFPyu2ZJts873baLwGKAFUfhpHYKZAqQU7qG4NH35FjP\r\nrXSJ53MbAEgHsfN6KJYICV2Gw3Ljitil/QVmyOL+bxmHMPbnmThkU0DrIT8H\r\nluxAL6eB+Tr9efbYhU6KBGEEzaTO/il8uAIRHQC8w/Hqibh24WSU8J8HKt+p\r\nFpMH4MZaZca7NuWhBtp7shvpLSVqX/U1rzglRMCzGLX56T8Zl6VHWN3Gnbxh\r\nAOmIJ6chL04YpmzxAjLiO8nlmrHPuJ6GbTo=\r\n=ki5x\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.2-beta.0_1649449147303_0.5406780213106481"},"_hasShrinkwrap":false},"1.0.2":{"name":"@asemirsk/oidc","version":"1.0.2","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.0.2","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"19cad7cb078a3029c7b40248078ddfa4d413bdcc","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.2","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-4X0bHyBM+D+U6C0pi28n2KXeqsy3TkLBJAhVk1dOQ+7HAy6qchQl4jMpiLsrYjFWk0jUGtuY8C2IAF7OXVPQkQ==","shasum":"2b926a30fc888f6167f4e5dccd94b7f90d73312b","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.2.tgz","fileCount":4,"unpackedSize":26071,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCBXptLkeMSGj5Ue4NOHcVZki8dFLdXBuec/cLtnTojGAIgHlCs941kKzErzsCEqzvnL/a6oFoW/5a3mCInPu9ITuM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUJl7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPihAAlfKKKBSuvNv/c9LGSOe5JF7Byh6hQzAz1DxVSvoUVb298S9P\r\nCs/QC251CqUTAfaKoFSLQ8gYowxrpVAhtTe6GstOpCI+u4YJvAQNlhE+ygou\r\ni2+fLstTz8Loi41p1GGASnr3+QYG2HnTvkzRwWmgBNt1ujFstzQQK+1xsT7I\r\nO7hXrOTog6uvxQ3AUdz93IjPlSrcNeEopyLWxIMUhVFkYtpO2m0MhNZmKLlM\r\nBGh+MbyQ2m4AWrIZ1uICCXqIfMJGh8CkBZlFqeriuCIj3NgP/RMv/jkF+z/c\r\n7Wl0ptHNIOIjdKkFjR+uB4qptgpTeSKd8DXkmc16RxBQ6OpAQGX+gHxHzTSQ\r\nKG2EYWU0xwbMGjFZBW1iUCH5n6ufXOLg9gez7KRtWVXBaOuJC3u3wKZIyp5H\r\noEh5+PH5kKHo8i1O7UUGAhD3l8bJtyLhdAg90crexxpClrvEqD4eo8y+A8Im\r\n3O0/hUvi2Rmnj7adFpe6n97ReKEGxbSaGpe1n5SoI22t/CTz+uaFQJ2s02q4\r\nAsxZ7Kca7LH0W8O+gG11eksel1XUv9vN7lBK+D1EfAMWtc9ecpcsf478oZUG\r\nhlPYSCLIsLHptqAdWhrh0Zt5TGGMdvRAQ7wNrb5WEBwUM9Av0ydk/Tw89xBt\r\no68BcVXLovBIWio1J8O+TaZDA3a06f9rJpE=\r\n=dvj9\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.2_1649449339447_0.28283183496280095"},"_hasShrinkwrap":false},"1.1.0":{"name":"@asemirsk/oidc","version":"1.1.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ./tsconfig.json && npm run build:api-doc","build:watch":"npm run build -- --watch","build:api-doc":"typedoc --out doc/api src","lint":"tslint ./src/**/*.ts?x","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"@asemirsk/cli":"^1.1.0","axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"e767bae774cc17eba5d92b638b7628cdc9236086","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.1.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-Jq24CuumVKGA6Qesegqz+jKD44taWvmg36BXq9adgdMnY8zc6+EwZM2RYMaeAmM8phs1cKFmRee5xqofv3T3xg==","shasum":"00cc2614e3ab64981bbee10972166eb4cd098b5a","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.1.0.tgz","fileCount":5,"unpackedSize":26905,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZDiYnB8s8Ip+Q2y8dwecn4vqy0KewbIr6P20gkXibkQIgSssHreh8vNAm424bfIU/+Mx2PzO65tbSbf3t6BKLh+I="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXtAbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrBIw/+K26M1kUAie6D4sqrky9XgiEJsLmKg8eFcDdThb1OMitX3uV8\r\nEDHGM8L/SXoyjcfsG5TdQMdcmq0vmNSlHw5VjyNPoIt4BzfeT89Hx3mYp36M\r\nyDXgBYevUn16GZ+AGVH4bIFSOecMLKvbIk0sH9jGwaP0L3DUlOgGhdw0zVXH\r\nt+VhFR/pbz5JWnzdbR/KCaKn4aBEsYUxdY+PoCXIg8NJLWAtTcaVdoZGvZq4\r\n+HsckhaKM51UYfukLbRpi4XBBsBjkXXCAKaE1z3pKxpxRR+8wruNLqpMakUq\r\nuXfeHk9gBiO8vwQE+bjSlYCMWfPMuqMLbNSRgxBr2h1kM8o72hYzY/JdlR7j\r\nQnB+QasqNsNzDGPHzs70Le8gu97TOUQYmAVtVhaZKjYIBghlZTDBAS1AZ/Vf\r\nVzGgh4EckkcPEmTLY3PNhsQjrABl8Vz4JUe4GFsnWfFxcW7SOi2RAeK4nQW1\r\nZoJFMb5zXLt1I+qPg5z8OewBqESXKmQzTQrQQ1+YUQ6RiKmP6WGevrJylbcw\r\n7uzxTvR6pFTsK74RleGrKULqxZM3Ne2XWAc/fxkkR1ZYV31mKog75ZeZ2b+7\r\ns6wGUHWMV8MO1d+70QIoqzOLEKd/wgYRfeDbSdidgg6k7swLKW1lA0rpD+d0\r\ntFpKLJ27655/VsfYJovCU9UklHUTqAxSH6M=\r\n=whP5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.1.0_1650380827620_0.20109903585713895"},"_hasShrinkwrap":false},"1.0.0-canary-24-22.0":{"name":"@asemirsk/oidc","version":"1.0.0-canary-24-22.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"run-p build:lib","build:lib":"tsc -p ./tsconfig.json","build:watch":"npm run build:lib -- --watch","build:api-doc":"typedoc --options ../../typedoc.js --out doc/api ./src","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"a48e91c77704024ccd08e24d4f85d1cd6971ccb1","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@bodiless/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@bodiless/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@bodiless/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@bodiless/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@bodiless/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { AuthCallback } from '@bodiless/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@bodiless/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@bodiless/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-canary-24-22.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-+fa0hESoytB+Whn1DGSrml/fvB9IoQ8jBDLINRxUf0MmtrXdE23F4PJq7FRUps0WAiC403kl6ckjS5tjLt0+Jg==","shasum":"a28f7285da122fa7c088296ce79df8f78f28e86d","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-canary-24-22.0.tgz","fileCount":5,"unpackedSize":26903,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2gfPisbZEA9hRl7ZlCEf83pfGWyE5DyZMtDYqGian5gIgK++NOw+MSDC6Gi/tQTLRZHCrWcMe8gMdKLEFNlDQSsQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijezbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmplOg/+PTkiPaqL3njTYVqCshfsTpuOOUC6l3dFTG7CfHxMe2KFas9p\r\nJig73+JE3sUC+FpSgXYSiSFkmxuxc2WlC+0hRsjnh23Yq97O9V81LMUqae4C\r\nk/gFd9EJ0mXpPrkNTlIHl2IQxpdswZzuP29HlOw/dr0Q+VQ31+Fh4knV8X+z\r\nmkKP8f36jVtwgLr1lDd5cRupCiAK8J9kPCw/juvKrdjAwXtaojO8eep2Vop4\r\n9v1kSK13P/RzupQesGFCInUaZau0N1oZYWYoBjmo9rNsXELyTTO0Izk3hJ1V\r\ndgJi5zhfngSyl56S+baMafGa7/3FsDbIfOdkbzUsDlY2hl9oAe4Z+xCwiOa9\r\nlksmwiAeDFaHuNv0SMV+fhN9bgCseLIH0jIfWIJZbntkU/bXhg684oB4k0VP\r\n7bOiaYzrUtXYhopcq6mSDWXH+zlAS0SViX0MAmT/kQyR9ig3M4YGMGlRb7+t\r\njPcZwaaKKYdIZePfgdD1LDG0WIinfrxFfpPOZYqHtFcaqD+wnXq7wxNM99Y+\r\nvJ1+Z39LeoEHro40hBjfd5IqZlpgwdUK4iujlc1XcgTpStu+RMk7TvvihgwI\r\nsVCyK7k7l+uP/MxfJLpJo9yMsJi+uWIXZlGClxbZ/gg5FDRt/qBD2FxzR92O\r\nwwsAYYT7sOtuMcFFLZaRr2vSIPe+MAoWM9M=\r\n=KWJ7\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-canary-24-22.0_1653468378921_0.8804700729937049"},"_hasShrinkwrap":false},"1.0.0-canary-24-23.0":{"name":"@asemirsk/oidc","version":"1.0.0-canary-24-23.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"run-p build:lib","build:lib":"tsc -p ./tsconfig.json","build:watch":"npm run build:lib -- --watch","build:api-doc":"typedoc --options ../../typedoc.js --out doc/api ./src","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"2cab1eaf4ac4d1a8ef3ef53ba3228ff16f7504eb","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@asemirsk/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@asemirsk/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@asemirsk/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@asemirsk/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@asemirsk/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@asemirsk/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { AuthCallback } from '@asemirsk/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@asemirsk/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-canary-24-23.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-Yg3S3L5mq+UIAE0exPOh1pJri3O4FUo52Hlzup8nc+TntmDdtLMNf/cJT4bZFDCh+wwVYwzA72r+M9LY58xAaw==","shasum":"ab67c98cd42b8b71e6356d5176f1934044db3a24","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-canary-24-23.0.tgz","fileCount":5,"unpackedSize":26903,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDrNHMBirmXsdaBJBAcQm71TcemmUtI71r+I2fqRQqN/wIhALXB6Pcig42jABpXaMBX+cuWNGeIdqG0WOdZrjo4n9iL"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijfHoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoX0Q//V2kBtXddgnZLLeCadheY/tWZ3g4RiDnq5fnbZagnPpa/tFEl\r\n7z9Tf/I9WEQHPW1lUyBcthcgAzTMFBHVnmfYIflnoBGZAy4mVUWFrwi6slZ1\r\nQ0bGSR1o4b2jed6jyKMQ2Kcdu+ohjw4zqLaLh7Wqs6rRV2rKzjNbEPgHleGG\r\nE19t3h7pa/6XwUF1G2fEefqolj76BcbJTgzogw3kOAzwG8X0xHJXf8aVCbuT\r\nk9nNPuRgvfh0yxgaLd66KAndCVVT2oZ134QpwDp8FgN3cBL08RMh9of7BMp8\r\n9gldfaMu7sT4yyEJ/Hk63ovOESn4tNdn/Fxxf1XKeqmuJAsBoe547Bgm15LQ\r\nl24zWmZPxUCEXWHOykUogGKuTHSa+TH5Z3bU//t7q/+/APKXsVDeu+ycoCyL\r\nS+kNh29la/sUehlSufHCAj1cdHNoz2xMzfTRQZgFiWsyFA639eDHPjGu+KPJ\r\nag+I3Btk8w5RQPmBNFyzmOlY7siWULCWLO+JffDZyRK03otFOC0jAqIASMpi\r\n4+wklwqYFvR9ySfH9rR46deBsP2+EUSvGe7qHXTNFibXX4XvLvJGYxkl8uE2\r\nRq0G2lO1yoB8qW2C1uynyOHDKgVBaxZcTPD1qYu3tpJ8Kvdq6M1PmlgbJSft\r\ntDsMCIPkyoM433yBVIguprKOrVPFvNOSTUs=\r\n=G/2Q\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-canary-24-23.0_1653469672644_0.13302832333504755"},"_hasShrinkwrap":false},"1.0.0-canary-24-24.0":{"name":"@asemirsk/oidc","version":"1.0.0-canary-24-24.0","description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"license":"Apache-2.0","main":"lib/index.js","typings":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"publishConfig":{"access":"public"},"scripts":{"build":"run-p build:lib","build:lib":"tsc -p ./tsconfig.json","build:watch":"npm run build:lib -- --watch","build:api-doc":"typedoc --options ../../typedoc.js --out doc/api ./src","clean":"rimraf \"lib/*\" && rimraf tsconfig.tsbuildinfo && rimraf \"doc/api\""},"dependencies":{"axios":"^0.21.0","enzyme":"^3.9.0","oidc-client-ts":"2.0.0-rc.2"},"peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"gitHead":"af2c8ace172b3dc3a1f237c51eb55be1e21978bb","readme":"\n\n# Bodiless OIDC\n\nBodiless OICD is a library that provides OpenID Connect (OIDC) and OAuth2 protocol support.\n\nOpenID Connect (OIDC) is a secure mechanism that is employed in user authentication and authorization and enables an app or a website to contact an identity service provider (like the Akamai or Okta) and authenticate the user, receive an access token that (in the case of Hosted Login) specifies the user profile information that the client is authorized to access, retrieve personal information needed by the user or by the system and refresh the user’s authentication/authorization state, and prevent that session from timing out.\n\n### Usage\nTo enable OIDC on a site you need to wrap your content with the `AuthProvider`. `AuthProvider` is responsible for signing a user in, signing out, and managing the current User state. It also provides access to the currently initiated `UserManager`.\n\n```js\nimport React from 'react';\n// ...\nimport { AuthProvider } from '@asemirsk/oidc';\n\n// First we create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Note that we *spread* all `oidcConfig` props into the `AuthProvider`.\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthProvider {...oidcConfig}>\n        // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n        // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n        ...\n      </AuthProvider>\n    </Layout>\n  </Page>\n);\n```\n\n#### Use `withOidcProvider`\nThe other way to wrap something with the `AuthProvider` is to use `withOidcProvider` HOC. It accepts `oidcConfig` as a prop and wraps the provided component with the `AuthProvider`:\n\n```js\nimport React from 'react';\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { withOidcProvider } from '@asemirsk/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create the OIDC config.\n// See `AuthProviderProps` for the full config props list.\nconst oidcConfig = {\n  authority: 'https://demo.identityserver.io',\n  clientId: 'interactive.public',\n  redirectUri: 'http://localhost:8005/oidc',\n  scope: 'openid profile email api offline_access',\n};\n\n// Wrap the default Layout component with the `AuthProvider`.\nconst PageLayout = withOidcProvider(oidcConfig)(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // Access to `UserManager`, `userData`, `signIn`, `signInPopup`,\n      // `signOut` and `signOutRedirect` as well as `isLoading` indicator.\n      ...\n    </PageLayout>\n  </Page>\n);\n```\n\n### OIDC Config:\nThe OIDC config is used to pass required props to the `AuthProvider`. The following props are required:\n```js\n{\n  /**\n   * The URL of the OIDC/OAuth2 provider. (Okta, Akamai, etc)\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   * Usually a page with the `<AuthCallback />` component.\n   */\n  redirectUri: string;\n}\n```\n\nYou may also find usefull `onSignIn` and `onSignOut` callbacks that you can pass to the `AuthProviderProps`. These are the callbacks that will be executed after successfull Sign In or Sign Out. You may redirect a user to a particular page or display a confirmation message.\n\nThe full list of the `oidcConfig` corresponds to the `AuthProviderProps` and includes the following props:\n```ts\nexport type AuthProviderProps = {\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager?: UserManager;\n  /**\n   * The URL of the OIDC/OAuth2 provider.\n   */\n  authority: string;\n  /**\n   * Your client application's identifier as registered with the OIDC/OAuth2 provider.\n   */\n  clientId: string;\n  /**\n   * Client secret defined on the identity server.\n   */\n  clientSecret?: string;\n  /**\n   * The redirect URI of your client application\n   * to receive a response from the OIDC/OAuth2 provider.\n   */\n  redirectUri: string;\n  /**\n   * The redirect URI of your client application to receive a response from\n   * the OIDC/OAuth2 provider when completing a background sign-in refresh.\n   */\n  silentRedirectUri?: string;\n  /**\n   * The post-logout redirect URI of your client application\n   * which your OIDC/OAuth2 provider can redirect to after completing logout.\n   */\n  postLogoutRedirectUri?: string;\n  /**\n   * Tells the authorization server which grant to execute.\n   *\n   * Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1\n   */\n  responseType?: string;\n  /**\n   * A space-delimited list of permissions that the application requires.\n   */\n  scope?: string;\n  /**\n   * Defaults to `windows.location`.\n   */\n  location?: Location;\n  /**\n   * defaults to true\n   */\n  autoSignIn?: boolean;\n  /**\n   * Flag to indicate if there should be an automatic attempt\n   * to renew the access token prior to its expiration.\n   *\n   * defaults to false\n   */\n  automaticSilentRenew?: boolean;\n  /**\n   * Flag to control if additional identity data is loaded from\n   * the user info endpoint in order to populate the user's profile.\n   *\n   * defaults to true\n   */\n  loadUserInfo?:boolean;\n  /**\n   * The features parameter to window.open for the popup signin window\n   *\n   * defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100'\n   */\n  popupWindowFeatures?: string;\n  /**\n   * The URL for the page containing the call to signinPopupCallback\n   * to handle the callback from the OIDC/OAuth2\n   *\n   */\n  popupRedirectUri?: string;\n  /**\n   * The target parameter to window.open for the popup signin window.\n   *\n   * defaults to '_blank'\n   */\n  popupWindowTarget?:string;\n  /**\n   * On before sign in hook. Can be use to store the current url for use after signing in.\n   *\n   * This only gets called if autoSignIn is true\n   */\n  onBeforeSignIn?: () => void;\n  /**\n   * On sign out hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Consume `AuthContext`:\nTo consume `AuthContext` you may use `useBodilessOidc` hook:\n\n```js\nimport { useBodilessOidc } from '@asemirsk/oidc';\n\nconst UserPreview:FC<any> = props => {\n    // Get `userData` from the AuthContext.\n    // See `AuthContextProps`.\n  const { userData, signIn, signOut } = useBodilessOidc();\n\n  // See if we logged in display a first name.\n  // If `userData` is `null` it means user in not authenticated.\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <button onClick={()=>signOut()}>Sign Out</button>\n      </div>\n    );\n  // If not logged in display Sign In button.\n  } else {\n    return (\n      <button onClick={()=>signIn()}>Sign In</button>\n    );\n  }\n};\n```\n\nHere is a list of all `useBodilessOidc` props:\n\n```ts\nexport type AuthContextProps = {\n  /**\n   * Alias for userManager.signInRedirect\n   */\n  signIn: (args?: SigninRedirectArgs) => Promise<void>;\n  /**\n   * Alias for userManager.signinPopup\n   */\n  signInPopup: () => Promise<void>\n  /**\n   * Alias for userManager.removeUser\n   */\n  signOut: () => Promise<void>;\n  /**\n   * Alias for userManager.signoutRedirect\n   */\n  signOutRedirect: (args?: SignoutRedirectArgs) => Promise<void>;\n  /**\n   * See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details.\n   */\n  userManager: UserManager;\n  /**\n   * See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details.\n   */\n  userData?: User | null;\n  /**\n   * State setter that may be used to update `userData`.\n   */\n  setUserData: React.Dispatch<React.SetStateAction<User | null>>\n  /**\n   * Auth state: True until the library has been initialized.\n   */\n  isLoading: boolean;\n  /**\n   * On sign in hook. Can be a async function.\n   * @param userData User\n   */\n  onSignIn?: (userData: User | null) => Promise<void> | void;\n  /**\n   * On sign out hook. Can be a async function.\n   */\n  onSignOut?: (options?: AuthProviderSignOutProps) => Promise<void> | void;\n};\n```\n\n### Helper HOCs\nThere are several HOCs exported from the `@asemirsk/oidc` package that may be used to add OIDC functionality to the components:\n\n - `withSignInOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signIn` handler when executed.\n - `withSignOutOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOut` handler when executed.\n - `withSignInPopupOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signInPopup` handler when executed.\n - `withSignOutRedirectOnClick` - HOC that adds an `onClick` event to the underlying component and invokes OIDC `signOutRedirect` handler when executed.\n\n```js\nimport { Button } from '@asemirsk/fclasses';\nimport { withSignInOnClick, withSignOutOnClick } from '@asemirsk/oidc';\n\nconst SignInButton = withSignInOnClick(Button);\n/**\n * `withSignOutOnClick` does not end provider session,\n * only the local session is closed. When user tries to login after\n * this type of Sign Out, provider will usually authorize user without\n * a need to re-enter credentials.\n */\nconst SignOutButton = withSignOutOnClick(Button);\n\n/**\n * `withSignOutRedirectOnClick` closes both: local and provider sessions.\n * This is the complete Sign Out and user credentials will be required\n * to login next time.\n *\n * Accepts optional `post_logout_redirect_uri` and `state` arguments.\n * `post_logout_redirect_uri` is the redirect after successfull closing\n * of the provider session.\n */\nconst SignOutRedirectButton = withSignOutRedirectOnClick({\n  // Redirect to the current page when Sign Out is complete.\n  post_logout_redirect_uri: window.location.href,\n})(Button);\n\nconst UserPreview:FC<any> = props => {\n  const { userData } = useBodilessOidc();\n\n  if (userData) {\n    return (\n      <div>\n        <h3>Hi! My name is {userData.profile.given_name}!</h3>\n        <SignOutButton>Sign Out</SignOutButton>\n        <SignOutRedirectButton>Sign Out Redirect</SignOutRedirectButton>\n      </div>\n    );\n  } else {\n    return (\n      <SignInButton>Sign In</SignInButton>\n    );\n  }\n};\n```\n\n### `AuthCallback` Component\nThis component handles OIDC Sign In and Sign Out responses. It reads the OIDC/OAuth2 provider response data from the URL and initializes `signinCallback` or `signoutCallback` with this data.\n\nWhen you define OIDC config, `redirectUri` and `postLogoutRedirectUri` should point to the page with `<AuthCallback />` component.\n\n```js\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { AuthCallback } from '@asemirsk/oidc';\n\n/**\n * In addition to the `onSignIn` and `onSignOut` callbacks\n * from the OIDC config, we can add `onSuccess` and `onError` handlers\n * to the `<AuthCallback />` component.\n */\nconst onSuccess = (user: User | null) => {\n  // ... do something when auth callback is successfull.\n};\n\nconst onError = (error) => {\n  // ... do something when auth callback has failed.\n};\n\nexport default (props: any) => (\n  <Page {...props}>\n    <Layout>\n      <AuthCallback onSuccess={onSuccess} onError={onError} />\n    </Layout>\n  </Page>\n);\n\n```\n\n#### Use `withAuthCallback`\nYou can wrap any page or component with `withAuthCallback()` HOC. It takes `onSuccess` and `onError` optional params.\n```js\nimport React from 'react';\nimport { Page } from '@asemirsk/gatsby-theme-bodiless';\nimport { withAuthCallback } from '@asemirsk/oidc';\nimport Layout from '../../../components/Layout';\n\n// Create onSuccess handler\nconst onSuccess = (user: User | null) => {...};\n\n// Wrap the default Layout component with the `AuthCallback`.\nconst PageLayout = withAuthCallback({ onSuccess })(Layout);\n\nexport default (props: any) => (\n  <Page {...props}>\n    <PageLayout>\n      // OIDC redirects to this page with valid response in URL\n      // will Sign In or Sign Out user.\n      ...\n    </PageLayout>\n  </Page>\n);\n```","readmeFilename":"README.md","bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","_id":"@asemirsk/oidc@1.0.0-canary-24-24.0","_nodeVersion":"16.13.2","_npmVersion":"lerna/4.0.0/node@v16.13.2+x64 (linux)","dist":{"integrity":"sha512-B3ay6dJ1MAon/plgFWqS7evm1e96Kr56Uo6GsToiFaeybE8tidncm2AJ+sQbxCcmgUiFsqaIErTXx4LkSRkuvg==","shasum":"1f58e1db3b626de2f36f92a3a0f3333114b16d51","tarball":"https://registry.npmjs.org/@asemirsk/oidc/-/oidc-1.0.0-canary-24-24.0.tgz","fileCount":5,"unpackedSize":26903,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2UGvpvEhxLdQXvhMgq+ogcc80UVxm6r0ni3+szOgyCgIgQS1N4i4NFMe5OkQTd4kYyt8Gbf7K0YMByuOCJcPOF4k="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijfQ8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQ/g//blDdyYSoqYV1FEZSepf/Ix9RhVX52eTUwQ0GozbRdYhTZieS\r\nPqT3PCWodF3nnS1rDzcGv8o8Zii0NwTPE01G3FdHcoQ7x/OLuAKZF12V/Uy0\r\nOL3ILCSl2DlolcC67AR8QbE1iLFlpa4+mDsSG+cFMYmSjVSMTbFM2SgvCHS/\r\nj9cX7UVoUnnsB7taF5TwApSZHUPB4pjpPvcskzh4pJL1Y3QQtxntBGwGj/Uh\r\nSSedYzWcX14Zr55dVE6J5dXtp96FeTqGRR77weKZyD3OdGXwDJOj/NOTaNQT\r\nECcXuFnfNZtuFtc4FjCM6EtHdmZWOGMjFXAzM2W2R9QRhN3/8ue8MUZjuiK9\r\nRC0LIcgArSH/aXPyMBLcuvulLwafjyr5GHyXYb2/bS0RZcIo1iHehQyslOju\r\nmCdvTxa7hx0GPNaUeCefXzg9whuMaaba7Cqz+O3YbuRSiOfU5ipdt6Es24CB\r\nCQWAElfmIooKmWiQIvVNn5yew5EkTA+ZcESISzRYVw0AprreEbIkVqL4LdIu\r\niW5lI9eNqX+SmfM+9zZifrlUXKmkOlvtC+aiXkM0/f1pQr65blnhY1IRP/6I\r\neQoZJDfxymaCYbBuX3JEMEAlyQ928KfaGYCn+wsOpzBsI274x4SKCQzrM9fS\r\ngvO3bgUBFy6WOggSgS2f2J+OEg/+XB0JUj4=\r\n=Rgu8\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asemirsk","email":"al.semirski@gmail.com"},"directories":{},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0-canary-24-24.0_1653470268125_0.2306576624173653"},"_hasShrinkwrap":false}},"maintainers":[{"name":"asemirsk","email":"al.semirski@gmail.com"}],"description":"Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side","homepage":"https://github.com/johnsonandjohnson/bodiless-js#readme","repository":{"type":"git","url":"git+https://github.com/johnsonandjohnson/bodiless-js.git"},"author":{"name":"Ivan Rudiuk","email":"IRudiuk@its.jnj.com"},"bugs":{"url":"https://github.com/johnsonandjohnson/bodiless-js/issues"},"license":"Apache-2.0","readme":"","readmeFilename":""}