├── .github └── workflows │ ├── npmpublish.yml │ └── pr-check.yml ├── .gitignore ├── .vscode └── launch.json ├── .yarn └── releases │ └── yarn-3.1.0.cjs ├── .yarnrc.yml ├── LICENSE ├── babel.config.js ├── eas.json ├── google10abf99cd93ff1d6.html ├── jest.config.js ├── package.json ├── packages ├── b2c-sample │ ├── .expo-shared │ │ └── assets.json │ ├── .gitignore │ ├── App.tsx │ ├── __generated__ │ │ └── AppEntry.js │ ├── app.config.js │ ├── app.json │ ├── assets │ │ ├── adaptive-icon.png │ │ ├── favicon.png │ │ ├── icon.png │ │ └── splash.png │ ├── babel.config.js │ ├── eas.json │ ├── metro.config.js │ ├── package.json │ ├── src │ │ ├── Home.tsx │ │ ├── Protected.tsx │ │ ├── Redirect.tsx │ │ └── navTypes.ts │ └── tsconfig.json └── lib │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc.json │ ├── app.json │ ├── babel.config.js │ ├── index.ts │ ├── jest.config.js │ ├── package.json │ ├── readme.md │ ├── src │ ├── __test-utils │ │ └── index.js │ ├── hooks │ │ ├── useAuth.test.js │ │ ├── useAuth.ts │ │ ├── useToken.test.js │ │ └── useToken.ts │ ├── interfaces │ │ └── index.ts │ ├── providers │ │ ├── AuthProvider.test.js │ │ └── AuthProvider.tsx │ └── services │ │ ├── Auth.test.js │ │ └── Auth.ts │ └── tsconfig.json ├── readme.md ├── setupJest.js ├── tsconfig.json └── yarn.lock /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | name: npm publish 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | build-publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16 15 | registry-url: https://registry.npmjs.org/ 16 | - run: yarn install --immutable 17 | - run: yarn test --coverage 18 | - name: Codecov 19 | uses: codecov/codecov-action@v1.0.0 20 | with: 21 | token: ${{secrets.CODECOV_TOKEN}} 22 | - name: Setup .yarnrc.yml 23 | run: | 24 | yarn config set npmAuthToken $NPM_TOKEN 25 | yarn config set npmAlwaysAuth true 26 | env: 27 | NPM_TOKEN: ${{ secrets.npm_token }} 28 | - run: yarn publish 29 | -------------------------------------------------------------------------------- /.github/workflows/pr-check.yml: -------------------------------------------------------------------------------- 1 | name: Pr check 2 | 3 | on: 4 | pull_request: 5 | branches: ["master"] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16 15 | - run: yarn install --immutable 16 | - run: yarn test --coverage 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .expo/ 3 | .pnp.* 4 | .yarn/* 5 | !.yarn/patches 6 | !.yarn/plugins 7 | !.yarn/releases 8 | !.yarn/sdks 9 | !.yarn/versions 10 | packages/b2c-sample/env/config.js 11 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Attach to metro", 9 | "request": "attach", 10 | "type": "reactnative", 11 | "cwd": "${workspaceFolder}/packages/b2c-sample", 12 | "port": 19000 13 | }, 14 | { 15 | "type": "node", 16 | "request": "launch", 17 | "name": "Jest Tests", 18 | "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", 19 | "args": ["-i"], 20 | "internalConsoleOptions": "openOnSessionStart" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | yarnPath: .yarn/releases/yarn-3.1.0.cjs 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 GSingh01 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | targets: { 7 | node: "current", 8 | }, 9 | }, 10 | ], 11 | "@babel/preset-typescript", 12 | "module:metro-react-native-babel-preset", 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /eas.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": { 3 | "version": ">= 0.42.4" 4 | }, 5 | "build": { 6 | "development": { 7 | "developmentClient": true, 8 | "distribution": "internal" 9 | }, 10 | "preview": { 11 | "distribution": "internal" 12 | }, 13 | "production": {} 14 | }, 15 | "submit": { 16 | "production": {} 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /google10abf99cd93ff1d6.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google10abf99cd93ff1d6.html -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: "react-native", 3 | setupFilesAfterEnv: ["@testing-library/jest-native/extend-expect"], 4 | transform: { 5 | "^.+\\.(ts|js)x?$": "babel-jest", 6 | }, 7 | transformIgnorePatterns: [ 8 | "/node_modules/(react-clone-referenced-element|@react-native-community|react-navigation|@react-navigation/.*|@unimodules/.*|native-base|react-native-code-push)", 9 | ], 10 | projects: ["/packages/lib"], 11 | coverageThreshold: { 12 | global: { 13 | branches: 80, 14 | functions: 80, 15 | lines: 90, 16 | statements: 90, 17 | }, 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ad-b2c-react-native-workspace", 3 | "repository": "https://github.com/GSingh01/ad-b2c-react-native.git", 4 | "author": "gsingh01 ", 5 | "license": "MIT", 6 | "private": true, 7 | "workspaces": [ 8 | "packages/*" 9 | ], 10 | "scripts": { 11 | "start": "yarn workspace b2c-sample start", 12 | "android": "yarn workspace b2c-sample android", 13 | "ios": "yarn workspace b2c-sample ios", 14 | "web": "yarn workspace b2c-sample web", 15 | "test": "jest", 16 | "watch": "jest --watch", 17 | "compile": "yarn workspace ad-b2c-react-native compile", 18 | "publish": "yarn workspace ad-b2c-react-native prep-publish", 19 | "clean": "yarn workspace ad-b2c-react-native clean" 20 | }, 21 | "installConfig": { 22 | "hoistingLimits": "workspaces" 23 | }, 24 | "packageManager": "yarn@3.1.0", 25 | "devDependencies": { 26 | "@babel/core": "^7.16.5", 27 | "@babel/preset-env": "^7.16.5", 28 | "@babel/preset-typescript": "^7.16.5", 29 | "@testing-library/jest-native": "^4.0.4", 30 | "@testing-library/react-native": "^9.0.0", 31 | "@types/babel__core": "^7.1.19", 32 | "@types/jest": "^27.0.3", 33 | "babel-jest": "^27.4.5", 34 | "jest": "^27.4.7", 35 | "metro-react-native-babel-preset": "^0.66.2" 36 | }, 37 | "resolutions": { 38 | "@types/react": "17.0.21" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/b2c-sample/.expo-shared/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true, 3 | "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true 4 | } 5 | -------------------------------------------------------------------------------- /packages/b2c-sample/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .expo/ 3 | dist/ 4 | npm-debug.* 5 | *.jks 6 | *.p8 7 | *.p12 8 | *.key 9 | *.mobileprovision 10 | *.orig.* 11 | web-build/ 12 | env/config.js 13 | # macOS 14 | .DS_Store 15 | .vscode/.react/ 16 | -------------------------------------------------------------------------------- /packages/b2c-sample/App.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Text } from "react-native"; 3 | import { NavigationContainer } from "@react-navigation/native"; 4 | import { createNativeStackNavigator } from "@react-navigation/native-stack"; 5 | import * as Linking from "expo-linking"; 6 | import Constants from "expo-constants"; 7 | 8 | import { AuthProvider } from "ad-b2c-react-native"; 9 | import Home from "./src/Home"; 10 | import Protected from "./src/Protected"; 11 | import { RootStackParamList, RouteNames } from "./src/navTypes"; 12 | import Redirect from "./src/Redirect"; 13 | 14 | const Stack = createNativeStackNavigator(); 15 | 16 | const prefix = Linking.createURL("/"); 17 | 18 | const linking = { 19 | prefixes: [prefix], 20 | }; 21 | 22 | export default function App() { 23 | return ( 24 | Loading...}> 25 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /packages/b2c-sample/__generated__/AppEntry.js: -------------------------------------------------------------------------------- 1 | // @generated by expo-yarn-workspaces 2 | 3 | import 'expo/build/Expo.fx'; 4 | import { activateKeepAwake } from 'expo-keep-awake'; 5 | import registerRootComponent from 'expo/build/launch/registerRootComponent'; 6 | 7 | import App from '../App'; 8 | 9 | if (__DEV__) { 10 | activateKeepAwake(); 11 | } 12 | 13 | registerRootComponent(App); 14 | -------------------------------------------------------------------------------- /packages/b2c-sample/app.config.js: -------------------------------------------------------------------------------- 1 | import envConfig from "./env/config"; 2 | 3 | export default ({ config }) => { 4 | return { 5 | ...config, 6 | extra: { 7 | ...envConfig, 8 | }, 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/b2c-sample/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "b2c-sample", 4 | "slug": "b2c-sample", 5 | "version": "1.0.0", 6 | "orientation": "portrait", 7 | "icon": "./assets/icon.png", 8 | "scheme": "bazaar", 9 | "splash": { 10 | "image": "./assets/splash.png", 11 | "resizeMode": "contain", 12 | "backgroundColor": "#ffffff" 13 | }, 14 | "updates": { 15 | "fallbackToCacheTimeout": 0 16 | }, 17 | "assetBundlePatterns": [ 18 | "**/*" 19 | ], 20 | "ios": { 21 | "supportsTablet": true, 22 | "bundleIdentifier": "ad.b2c.react.native.sample" 23 | }, 24 | "android": { 25 | "adaptiveIcon": { 26 | "foregroundImage": "./assets/adaptive-icon.png", 27 | "backgroundColor": "#FFFFFF" 28 | }, 29 | "package": "ad.b2c.react.native.sample" 30 | }, 31 | "web": { 32 | "favicon": "./assets/favicon.png", 33 | "build": { "babel": { "include": [ "ad-b2c-react-native" ] }} 34 | }, 35 | "sdkVersion": "45.0.0" 36 | }, 37 | "name": "b2c-sample" 38 | } -------------------------------------------------------------------------------- /packages/b2c-sample/assets/adaptive-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GSingh01/ad-b2c-react-native/8327ea34ed4452c1b5a1279a6e42b76cf1ae56f3/packages/b2c-sample/assets/adaptive-icon.png -------------------------------------------------------------------------------- /packages/b2c-sample/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GSingh01/ad-b2c-react-native/8327ea34ed4452c1b5a1279a6e42b76cf1ae56f3/packages/b2c-sample/assets/favicon.png -------------------------------------------------------------------------------- /packages/b2c-sample/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GSingh01/ad-b2c-react-native/8327ea34ed4452c1b5a1279a6e42b76cf1ae56f3/packages/b2c-sample/assets/icon.png -------------------------------------------------------------------------------- /packages/b2c-sample/assets/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GSingh01/ad-b2c-react-native/8327ea34ed4452c1b5a1279a6e42b76cf1ae56f3/packages/b2c-sample/assets/splash.png -------------------------------------------------------------------------------- /packages/b2c-sample/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | api.cache(true); 3 | return { 4 | presets: ['babel-preset-expo'], 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /packages/b2c-sample/eas.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": { 3 | "version": ">= 0.42.4" 4 | }, 5 | "build": { 6 | "development": { 7 | "developmentClient": true, 8 | "distribution": "internal", 9 | "android": { 10 | "buildType": "apk", 11 | "gradleCommand": ":app:assembleRelease" 12 | } 13 | }, 14 | "preview": { 15 | "distribution": "internal", 16 | "android": { 17 | "buildType": "apk" 18 | } 19 | }, 20 | "production": {} 21 | }, 22 | "submit": { 23 | "production": {} 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/b2c-sample/metro.config.js: -------------------------------------------------------------------------------- 1 | const { createMetroConfiguration } = require("expo-yarn-workspaces"); 2 | 3 | module.exports = createMetroConfiguration(__dirname); 4 | -------------------------------------------------------------------------------- /packages/b2c-sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "__generated__/AppEntry.js", 3 | "name": "b2c-sample", 4 | "version": "1.0.0", 5 | "scripts": { 6 | "start": "expo start --https --localhost", 7 | "android": "expo start -a --localhost", 8 | "ios": "expo start -i --localhost", 9 | "web": "expo start -w --https --localhost", 10 | "eject": "expo eject", 11 | "cpToBin": "shx cp ../../node_modules/.bin/react-native* ./node_modules/.bin/", 12 | "postinstall": "expo-yarn-workspaces postinstall & yarn cpToBin" 13 | }, 14 | "expo-yarn-workspaces": { 15 | "symlinks": [ 16 | "open", 17 | "opn", 18 | "@react-native-community/cli" 19 | ] 20 | }, 21 | "dependencies": { 22 | "@react-navigation/native": "^6.0.11", 23 | "@react-navigation/native-stack": "^6.7.0", 24 | "ad-b2c-react-native": "2.0.1", 25 | "expo": "^45.0.0", 26 | "expo-constants": "~13.1.1", 27 | "expo-dev-client": "~1.0.1", 28 | "expo-linking": "~3.1.0", 29 | "expo-modules-core": "~0.9.2", 30 | "expo-status-bar": "~1.3.0", 31 | "expo-web-browser": "~10.2.1", 32 | "react": "17.0.2", 33 | "react-dom": "17.0.2", 34 | "react-native": "0.68.2", 35 | "react-native-safe-area-context": "4.2.4", 36 | "react-native-screens": "~3.11.1", 37 | "react-native-web": "0.17.7" 38 | }, 39 | "devDependencies": { 40 | "@babel/core": "^7.12.9", 41 | "@types/babel__core": "^7.1.19", 42 | "@types/react": "~17.0.21", 43 | "@types/react-native": "~0.67.6", 44 | "expo-yarn-workspaces": "^2.0.0", 45 | "shx": "^0.3.4", 46 | "typescript": "~4.3.5" 47 | }, 48 | "resolutions": { 49 | "@types/react": "17.0.21" 50 | }, 51 | "private": true 52 | } 53 | -------------------------------------------------------------------------------- /packages/b2c-sample/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { StatusBar } from "expo-status-bar"; 3 | import { View, Text, StyleSheet, Button } from "react-native"; 4 | import { useNavigation } from "@react-navigation/native"; 5 | import { RootStackNavigationProp, RouteNames } from "./navTypes"; 6 | 7 | const styles = StyleSheet.create({ 8 | container: { 9 | flex: 1, 10 | backgroundColor: "#fff", 11 | alignItems: "center", 12 | justifyContent: "space-evenly", 13 | }, 14 | }); 15 | 16 | export default function () { 17 | const navigation = useNavigation(); 18 | 19 | return ( 20 | 21 | Open up App.tsx to start working on your app! 22 | 23 |