Skip to content

Commit a1a23ce

Browse files
authored
Merge pull request #1 from cobuildlab/feature/main/first-version-hook
React Native Auth0 hook
2 parents bbd900a + 2cb9976 commit a1a23ce

20 files changed

Lines changed: 29106 additions & 1 deletion

.eslintrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
plugins: ['jsdoc', '@typescript-eslint'],
4+
extends: [
5+
'eslint:recommended',
6+
'prettier',
7+
'plugin:jsdoc/recommended',
8+
'plugin:react-hooks/recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
],
11+
ignorePatterns: ['lib/**/*.js.', 'lib/*.js'],
12+
env: {
13+
node: true,
14+
es6: true,
15+
},
16+
parserOptions: {
17+
ecmaVersion: 6,
18+
sourceType: 'module',
19+
},
20+
rules: {
21+
indent: ['error', 2],
22+
semi: [2, 'always'],
23+
'no-console': ['error', { allow: ['warn', 'error', 'log'] }],
24+
'jsdoc/require-description-complete-sentence': 1,
25+
'jsdoc/require-hyphen-before-param-description': 1,
26+
},
27+
};

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build Node.js Package
2+
3+
on: pull_request
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: actions/setup-node@v1
11+
with:
12+
node-version: 12
13+
- run: npm ci
14+
# - run: npm run test
15+
- run: npm run build
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Code scanning - action"
2+
3+
on:
4+
pull_request:
5+
schedule:
6+
- cron: '0 15 * * 4'
7+
8+
jobs:
9+
CodeQL-Build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
with:
17+
# We must fetch at least the immediate parents so that if this is
18+
# a pull request then we can checkout the head.
19+
fetch-depth: 2
20+
21+
# If this run was triggered by a pull request event, then checkout
22+
# the head of the pull request instead of the merge commit.
23+
- run: git checkout HEAD^2
24+
if: ${{ github.event_name == 'pull_request' }}
25+
26+
# Initializes the CodeQL tools for scanning.
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v1
29+
# Override language selection by uncommenting this and choosing your languages
30+
# with:
31+
# languages: go, javascript, csharp, python, cpp, java
32+
33+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
34+
# If this step fails, then you should remove it and run the build manually (see below)
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v1
37+
38+
# ℹ️ Command-line programs to run using the OS shell.
39+
# 📚 https://git.io/JvXDl
40+
41+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
42+
# and modify them (or add more) to build your code if your project
43+
# uses a compiled language
44+
45+
#- run: |
46+
# make bootstrap
47+
# make release
48+
49+
- name: Perform CodeQL Analysis
50+
uses: github/codeql-action/analyze@v1

.github/workflows/npmpublish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-npm:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
registry-url: https://registry.npmjs.org/
17+
- run: npm ci
18+
- run: npm run build
19+
- run: npm publish --access public
20+
env:
21+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
22+

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea/
2+
3+
node_modules/
4+
.c9
5+
.DS_Store
6+
coverage/
7+
lib/

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src
2+
tsconfig.json
3+
tslint.json
4+
.prettierrc

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"jsxSingleQuote": false,
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": true,
10+
"arrowParens": "always",
11+
"trailingComma": "all"
12+
}

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
1-
# TODO
1+
# TODO
2+
3+
- Documentation
4+
- Refresh Token
5+
- Auth0 Params
6+
- Clean Code
7+
8+
9+
Basic use:
10+
11+
```tsx
12+
import React from 'react';
13+
import { View, Button, Text } from 'react-native';
14+
import { useAuth, AuthProviderConfig, AuthProvider } from '@cobuildlab/react-native-auth0';
15+
import { Credentials } from 'react-native-auth0';
16+
import AsyncStorage from '@react-native-async-storage/async-storage';
17+
18+
import { auth0 } from './src/shared/auth0/client';
19+
20+
const App: React.FC = () => {
21+
const { login, logout, isLoading, isAuthenticated } = useAuth();
22+
console.log('---- isAuthenticated --- ', isAuthenticated);
23+
console.log('---- isLoading --- ', isLoading);
24+
25+
return (
26+
<View>
27+
<Text>{isAuthenticated ? 'Im On' : 'Im Off'}</Text>
28+
<Button onPress={login} title="login" />
29+
<Button onPress={logout} title="logout" />
30+
</View>
31+
);
32+
};
33+
34+
const Conifg: AuthProviderConfig = {
35+
auth0,
36+
eichBaseToken: '8base-token',
37+
eichBaseAuthProfileId: 'my-profile-id',
38+
eichBaseEndpoint: '8base-environemnt-branch',
39+
removeCredentials: async () => {
40+
await AsyncStorage.removeItem('credentials_store');
41+
},
42+
saveCredentials: async (credentials) => {
43+
const value = JSON.stringify(credentials);
44+
await AsyncStorage.setItem('credentials_store', value);
45+
},
46+
getCredentials: async (): Promise<Credentials | null> => {
47+
const value = await AsyncStorage.getItem('credentials_store');
48+
return value != null ? JSON.parse(value) : null;
49+
},
50+
};
51+
52+
export const App = () => {
53+
return (
54+
<AuthProvider config={Conifg}>
55+
<App />
56+
</AuthProvider>
57+
);
58+
};
59+
```
60+

babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
'@babel/preset-react',
12+
'@babel/preset-typescript',
13+
],
14+
};

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
transform: {
4+
'^.+\\.ts?$': 'ts-jest',
5+
},
6+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
7+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
};

0 commit comments

Comments
 (0)