open-index/open-npm huggingface dataset:
npm package: @jfront/oauth-context
Description: React Context API OAuth 2.0 authorization management.
Latest version: 0.3.0

# oauth-context

React Context API OAuth 2.0 authorization management.

## Usage

```js
import { OAuthContextProvider, useOAuth } from "@jfront/oauth-context"

function Component() {
  const context = useOAuth()
  return <div>{context.expiresIn}</div>
}

function App() {
  return (
    <OAuthContextProvider
      onAuthorizationRequest={onAuthorizationRequest} //submit redirect after authorization URL is ready
      isOAuthCallback={isOAuthCallback} //pass function which will determine if current route is OAuth callback
      redirect={redirect} //pass function which allows to forward application between routes with URL scheme
      getCurrentUrl={getCurrentUrl} //pass function which gets current route URL scheme
      getQueryParams={getQueryParams} //pass function which gets OAuth params from current URL (code, state, error, errorDescription)
      clientId={"clientId"}
      redirectUri={"http://server/app/cb"}
      oauthContextPath={"http://server/oauth/api"}
      storage={window.sessionStorage} //pass your platform storage, for browser default is HTML5 Session Storage
      onLogout={onLogout} //submit logout URL
    >
      <Component />
    </OAuthContextProvider>
  )
}
```
npm package: @jfront/oauth-core
Description: Core functionality for OAuth 2.0 connection.
Latest version: 0.3.0

# oauth-core

Core functionality for OAuth 2.0 connection.

## Usage

```js
import { OAuth } from "@jfront/oauth-core"

const oauth = new OAuth(
  "clientId",
  "http://localhost/app/oauth",
  "http://localhost/authorize",
  "http://localhost/token",
  "http://localhost/logout",
  window.sessionStorage,
)
```

## API

### authorize

Authorization Code/Implicit flow authorization.

```js
oauth.authorize("code", "http://localhost/app/view")
```

### getTokenWithAuthCode

Get token with authorization code, when authorization step was completed.

```js
oauth.getTokenWithAuthCode("authorization_code", "random_nonce_string")
```

### refreshToken

Refresh access token, if you have refresh_token.

```js
oauth.refreshToken("refresh_token")
```

### getTokenWithUserCredentials

Get token with user login/password.

```js
oauth.getTokenWithUserCredentials("login", "password")
```

### logout

Logout for client-side apps.

```js
oauth.getTokenWithUserCredentials("http://localhost/app/view")
```
npm package: @jfront/oauth-ui
Description: React Web implementation.
Latest version: 0.4.0

# oauth-context

React Web implementation.

### Usage

Simple usage in React SPA. Uses
[Authorization Code Grant with PKCE extension](https://tools.ietf.org/html/rfc7636)
by default.

```js
import React from "react"
import { OAuthWebContext, OAuthSecuredFragment } from "@jfront/oauth-ui"

function App() {
  return (
    <OAuthWebContext
      clientId={"243j24h246j242gjikh6kllnn5l"} //application client_id
      redirectUri={"http://localhost/app/oauth"} //library uses scheme:[//authority]/context_path/oauth url as default callback endpoint
      oauthContextPath={"http://localhost/oauth/api"} //oauth API base url
    >
      <OAuthSecuredFragment>
        <div>Logged in</div>
      </OAuthSecuredFragment>
    </OAuthWebContext>
  )
}
```
npm package: @jfront/oauth-user
Description: React Web implementation.
Latest version: 0.2.5

# oauth-context

React Web implementation.

### Usage

Simple usage in React SPA. Uses
[Authorization Code Grant with PKCE extension](https://tools.ietf.org/html/rfc7636)
by default.

```js
import React from "react"
import { OAuthWebContext, OAuthSecuredFragment } from "@jfront/oauth-ui"

function App() {
  return (
    <OAuthWebContext
      clientId={"243j24h246j242gjikh6kllnn5l"} //application client_id
      redirectUri={"http://localhost/app/oauth"} //library uses scheme:[//authority]/context_path/oauth url as default callback endpoint
      oauthContextPath={"http://localhost/oauth/api"} //oauth API base url
    >
      <OAuthSecuredFragment>
        <div>Logged in</div>
      </OAuthSecuredFragment>
    </OAuthWebContext>
  )
}
```