diff --git a/TestingApp/App.js b/TestingApp/App.js
index d49805f..b3c10ef 100644
--- a/TestingApp/App.js
+++ b/TestingApp/App.js
@@ -6,244 +6,253 @@
* @flow strict-local
*/
- import React from 'react';
- import {
- View,
- Text,
- Button
- } from 'react-native';
-
- import SuperTokens from "supertokens-react-native"
- import axios from "axios";
+import React from "react";
+import { View, Text, Button } from "react-native";
+
+import SuperTokens from "supertokens-react-native";
+import axios from "axios";
SuperTokens.addAxiosInterceptors(axios);
-const BASE_URL = "http://192.168.1.100:8080/"
-
- class App extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- loggedIn: undefined,
- sessionVerified: undefined
- };
- }
-
- render() {
- if (this.state.loggedIn === undefined) {
- return (
-
- );
- } else if (this.state.loggedIn) {
- if (this.state.sessionVerified === undefined) {
- return (
-
- );
- } else if (this.state.sessionVerified) {
- return (
-
-
- Logged in, session verification passed!
-
-
-
-
-
-
-
-
-
-
- )
- } else {
- return (
-
-
- Logged in, session verification failed
-
-
- );
- }
- } else {
- return (
-
-
-
-
-
- );
- }
- }
-
- logoutAxios = async () => {
- let response = await axios.post(`${BASE_URL}logout`, {
- withCredentials: true,
- });
-
- this.setState(oldState => {
- return {
- ...oldState,
- loggedIn: false
- }
- });
- }
-
- sessionVerifyAxios = () => {
- this.setState(oldState => {
- return {
- ...oldState,
- sessionVerified: undefined
- }
- }, async () => {
- let response = await axios.get(`${BASE_URL}`, {
- withCredentials: true
- });
-
- if (response.status === 440) {
- this.logout();
- return;
- }
-
- let resText = await response.data;
- this.setState(oldState => {
- return {
- ...oldState,
- sessionVerified: resText === "rishabh"
- }
- });
- });
- }
-
- sessionVerify = () => {
- this.setState(oldState => {
- return {
- ...oldState,
- sessionVerified: undefined
- }
- }, async () => {
- let response = await fetch(`${BASE_URL}`, {
- method: "get",
- credentials: "include"
- });
-
- if (response.status === 440) {
- this.logout();
- return;
- }
-
- let resText = await response.text();
- this.setState(oldState => {
- return {
- ...oldState,
- sessionVerified: resText === "rishabh"
- }
- });
- });
- }
-
- logout = async () => {
- let response = await fetch(`${BASE_URL}logout`, {
- method: "post",
- credentials: "include",
- });
-
- this.setState(oldState => {
- return {
- ...oldState,
- loggedIn: false
- }
- });
- }
-
- loginAxios = async () => {
- let response = await axios.post(`${BASE_URL}login`, {
- userId: "rishabh"
- }, {
- withCredentials: true
- });
-
- this.setState(oldState => {
- return {
- ...oldState,
- loggedIn: true
- }
- }, () => {
- this.sessionVerify();
- });
- }
-
- login = async () => {
- let response = await fetch(`${BASE_URL}login`, {
- method: "post",
- credentials: "include",
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- userId: "rishabh"
- })
- });
-
- this.setState(oldState => {
- return {
- ...oldState,
- loggedIn: true
- }
- }, () => {
- this.sessionVerify();
- });
- }
-
- componentDidMount() {
- SuperTokens.init({
- apiDomain: `${BASE_URL}`,
- sessionExpiredStatusCode: 440,
- })
- this.checkLogin();
- }
-
- checkLogin = async () => {
- let loggedIn = await SuperTokens.doesSessionExist();
- this.setState((oldState) => {
- return {
- ...oldState,
- loggedIn
- };
- }, () => {
- if (this.state.loggedIn) {
- this.sessionVerify();
- }
- });
- }
-
- }
-
- export default App;
-
\ No newline at end of file
+const BASE_URL = "http://192.168.1.100:8080/";
+
+class App extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ loggedIn: undefined,
+ sessionVerified: undefined
+ };
+ }
+
+ render() {
+ if (this.state.loggedIn === undefined) {
+ return (
+
+ );
+ } else if (this.state.loggedIn) {
+ if (this.state.sessionVerified === undefined) {
+ return (
+
+ );
+ } else if (this.state.sessionVerified) {
+ return (
+
+ Logged in, session verification passed!
+
+
+
+
+
+
+
+
+
+ );
+ } else {
+ return (
+
+ Logged in, session verification failed
+
+ );
+ }
+ } else {
+ return (
+
+
+
+
+
+ );
+ }
+ }
+
+ logoutAxios = async () => {
+ let response = await axios.post(`${BASE_URL}logout`, {
+ withCredentials: true
+ });
+
+ this.setState(oldState => {
+ return {
+ ...oldState,
+ loggedIn: false
+ };
+ });
+ };
+
+ sessionVerifyAxios = () => {
+ this.setState(
+ oldState => {
+ return {
+ ...oldState,
+ sessionVerified: undefined
+ };
+ },
+ async () => {
+ let response = await axios.get(`${BASE_URL}`, {
+ withCredentials: true
+ });
+
+ if (response.status === 440) {
+ this.logout();
+ return;
+ }
+
+ let resText = await response.data;
+ this.setState(oldState => {
+ return {
+ ...oldState,
+ sessionVerified: resText === "rishabh"
+ };
+ });
+ }
+ );
+ };
+
+ sessionVerify = () => {
+ this.setState(
+ oldState => {
+ return {
+ ...oldState,
+ sessionVerified: undefined
+ };
+ },
+ async () => {
+ let response = await fetch(`${BASE_URL}`, {
+ method: "get",
+ credentials: "include"
+ });
+
+ if (response.status === 440) {
+ this.logout();
+ return;
+ }
+
+ let resText = await response.text();
+ this.setState(oldState => {
+ return {
+ ...oldState,
+ sessionVerified: resText === "rishabh"
+ };
+ });
+ }
+ );
+ };
+
+ logout = async () => {
+ let response = await fetch(`${BASE_URL}logout`, {
+ method: "post",
+ credentials: "include"
+ });
+
+ this.setState(oldState => {
+ return {
+ ...oldState,
+ loggedIn: false
+ };
+ });
+ };
+
+ loginAxios = async () => {
+ let response = await axios.post(
+ `${BASE_URL}login`,
+ {
+ userId: "rishabh"
+ },
+ {
+ withCredentials: true
+ }
+ );
+
+ this.setState(
+ oldState => {
+ return {
+ ...oldState,
+ loggedIn: true
+ };
+ },
+ () => {
+ this.sessionVerify();
+ }
+ );
+ };
+
+ login = async () => {
+ let response = await fetch(`${BASE_URL}login`, {
+ method: "post",
+ credentials: "include",
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify({
+ userId: "rishabh"
+ })
+ });
+
+ this.setState(
+ oldState => {
+ return {
+ ...oldState,
+ loggedIn: true
+ };
+ },
+ () => {
+ this.sessionVerify();
+ }
+ );
+ };
+
+ componentDidMount() {
+ SuperTokens.init({
+ apiDomain: `${BASE_URL}`,
+ sessionExpiredStatusCode: 440
+ });
+ this.checkLogin();
+ }
+
+ checkLogin = async () => {
+ let loggedIn = await SuperTokens.doesSessionExist();
+ this.setState(
+ oldState => {
+ return {
+ ...oldState,
+ loggedIn
+ };
+ },
+ () => {
+ if (this.state.loggedIn) {
+ this.sessionVerify();
+ }
+ }
+ );
+ };
+}
+
+export default App;
diff --git a/TestingApp/__mocks__/@react-native-async-storage/async-storage.js b/TestingApp/__mocks__/@react-native-async-storage/async-storage.js
index 0bc2bcf..2051b5f 100644
--- a/TestingApp/__mocks__/@react-native-async-storage/async-storage.js
+++ b/TestingApp/__mocks__/@react-native-async-storage/async-storage.js
@@ -1,3 +1,3 @@
-import MockStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
+import MockStorage from "@react-native-async-storage/async-storage/jest/async-storage-mock";
-export default MockStorage;
\ No newline at end of file
+export default MockStorage;
diff --git a/TestingApp/__tests__/App-test.js b/TestingApp/__tests__/App-test.js
index 1784766..14f7d5e 100644
--- a/TestingApp/__tests__/App-test.js
+++ b/TestingApp/__tests__/App-test.js
@@ -2,13 +2,13 @@
* @format
*/
-import 'react-native';
-import React from 'react';
-import App from '../App';
+import "react-native";
+import React from "react";
+import App from "../App";
// Note: test renderer must be required after react-native.
-import renderer from 'react-test-renderer';
+import renderer from "react-test-renderer";
-it('renders correctly', () => {
- renderer.create();
+it("renders correctly", () => {
+ renderer.create();
});
diff --git a/TestingApp/babel.config.js b/TestingApp/babel.config.js
index f842b77..651fc7d 100644
--- a/TestingApp/babel.config.js
+++ b/TestingApp/babel.config.js
@@ -1,3 +1,3 @@
module.exports = {
- presets: ['module:metro-react-native-babel-preset'],
+ presets: ["module:metro-react-native-babel-preset"]
};
diff --git a/TestingApp/index.js b/TestingApp/index.js
index a850d03..881337a 100644
--- a/TestingApp/index.js
+++ b/TestingApp/index.js
@@ -2,8 +2,8 @@
* @format
*/
-import {AppRegistry} from 'react-native';
-import App from './App';
-import {name as appName} from './app.json';
+import { AppRegistry } from "react-native";
+import App from "./App";
+import { name as appName } from "./app.json";
AppRegistry.registerComponent(appName, () => App);
diff --git a/TestingApp/metro.config.js b/TestingApp/metro.config.js
index e91aba9..5868bfe 100644
--- a/TestingApp/metro.config.js
+++ b/TestingApp/metro.config.js
@@ -6,12 +6,12 @@
*/
module.exports = {
- transformer: {
- getTransformOptions: async () => ({
- transform: {
- experimentalImportSupport: false,
- inlineRequires: true,
- },
- }),
- },
+ transformer: {
+ getTransformOptions: async () => ({
+ transform: {
+ experimentalImportSupport: false,
+ inlineRequires: true
+ }
+ })
+ }
};
diff --git a/package.json b/package.json
index d855943..4a81be6 100644
--- a/package.json
+++ b/package.json
@@ -6,9 +6,9 @@
"scripts": {
"build-check": "cd lib && npx tsc -p tsconfig.json --skipLibCheck --noEmit",
"build": "cd lib && npx tsc -p tsconfig.json --skipLibCheck && cd ../ && cd test/playground && npx tsc -p tsconfig.json",
- "pretty": "npx prettier --write --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/test/**/*.js\" \"examples/**/*.js\"",
+ "pretty": "npx prettier --write --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/**/*.js\" \"examples/**/*.js\"",
"build-pretty": "npm run build && npm run pretty",
- "pretty-check": "npx prettier --check --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/test/**/*.js\" \"examples/**/*.js\"",
+ "pretty-check": "npx prettier --check --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/**/*.js\" \"examples/**/*.js\"",
"set-up-hooks": "cp hooks/pre-commit.sh .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit",
"build-docs": "rm -rf ./docs && npx typedoc --out ./docs --tsconfig ./lib/tsconfig.json ./lib/ts/index.ts",
"size": "size-limit"