├── .prettierignore ├── TestingApp ├── .watchmanconfig ├── test │ ├── server │ │ ├── .gitignore │ │ ├── package.json │ │ └── index.html │ ├── tough-cookie │ │ ├── lib │ │ │ ├── version.js │ │ │ ├── pubsuffix-psl.js │ │ │ ├── permuteDomain.js │ │ │ ├── pathMatch.js │ │ │ └── store.js │ │ ├── LICENSE │ │ └── package.json │ ├── startServer │ ├── docker │ │ └── Dockerfile │ ├── setup.js │ ├── asyncStorage.js │ └── logger.spec.js ├── .editorconfig ├── app.json ├── babel.config.js ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── testingapp │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ └── AndroidManifest.xml │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ └── _BUCK │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ └── gradlew.bat ├── ios │ ├── TestingApp │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Info.plist │ │ └── AppDelegate.m │ ├── TestingApp.xcworkspace │ │ └── contents.xcworkspacedata │ ├── TestingAppTests │ │ ├── Info.plist │ │ └── TestingAppTests.m │ └── Podfile ├── .buckconfig ├── .gitattributes ├── __mocks__ │ └── @react-native-async-storage │ │ └── async-storage.js ├── index.js ├── __tests__ │ └── App-test.js ├── metro.config.js ├── simulatorInstrs.txt ├── .gitignore ├── .flowconfig └── package.json ├── .gitattributes ├── examples └── with-thirdparty │ ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values-night │ │ │ │ │ │ └── colors.xml │ │ │ │ │ ├── drawable │ │ │ │ │ │ ├── splashscreen.xml │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── drawable-hdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-mdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── values │ │ │ │ │ │ ├── colors.xml │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── mipmap-anydpi-v26 │ │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── supertokens │ │ │ │ │ └── supertokensexample │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── release │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── supertokens │ │ │ │ └── supertokensexample │ │ │ │ └── ReactNativeFlipper.java │ │ └── proguard-rules.pro │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ └── gradlew.bat │ ├── constants.ts │ ├── ios │ ├── Podfile.properties.json │ ├── withthirdparty │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ ├── SplashScreen.imageset │ │ │ │ ├── image.png │ │ │ │ └── Contents.json │ │ │ ├── SplashScreenBackground.imageset │ │ │ │ ├── image.png │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── App-Icon-1024x1024@1x.png │ │ │ │ └── Contents.json │ │ ├── noop-file.swift │ │ ├── withthirdparty-Bridging-Header.h │ │ ├── main.m │ │ ├── AppDelegate.h │ │ ├── withthirdparty.entitlements │ │ ├── Supporting │ │ │ └── Expo.plist │ │ ├── Info.plist │ │ └── AppDelegate.mm │ ├── withthirdparty.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── .gitignore │ └── .xcode.env │ ├── tsconfig.json │ ├── types.ts │ ├── assets │ ├── icon.png │ ├── favicon.png │ ├── splash.png │ └── adaptive-icon.png │ ├── babel.config.js │ ├── .gitignore │ ├── backend │ ├── package.json │ ├── index.ts │ └── config.ts │ ├── app.json │ ├── package.json │ ├── splash.tsx │ ├── google.ts │ ├── apple.ts │ ├── App.tsx │ ├── github.ts │ └── login.tsx ├── docs ├── assets │ ├── hierarchy.js │ ├── navigation.js │ ├── highlight.css │ └── search.js └── .nojekyll ├── .prettierrc ├── lib ├── build │ ├── version.d.ts │ ├── recipeImplementation.d.ts │ ├── axiosError.d.ts │ ├── normalisedURLDomain.d.ts │ ├── logger.d.ts │ ├── normalisedURLPath.d.ts │ ├── locking.d.ts │ ├── antiCsrf.d.ts │ ├── error.d.ts │ ├── processState.d.ts │ ├── frontToken.d.ts │ ├── types.js │ ├── version.js │ ├── index.d.ts │ ├── error.js │ ├── axios.d.ts │ ├── fetch.d.ts │ ├── logger.js │ ├── utils.d.ts │ ├── locking.js │ ├── normalisedURLDomain.js │ ├── normalisedURLPath.js │ └── types.d.ts ├── tsconfig.json ├── ts │ ├── version.ts │ ├── error.ts │ ├── logger.ts │ ├── locking.ts │ ├── processState.ts │ └── normalisedURLDomain.ts └── tslint.json ├── ios ├── Podfile ├── RNSuperTokens.xcworkspace │ └── contents.xcworkspacedata ├── RNSuperTokens.podspec ├── RNSuperTokens.h └── RNSuperTokens.m ├── android ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── reactlibrary │ │ ├── RNSuperTokensModule.java │ │ └── RNSuperTokensPackage.java ├── build.gradle └── .project ├── frontendDriverInterfaceSupported.json ├── .npmignore ├── .circleci ├── generateConfig.sh ├── publish.sh ├── updateDocsInWebsite.sh ├── markDevTagAsTestNotPassed.sh ├── markAsSuccess.sh ├── config.yml ├── setupAndTestWithFreeCore.sh ├── config_continue.yml └── doTests.sh ├── index.d.ts ├── utils └── error │ ├── index.d.ts │ └── index.js ├── .github ├── workflows │ ├── size-limit.yml │ ├── github-actions-changelog.yml │ ├── lint-pr-title.yml │ └── pre-commit-hook-run.yml └── PULL_REQUEST_TEMPLATE.md ├── test └── playground │ └── tsconfig.json ├── .gitignore ├── index.js ├── README.md ├── otherInfo.txt ├── package.json └── addDevTag /.prettierignore: -------------------------------------------------------------------------------- 1 | docs/ 2 | -------------------------------------------------------------------------------- /TestingApp/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | lib/build/* linguist-generated=true -------------------------------------------------------------------------------- /TestingApp/test/server/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | package-lock.json -------------------------------------------------------------------------------- /TestingApp/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /TestingApp/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TestingApp", 3 | "displayName": "TestingApp" 4 | } -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/with-thirdparty/constants.ts: -------------------------------------------------------------------------------- 1 | export const API_DOMAIN = "http://192.168.29.87:3001"; 2 | -------------------------------------------------------------------------------- /docs/assets/hierarchy.js: -------------------------------------------------------------------------------- 1 | window.hierarchyData = "eJyrVirKzy8pVrKKjtVRKkpNy0lNLsnMzytWsqqurQUAmx4Kpg==" -------------------------------------------------------------------------------- /TestingApp/test/tough-cookie/lib/version.js: -------------------------------------------------------------------------------- 1 | // generated by genversion 2 | module.exports = "3.0.1"; 3 | -------------------------------------------------------------------------------- /TestingApp/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["module:metro-react-native-babel-preset"] 3 | }; 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "semi": true, 4 | "singleQuote": false, 5 | "printWidth": 120 6 | } -------------------------------------------------------------------------------- /lib/build/version.d.ts: -------------------------------------------------------------------------------- 1 | export declare const package_version = "5.1.5"; 2 | export declare const supported_fdi: string[]; 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | use_frameworks! 3 | 4 | target 'RNSuperTokens' do 5 | pod 'SuperTokensSession', '~> 1.1.2' 6 | end -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TestingApp 3 | 4 | -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /TestingApp/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/debug.keystore -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/Podfile.properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo.jsEngine": "hermes", 3 | "EX_DEV_CLIENT_NETWORK_INSPECTOR": "true" 4 | } 5 | -------------------------------------------------------------------------------- /examples/with-thirdparty/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "expo/tsconfig.base", 3 | "compilerOptions": { 4 | "strict": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-thirdparty/types.ts: -------------------------------------------------------------------------------- 1 | type RootStackParamList = { 2 | Splash: undefined; 3 | Home: undefined; 4 | Login: undefined; 5 | }; 6 | -------------------------------------------------------------------------------- /examples/with-thirdparty/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/assets/icon.png -------------------------------------------------------------------------------- /lib/build/recipeImplementation.d.ts: -------------------------------------------------------------------------------- 1 | import { RecipeInterface } from "./types"; 2 | export default function RecipeImplementation(): RecipeInterface; 3 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /examples/with-thirdparty/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/assets/favicon.png -------------------------------------------------------------------------------- /examples/with-thirdparty/assets/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/assets/splash.png -------------------------------------------------------------------------------- /TestingApp/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "expo" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /TestingApp/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /TestingApp/test/startServer: -------------------------------------------------------------------------------- 1 | # use: ./test/startServer ../../../com-root 2 | (cd test/server && TEST_MODE=testing INSTALL_PATH=../../$1 NODE_PORT=$2 TRANSFER_METHOD=$3 node .) -------------------------------------------------------------------------------- /examples/with-thirdparty/assets/adaptive-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/assets/adaptive-icon.png -------------------------------------------------------------------------------- /lib/build/axiosError.d.ts: -------------------------------------------------------------------------------- 1 | import { AxiosError } from "axios"; 2 | export declare function createAxiosErrorFromFetchResp(responseOrError: Response): Promise; 3 | -------------------------------------------------------------------------------- /TestingApp/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/with-thirdparty/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | api.cache(true); 3 | return { 4 | presets: ["babel-preset-expo"] 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/noop-file.swift: -------------------------------------------------------------------------------- 1 | // 2 | // @generated 3 | // A blank Swift file must be created for native modules with Swift files to work correctly. 4 | // 5 | -------------------------------------------------------------------------------- /lib/build/normalisedURLDomain.d.ts: -------------------------------------------------------------------------------- 1 | export default class NormalisedURLDomain { 2 | private value; 3 | constructor(url: string); 4 | getAsStringDangerous: () => string; 5 | } 6 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/withthirdparty-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /lib/build/logger.d.ts: -------------------------------------------------------------------------------- 1 | export declare function enableLogging(): void; 2 | export declare function disableLogging(): void; 3 | export declare function logDebugMessage(message: string): void; 4 | -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestingApp/__mocks__/@react-native-async-storage/async-storage.js: -------------------------------------------------------------------------------- 1 | import MockStorage from "@react-native-async-storage/async-storage/jest/async-storage-mock"; 2 | 3 | export default MockStorage; 4 | -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/TestingApp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable/splashscreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'TestingApp' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Android/IntelliJ 6 | # 7 | build/ 8 | .idea 9 | .gradle 10 | local.properties 11 | *.iml 12 | *.hprof 13 | 14 | # Bundle artifacts 15 | *.jsbundle 16 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable-hdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/drawable-hdpi/splashscreen_image.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable-mdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/drawable-mdpi/splashscreen_image.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /TestingApp/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import { AppRegistry } from "react-native"; 6 | import App from "./App"; 7 | import { name as appName } from "./app.json"; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreen.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreen.imageset/image.png -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreenBackground.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreenBackground.imageset/image.png -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TestingApp/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-react-native/HEAD/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | #ffffff 3 | #ffffff 4 | #023c69 5 | #ffffff 6 | -------------------------------------------------------------------------------- /lib/build/normalisedURLPath.d.ts: -------------------------------------------------------------------------------- 1 | export default class NormalisedURLPath { 2 | private value; 3 | constructor(url: string); 4 | startsWith: (other: NormalisedURLPath) => boolean; 5 | appendPath: (other: NormalisedURLPath) => NormalisedURLPath; 6 | getAsStringDangerous: () => string; 7 | } 8 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /ios/RNSuperTokens.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | with-thirdparty 3 | contain 4 | false 5 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TestingApp/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import "react-native"; 6 | import React from "react"; 7 | import App from "../App"; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from "react-test-renderer"; 11 | 12 | it("renders correctly", () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "filename": "App-Icon-1024x1024@1x.png", 5 | "idiom": "universal", 6 | "platform": "ios", 7 | "size": "1024x1024" 8 | } 9 | ], 10 | "info": { 11 | "version": 1, 12 | "author": "expo" 13 | } 14 | } -------------------------------------------------------------------------------- /frontendDriverInterfaceSupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "contains a list of frontend-backend interface versions that this package supports", 3 | "versions": [ 4 | "1.16", 5 | "1.17", 6 | "1.18", 7 | "1.19", 8 | "2.0", 9 | "3.0", 10 | "3.1", 11 | "4.0", 12 | "4.1" 13 | ] 14 | } -------------------------------------------------------------------------------- /docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "eJyN0DFPwzAQBeD/4jkiNAgB2TowZAK1ZUIMxr4kp7q25bugRIj/joCoJanrdvV777Pl10/B0LMohYZadoZFJrzkVpRCGUkElI/BVcs7IzKxRatFuSjuv7L9trK+483g4bDmwQPl+2C6Lq4f7ha3xT9hBQo9VJYh1FIdObP4nCa1Xvbo6HegwLMLdCA/ZED5boDyWG9q30xYZth5XkEdgFq0zRqI0NkofaKb4LUDGluPPRLH2HknwTXAS6WAaOO2EH3jtHEx9SwH46Reg+oCmOG8PBukL3ohCJU+gf6FCQAtRv/t5zwxI2zsUxddjtHR+O0bcjkeyw==" -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | **/*.ts 2 | !**/*.d.ts 3 | .git/ 4 | test/ 5 | hooks/ 6 | .circleci/ 7 | lib/tsconfig.json 8 | .mocharc.yml 9 | .prettierrc 10 | lib/tslint.json 11 | addDevTag 12 | addReleaseTag 13 | frontendDriverInterfaceSupported.json 14 | .github/ 15 | .babelrc 16 | /TestingApp 17 | /android 18 | /ios 19 | /otherInfo.txt 20 | /test 21 | /docs 22 | .prettierignore 23 | /examples -------------------------------------------------------------------------------- /lib/build/locking.d.ts: -------------------------------------------------------------------------------- 1 | declare class Locking { 2 | static instance: undefined | Locking; 3 | private locked; 4 | static getInstance(): Locking; 5 | private addToLocked; 6 | isLocked: (key: string) => boolean; 7 | lock: (key: string) => Promise; 8 | unlock: (key: string) => void; 9 | } 10 | export default function getLock(): Locking; 11 | export {}; 12 | -------------------------------------------------------------------------------- /.circleci/generateConfig.sh: -------------------------------------------------------------------------------- 1 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 2 | frontendDriverArray=`echo $frontendDriverJson | jq ".versions"` 3 | 4 | if [ -z "$SUPERTOKENS_API_KEY" ]; then 5 | echo "SUPERTOKENS_API_KEY missing" 6 | exit 1; 7 | fi 8 | 9 | sed -i -e 's/fdi-version: placeholder/fdi-version: '`printf "%q" $frontendDriverArray`'/' config_continue.yml 10 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./lib/build/"; 2 | /** 3 | * 'export *' does not re-export a default. 4 | * import SuperTokens from "supertokens-react-native"; 5 | * the above import statement won't be possible unless either 6 | * - user add "esModuleInterop": true in their tsconfig.json file 7 | * - we do the following change: 8 | */ 9 | import * as _default from "./lib/build"; 10 | export default _default; -------------------------------------------------------------------------------- /TestingApp/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: true 14 | } 15 | }) 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /utils/error/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "../../lib/build/error"; 2 | /** 3 | * 'export *' does not re-export a default. 4 | * import SuperTokens from "supertokens-react-native"; 5 | * the above import statement won't be possible unless either 6 | * - user add "esModuleInterop": true in their tsconfig.json file 7 | * - we do the following change: 8 | */ 9 | import * as _default from "../../lib/build/error"; 10 | export default _default; -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import "RNAppAuthAuthorizationFlowManager.h" 6 | 7 | @interface AppDelegate : EXAppDelegateWrapper 8 | 9 | @property(nonatomic, weak) id authorizationFlowManagerDelegate; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/withthirdparty.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | com.apple.developer.applesignin 8 | 9 | Default 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2016", 4 | "noImplicitAny": true, 5 | "allowSyntheticDefaultImports": true, 6 | "strictNullChecks": true, 7 | "noImplicitThis": true, 8 | "module": "ES6", 9 | "outDir": "build", 10 | "moduleResolution": "node", 11 | "declaration": true, 12 | "skipLibCheck": true 13 | }, 14 | "compileOnSave": true, 15 | } -------------------------------------------------------------------------------- /lib/build/antiCsrf.d.ts: -------------------------------------------------------------------------------- 1 | export default class AntiCSRF { 2 | private static tokenInfo; 3 | private constructor(); 4 | private static getAntiCSRFToken; 5 | static getToken(associatedAccessTokenUpdate: string | undefined): Promise; 6 | private static setAntiCSRF; 7 | static setItem(associatedAccessTokenUpdate: string | undefined, antiCsrf: string): Promise; 8 | static removeToken(): Promise; 9 | } 10 | -------------------------------------------------------------------------------- /lib/build/error.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This error usually indicates that the API exposed by the backend SDKs responded 3 | * with `{status: "GENERAL_ERROR"}`. This should be used to show errors to the user 4 | * in your frontend application. 5 | */ 6 | export declare class SuperTokensGeneralError extends Error { 7 | isSuperTokensGeneralError: boolean; 8 | constructor(message: string); 9 | static isThisError(err: any): err is SuperTokensGeneralError; 10 | } 11 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreen.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "universal", 5 | "filename": "image.png", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "universal", 10 | "scale": "2x" 11 | }, 12 | { 13 | "idiom": "universal", 14 | "scale": "3x" 15 | } 16 | ], 17 | "info": { 18 | "version": 1, 19 | "author": "expo" 20 | } 21 | } -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/java/com/testingapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.testingapp; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "TestingApp"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreenBackground.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "universal", 5 | "filename": "image.png", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "universal", 10 | "scale": "2x" 11 | }, 12 | { 13 | "idiom": "universal", 14 | "scale": "3x" 15 | } 16 | ], 17 | "info": { 18 | "version": 1, 19 | "author": "expo" 20 | } 21 | } -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | .xcode.env.local 25 | 26 | # Bundle artifacts 27 | *.jsbundle 28 | 29 | # CocoaPods 30 | /Pods/ 31 | -------------------------------------------------------------------------------- /TestingApp/simulatorInstrs.txt: -------------------------------------------------------------------------------- 1 | - run ./startDevEnd COMMERCIAL DOWNGRADE in com-root 2 | - change config.yaml file to have cookie_domain as 192.168.1.112 3 | - run in com-root: java -classpath "./core/*:./plugin-interface/*" io.supertokens.Main ./ DEV port=9000 4 | - go to ./Example/test/server and run TEST_MODE=testing INSTALL_PATH=../../../../com-root node . 5 | - go to Example folder and run npm run ios 6 | - To test on android, open android studio -> tools -> avd manager -> start a simulator -> run npm run android -------------------------------------------------------------------------------- /TestingApp/test/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "cookie-parser": "1.4.4", 13 | "cors": "^2.8.5", 14 | "express": "4.17.1", 15 | "morgan": "^1.10.0", 16 | "node-fetch": "^2.7.0", 17 | "supertokens-node": "^22.1.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TestingApp/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /lib/build/processState.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum PROCESS_STATE { 2 | CALLING_INTERCEPTION_REQUEST = 0, 3 | CALLING_INTERCEPTION_RESPONSE = 1 4 | } 5 | export declare class ProcessState { 6 | history: PROCESS_STATE[]; 7 | private static instance; 8 | static getInstance(): ProcessState; 9 | addState: (state: PROCESS_STATE) => void; 10 | private getEventByLastEventByName; 11 | reset: () => void; 12 | waitForEvent: (state: PROCESS_STATE, timeInMS?: number) => Promise; 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/size-limit.yml: -------------------------------------------------------------------------------- 1 | name: "size" 2 | on: 3 | pull_request: 4 | types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] 5 | jobs: 6 | size: 7 | runs-on: ubuntu-latest 8 | env: 9 | CI_JOB_NUMBER: 1 10 | steps: 11 | - uses: actions/checkout@v1 12 | - uses: supertokens/size-limit-action@feature/continue_on_base_branch_error 13 | with: 14 | github_token: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /.circleci/publish.sh: -------------------------------------------------------------------------------- 1 | version=$(cat ../package.json | jq .version | tr -d '"') 2 | isLatest=`curl -s -X GET \ 3 | "https://api.supertokens.io/0/frontend/latest/check?password=$SUPERTOKENS_API_KEY&version=$version&name=react-native" \ 4 | -H 'api-version: 0'` 5 | if [[ $? -ne 0 ]] 6 | then 7 | echo "api not working... exiting!" 8 | exit 1 9 | fi 10 | if [[ `echo $isLatest | jq .isLatest` == "true" ]] 11 | then 12 | cd .. 13 | npm publish --tag latest 14 | else 15 | cd .. 16 | npm publish --tag version-$version 17 | fi -------------------------------------------------------------------------------- /.github/workflows/github-actions-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Enforcing changelog in PRs Workflow" 2 | on: 3 | pull_request: 4 | types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] 5 | 6 | jobs: 7 | # Enforces the update of a changelog file on every pull request 8 | changelog: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: dangoslen/changelog-enforcer@v2 13 | with: 14 | changeLogPath: 'CHANGELOG.md' 15 | skipLabels: 'Skip-Changelog' -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/withthirdparty/Supporting/Expo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | EXUpdatesCheckOnLaunch 6 | ALWAYS 7 | EXUpdatesEnabled 8 | 9 | EXUpdatesLaunchWaitMs 10 | 0 11 | EXUpdatesSDKVersion 12 | 49.0.0 13 | 14 | -------------------------------------------------------------------------------- /examples/with-thirdparty/ios/.xcode.env: -------------------------------------------------------------------------------- 1 | # This `.xcode.env` file is versioned and is used to source the environment 2 | # used when running script phases inside Xcode. 3 | # To customize your local environment, you can create an `.xcode.env.local` 4 | # file that is not versioned. 5 | 6 | # NODE_BINARY variable contains the PATH to the node executable. 7 | # 8 | # Customize the NODE_BINARY variable here. 9 | # For example, to use nvm with brew, add the following line 10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use 11 | export NODE_BINARY=$(command -v node) 12 | -------------------------------------------------------------------------------- /.github/workflows/lint-pr-title.yml: -------------------------------------------------------------------------------- 1 | name: "Lint PR Title" 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - reopened 8 | - edited 9 | - synchronize 10 | 11 | jobs: 12 | pr-title: 13 | name: Lint PR title 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: amannn/action-semantic-pull-request@v3 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | with: 20 | validateSingleCommit: true -------------------------------------------------------------------------------- /lib/build/frontToken.d.ts: -------------------------------------------------------------------------------- 1 | export default class FrontToken { 2 | private static waiters; 3 | private constructor(); 4 | private static getFrontTokenFromStorage; 5 | static getFrontToken(): Promise; 6 | static getTokenInfo(): Promise<{ 7 | uid: string; 8 | ate: number; 9 | up: any; 10 | } | undefined>; 11 | private static setFrontToken; 12 | static removeToken(): Promise; 13 | static setItem(frontToken: string): Promise; 14 | static doesTokenExists(): Promise; 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-thirdparty/.gitignore: -------------------------------------------------------------------------------- 1 | # Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files 2 | 3 | # dependencies 4 | node_modules/ 5 | 6 | # Expo 7 | .expo/ 8 | dist/ 9 | web-build/ 10 | 11 | # Native 12 | *.orig.* 13 | *.jks 14 | *.p8 15 | *.p12 16 | *.key 17 | *.mobileprovision 18 | 19 | # Metro 20 | .metro-health-check* 21 | 22 | # debug 23 | npm-debug.* 24 | yarn-debug.* 25 | yarn-error.* 26 | 27 | # macOS 28 | .DS_Store 29 | *.pem 30 | 31 | # local env files 32 | .env*.local 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | -------------------------------------------------------------------------------- /TestingApp/test/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rishabhpoddar/supertokens_node_driver_testing 2 | 3 | RUN apt-get update 4 | 5 | RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget -------------------------------------------------------------------------------- /TestingApp/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-code-background: #FFFFFF; 3 | --dark-code-background: #1E1E1E; 4 | } 5 | 6 | @media (prefers-color-scheme: light) { :root { 7 | --code-background: var(--light-code-background); 8 | } } 9 | 10 | @media (prefers-color-scheme: dark) { :root { 11 | --code-background: var(--dark-code-background); 12 | } } 13 | 14 | :root[data-theme='light'] { 15 | --code-background: var(--light-code-background); 16 | } 17 | 18 | :root[data-theme='dark'] { 19 | --code-background: var(--dark-code-background); 20 | } 21 | 22 | pre, code { background: var(--code-background); } 23 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # react-native-reanimated 11 | -keep class com.swmansion.reanimated.** { *; } 12 | -keep class com.facebook.react.turbomodule.** { *; } 13 | 14 | # Add any project specific keep options here: 15 | -------------------------------------------------------------------------------- /test/playground/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "strictNullChecks": true, 5 | "module": "commonJS", 6 | "moduleResolution": "Node", 7 | "skipLibCheck": true, 8 | "noFallthroughCasesInSwitch": true, 9 | "lib": ["ES2017"], 10 | "noEmit": true, 11 | "strict": true, 12 | "jsx": "react-native", 13 | "esModuleInterop": true, 14 | "isolatedModules": true, 15 | "allowJs": true, 16 | "allowSyntheticDefaultImports": true, 17 | }, 18 | "include": ["./**/*"], 19 | "exclude": ["build"], 20 | "compileOnSave": true 21 | } -------------------------------------------------------------------------------- /examples/with-thirdparty/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'with-thirdparty' 2 | 3 | apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle"); 4 | useExpoModules() 5 | 6 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); 7 | applyNativeModulesSettingsGradle(settings) 8 | 9 | include ':app' 10 | includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile()) 11 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | } 10 | } 11 | 12 | apply plugin: 'com.android.library' 13 | 14 | android { 15 | compileSdkVersion 23 16 | buildToolsVersion "23.0.1" 17 | 18 | defaultConfig { 19 | minSdkVersion 16 20 | targetSdkVersion 22 21 | versionCode 1 22 | versionName "1.0" 23 | } 24 | lintOptions { 25 | abortOnError false 26 | } 27 | } 28 | 29 | repositories { 30 | mavenCentral() 31 | } 32 | 33 | dependencies { 34 | compile 'com.facebook.react:react-native:+' 35 | } 36 | -------------------------------------------------------------------------------- /TestingApp/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactlibrary/RNSuperTokensModule.java: -------------------------------------------------------------------------------- 1 | 2 | package com.reactlibrary; 3 | 4 | import com.facebook.react.bridge.ReactApplicationContext; 5 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 6 | import com.facebook.react.bridge.ReactMethod; 7 | import com.facebook.react.bridge.Callback; 8 | 9 | public class RNSuperTokensModule extends ReactContextBaseJavaModule { 10 | 11 | private final ReactApplicationContext reactContext; 12 | 13 | public RNSuperTokensModule(ReactApplicationContext reactContext) { 14 | super(reactContext); 15 | this.reactContext = reactContext; 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "RNSuperTokens"; 21 | } 22 | } -------------------------------------------------------------------------------- /lib/build/types.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | export {}; 16 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit-hook-run.yml: -------------------------------------------------------------------------------- 1 | name: "Pre commit hook check" 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - reopened 8 | - edited 9 | - synchronize 10 | 11 | jobs: 12 | pre-commit-check: 13 | name: Pre commit hook check 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set up node 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: 16 21 | - run: rm -rf .git && git init && git add --all && git -c user.name='test' -c user.email='test@example.com' commit -m 'init for pr action' 22 | - run: npm i --force 23 | - run: ./hooks/pre-commit.sh -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /ios/Pods 3 | /ios/Podflie.lock 4 | /node_modules 5 | .DS_Store 6 | /.history 7 | .vscode 8 | coverage 9 | apiPassword 10 | releasePassword 11 | 12 | 13 | # OSX 14 | # 15 | .DS_Store 16 | 17 | # node.js 18 | # 19 | node_modules/ 20 | npm-debug.log 21 | yarn-error.log 22 | yarn.lock 23 | 24 | 25 | # Xcode 26 | # 27 | build/ 28 | *.pbxuser 29 | !default.pbxuser 30 | *.mode1v3 31 | !default.mode1v3 32 | *.mode2v3 33 | !default.mode2v3 34 | *.perspectivev3 35 | !default.perspectivev3 36 | xcuserdata 37 | *.xccheckout 38 | *.moved-aside 39 | DerivedData 40 | *.hmap 41 | *.ipa 42 | *.xcuserstate 43 | project.xcworkspace 44 | 45 | 46 | # Android/IntelliJ 47 | # 48 | build/ 49 | .idea 50 | .gradle 51 | local.properties 52 | *.iml 53 | 54 | # BUCK 55 | buck-out/ 56 | \.buckd/ 57 | *.keystore 58 | 59 | !lib/build/ -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | import SuperTokens from "./lib/build/index.js"; 17 | export default SuperTokens; 18 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android 4 | Project android created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | 19 | 1715234366601 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /utils/error/index.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | import SuperTokens from "../../lib/build/error.js"; 17 | export default SuperTokens; 18 | -------------------------------------------------------------------------------- /ios/RNSuperTokens.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = "RNSuperTokens" 4 | s.version = "0.0.1" 5 | s.summary = "RNSuperTokens" 6 | s.description = <<-DESC 7 | RNSuperTokens 8 | DESC 9 | s.homepage = "https://github.com/supertokens/supertokens-react-native" 10 | s.license = "Apache 2.0" 11 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 12 | s.author = { "author" => "team@supertokens.io" } 13 | s.platform = :ios, "7.0" 14 | s.source = { :git => "https://github.com/supertokens/supertokens-react-native.git", :tag => "master" } 15 | s.source_files = "./**/*.{h,m}" 16 | s.requires_arc = true 17 | 18 | 19 | s.dependency "React" 20 | s.dependency "SuperTokensSession",'~> 1.1.0' 21 | #s.dependency "others" 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /TestingApp/ios/TestingAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/release/java/com/supertokens/supertokensexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.supertokens.supertokensexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.react.ReactInstanceManager; 11 | 12 | /** 13 | * Class responsible of loading Flipper inside your React Native application. This is the release 14 | * flavor of it so it's empty as we don't want to load Flipper. 15 | */ 16 | public class ReactNativeFlipper { 17 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 18 | // Do nothing as we don't want to initialize Flipper on Release. 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/build/version.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | export const package_version = "5.1.5"; 16 | export const supported_fdi = ["1.16", "1.17", "1.18", "1.19", "2.0", "3.0", "3.1", "4.0", "4.1"]; 17 | -------------------------------------------------------------------------------- /lib/ts/version.ts: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | export const package_version = "5.1.5"; 16 | 17 | export const supported_fdi = ["1.16", "1.17", "1.18", "1.19", "2.0", "3.0", "3.1", "4.0", "4.1"]; 18 | -------------------------------------------------------------------------------- /examples/with-thirdparty/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "supertokens-node", 3 | "version": "0.0.1", 4 | "private": true, 5 | "description": "", 6 | "main": "index.js", 7 | "scripts": { 8 | "start": "npx ts-node-dev --project ./tsconfig.json ./index.ts" 9 | }, 10 | "dependencies": { 11 | "cors": "^2.8.5", 12 | "express": "^4.18.1", 13 | "helmet": "^5.1.0", 14 | "morgan": "^1.10.0", 15 | "npm-run-all": "^4.1.5", 16 | "supertokens-node": "latest", 17 | "ts-node-dev": "^2.0.0", 18 | "typescript": "^4.7.2" 19 | }, 20 | "devDependencies": { 21 | "@types/cors": "^2.8.12", 22 | "@types/express": "^4.17.17", 23 | "@types/morgan": "^1.9.3", 24 | "@types/node": "^16.11.38", 25 | "nodemon": "^2.0.16" 26 | }, 27 | "keywords": [], 28 | "author": "", 29 | "license": "ISC" 30 | } 31 | -------------------------------------------------------------------------------- /TestingApp/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | 6 | target 'TestingApp' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | target 'TestingAppTests' do 16 | inherit! :complete 17 | # Pods for testing 18 | end 19 | 20 | # Enables Flipper. 21 | # 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and 23 | # you should disable the next line. 24 | use_flipper!() 25 | 26 | post_install do |installer| 27 | react_native_post_install(installer) 28 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /examples/with-thirdparty/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "with-thirdparty", 4 | "slug": "with-thirdparty", 5 | "version": "1.0.0", 6 | "orientation": "portrait", 7 | "icon": "./assets/icon.png", 8 | "userInterfaceStyle": "light", 9 | "splash": { 10 | "image": "./assets/splash.png", 11 | "resizeMode": "contain", 12 | "backgroundColor": "#ffffff" 13 | }, 14 | "assetBundlePatterns": ["**/*"], 15 | "ios": { 16 | "supportsTablet": true, 17 | "bundleIdentifier": "com.supertokens.with-thirdparty" 18 | }, 19 | "android": { 20 | "adaptiveIcon": { 21 | "foregroundImage": "./assets/adaptive-icon.png", 22 | "backgroundColor": "#ffffff" 23 | }, 24 | "package": "com.supertokens.supertokensexample" 25 | }, 26 | "web": { 27 | "favicon": "./assets/favicon.png" 28 | }, 29 | "plugins": ["@react-native-google-signin/google-signin"] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ios/RNSuperTokens.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | #if __has_include("RCTBridgeModule.h") 17 | #import "RCTBridgeModule.h" 18 | #else 19 | #import 20 | #endif 21 | 22 | @interface RNSuperTokens : NSObject 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /examples/with-thirdparty/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) 2 | 3 | # SuperTokens React Native SDK 4 | 5 | 6 | chat on Discord 8 | 9 | ## About 10 | This is a react native SDK that is responsible for maintaining a SuperTokens session for mobile apps. 11 | 12 | Learn more at https://supertokens.io 13 | 14 | ## Documentation 15 | To see documentation, please click [here](https://supertokens.io/docs/community/introduction). 16 | 17 | ## Contributing 18 | Please refer to the [CONTRIBUTING.md](https://github.com/supertokens/supertokens-react-native/blob/master/CONTRIBUTING.md) file in this repo. 19 | 20 | ## Contact us 21 | For any queries, or support requests, please email us at team@supertokens.io, or join our [Discord](supertokens.io/discord) server. 22 | 23 | ## Authors 24 | Created with :heart: by the folks at SuperTokens.io. -------------------------------------------------------------------------------- /android/src/main/java/com/reactlibrary/RNSuperTokensPackage.java: -------------------------------------------------------------------------------- 1 | 2 | package com.reactlibrary; 3 | 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.bridge.NativeModule; 10 | import com.facebook.react.bridge.ReactApplicationContext; 11 | import com.facebook.react.uimanager.ViewManager; 12 | import com.facebook.react.bridge.JavaScriptModule; 13 | public class RNSuperTokensPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Arrays.asList(new RNSuperTokensModule(reactContext)); 17 | } 18 | 19 | // Deprecated from RN 0.47 20 | public List> createJSModules() { 21 | return Collections.emptyList(); 22 | } 23 | 24 | @Override 25 | public List createViewManagers(ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | } -------------------------------------------------------------------------------- /TestingApp/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TestingApp/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | *.hprof 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | -------------------------------------------------------------------------------- /examples/with-thirdparty/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-thirdparty", 3 | "version": "1.0.0", 4 | "main": "node_modules/expo/AppEntry.js", 5 | "scripts": { 6 | "start": "expo start", 7 | "android": "expo run:android", 8 | "ios": "expo run:ios", 9 | "web": "expo start --web" 10 | }, 11 | "dependencies": { 12 | "@invertase/react-native-apple-authentication": "^2.3.0", 13 | "@react-native-async-storage/async-storage": "^1.18.2", 14 | "@react-native-google-signin/google-signin": "^10.1.0", 15 | "@react-navigation/native": "^6.1.9", 16 | "@react-navigation/native-stack": "^6.9.17", 17 | "expo": "~49.0.15", 18 | "expo-splash-screen": "~0.20.5", 19 | "expo-status-bar": "~1.6.0", 20 | "react": "18.2.0", 21 | "react-native": "0.72.6", 22 | "react-native-app-auth": "^7.1.0", 23 | "react-native-safe-area-context": "4.6.3", 24 | "react-native-screens": "~3.22.0", 25 | "supertokens-react-native": "^4.0.8" 26 | }, 27 | "devDependencies": { 28 | "@babel/core": "^7.20.0", 29 | "@types/react": "~18.2.14", 30 | "typescript": "^5.1.3" 31 | }, 32 | "private": true 33 | } 34 | -------------------------------------------------------------------------------- /examples/with-thirdparty/splash.tsx: -------------------------------------------------------------------------------- 1 | import { NativeStackScreenProps } from "@react-navigation/native-stack"; 2 | import { useEffect } from "react"; 3 | import { View, Text, StyleSheet } from "react-native"; 4 | import SuperTokens from "supertokens-react-native"; 5 | 6 | type Props = NativeStackScreenProps; 7 | 8 | export const SplashScreen = ({ navigation }: Props) => { 9 | const checkSessionExists = async () => { 10 | const sessionExists = await SuperTokens.doesSessionExist(); 11 | 12 | if (sessionExists) { 13 | navigation.replace("Home"); 14 | } else { 15 | navigation.replace("Login"); 16 | } 17 | }; 18 | 19 | useEffect(() => { 20 | checkSessionExists(); 21 | }, []); 22 | 23 | return ( 24 | 25 | SuperTokens Example 26 | 27 | ); 28 | }; 29 | 30 | const styles = StyleSheet.create({ 31 | container: { 32 | flex: 1, 33 | backgroundColor: "#fff", 34 | alignItems: "center", 35 | justifyContent: "center", 36 | }, 37 | text: { 38 | fontSize: 32, 39 | fontWeight: "bold", 40 | }, 41 | }); 42 | -------------------------------------------------------------------------------- /.circleci/updateDocsInWebsite.sh: -------------------------------------------------------------------------------- 1 | # get driver version 2 | version=`cat ../package.json | grep -e '"version":'` 3 | while IFS='"' read -ra ADDR; do 4 | counter=0 5 | for i in "${ADDR[@]}"; do 6 | if [ $counter == 3 ] 7 | then 8 | version=$i 9 | fi 10 | counter=$(($counter+1)) 11 | done 12 | done <<< "$version" 13 | 14 | # replace path version with X 15 | IFS='.' read -r -a array <<< "$version" 16 | versionFolder="${array[0]}"."${array[1]}".X 17 | 18 | # create react-native docs dir in repo if not exists 19 | (cd ../../supertokens-backend-website && mkdir -p ./app/docs/sdk/docs/react-native/${versionFolder}) 20 | 21 | # copy docs content from this repo to the supertokens-backend-website repo 22 | cp -r ../docs/* ../../supertokens-backend-website/app/docs/sdk/docs/react-native/ 23 | cp -r ../docs/* ../../supertokens-backend-website/app/docs/sdk/docs/react-native/${versionFolder} 24 | 25 | # push to git 26 | git config --global user.email "$EMAIL" 27 | git config --global user.name "$NAME" 28 | (cd ../../supertokens-backend-website && git add --all && git commit -m"updates react-native docs" && git pull && git push && ./releaseDev.sh) -------------------------------------------------------------------------------- /TestingApp/test/setup.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | import MockStorage from "./asyncStorage"; 17 | 18 | jest.mock("react-native", () => { 19 | return { 20 | Platform: {}, 21 | NativeModules: {} 22 | }; 23 | }); 24 | 25 | // React native async storage eposes a mocked version to use (Refer to the "../__mocks__/" folder ) 26 | // jest.mock("@react-native-async-storage/async-storage", () => { 27 | // return new MockStorage({}); 28 | // }); 29 | -------------------------------------------------------------------------------- /lib/build/index.d.ts: -------------------------------------------------------------------------------- 1 | import { InputType, RecipeInterface } from "./types"; 2 | export default class AuthHttpRequest { 3 | private static axiosInterceptorQueue; 4 | static init(options: InputType): void; 5 | static getUserId(): Promise; 6 | static getAccessTokenPayloadSecurely(): Promise; 7 | static attemptRefreshingSession: () => Promise; 8 | static doesSessionExist: () => Promise; 9 | static addAxiosInterceptors: (axiosInstance: any) => void; 10 | static signOut: () => Promise; 11 | static getAccessToken: () => Promise; 12 | } 13 | export declare let init: typeof AuthHttpRequest.init; 14 | export declare let getUserId: typeof AuthHttpRequest.getUserId; 15 | export declare let getAccessTokenPayloadSecurely: typeof AuthHttpRequest.getAccessTokenPayloadSecurely; 16 | export declare let attemptRefreshingSession: () => Promise; 17 | export declare let doesSessionExist: () => Promise; 18 | export declare let addAxiosInterceptors: (axiosInstance: any) => void; 19 | export declare let signOut: () => Promise; 20 | export declare let getAccessToken: () => Promise; 21 | export { RecipeInterface, InputType }; 22 | -------------------------------------------------------------------------------- /TestingApp/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "30.0.2" 6 | minSdkVersion = 21 7 | compileSdkVersion = 30 8 | targetSdkVersion = 30 9 | ndkVersion = "21.4.7075529" 10 | } 11 | repositories { 12 | google() 13 | mavenCentral() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.2.2") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenCentral() 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | 35 | google() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/build/error.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | /** 16 | * This error usually indicates that the API exposed by the backend SDKs responded 17 | * with `{status: "GENERAL_ERROR"}`. This should be used to show errors to the user 18 | * in your frontend application. 19 | */ 20 | export class SuperTokensGeneralError extends Error { 21 | constructor(message) { 22 | super(message); 23 | this.isSuperTokensGeneralError = true; 24 | } 25 | static isThisError(err) { 26 | return err.isSuperTokensGeneralError === true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/with-thirdparty/google.ts: -------------------------------------------------------------------------------- 1 | import { GoogleSignin } from "@react-native-google-signin/google-signin"; 2 | import { API_DOMAIN } from "./constants"; 3 | 4 | export const performGoogleSignIn = async (): Promise => { 5 | GoogleSignin.configure({ 6 | webClientId: "GOOGLE_WEB_CLIENT_ID", 7 | iosClientId: "GOOGLE_IOS_CLIENT_ID", 8 | }); 9 | 10 | try { 11 | const user = await GoogleSignin.signIn({}); 12 | 13 | const response = await fetch(API_DOMAIN + "/auth/signinup", { 14 | method: "POST", 15 | headers: { 16 | 'Content-Type': 'application/json; charset=utf-8' 17 | }, 18 | body: JSON.stringify({ 19 | thirdPartyId: "google", 20 | redirectURIInfo: { 21 | redirectURIOnProviderDashboard: "https://example.com", // this value doesn't matter cause it's mobile login, and Google doesn't check it, but our APIs need some value for it. 22 | redirectURIQueryParams: { 23 | code: user.serverAuthCode, 24 | }, 25 | }, 26 | }), 27 | }); 28 | 29 | if (response.status !== 200) { 30 | throw new Error(); 31 | } 32 | 33 | return true; 34 | } catch (e) { 35 | console.log("Google sign in failed with error", e); 36 | } 37 | 38 | return false; 39 | }; 40 | -------------------------------------------------------------------------------- /lib/ts/error.ts: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | /** 17 | * This error usually indicates that the API exposed by the backend SDKs responded 18 | * with `{status: "GENERAL_ERROR"}`. This should be used to show errors to the user 19 | * in your frontend application. 20 | */ 21 | export class SuperTokensGeneralError extends Error { 22 | isSuperTokensGeneralError = true; 23 | 24 | constructor(message: string) { 25 | super(message); 26 | } 27 | 28 | static isThisError(err: any): err is SuperTokensGeneralError { 29 | return err.isSuperTokensGeneralError === true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/build/axios.d.ts: -------------------------------------------------------------------------------- 1 | import { AxiosPromise, AxiosRequestConfig as OriginalAxiosRequestConfig, AxiosResponse } from "axios"; 2 | type AxiosRequestConfig = OriginalAxiosRequestConfig & { 3 | __supertokensSessionRefreshAttempts?: number; 4 | __supertokensAddedAuthHeader?: boolean; 5 | }; 6 | export declare function interceptorFunctionRequestFulfilled(config: AxiosRequestConfig): Promise; 7 | export declare function responseInterceptor(axiosInstance: any): (response: AxiosResponse) => Promise>; 8 | export declare function responseErrorInterceptor(axiosInstance: any): (error: any) => Promise>; 9 | /** 10 | * @class AuthHttpRequest 11 | * @description wrapper for common http methods. 12 | */ 13 | export default class AuthHttpRequest { 14 | /** 15 | * @description sends the actual http request and returns a response if successful/ 16 | * If not successful due to session expiry reasons, it 17 | * attempts to call the refresh token API and if that is successful, calls this API again. 18 | * @throws Error 19 | */ 20 | static doRequest: (httpCall: (config: AxiosRequestConfig) => AxiosPromise, config: AxiosRequestConfig, url?: string, prevResponse?: AxiosResponse, prevError?: any, viaInterceptor?: boolean) => Promise>; 21 | } 22 | export {}; 23 | -------------------------------------------------------------------------------- /lib/build/fetch.d.ts: -------------------------------------------------------------------------------- 1 | import { InputType, NormalisedInputType, RecipeInterface } from "./types"; 2 | import { LocalSessionState } from "./utils"; 3 | /** 4 | * @class AuthHttpRequest 5 | * @description wrapper for common http methods. 6 | */ 7 | export default class AuthHttpRequest { 8 | static refreshTokenUrl: string; 9 | static signOutUrl: string; 10 | static initCalled: boolean; 11 | static rid: string; 12 | static env: any; 13 | static recipeImpl: RecipeInterface; 14 | static config: NormalisedInputType; 15 | static init(options: InputType): void; 16 | /** 17 | * @description sends the actual http request and returns a response if successful/ 18 | * If not successful due to session expiry reasons, it 19 | * attempts to call the refresh token API and if that is successful, calls this API again. 20 | * @throws Error 21 | */ 22 | static doRequest: (httpCall: (config?: RequestInit) => Promise, config?: RequestInit, url?: any) => Promise; 23 | static attemptRefreshingSession: () => Promise; 24 | } 25 | export declare function onUnauthorisedResponse(preRequestLocalSessionState: LocalSessionState): Promise<{ 26 | result: "SESSION_EXPIRED"; 27 | error?: any; 28 | } | { 29 | result: "API_ERROR"; 30 | error: any; 31 | } | { 32 | result: "RETRY"; 33 | }>; 34 | -------------------------------------------------------------------------------- /lib/build/logger.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | import { package_version as version } from "./version"; 16 | const SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens"; 17 | let __supertokensWebsiteLogging = false; 18 | export function enableLogging() { 19 | __supertokensWebsiteLogging = true; 20 | } 21 | export function disableLogging() { 22 | __supertokensWebsiteLogging = false; 23 | } 24 | export function logDebugMessage(message) { 25 | if (__supertokensWebsiteLogging) { 26 | console.log( 27 | `${SUPERTOKENS_DEBUG_NAMESPACE} {t: "${new Date().toISOString()}", message: \"${message}\", supertokens-react-native: "${version}"}` 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TestingApp/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.99.0 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Summary of change 2 | (A few sentences about this PR) 3 | 4 | ## Related issues 5 | - Link to issue1 here 6 | - Link to issue1 here 7 | 8 | ## Test Plan 9 | (Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) 10 | 11 | ## Documentation changes 12 | (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) 13 | 14 | ## Checklist for important updates 15 | - [ ] Changelog has been updated 16 | - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) 17 | - Along with the associated array in `lib/ts/version.ts` 18 | - [ ] Changes to the version if needed 19 | - In `package.json` 20 | - In `package-lock.json` 21 | - In `lib/ts/version.ts` 22 | - [ ] Had run `npm run build-pretty` 23 | - [ ] Had installed and ran the pre-commit hook 24 | - [ ] Issue this PR against the latest non released version branch. 25 | - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. 26 | - If no such branch exists, then create one from the latest released branch. 27 | 28 | ## Remaining TODOs for this PR 29 | - [ ] Item1 30 | - [ ] Item2 -------------------------------------------------------------------------------- /lib/ts/logger.ts: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | * 3 | * This software is licensed under the Apache License, Version 2.0 (the 4 | * "License") as published by the Apache Software Foundation. 5 | * 6 | * You may not use this file except in compliance with the License. You may 7 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | * License for the specific language governing permissions and limitations 13 | * under the License. 14 | */ 15 | 16 | import { package_version as version } from "./version"; 17 | 18 | const SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens"; 19 | 20 | let __supertokensWebsiteLogging = false; 21 | 22 | export function enableLogging() { 23 | __supertokensWebsiteLogging = true; 24 | } 25 | 26 | export function disableLogging() { 27 | __supertokensWebsiteLogging = false; 28 | } 29 | 30 | export function logDebugMessage(message: string) { 31 | if (__supertokensWebsiteLogging) { 32 | console.log( 33 | `${SUPERTOKENS_DEBUG_NAMESPACE} {t: "${new Date().toISOString()}", message: \"${message}\", supertokens-react-native: "${version}"}` 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/with-thirdparty/apple.ts: -------------------------------------------------------------------------------- 1 | import { appleAuth } from "@invertase/react-native-apple-authentication"; 2 | import { API_DOMAIN } from "./constants"; 3 | 4 | export const performAppleLogin = async (): Promise => { 5 | try { 6 | const appleAuthRequestResponse = await appleAuth.performRequest({ 7 | requestedOperation: appleAuth.Operation.LOGIN, 8 | // Note: it appears putting FULL_NAME first is important, see issue https://github.com/invertase/react-native-apple-authentication/issues/293 9 | requestedScopes: [appleAuth.Scope.EMAIL], 10 | }); 11 | 12 | const response = await fetch(API_DOMAIN + "/auth/signinup", { 13 | method: "POST", 14 | headers: { 15 | 'Content-Type': 'application/json; charset=utf-8' 16 | }, 17 | body: JSON.stringify({ 18 | thirdPartyId: "apple", 19 | redirectURIInfo: { 20 | redirectURIOnProviderDashboard: "https://example.com", // this value doesn't matter cause it's mobile login, and Google doesn't check it, but our APIs need some value for it. 21 | redirectURIQueryParams: { 22 | code: appleAuthRequestResponse.authorizationCode, 23 | }, 24 | }, 25 | }), 26 | }); 27 | 28 | if (response.status !== 200) { 29 | throw new Error(); 30 | } 31 | 32 | return true; 33 | } catch (e) { 34 | console.log("Apple sign in failed with error", e); 35 | } 36 | 37 | return false; 38 | }; 39 | -------------------------------------------------------------------------------- /examples/with-thirdparty/backend/index.ts: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import cors from "cors"; 3 | import supertokens from "supertokens-node"; 4 | import { verifySession } from "supertokens-node/recipe/session/framework/express"; 5 | import { middleware, errorHandler, SessionRequest } from "supertokens-node/framework/express"; 6 | import { SuperTokensConfig } from "./config"; 7 | import Multitenancy from "supertokens-node/recipe/multitenancy"; 8 | 9 | supertokens.init(SuperTokensConfig); 10 | 11 | const app = express(); 12 | 13 | app.use( 14 | cors({ 15 | origin: "http://localhost:3000", 16 | allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()], 17 | methods: ["GET", "PUT", "POST", "DELETE"], 18 | credentials: true, 19 | }) 20 | ); 21 | 22 | // This exposes all the APIs from SuperTokens to the client. 23 | app.use(middleware()); 24 | 25 | // An example API that requires session verification 26 | app.get("/sessioninfo", verifySession(), async (req: SessionRequest, res) => { 27 | let session = req.session; 28 | res.send({ 29 | sessionHandle: session!.getHandle(), 30 | userId: session!.getUserId(), 31 | accessTokenPayload: session!.getAccessTokenPayload(), 32 | }); 33 | }); 34 | 35 | // In case of session related errors, this error handler 36 | // returns 401 to the client. 37 | app.use(errorHandler()); 38 | 39 | app.listen(3001, () => console.log(`API Server listening on port 3001`)); 40 | -------------------------------------------------------------------------------- /examples/with-thirdparty/App.tsx: -------------------------------------------------------------------------------- 1 | import SuperTokens from "supertokens-react-native"; 2 | import { API_DOMAIN } from "./constants"; 3 | import { createNativeStackNavigator } from "@react-navigation/native-stack"; 4 | import { NavigationContainer } from "@react-navigation/native"; 5 | import { SplashScreen } from "./splash"; 6 | import { LoginSreen } from "./login"; 7 | import { HomeScreen } from "./home"; 8 | import { SafeAreaProvider } from "react-native-safe-area-context"; 9 | 10 | SuperTokens.init({ 11 | apiDomain: API_DOMAIN, 12 | }); 13 | 14 | const Stack = createNativeStackNavigator(); 15 | 16 | export default function App() { 17 | return ( 18 | 19 | 20 | 21 | 28 | 35 | 42 | 43 | 44 | 45 | ); 46 | } 47 | -------------------------------------------------------------------------------- /.circleci/markDevTagAsTestNotPassed.sh: -------------------------------------------------------------------------------- 1 | # get git branch name----------- 2 | branch_name="$(git symbolic-ref HEAD 2>/dev/null)" || 3 | branch_name="(unnamed branch)" # detached HEAD 4 | 5 | branch_name=${branch_name##refs/heads/} 6 | 7 | if [[ $branch_name =~ ^test-cicd/.*$ ]] 8 | then 9 | echo "This is a ci testing branch ($branch_name), exiting early" 10 | exit 0 11 | fi 12 | 13 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 14 | frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"` 15 | frontendDriverArray=`echo $frontendDriverJson | jq ".versions"` 16 | echo "got frontend driver relations" 17 | 18 | # get sdk version 19 | version=`cat ../package.json | grep -e '"version":'` 20 | while IFS='"' read -ra ADDR; do 21 | counter=0 22 | for i in "${ADDR[@]}"; do 23 | if [ $counter == 3 ] 24 | then 25 | version=$i 26 | fi 27 | counter=$(($counter+1)) 28 | done 29 | done <<< "$version" 30 | 31 | responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PUT \ 32 | https://api.supertokens.io/0/frontend \ 33 | -H 'Content-Type: application/json' \ 34 | -H 'api-version: 0' \ 35 | -d "{ 36 | \"password\": \"$SUPERTOKENS_API_KEY\", 37 | \"version\":\"$version\", 38 | \"name\": \"react-native\", 39 | \"frontendDriverInterfaces\": $frontendDriverArray 40 | }"` 41 | if [ $responseStatus -ne "200" ] 42 | then 43 | echo "failed core PUT API status code: $responseStatus. Exiting!" 44 | exit 1 45 | fi -------------------------------------------------------------------------------- /examples/with-thirdparty/github.ts: -------------------------------------------------------------------------------- 1 | import { authorize } from "react-native-app-auth"; 2 | import { API_DOMAIN } from "./constants"; 3 | 4 | export const performGithubLogin = async (): Promise => { 5 | try { 6 | const result = await authorize({ 7 | serviceConfiguration: { 8 | authorizationEndpoint: "https://github.com/login/oauth/authorize", 9 | tokenEndpoint: "https://github.com/login/oauth/access_token", 10 | revocationEndpoint: 11 | "https://github.com/settings/connections/applications/", 12 | }, 13 | additionalHeaders: { Accept: "application/json" }, 14 | clientId: "GITHUB_CLIENT_ID", 15 | redirectUrl: "com.supertokens.supertokensexample://oauthredirect", 16 | scopes: ["user"], 17 | skipCodeExchange: true, 18 | }); 19 | 20 | const response = await fetch(API_DOMAIN + "/auth/signinup", { 21 | method: "POST", 22 | body: JSON.stringify({ 23 | thirdPartyId: "github", 24 | redirectURIInfo: { 25 | redirectURIOnProviderDashboard: "com.supertokens.supertokensexample://oauthredirect", 26 | redirectURIQueryParams: { 27 | code: result.authorizationCode, 28 | }, 29 | }, 30 | }), 31 | }); 32 | 33 | if (response.status !== 200) { 34 | throw new Error(); 35 | } 36 | 37 | return true; 38 | } catch (e) { 39 | console.log("Github login failed with error", e); 40 | } 41 | 42 | return false; 43 | }; 44 | -------------------------------------------------------------------------------- /.circleci/markAsSuccess.sh: -------------------------------------------------------------------------------- 1 | # get git branch name----------- 2 | branch_name="$(git symbolic-ref HEAD 2>/dev/null)" || 3 | branch_name="(unnamed branch)" # detached HEAD 4 | 5 | branch_name=${branch_name##refs/heads/} 6 | 7 | if [[ $branch_name =~ ^test-cicd/.*$ ]] 8 | then 9 | echo "This is a ci testing branch ($branch_name), exiting early" 10 | exit 0 11 | fi 12 | 13 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 14 | frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"` 15 | frontendDriverArray=`echo $frontendDriverJson | jq ".versions"` 16 | echo "got frontend driver relations" 17 | 18 | # get sdk version 19 | version=`cat ../package.json | grep -e '"version":'` 20 | while IFS='"' read -ra ADDR; do 21 | counter=0 22 | for i in "${ADDR[@]}"; do 23 | if [ $counter == 3 ] 24 | then 25 | version=$i 26 | fi 27 | counter=$(($counter+1)) 28 | done 29 | done <<< "$version" 30 | 31 | echo "calling /frontend PATCH to make testing passed" 32 | responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \ 33 | https://api.supertokens.io/0/frontend \ 34 | -H 'Content-Type: application/json' \ 35 | -H 'api-version: 0' \ 36 | -d "{ 37 | \"password\": \"$SUPERTOKENS_API_KEY\", 38 | \"version\":\"$version\", 39 | \"name\": \"react-native\", 40 | \"testPassed\": true 41 | }"` 42 | if [ $responseStatus -ne "200" ] 43 | then 44 | echo "patch api failed" 45 | exit 1 46 | fi -------------------------------------------------------------------------------- /TestingApp/test/tough-cookie/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Salesforce.com, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /TestingApp/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.testingapp", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.testingapp", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /TestingApp/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | [untyped] 15 | .*/node_modules/@react-native-community/cli/.*/.* 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/interface.js 21 | node_modules/react-native/flow/ 22 | 23 | [options] 24 | emoji=true 25 | 26 | exact_by_default=true 27 | 28 | format.bracket_spacing=false 29 | 30 | module.file_ext=.js 31 | module.file_ext=.json 32 | module.file_ext=.ios.js 33 | 34 | munge_underscores=true 35 | 36 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 37 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 38 | 39 | suppress_type=$FlowIssue 40 | suppress_type=$FlowFixMe 41 | suppress_type=$FlowFixMeProps 42 | suppress_type=$FlowFixMeState 43 | 44 | [lints] 45 | sketchy-null-number=warn 46 | sketchy-null-mixed=warn 47 | sketchy-number=warn 48 | untyped-type-import=warn 49 | nonstrict-import=warn 50 | deprecated-type=warn 51 | unsafe-getters-setters=warn 52 | unnecessary-invariant=warn 53 | signature-verification-failure=warn 54 | 55 | [strict] 56 | deprecated-type 57 | nonstrict-import 58 | sketchy-null 59 | unclear-type 60 | unsafe-getters-setters 61 | untyped-import 62 | untyped-type-import 63 | 64 | [version] 65 | ^0.158.0 66 | -------------------------------------------------------------------------------- /TestingApp/test/server/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /TestingApp/ios/TestingApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | TestingApp 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /lib/build/utils.d.ts: -------------------------------------------------------------------------------- 1 | import { InputType, NormalisedInputType, TokenType } from "./types"; 2 | export declare function isAnIpAddress(ipaddress: string): boolean; 3 | export declare function normaliseURLDomainOrThrowError(input: string): string; 4 | export declare function normaliseURLPathOrThrowError(input: string): string; 5 | export declare function normaliseSessionScopeOrThrowError(cookieDomain: string): string; 6 | export declare function validateAndNormaliseInputOrThrowError(options: InputType): NormalisedInputType; 7 | export declare function setToken(tokenType: TokenType, value: string): Promise; 8 | export declare function storeInStorage(name: string, value: string, expiry: number): Promise; 9 | /** 10 | * Last access token update is used to record the last time the access token had changed. 11 | * This is used to synchronise parallel calls to the refresh API to prevent multiple calls 12 | * to the refresh endpoint 13 | */ 14 | export declare function saveLastAccessTokenUpdate(): Promise; 15 | export declare function getStorageNameForToken(tokenType: TokenType): "st-access-token" | "st-refresh-token"; 16 | export declare function getTokenForHeaderAuth(tokenType: TokenType): Promise; 17 | export type LocalSessionState = { 18 | status: "NOT_EXISTS" | "MAY_EXIST"; 19 | } | { 20 | status: "EXISTS"; 21 | lastAccessTokenUpdate: string; 22 | }; 23 | /** 24 | * The web SDK has additional checks for this function. This difference is because 25 | * for the mobile SDKs there will never be a case where the fronttoken is undefined 26 | * but a session may still exist 27 | */ 28 | export declare function getLocalSessionState(): Promise; 29 | export declare function fireSessionUpdateEventsIfNecessary(wasLoggedIn: boolean, status: number, frontTokenHeaderFromResponse: string | null | undefined): void; 30 | -------------------------------------------------------------------------------- /TestingApp/test/tough-cookie/lib/pubsuffix-psl.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright (c) 2018, Salesforce.com, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Salesforce.com nor the names of its contributors may 16 | * be used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | "use strict"; 32 | var psl = require("psl"); 33 | 34 | function getPublicSuffix(domain) { 35 | return psl.get(domain); 36 | } 37 | 38 | exports.getPublicSuffix = getPublicSuffix; 39 | -------------------------------------------------------------------------------- /TestingApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "npx jest test/*.spec.js --runInBand --silent=false", 10 | "test-ci": "npx jest --listTests test/*.spec.js | circleci tests run --command=\"JEST_JUNIT_ADD_FILE_ATTRIBUTE=true xargs npx jest --ci --reporters=default --reporters=jest-junit --runInBand --\" --verbose --split-by=timings", 11 | "lint": "eslint ." 12 | }, 13 | "dependencies": { 14 | "@react-native-async-storage/async-storage": "^1.12.1", 15 | "axios": "0.19.2", 16 | "headers-polyfill": "^4.0.3", 17 | "react": "17.0.2", 18 | "react-native": "0.66.1", 19 | "supertokens-react-native": "github:supertokens/supertokens-react-native#5.1" 20 | }, 21 | "devDependencies": { 22 | "@babel/core": "^7.12.9", 23 | "@babel/runtime": "^7.12.5", 24 | "@react-native-community/eslint-config": "^2.0.0", 25 | "axios-cookiejar-support": "github:supertokens/axios-cookiejar-support#0.5.1", 26 | "babel-jest": "^26.6.3", 27 | "babel-preset-react-app": "7.0.0", 28 | "eslint": "7.14.0", 29 | "fetch-cookie": "^3.1.0", 30 | "isomorphic-fetch": "^3.0.0", 31 | "jest": "^26.6.3", 32 | "jest-junit": "^16.0.0", 33 | "metro-react-native-babel-preset": "^0.66.2", 34 | "node-fetch": "^2.7.0", 35 | "react-test-renderer": "17.0.2", 36 | "ts-jest": "^26.5.6" 37 | }, 38 | "jest": { 39 | "preset": "react-native", 40 | "setupFiles": [ 41 | "./test/setup.js" 42 | ], 43 | "testEnvironment": "node", 44 | "transform": { 45 | "^.+\\.(ts|tsx)?$": "ts-jest", 46 | "^.*\\.(js|jsx)$": "babel-jest" 47 | }, 48 | "transformIgnorePatterns": [ 49 | "/node_modules/.+\\.(js | ts | jsx | tsx)" 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/with-thirdparty/login.tsx: -------------------------------------------------------------------------------- 1 | import { View, StyleSheet, Button, Platform } from "react-native"; 2 | import { performGoogleSignIn } from "./google"; 3 | import { NativeStackScreenProps } from "@react-navigation/native-stack"; 4 | import { performGithubLogin } from "./github"; 5 | import { performAppleLogin } from "./apple"; 6 | 7 | type Props = NativeStackScreenProps; 8 | 9 | export const LoginSreen = ({ navigation }: Props) => { 10 | const onGoogleClicked = async () => { 11 | const result = await performGoogleSignIn(); 12 | 13 | if (result) { 14 | navigation.replace("Home"); 15 | } else { 16 | navigation.replace("Splash"); 17 | } 18 | }; 19 | const onGithubClicked = async () => { 20 | const result = await performGithubLogin(); 21 | 22 | if (result) { 23 | navigation.replace("Home"); 24 | } else { 25 | navigation.replace("Splash"); 26 | } 27 | }; 28 | const onAppleClicked = async () => { 29 | const result = await performAppleLogin(); 30 | 31 | if (result) { 32 | navigation.replace("Home"); 33 | } else { 34 | navigation.replace("Splash"); 35 | } 36 | }; 37 | 38 | return ( 39 | 40 |