packages = new PackageList(this).getPackages();
34 | // Packages that cannot be autolinked yet can be added manually here, for example:
35 | // packages.add(new MyReactNativePackage());
36 | return packages;
37 | }
38 |
39 | @Override
40 | protected String getJSMainModuleName() {
41 | return ".expo/.virtual-metro-entry";
42 | }
43 |
44 | @Override
45 | protected boolean isNewArchEnabled() {
46 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
47 | }
48 |
49 | @Override
50 | protected Boolean isHermesEnabled() {
51 | return BuildConfig.IS_HERMES_ENABLED;
52 | }
53 | });
54 |
55 | @Override
56 | public ReactNativeHost getReactNativeHost() {
57 | return mReactNativeHost;
58 | }
59 |
60 | @Override
61 | public void onCreate() {
62 | super.onCreate();
63 | SoLoader.init(this, /* native exopackage */ false);
64 | if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
65 | ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false;
66 | }
67 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
68 | // If you opted-in for the New Architecture, we load the native entry point for this app.
69 | DefaultNewArchitectureEntryPoint.load();
70 | }
71 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
72 | ApplicationLifecycleDispatcher.onApplicationCreate(this);
73 | }
74 |
75 | @Override
76 | public void onConfigurationChanged(@NonNull Configuration newConfig) {
77 | super.onConfigurationChanged(newConfig);
78 | ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/drawable-hdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/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/b078a26fb61dab6357ac94ecb582c270e4d72f9a/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/b078a26fb61dab6357ac94ecb582c270e4d72f9a/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/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
23 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/drawable/splashscreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/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/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/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.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/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.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/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/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 | #ffffff
3 | #ffffff
4 | #023c69
5 | #ffffff
6 |
--------------------------------------------------------------------------------
/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/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
17 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/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 = findProperty('android.buildToolsVersion') ?: '33.0.0'
6 | minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
7 | compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
8 | targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
9 | kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
10 | frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
11 | googlePlayServicesAuthVersion = "20.7.0"
12 |
13 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
14 | ndkVersion = "23.1.7779620"
15 | }
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | dependencies {
21 | classpath('com.android.tools.build:gradle:7.4.2')
22 | classpath('com.facebook.react:react-native-gradle-plugin')
23 | classpath 'com.google.gms:google-services:4.4.0'
24 | }
25 | }
26 |
27 | allprojects {
28 | repositories {
29 | maven {
30 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
31 | url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
32 | }
33 | maven {
34 | // Android JSC is installed from npm
35 | url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
36 | }
37 |
38 | maven {
39 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
40 | url "$rootDir/../node_modules/react-native/android"
41 | }
42 |
43 | google()
44 | mavenCentral()
45 | maven { url 'https://www.jitpack.io' }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/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: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
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 |
25 | # Automatically convert third-party libraries to use AndroidX
26 | android.enableJetifier=true
27 |
28 | # Version of flipper SDK to use with React Native
29 | FLIPPER_VERSION=0.182.0
30 |
31 | # Use this property to specify which architecture you want to build.
32 | # You can also override it from the CLI using
33 | # ./gradlew -PreactNativeArchitectures=x86_64
34 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
35 |
36 | # Use this property to enable support to the new architecture.
37 | # This will allow you to use TurboModules and the Fabric render in
38 | # your application. You should enable this flag either if you want
39 | # to write custom TurboModules/Fabric components OR use libraries that
40 | # are providing them.
41 | newArchEnabled=false
42 |
43 | # Use this property to enable or disable the Hermes JS engine.
44 | # If set to false, you will be using JSC instead.
45 | hermesEnabled=true
46 |
47 | # Enable GIF support in React Native images (~200 B increase)
48 | expo.gif.enabled=true
49 | # Enable webp support in React Native images (~85 KB increase)
50 | expo.webp.enabled=true
51 | # Enable animated webp support (~3.4 MB increase)
52 | # Disabled by default because iOS doesn't support animated webp
53 | expo.webp.animated=false
54 |
55 | # Enable network inspector
56 | EX_DEV_CLIENT_NETWORK_INSPECTOR=true
57 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if %ERRORLEVEL% equ 0 goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if %ERRORLEVEL% equ 0 goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/assets/adaptive-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/assets/adaptive-icon.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/assets/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/assets/favicon.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/assets/icon.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/assets/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/assets/splash.png
--------------------------------------------------------------------------------
/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/backend/config.ts:
--------------------------------------------------------------------------------
1 | import ThirdParty from "supertokens-node/recipe/thirdparty";
2 | import Session from "supertokens-node/recipe/session";
3 | import { TypeInput } from "supertokens-node/types";
4 | import Dashboard from "supertokens-node/recipe/dashboard";
5 |
6 | export const SuperTokensConfig: TypeInput = {
7 | supertokens: {
8 | // this is the location of the SuperTokens core.
9 | connectionURI: "https://try.supertokens.com",
10 | },
11 | appInfo: {
12 | appName: "SuperTokens Demo App",
13 | apiDomain: "http://192.168.29.87:3001",
14 | websiteDomain: "http://localhost:3000", // this value does not matter for the android app
15 | },
16 | // recipeList contains all the modules that you want to
17 | // use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
18 | recipeList: [
19 | ThirdParty.init({
20 | signInAndUpFeature: {
21 | providers: [
22 | // We have provided you with development keys which you can use for testing.
23 | // IMPORTANT: Please replace them with your own OAuth keys for production use.
24 | {
25 | config: {
26 | thirdPartyId: "google",
27 | clients: [
28 | {
29 | clientId: "GOOGLE_WEB_CLIENT_ID",
30 | clientSecret: "GOOGLE_WEB_CLIENT_SECRET",
31 | },
32 | ],
33 | },
34 | },
35 | {
36 | config: {
37 | thirdPartyId: "github",
38 | clients: [
39 | {
40 | clientId: "GITHUB_CLIENT_ID",
41 | clientSecret: "GITHUB_CLIENT_SECRET",
42 | },
43 | ],
44 | },
45 | },
46 | {
47 | config: {
48 | thirdPartyId: "apple",
49 | clients: [
50 | {
51 | clientId: "APPLE_CLIENT_ID",
52 | additionalConfig: {
53 | keyId: "APPLE_KEY_ID",
54 | privateKey: "APPLE_PRIVATE_KEY",
55 | teamId: "APPLE_TEAM_ID",
56 | },
57 | },
58 | ],
59 | },
60 | },
61 | ],
62 | },
63 | }),
64 | Session.init(),
65 | Dashboard.init(),
66 | ],
67 | };
68 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/constants.ts:
--------------------------------------------------------------------------------
1 | export const API_DOMAIN = "http://192.168.29.87:3001";
2 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/ios/Podfile.properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo.jsEngine": "hermes",
3 | "EX_DEV_CLIENT_NETWORK_INSPECTOR": "true"
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 |
--------------------------------------------------------------------------------
/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/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 | #import
5 | #import
6 |
7 | @implementation AppDelegate
8 |
9 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
10 | {
11 | self.moduleName = @"main";
12 |
13 | // You can add your custom initial props in the dictionary below.
14 | // They will be passed down to the ViewController used by React Native.
15 | self.initialProps = @{};
16 |
17 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
18 | }
19 |
20 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
21 | {
22 | #if DEBUG
23 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
24 | #else
25 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
26 | #endif
27 | }
28 |
29 | // Linking API
30 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options {
31 | BOOL handled;
32 |
33 | handled = [GIDSignIn.sharedInstance handleURL:url];
34 | if (handled) {
35 | return YES;
36 | }
37 |
38 | if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
39 | return YES;
40 | }
41 |
42 | return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
43 | }
44 |
45 | // Universal Links
46 | - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler {
47 | BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
48 | return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
49 | }
50 |
51 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
52 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
53 | {
54 | return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
55 | }
56 |
57 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
58 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
59 | {
60 | return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
61 | }
62 |
63 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
64 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
65 | {
66 | return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
67 | }
68 |
69 | @end
70 |
--------------------------------------------------------------------------------
/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "expo"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreen.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreen.imageset/image.png
--------------------------------------------------------------------------------
/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/withthirdparty/Images.xcassets/SplashScreenBackground.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/supertokens/supertokens-react-native/b078a26fb61dab6357ac94ecb582c270e4d72f9a/examples/with-thirdparty/ios/withthirdparty/Images.xcassets/SplashScreenBackground.imageset/image.png
--------------------------------------------------------------------------------
/examples/with-thirdparty/ios/withthirdparty/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleDisplayName
10 | with-thirdparty
11 | CFBundleExecutable
12 | $(EXECUTABLE_NAME)
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | $(PRODUCT_NAME)
19 | CFBundlePackageType
20 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
21 | CFBundleShortVersionString
22 | 1.0.0
23 | CFBundleSignature
24 | ????
25 | CFBundleURLTypes
26 |
27 |
28 | CFBundleURLSchemes
29 |
30 | com.supertokens.supertokensexample
31 | GOOGLE_IOS_URL_SCHEME
32 | com.supertokens.with-thirdparty
33 |
34 |
35 |
36 | CFBundleVersion
37 | 1
38 | GIDClientID
39 | GOOGLE_IOS_CLIENT_ID
40 | GIDServerClientID
41 | GOOGLE_WEB_CLIENT_ID
42 | LSRequiresIPhoneOS
43 |
44 | NSAppTransportSecurity
45 |
46 | NSAllowsArbitraryLoads
47 |
48 | NSExceptionDomains
49 |
50 | localhost
51 |
52 | NSExceptionAllowsInsecureHTTPLoads
53 |
54 |
55 |
56 |
57 | UILaunchStoryboardName
58 | SplashScreen
59 | UIRequiredDeviceCapabilities
60 |
61 | armv7
62 |
63 | UIRequiresFullScreen
64 |
65 | UIStatusBarStyle
66 | UIStatusBarStyleDefault
67 | UISupportedInterfaceOrientations
68 |
69 | UIInterfaceOrientationPortrait
70 | UIInterfaceOrientationPortraitUpsideDown
71 |
72 | UISupportedInterfaceOrientations~ipad
73 |
74 | UIInterfaceOrientationPortrait
75 | UIInterfaceOrientationPortraitUpsideDown
76 | UIInterfaceOrientationLandscapeLeft
77 | UIInterfaceOrientationLandscapeRight
78 |
79 | UIUserInterfaceStyle
80 | Light
81 | UIViewControllerBasedStatusBarAppearance
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
41 |
42 |
43 |
44 | {Platform.OS === "ios" && (
45 |
46 | )}
47 |
48 | );
49 | };
50 |
51 | const styles = StyleSheet.create({
52 | container: {
53 | flex: 1,
54 | backgroundColor: "#fff",
55 | alignItems: "center",
56 | justifyContent: "center",
57 | },
58 | text: {
59 | fontSize: 32,
60 | fontWeight: "bold",
61 | },
62 | spacer: {
63 | height: 16,
64 | },
65 | });
66 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | use_frameworks!
3 |
4 | target 'RNSuperTokens' do
5 | pod 'SuperTokensSession', '~> 1.1.2'
6 | end
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/RNSuperTokens.m:
--------------------------------------------------------------------------------
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 "RNSuperTokens.h"
17 | #import "SuperTokensSession-Swift.h"
18 |
19 | @implementation RNSuperTokens
20 |
21 | - (dispatch_queue_t)methodQueue
22 | {
23 | return dispatch_get_main_queue();
24 | }
25 | RCT_EXPORT_MODULE()
26 |
27 |
28 | //RCT_EXPORT_METHOD(initLib: (NSString *)refreshTokenEndpoint:
29 | // (int)sessionExpiryStatusCode:
30 | // (NSDictionary *)refreshAPICustomHeaders:
31 | // (RCTPromiseResolveBlock)resolve
32 | // rejecter:(RCTPromiseRejectBlock)reject)
33 | //{
34 | // NSError *error = nil;
35 | // [SuperTokens initialiseWithRefreshTokenEndpoint:refreshTokenEndpoint sessionExpiryStatusCode:sessionExpiryStatusCode refreshAPICustomHeaders:refreshAPICustomHeaders error:&error];
36 | //
37 | // if (error) {
38 | // reject(@"init_failed", @"Call to initialising native SDK failed", error);
39 | // } else {
40 | // resolve(nil);
41 | // }
42 | //}
43 | //
44 | //RCT_EXPORT_METHOD(doesSessionExist:
45 | // (RCTPromiseResolveBlock)resolve:
46 | // (RCTPromiseRejectBlock)reject)
47 | //{
48 | // NSNumber *result = [SuperTokens doesSessionExist] ? [NSNumber numberWithBool:YES] : [NSNumber numberWithBool:NO];
49 | // resolve(result);
50 | //}
51 | //
52 | //RCT_EXPORT_METHOD(dataTask:
53 | // (NSURLRequest *)request:
54 | // (RCTPromiseResolveBlock)resolve
55 | // rejecter:(RCTPromiseRejectBlock)reject)
56 | //{
57 | // [SuperTokensURLSession
58 | // dataTaskWithRequest:request
59 | // completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
60 | // if (error) {
61 | // reject(@"network_failed", @"Network request failed", error);
62 | // } else {
63 | //
64 | // }
65 | // }];
66 | //}
67 |
68 | @end
69 |
70 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/RNSuperTokens.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/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/axios.d.ts:
--------------------------------------------------------------------------------
1 | import { AxiosPromise, AxiosRequestConfig as OriginalAxiosRequestConfig, AxiosResponse } from "axios";
2 | declare 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 | undefined, prevResponse?: AxiosResponse | undefined, prevError?: any, viaInterceptor?: boolean) => Promise>;
21 | }
22 | export {};
23 |
--------------------------------------------------------------------------------
/lib/build/axiosError.d.ts:
--------------------------------------------------------------------------------
1 | import { AxiosError } from "axios";
2 | export declare function createAxiosErrorFromFetchResp(responseOrError: Response): Promise;
3 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | undefined) => Promise, config?: RequestInit | undefined, 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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/build/locking.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 | WARNING: Do not acquire a lock and then re acquire the same lock without
17 | releasing that lock first!!
18 | */
19 | class Locking {
20 | constructor() {
21 | this.locked = new Map();
22 | this.addToLocked = (key, toAdd) => {
23 | let callbacks = this.locked.get(key);
24 | if (callbacks === undefined) {
25 | if (toAdd === undefined) {
26 | this.locked.set(key, []);
27 | } else {
28 | this.locked.set(key, [toAdd]);
29 | }
30 | } else {
31 | if (toAdd !== undefined) {
32 | callbacks.unshift(toAdd);
33 | this.locked.set(key, callbacks);
34 | }
35 | }
36 | };
37 | this.isLocked = key => {
38 | return this.locked.has(key);
39 | };
40 | this.lock = key => {
41 | return new Promise((resolve, reject) => {
42 | if (this.isLocked(key)) {
43 | this.addToLocked(key, resolve);
44 | } else {
45 | this.addToLocked(key);
46 | resolve();
47 | }
48 | });
49 | };
50 | this.unlock = key => {
51 | let callbacks = this.locked.get(key);
52 | if (callbacks === undefined || callbacks.length === 0) {
53 | this.locked.delete(key);
54 | return;
55 | }
56 | let toCall = callbacks.pop();
57 | this.locked.set(key, callbacks);
58 | if (toCall !== undefined) {
59 | setImmediate(toCall);
60 | }
61 | };
62 | }
63 | static getInstance() {
64 | if (Locking.instance === undefined) {
65 | Locking.instance = new Locking();
66 | }
67 | return Locking.instance;
68 | }
69 | }
70 | export default function getLock() {
71 | return Locking.getInstance();
72 | }
73 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/build/normalisedURLDomain.d.ts:
--------------------------------------------------------------------------------
1 | export default class NormalisedURLDomain {
2 | private value;
3 | constructor(url: string);
4 | getAsStringDangerous: () => string;
5 | }
6 |
--------------------------------------------------------------------------------
/lib/build/normalisedURLDomain.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 { isAnIpAddress } from "./utils";
16 | import { URL } from "react-native-url-polyfill";
17 | export default class NormalisedURLDomain {
18 | constructor(url) {
19 | this.getAsStringDangerous = () => {
20 | return this.value;
21 | };
22 | this.value = normaliseURLDomainOrThrowError(url);
23 | }
24 | }
25 | function normaliseURLDomainOrThrowError(input, ignoreProtocol = false) {
26 | input = input.trim();
27 | try {
28 | if (!input.startsWith("http://") && !input.startsWith("https://")) {
29 | throw new Error("converting to proper URL");
30 | }
31 | // @ts-ignore (Typescript complains that URL does not expect a parameter in constructor even though it does for react-native-url-polyfill)
32 | const urlObj = new URL(input);
33 | if (ignoreProtocol) {
34 | if (urlObj.hostname.startsWith("localhost") || isAnIpAddress(urlObj.hostname)) {
35 | input = "http://" + urlObj.host;
36 | } else {
37 | input = "https://" + urlObj.host;
38 | }
39 | } else {
40 | input = urlObj.protocol + "//" + urlObj.host;
41 | }
42 | return input;
43 | // eslint-disable-next-line no-empty
44 | } catch (err) {}
45 | if (input.startsWith("/")) {
46 | throw new Error("Please provide a valid domain name");
47 | }
48 | // not a valid URL
49 | if (input.indexOf(".") === 0) {
50 | input = input.substr(1);
51 | }
52 | // If the input contains a . it means they have given a domain name.
53 | // So we try assuming that they have given a domain name
54 | if (
55 | (input.indexOf(".") !== -1 || input.startsWith("localhost")) &&
56 | !input.startsWith("http://") &&
57 | !input.startsWith("https://")
58 | ) {
59 | input = "https://" + input;
60 | // at this point, it should be a valid URL. So we test that before doing a recursive call
61 | try {
62 | // @ts-ignore (Typescript complains that URL does not expect a parameter in constructor even though it does for react-native-url-polyfill)
63 | new URL(input);
64 | return normaliseURLDomainOrThrowError(input, true);
65 | // eslint-disable-next-line no-empty
66 | } catch (err) {}
67 | }
68 | throw new Error("Please provide a valid domain name");
69 | }
70 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/build/recipeImplementation.d.ts:
--------------------------------------------------------------------------------
1 | import { RecipeInterface } from "./types";
2 | export default function RecipeImplementation(): RecipeInterface;
3 |
--------------------------------------------------------------------------------
/lib/build/types.d.ts:
--------------------------------------------------------------------------------
1 | import OverrideableBuilder from "supertokens-js-override";
2 | export declare type Event = {
3 | action: "SIGN_OUT" | "REFRESH_SESSION" | "SESSION_CREATED";
4 | } | {
5 | action: "UNAUTHORISED";
6 | sessionExpiredOrRevoked: boolean;
7 | };
8 | export declare type EventHandler = (event: Event) => void;
9 | export declare type InputType = {
10 | enableDebugLogs?: boolean;
11 | apiDomain: string;
12 | apiBasePath?: string;
13 | sessionExpiredStatusCode?: number;
14 | autoAddCredentials?: boolean;
15 | tokenTransferMethod?: "cookie" | "header";
16 | /**
17 | * This specifies the maximum number of times the interceptor will attempt to refresh
18 | * the session when a 401 Unauthorized response is received. If the number of retries
19 | * exceeds this limit, no further attempts will be made to refresh the session, and
20 | * and an error will be thrown.
21 | */
22 | maxRetryAttemptsForSessionRefresh?: number;
23 | sessionTokenBackendDomain?: string;
24 | preAPIHook?: (context: {
25 | action: "SIGN_OUT" | "REFRESH_SESSION";
26 | requestInit: RequestInit;
27 | url: string;
28 | }) => Promise<{
29 | url: string;
30 | requestInit: RequestInit;
31 | }>;
32 | onHandleEvent?: EventHandler;
33 | override?: {
34 | functions?: (originalImplementation: RecipeInterface, builder?: OverrideableBuilder) => RecipeInterface;
35 | };
36 | };
37 | export declare type NormalisedInputType = {
38 | apiDomain: string;
39 | apiBasePath: string;
40 | sessionExpiredStatusCode: number;
41 | autoAddCredentials: boolean;
42 | tokenTransferMethod: string;
43 | maxRetryAttemptsForSessionRefresh: number;
44 | sessionTokenBackendDomain: string | undefined;
45 | preAPIHook: (context: {
46 | action: "SIGN_OUT" | "REFRESH_SESSION";
47 | requestInit: RequestInit;
48 | url: string;
49 | }) => Promise<{
50 | url: string;
51 | requestInit: RequestInit;
52 | }>;
53 | onHandleEvent: EventHandler;
54 | override: {
55 | functions: (originalImplementation: RecipeInterface, builder?: OverrideableBuilder) => RecipeInterface;
56 | };
57 | };
58 | export declare type PreAPIHookFunction = (context: {
59 | requestInit: RequestInit;
60 | url: string;
61 | }) => Promise<{
62 | url: string;
63 | requestInit: RequestInit;
64 | }>;
65 | export declare type RecipeInterface = {
66 | addFetchInterceptorsAndReturnModifiedFetch: (originalFetch: any, config: NormalisedInputType) => typeof fetch;
67 | addAxiosInterceptors: (axiosInstance: any, config: NormalisedInputType) => void;
68 | getUserId: (config: NormalisedInputType) => Promise;
69 | getAccessTokenPayloadSecurely: (config: NormalisedInputType) => Promise;
70 | doesSessionExist: (config: NormalisedInputType) => Promise;
71 | signOut: (config: NormalisedInputType) => Promise;
72 | shouldDoInterceptionBasedOnUrl(toCheckUrl: string, apiDomain: string, sessionTokenBackendDomain: string | undefined): boolean;
73 | };
74 | export declare type IdRefreshTokenType = {
75 | status: "NOT_EXISTS" | "MAY_EXIST";
76 | } | {
77 | status: "EXISTS";
78 | token: string;
79 | };
80 | export declare type TokenType = "access" | "refresh";
81 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 declare 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 |
--------------------------------------------------------------------------------
/lib/build/version.d.ts:
--------------------------------------------------------------------------------
1 | export declare const package_version = "5.1.4";
2 | export declare const supported_fdi: string[];
3 |
--------------------------------------------------------------------------------
/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.4";
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/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/ts/locking.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 |
16 | /*
17 | WARNING: Do not acquire a lock and then re acquire the same lock without
18 | releasing that lock first!!
19 | */
20 | class Locking {
21 | static instance: undefined | Locking;
22 | private locked: Map void)[]> = new Map void)[]>();
23 |
24 | static getInstance() {
25 | if (Locking.instance === undefined) {
26 | Locking.instance = new Locking();
27 | }
28 | return Locking.instance;
29 | }
30 |
31 | private addToLocked = (key: string, toAdd?: () => void) => {
32 | let callbacks = this.locked.get(key);
33 | if (callbacks === undefined) {
34 | if (toAdd === undefined) {
35 | this.locked.set(key, []);
36 | } else {
37 | this.locked.set(key, [toAdd]);
38 | }
39 | } else {
40 | if (toAdd !== undefined) {
41 | callbacks.unshift(toAdd);
42 | this.locked.set(key, callbacks);
43 | }
44 | }
45 | };
46 |
47 | isLocked = (key: string): boolean => {
48 | return this.locked.has(key);
49 | };
50 |
51 | lock = (key: string): Promise => {
52 | return new Promise((resolve, reject) => {
53 | if (this.isLocked(key)) {
54 | this.addToLocked(key, resolve);
55 | } else {
56 | this.addToLocked(key);
57 | resolve();
58 | }
59 | });
60 | };
61 |
62 | unlock = (key: string) => {
63 | let callbacks = this.locked.get(key);
64 | if (callbacks === undefined || callbacks.length === 0) {
65 | this.locked.delete(key);
66 | return;
67 | }
68 | let toCall = callbacks.pop();
69 | this.locked.set(key, callbacks);
70 | if (toCall !== undefined) {
71 | setImmediate(toCall);
72 | }
73 | };
74 | }
75 |
76 | export default function getLock(): Locking {
77 | return Locking.getInstance();
78 | }
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/ts/normalisedURLDomain.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 { isAnIpAddress } from "./utils";
17 | import { URL } from "react-native-url-polyfill";
18 |
19 | export default class NormalisedURLDomain {
20 | private value: string;
21 |
22 | constructor(url: string) {
23 | this.value = normaliseURLDomainOrThrowError(url);
24 | }
25 |
26 | getAsStringDangerous = (): string => {
27 | return this.value;
28 | };
29 | }
30 |
31 | function normaliseURLDomainOrThrowError(input: string, ignoreProtocol = false): string {
32 | input = input.trim();
33 | try {
34 | if (!input.startsWith("http://") && !input.startsWith("https://")) {
35 | throw new Error("converting to proper URL");
36 | }
37 |
38 | // @ts-ignore (Typescript complains that URL does not expect a parameter in constructor even though it does for react-native-url-polyfill)
39 | const urlObj: any = new URL(input);
40 | if (ignoreProtocol) {
41 | if (urlObj.hostname.startsWith("localhost") || isAnIpAddress(urlObj.hostname)) {
42 | input = "http://" + urlObj.host;
43 | } else {
44 | input = "https://" + urlObj.host;
45 | }
46 | } else {
47 | input = urlObj.protocol + "//" + urlObj.host;
48 | }
49 | return input;
50 | // eslint-disable-next-line no-empty
51 | } catch (err) {}
52 |
53 | if (input.startsWith("/")) {
54 | throw new Error("Please provide a valid domain name");
55 | }
56 |
57 | // not a valid URL
58 | if (input.indexOf(".") === 0) {
59 | input = input.substr(1);
60 | }
61 | // If the input contains a . it means they have given a domain name.
62 | // So we try assuming that they have given a domain name
63 | if (
64 | (input.indexOf(".") !== -1 || input.startsWith("localhost")) &&
65 | !input.startsWith("http://") &&
66 | !input.startsWith("https://")
67 | ) {
68 | input = "https://" + input;
69 | // at this point, it should be a valid URL. So we test that before doing a recursive call
70 | try {
71 | // @ts-ignore (Typescript complains that URL does not expect a parameter in constructor even though it does for react-native-url-polyfill)
72 | new URL(input);
73 | return normaliseURLDomainOrThrowError(input, true);
74 |
75 | // eslint-disable-next-line no-empty
76 | } catch (err) {}
77 | }
78 | throw new Error("Please provide a valid domain name");
79 | }
80 |
--------------------------------------------------------------------------------
/lib/ts/processState.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 |
16 | export enum PROCESS_STATE {
17 | //CALLING_INTERCEPTION_REQUEST : Process state for the request interceptor.
18 | //CALLING_INTERCEPTION_RESOPONSE : Process state for the response interceptor.
19 | CALLING_INTERCEPTION_REQUEST,
20 | CALLING_INTERCEPTION_RESPONSE
21 | }
22 |
23 | declare let process: any;
24 |
25 | export class ProcessState {
26 | history: PROCESS_STATE[] = [];
27 | private static instance: ProcessState | undefined;
28 |
29 | static getInstance() {
30 | if (ProcessState.instance == undefined) {
31 | ProcessState.instance = new ProcessState();
32 | }
33 | return ProcessState.instance;
34 | }
35 |
36 | addState = (state: PROCESS_STATE) => {
37 | if (process !== undefined && process.env !== undefined && process.env.TEST_MODE === "testing") {
38 | this.history.push(state);
39 | }
40 | };
41 |
42 | private getEventByLastEventByName = (state: PROCESS_STATE) => {
43 | for (let i = this.history.length - 1; i >= 0; i--) {
44 | if (this.history[i] == state) {
45 | return this.history[i];
46 | }
47 | }
48 | return undefined;
49 | };
50 |
51 | reset = () => {
52 | this.history = [];
53 | };
54 |
55 | waitForEvent = async (state: PROCESS_STATE, timeInMS = 7000) => {
56 | let startTime = Date.now();
57 | return new Promise(resolve => {
58 | let actualThis = this;
59 | function tryAndGet() {
60 | let result = actualThis.getEventByLastEventByName(state);
61 | if (result === undefined) {
62 | if (Date.now() - startTime > timeInMS) {
63 | resolve(undefined);
64 | } else {
65 | setTimeout(tryAndGet, 1000);
66 | }
67 | } else {
68 | resolve(result);
69 | }
70 | }
71 | tryAndGet();
72 | });
73 | };
74 | }
75 |
--------------------------------------------------------------------------------
/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.4";
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 |
--------------------------------------------------------------------------------
/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/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "jsRules": {
3 | "class-name": true,
4 | "comment-format": [
5 | true,
6 | "check-space"
7 | ],
8 | "indent": [
9 | true,
10 | "spaces"
11 | ],
12 | "no-duplicate-variable": true,
13 | "no-eval": true,
14 | "no-trailing-whitespace": true,
15 | "no-unsafe-finally": true,
16 | "one-line": [
17 | true,
18 | "check-open-brace",
19 | "check-whitespace"
20 | ],
21 | "quotemark": [
22 | true,
23 | "double"
24 | ],
25 | "semicolon": [
26 | true,
27 | "always"
28 | ],
29 | "triple-equals": [
30 | true,
31 | "allow-null-check"
32 | ],
33 | "variable-name": [
34 | true,
35 | "ban-keywords"
36 | ],
37 | "whitespace": [
38 | true,
39 | "check-branch",
40 | "check-decl",
41 | "check-operator",
42 | "check-separator",
43 | "check-type"
44 | ]
45 | },
46 | "rules": {
47 | "class-name": true,
48 | "comment-format": [
49 | true,
50 | "check-space"
51 | ],
52 | "indent": [
53 | true,
54 | "spaces"
55 | ],
56 | "no-eval": true,
57 | "no-internal-module": true,
58 | "no-trailing-whitespace": true,
59 | "no-unsafe-finally": true,
60 | "no-var-keyword": true,
61 | "one-line": [
62 | true,
63 | "check-open-brace",
64 | "check-whitespace"
65 | ],
66 | "quotemark": [
67 | true,
68 | "double"
69 | ],
70 | "semicolon": [
71 | true,
72 | "always"
73 | ],
74 | "triple-equals": [
75 | true,
76 | "allow-null-check"
77 | ],
78 | "typedef-whitespace": [
79 | true,
80 | {
81 | "call-signature": "nospace",
82 | "index-signature": "nospace",
83 | "parameter": "nospace",
84 | "property-declaration": "nospace",
85 | "variable-declaration": "nospace"
86 | }
87 | ],
88 | "variable-name": [
89 | true,
90 | "ban-keywords"
91 | ],
92 | "whitespace": [
93 | true,
94 | "check-branch",
95 | "check-decl",
96 | "check-operator",
97 | "check-separator",
98 | "check-type"
99 | ]
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/otherInfo.txt:
--------------------------------------------------------------------------------
1 | Structure:
2 | There will be a pure JS implementation and a native implementation.
3 |
4 | If the user links the lib, then ONLY the native implementation will work, else only the pure JS implementation will work.
5 |
6 | Both the implementation's data - cookies, storage items, should be "in sync". If the user moves from one to the other, it should not break things and should not cause user logouts.
7 |
8 |
9 | Parts of readme:
10 | ---------------------------------
11 |
12 | ## Getting started
13 |
14 | `$ npm install react-native-lib --save`
15 |
16 | ### Mostly automatic installation
17 |
18 | `$ react-native link react-native-lib`
19 |
20 | ### Manual installation
21 |
22 |
23 | #### iOS
24 |
25 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
26 | 2. Go to `node_modules` ➜ `react-native-lib` and add `RNSuperTokens.xcodeproj`
27 | 3. In XCode, in the project navigator, select your project. Add `libRNSuperTokens.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
28 | 4. Run your project (`Cmd+R`)<
29 |
30 | #### Android
31 |
32 | 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
33 | - Add `import io.supertokens.reactnative.RNSuperTokensPackage;` to the imports at the top of the file
34 | - Add `new RNSuperTokensPackage()` to the list returned by the `getPackages()` method
35 | 2. Append the following lines to `android/settings.gradle`:
36 | ```
37 | include ':react-native-lib'
38 | project(':react-native-lib').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-lib/android')
39 | ```
40 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
41 | ```
42 | compile project(':react-native-lib')
43 | ```
44 |
45 | ## Usage
46 | ```javascript
47 | import RNSuperTokens from 'react-native-lib';
48 |
49 | // TODO: What to do with the module?
50 | RNSuperTokens;
51 | ```
52 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "supertokens-react-native",
3 | "version": "5.1.4",
4 | "description": "React Native SDK for SuperTokens",
5 | "main": "index.js",
6 | "scripts": {
7 | "build-check": "cd lib && npx tsc -p tsconfig.json --skipLibCheck --noEmit",
8 | "build": "cd lib && npx tsc -p tsconfig.json --skipLibCheck && cd ../ && cd test/playground && npx tsc -p tsconfig.json",
9 | "pretty": "npx prettier --write --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/**/*.js\" \"examples/**/*.js\"",
10 | "build-pretty": "npm run build && npm run pretty",
11 | "pretty-check": "npx prettier --check --config .prettierrc \"lib/ts/**/*.ts\" \"lib/build/**/*.js\" \"TestingApp/**/*.js\" \"examples/**/*.js\"",
12 | "set-up-hooks": "cp hooks/pre-commit.sh .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit",
13 | "build-docs": "rm -rf ./docs && npx typedoc --out ./docs --tsconfig ./lib/tsconfig.json ./lib/ts/index.ts",
14 | "size": "size-limit"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/supertokens/supertokens-react-native.git"
19 | },
20 | "keywords": [
21 | "react-native",
22 | "authentication",
23 | "authorisation",
24 | "supertokens",
25 | "ios",
26 | "android"
27 | ],
28 | "author": "rishabhpoddar",
29 | "license": "Apache 2.0",
30 | "bugs": {
31 | "url": "https://github.com/supertokens/supertokens-react-native/issues"
32 | },
33 | "homepage": "https://github.com/supertokens/supertokens-react-native#readme",
34 | "peerDependencies": {
35 | "axios": "*",
36 | "react-native": ">=0.61.5 <1.0.x",
37 | "@react-native-async-storage/async-storage": ">=1.13.0 <2.0.x"
38 | },
39 | "devDependencies": {
40 | "@react-native-async-storage/async-storage": "^1.13.0",
41 | "@size-limit/preset-small-lib": "^6.0.4",
42 | "@types/base-64": "^1.0.0",
43 | "@types/react-native": "0.62.0",
44 | "axios": "*",
45 | "prettier": "1.18.2",
46 | "size-limit": "^6.0.4",
47 | "typescript": "3.8.3",
48 | "typedoc": "^0.22.5"
49 | },
50 | "dependencies": {
51 | "base-64": "^1.0.0",
52 | "react-native-url-polyfill": "^1.3.0",
53 | "supertokens-js-override": "^0.0.4"
54 | },
55 | "size-limit": [
56 | {
57 | "path": "lib/build/index.js",
58 | "limit": "28kb"
59 | }
60 | ]
61 | }
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------