Skip to content

Commit

Permalink
feat: First implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Apr 9, 2020
1 parent 0aa59b4 commit 071d311
Show file tree
Hide file tree
Showing 28 changed files with 9,181 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 1

update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "live"
automerged_updates:
- match:
dependency_type: "all"
update_type: "semver:minor"
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**/*.js
build/
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:react/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-empty-function": 0,
"react/prop-types": 0,
"@typescript-eslint/no-non-null-assertion": 0
}
}
6 changes: 6 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
updateDocsComment: >
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update some of our documentation based on your changes. You can run `yarn generate-docs` to generate some!
# Terms that if found in the title of a PR will prevent the bot from commenting on it
updateDocsWhiteList:
- bug
- chore
48 changes: 48 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build & Deploy
on: [push,pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- run: yarn run lint
- run: yarn run build
- run: yarn test
env:
CI: true
- run: npx codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17.0.4
extra_plugins: |
@semantic-release/changelog@5.0.1
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"useTabs": false,
"tabWidth": 2
}
3 changes: 3 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@jedmao/semantic-release-npm-github-config"
}
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing to oidc-react

:+1::tada: Thanks for taking the time to contribute! :tada::+1:

The following is a set of guidelines for contributing to the Electron website
on GitHub. These are just guidelines, not rules, so use your best judgment and
feel free to propose changes to this document in a pull request.

## Issues and Pull Requests

* If you're not sure about adding something, [open an issue](https://github.com/bjerkio/oidc-react/issues/new) to discuss it.
* Feel free to open a Pull Request early so that a discussion can be had as changes are developed.

## Commit Messages and Pull Request Titles

We use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification to standardize our commit history. To enforce this convention on commit messages and/or pull request titles, we use the [Semantic Pull Requests](https://github.com/probot/semantic-pull-requests) bot.

The commit message summary (or pull request title) is constructed by prepending the type of change being made (e.g., feat, fix, refactor), followed by an imperative, present tense sentence (without a period).
Example: `fix: make header bold`.

If you are still working on your pull request, prepend `WIP:` to indicate that it's work in progress.

### Pull Request Title

Same as commit messages, prepend the type of change being made (refactor, fix, chore, feat, etc.)
Example: `docs: add linux setup instructions`

## Documentation

Most of the documentation are automatically generated. We utilize `typedoc` that uses tags inline
with classes in order to generate. The nice thing about this is that documentation will be visible
when using Typescript in editors as well.

However, we love to have examples and guides as well.

## Need Help?

If any of this information confusing, incorrect, or incomplete, feel free to
[open an issue](https://github.com/bjerkio/oidc-react/issues/new)
for help.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2020 Bjerk AS

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# OIDC React

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![code style: airbnb](https://img.shields.io/badge/eslint-airbnb-ff5a5f.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
![Build & Deploy](https://github.com/bjerkio/oidc-react/workflows/Build%20&%20Deploy/badge.svg)

[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/bjerkio/oidc-react.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bjerkio/oidc-react/context:javascript)
[![codecov](https://codecov.io/gh/bjerkio/oidc-react/branch/master/graph/badge.svg)](https://codecov.io/gh/bjerkio/oidc-react)
[![Maintainability](https://api.codeclimate.com/v1/badges/04b50822a61583ccdb5f/maintainability)](https://codeclimate.com/github/bjerkio/oidc-react/maintainability)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=bjerkio/oidc-react&identifier=253005089)](https://dependabot.com)

![oidc-react logo](assets/logo.png)

## About

React component (AuthContext) to provide OpenID Connect and OAuth2 protocol support. Has [hooks](guides/HOOKS.md) 🎉

Based on [oidc-client-js](https://github.com/IdentityModel/oidc-client-js).

## Quickstart

Install packages by running:

```shell
$ npm install oidc-react
```

## Usage

```typescript
...
import { AuthProvider } from 'oidc-react';

const oidcConfig = {
onSignIn: () => {
// Redirect?
},
authority: 'https://oidc.io/oauth',
clientId: 'this-is-a-client-id',
redirectUri: 'https://my-app.com/'
};

const Routes = () => (
<AuthProvider {...oidcConfig}>
<Switch>
<Route exact path="/">
<Dashboard />
</Route>
...
</Switch>
</AuthProvider>
);
```

# Documentation

Apart from this README, you can find details and examples of using the SDK in the following places:

- [SDK Documentation](docs/README.md)
- [Guides](guides/)
- [oidc-client-js Documentation](https://github.com/IdentityModel/oidc-client-js/wiki)

## Contribute & Disclaimer

We love to get help 🙏 Read more about how to get started in [CONTRIBUTING](CONTRIBUTING.md) 🌳
Binary file added assets/logo.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[oidc-react](README.md)

# oidc-react

## Index

### Interfaces

* [AuthContextProps](interfaces/authcontextprops.md)
* [AuthProviderProps](interfaces/authproviderprops.md)
* [Location](interfaces/location.md)

### Variables

* [AuthContext](README.md#const-authcontext)

### Functions

* [AuthProvider](README.md#const-authprovider)
* [useAuth](README.md#const-useauth)

## Variables

### `Const` AuthContext

**AuthContext**: *Context‹[AuthContextProps](interfaces/authcontextprops.md)* = React.createContext<AuthContextProps>({
signIn: /* istanbul ignore next */ () => {},
signOut: /* istanbul ignore next */ () => {},
})

## Functions

### `Const` AuthProvider

**AuthProvider**(`props`: [AuthProviderProps](interfaces/authproviderprops.md) & object): *Element‹›*

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`props` | [AuthProviderProps](interfaces/authproviderprops.md) & object | AuthProviderProps |

**Returns:** *Element‹›*

___

### `Const` useAuth

**useAuth**(): *[AuthContextProps](interfaces/authcontextprops.md)*

**Returns:** *[AuthContextProps](interfaces/authcontextprops.md)*

0 comments on commit 071d311

Please sign in to comment.