├── sample ├── .watchmanconfig ├── .gitattributes ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── raw │ │ │ │ │ │ └── index.html │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── sample │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── sample │ │ │ │ └── ReactNativeFlipper.java │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ ├── BUCK │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── app.json ├── babel.config.js ├── assets │ ├── login.jpg │ ├── footer.png │ └── background.jpeg ├── ios │ ├── sample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Info.plist │ │ ├── AppDelegate.m │ │ └── LaunchScreen.storyboard │ ├── sampleTests │ │ ├── Info.plist │ │ └── sampleTests.m │ ├── sample-tvOSTests │ │ └── Info.plist │ ├── Podfile │ ├── sample-tvOS │ │ └── Info.plist │ └── sample.xcodeproj │ │ └── xcshareddata │ │ └── xcschemes │ │ ├── sample.xcscheme │ │ └── sample-tvOS.xcscheme ├── .buckconfig ├── .prettierrc.js ├── __tests__ │ └── App-test.js ├── metro.config.js ├── tsconfig.json ├── components │ ├── index.js │ ├── ButtonContainer.js │ ├── Button.js │ └── styles.js ├── index.js ├── .gitignore ├── package.json ├── context │ └── LoginContext.tsx ├── .flowconfig ├── App.tsx ├── screen │ ├── HomeScreen.tsx │ └── LoginScreen.tsx └── .eslintrc.js ├── lib ├── babel.config.js ├── .npmignore ├── tsconfig.json ├── index.ts ├── .gitignore ├── package.json ├── src │ ├── store.ts │ ├── models.ts │ ├── crypto-utils.ts │ └── authenticate.tsx ├── .eslintrc.js └── LICENSE ├── .github ├── config.yml ├── feature_request.md ├── improvement.md ├── doc_issues.md ├── bug_report.md └── workflows │ └── notification.yml ├── lerna.json ├── .gitignore ├── pull_request_template.md ├── LICENSE └── README.md /sample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /sample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/raw/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sample/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "displayName": "sample" 4 | } -------------------------------------------------------------------------------- /lib/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ "module:metro-react-native-babel-preset" ] 3 | }; 4 | -------------------------------------------------------------------------------- /sample/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ "module:metro-react-native-babel-preset" ] 3 | }; 4 | -------------------------------------------------------------------------------- /sample/assets/login.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/assets/login.jpg -------------------------------------------------------------------------------- /sample/assets/footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/assets/footer.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sample 3 | 4 | -------------------------------------------------------------------------------- /sample/assets/background.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/assets/background.jpeg -------------------------------------------------------------------------------- /sample/ios/sample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sample/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/debug.keystore -------------------------------------------------------------------------------- /sample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /sample/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | *.log 3 | npm-debug.log 4 | 5 | # Dependency directory 6 | node_modules 7 | 8 | # Runtime data 9 | tmp 10 | 11 | # Examples (If applicable to your project) 12 | examples -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2-attic/asgardeo-react-native-oidc-sdk/HEAD/sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'sample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Ask a question 4 | url: https://github.com/wso2/product-is/wiki/Engage-with-the-community 5 | about: Check here on how you can ask a question about the product 6 | -------------------------------------------------------------------------------- /sample/ios/sample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /sample/ios/sample/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 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "command": { 4 | "version": { 5 | "message": "[Asgardeo Release] [GitHub Actions] [Release %s] Bump version" 6 | } 7 | }, 8 | "packages": [ 9 | "asgardio-react-native-oidc-sdk/*", 10 | "sample/*" 11 | ], 12 | "version": "0.1.0" 13 | } 14 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import "react-native"; 6 | import React from "react"; 7 | import App from "../App"; 8 | 9 | // Note: test renderer must be required after react-native. 10 | // eslint-disable-next-line import/order 11 | import renderer from "react-test-renderer"; 12 | 13 | it("renders correctly", () => { 14 | renderer.create(); 15 | }); 16 | -------------------------------------------------------------------------------- /sample/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: false 14 | } 15 | }) 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/com/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "sample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /.github/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ➕ Feature request 3 | about: Suggest an idea for this project 4 | title: "" 5 | labels: "feature" 6 | assignees: "" 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | 11 | 12 | 13 | **Describe the solution you would prefer** 14 | 15 | 16 | 17 | **Additional context** 18 | 19 | 20 | -------------------------------------------------------------------------------- /.github/improvement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ✅ Improvement suggestion 3 | about: Suggest an improvement for the project 4 | title: "" 5 | labels: "improvement" 6 | assignees: "" 7 | --- 8 | 9 | **Is your suggestion related to an experience ? Please describe.** 10 | 11 | 12 | 13 | **Describe the improvement** 14 | 15 | 16 | 17 | **Additional context** 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /.github/doc_issues.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 📕 Doc issues 3 | about: Please report documentation issues here 4 | title: "" 5 | labels: "docs" 6 | assignees: "" 7 | --- 8 | 9 | **Is your suggestion related to a missing or misleading document? Please describe.** 10 | 11 | 12 | 13 | **Describe the improvement** 14 | 15 | 16 | 17 | --- 18 | 19 | ### Optional Fields 20 | 21 | **Additional context** 22 | 23 | 24 | 25 | **Related Issues:** 26 | 27 | 28 | -------------------------------------------------------------------------------- /lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "target": "es6", 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | "noImplicitAny": false, 8 | "jsx": "react", 9 | "resolveJsonModule": true, 10 | "sourceMap": true, 11 | "noLib": false, 12 | "lib":["es5","es2017","dom"], 13 | "suppressImplicitAnyIndexErrors": true, 14 | "experimentalDecorators": true, 15 | "composite": true, 16 | "declarationMap": true, 17 | "baseUrl": "/", 18 | "paths": { 19 | "*": ["types/*"] 20 | }, 21 | 22 | }, 23 | "compileOnSave": false, 24 | "exclude": ["node_modules", "test-configs", "src/**/tests/*", "babel.config.js", "metro.config.js", "jest.config.js"] 25 | } 26 | -------------------------------------------------------------------------------- /sample/ios/sample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /sample/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "target": "es6", 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | "noImplicitAny": false, 8 | "jsx": "react", 9 | "resolveJsonModule": true, 10 | "sourceMap": true, 11 | "noLib": false, 12 | "lib":["es5","es2017","dom"], 13 | "suppressImplicitAnyIndexErrors": true, 14 | "experimentalDecorators": true, 15 | "composite": true, 16 | "allowSyntheticDefaultImports": true, 17 | "declarationMap": true, 18 | "baseUrl": "/", 19 | "paths": { 20 | "*": ["types/*"] 21 | }, 22 | 23 | }, 24 | "compileOnSave": false, 25 | "exclude": ["node_modules", "test-configs", "src/**/tests/*", "babel.config.js", "metro.config.js", "jest.config.js"] 26 | } 27 | -------------------------------------------------------------------------------- /sample/ios/sampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/ios/sample-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | import { AuthClient, AuthProvider, useAuthContext } from "./src/authenticate"; 19 | 20 | export { AuthClient, AuthProvider, useAuthContext }; 21 | -------------------------------------------------------------------------------- /sample/components/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | export { default as Button } from "./Button"; 20 | export { default as ButtonContainer } from "./ButtonContainer"; 21 | -------------------------------------------------------------------------------- /sample/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'sample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | target 'sampleTests' do 12 | inherit! :complete 13 | # Pods for testing 14 | end 15 | 16 | # Enables Flipper. 17 | # 18 | # Note that if you have use_frameworks! enabled, Flipper will not work and 19 | # you should disable these next few lines. 20 | use_flipper! 21 | post_install do |installer| 22 | flipper_post_install(installer) 23 | end 24 | end 25 | 26 | target 'sample-tvOS' do 27 | # Pods for sample-tvOS 28 | 29 | target 'sample-tvOSTests' do 30 | inherit! :search_paths 31 | # Pods for testing 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /sample/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import { AppRegistry } from "react-native"; 20 | import App from "./App"; 21 | import { name as appName } from "./app.json"; 22 | 23 | AppRegistry.registerComponent(appName, () => App); 24 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /.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 | 25 | 26 | # Android/IntelliJ 27 | # 28 | build/ 29 | .idea 30 | .gradle 31 | local.properties 32 | *.iml 33 | 34 | # node.js 35 | # 36 | node_modules/ 37 | npm-debug.log 38 | yarn-error.log 39 | 40 | # BUCK 41 | buck-out/ 42 | \.buckd/ 43 | *.keystore 44 | !debug.keystore 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/ 52 | 53 | */fastlane/report.xml 54 | */fastlane/Preview.html 55 | */fastlane/screenshots 56 | 57 | # Bundle artifact 58 | *.jsbundle 59 | 60 | # CocoaPods 61 | /ios/Pods/ 62 | -------------------------------------------------------------------------------- /.github/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ❗️ Issue/Bug report 3 | about: Report issue or bug related to the project 4 | title: "" 5 | labels: "bug" 6 | assignees: "" 7 | --- 8 | 9 | **Describe the issue:** 10 | 11 | 12 | 13 | **How to reproduce:** 14 | 15 | 16 | 17 | **Expected behavior:** 18 | 19 | 20 | 21 | **Environment information** (_Please complete the following information; remove any unnecessary fields_) **:** 22 | 23 | - Product Version: [e.g., IS 5.10.0, IS 5.9.0] 24 | - OS: [e.g., Windows, Linux, Mac] 25 | - React Native Version: [e.g., 0.63, 0.62, 0.61] 26 | - Node version (node -v): [e.g., v15.2.1, v14.15.1, v12.19.1] 27 | - SDK Version: [e.g., 0.1.0, 0.1.1] 28 | 29 | --- 30 | 31 | ### Optional Fields 32 | 33 | **Related issues:** 34 | 35 | 36 | 37 | **Suggested labels:** 38 | 39 | 40 | -------------------------------------------------------------------------------- /sample/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 = "29.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | } 10 | repositories { 11 | google() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.3") 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | mavenLocal() 24 | maven { 25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 26 | url("$rootDir/../node_modules/react-native/android") 27 | } 28 | maven { 29 | // Android JSC is installed from npm 30 | url("$rootDir/../node_modules/jsc-android/dist") 31 | } 32 | 33 | google() 34 | jcenter() 35 | maven { url 'https://www.jitpack.io' } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | 61 | # Certificate 62 | android/app/src/main/res/raw/wso2carbon.pem 63 | 64 | # IDE generated folders. 65 | /.vscode/ 66 | -------------------------------------------------------------------------------- /sample/components/ButtonContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import React from "react"; 20 | import { StyleSheet, View } from "react-native"; 21 | 22 | const ButtonContainer = props => ; 23 | 24 | const styles = StyleSheet.create({ 25 | view: { 26 | alignSelf: "flex-end", 27 | bottom: 0, 28 | flexDirection: "row", 29 | left: 0, 30 | margin: 5, 31 | position: "absolute", 32 | right: 0 33 | } 34 | }); 35 | 36 | export default ButtonContainer; 37 | -------------------------------------------------------------------------------- /sample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.54.0 29 | -------------------------------------------------------------------------------- /sample/components/Button.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import React from "react"; 20 | import { StyleSheet, Text, TouchableOpacity } from "react-native"; 21 | 22 | // eslint-disable-next-line react/prop-types 23 | const Button = ({ text, color, onPress }) => ( 24 | 29 | { text } 30 | 31 | ); 32 | 33 | const styles = StyleSheet.create({ 34 | buttonBox: { 35 | alignItems: "center", 36 | flex: 1, 37 | height: 50, 38 | justifyContent: "center", 39 | margin: 5 40 | }, 41 | text: { 42 | color: "white" 43 | } 44 | }); 45 | 46 | export default Button; 47 | -------------------------------------------------------------------------------- /sample/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.sample", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.sample", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /sample/ios/sample-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /sample/ios/sample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | sample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /sample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx" 11 | }, 12 | "dependencies": { 13 | "@asgardeo/auth-react-native": "file:../lib/asgardeo-auth-react-native-0.0.1.tgz", 14 | "@react-native-async-storage/async-storage": "^1.13.2", 15 | "@react-native-community/masked-view": "^0.1.11", 16 | "@react-navigation/native": "^5.9.0", 17 | "@react-navigation/stack": "^5.13.0", 18 | "react": "16.13.1", 19 | "react-native": "^0.63.4", 20 | "react-native-gesture-handler": "^1.9.0", 21 | "react-native-reanimated": "^1.13.2", 22 | "react-native-safe-area-context": "^3.1.9", 23 | "react-native-screens": "^2.16.1", 24 | "react-native-webview": "^11.0.3", 25 | "reactotron-react-native": "^5.0.0", 26 | "text-encoding-polyfill": "^0.6.7" 27 | }, 28 | "devDependencies": { 29 | "@babel/core": "^7.8.4", 30 | "@babel/runtime": "^7.8.4", 31 | "@types/jest": "^26.0.16", 32 | "@types/react": "^17.0.0", 33 | "@types/react-native": "^0.63.37", 34 | "@types/react-test-renderer": "^17.0.0", 35 | "@typescript-eslint/eslint-plugin": "^4.33.0", 36 | "@typescript-eslint/parser": "^4.33.0", 37 | "babel-jest": "^25.1.0", 38 | "eslint": "^7.32.0", 39 | "eslint-plugin-import": "^2.24.2", 40 | "eslint-plugin-react": "^7.27.1", 41 | "eslint-plugin-react-hooks": "^4.3.0", 42 | "jest": "^25.1.0", 43 | "metro-react-native-babel-preset": "^0.59.0", 44 | "react-test-renderer": "16.13.1", 45 | "typescript": "^4.1.2" 46 | }, 47 | "jest": { 48 | "preset": "react-native", 49 | "moduleFileExtensions": [ 50 | "ts", 51 | "tsx", 52 | "js", 53 | "jsx", 54 | "json", 55 | "node" 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /sample/ios/sampleTests/sampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface sampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation sampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@asgardeo/auth-react-native", 3 | "description": "Asgardeo Auth React Native SDK for Mobile Applications.", 4 | "main": "index.ts", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1", 7 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx" 8 | }, 9 | "version": "0.0.1", 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/asgardeo/asgardeo-react-native-oidc-sdk.git" 13 | }, 14 | "keywords": [ 15 | "Asgardeo", 16 | "OIDC", 17 | "OAuth2", 18 | "Authentication", 19 | "Authorization", 20 | "React Native" 21 | ], 22 | "author": "Asgardeo", 23 | "license": "Apache-2.0", 24 | "bugs": { 25 | "url": "https://github.com/asgardeo/asgardeo-react-native-oidc-sdk/issues" 26 | }, 27 | "homepage": "https://github.com/asgardeo/asgardeo-react-native-oidc-sdk#readme", 28 | "dependencies": { 29 | "@asgardeo/auth-js": "^1.0.0", 30 | "@react-native-async-storage/async-storage": "^1.13.2", 31 | "@types/crypto-js": "^4.0.1", 32 | "base-64": "^1.0.0", 33 | "crypto-js": "^3.3.0", 34 | "jsrsasign": "^10.5.1", 35 | "jsrsasign-util": "^1.0.5", 36 | "react": "16.13.1", 37 | "react-native": "^0.63.4", 38 | "react-native-gesture-handler": "^1.9.0", 39 | "url": "^0.11.0" 40 | }, 41 | "deprecated": false, 42 | "devDependencies": { 43 | "@babel/core": "^7.8.4", 44 | "@babel/runtime": "^7.8.4", 45 | "@types/jest": "^26.0.16", 46 | "@types/react": "^17.0.0", 47 | "@types/react-native": "^0.63.37", 48 | "@types/react-test-renderer": "^17.0.0", 49 | "@typescript-eslint/eslint-plugin": "^4.33.0", 50 | "@typescript-eslint/parser": "^4.33.0", 51 | "babel-jest": "^25.1.0", 52 | "eslint": "^7.32.0", 53 | "eslint-plugin-import": "^2.24.2", 54 | "eslint-plugin-react": "^7.27.1", 55 | "eslint-plugin-react-hooks": "^4.3.0", 56 | "metro-react-native-babel-preset": "^0.65.1", 57 | "react-test-renderer": "16.13.1", 58 | "text-encoding-polyfill": "^0.6.7", 59 | "typescript": "^4.1.2" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sample/context/LoginContext.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import React, { useContext, useState } from "react"; 20 | 21 | const initialState = { 22 | accessToken: "", 23 | allowedScopes: "", 24 | amr: "", 25 | at_hash: "", 26 | aud: "", 27 | azp: "", 28 | c_hash: "", 29 | exp: "", 30 | hasLogin: false, 31 | hasLogoutInitiated: false, 32 | iat: "", 33 | idToken: "", 34 | iss: "", 35 | loading: false, 36 | nbf: "", 37 | refreshToken: "", 38 | sessionState: "", 39 | sub: "", 40 | username: "" 41 | }; 42 | 43 | const LoginContext = React.createContext(null); 44 | 45 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 46 | const LoginContextProvider = ( 47 | props: { children: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal; } 48 | ) => { 49 | const [ loginState, setLoginState ] = useState(initialState); 50 | const [ loading, setLoading ] = useState(false); 51 | 52 | return ( 53 | 61 | { props.children } 62 | 63 | ); 64 | }; 65 | 66 | const useLoginContext = (): any => { 67 | return useContext(LoginContext); 68 | }; 69 | 70 | export { initialState, LoginContextProvider, useLoginContext }; 71 | -------------------------------------------------------------------------------- /sample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | unnecessary-invariant=warn 60 | signature-verification-failure=warn 61 | deprecated-utility=error 62 | 63 | [strict] 64 | deprecated-type 65 | nonstrict-import 66 | sketchy-null 67 | unclear-type 68 | unsafe-getters-setters 69 | untyped-import 70 | untyped-type-import 71 | 72 | [version] 73 | ^0.122.0 74 | -------------------------------------------------------------------------------- /sample/App.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import "react-native-gesture-handler"; 20 | import { AuthProvider } from "@asgardeo/auth-react-native"; 21 | import { NavigationContainer } from "@react-navigation/native"; 22 | import { createStackNavigator } from "@react-navigation/stack"; 23 | import React from "react"; 24 | import { LoginContextProvider } from "./context/LoginContext"; 25 | import HomeScreen from "./screen/HomeScreen"; 26 | import LoginScreen from "./screen/LoginScreen"; 27 | 28 | const Stack = createStackNavigator(); 29 | 30 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 31 | const App = () => { 32 | 33 | return ( 34 | 35 | 36 | 37 | 38 | 43 | 48 | 49 | 50 | 51 | 52 | ); 53 | }; 54 | 55 | export default App; 56 | -------------------------------------------------------------------------------- /lib/src/store.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import "text-encoding-polyfill"; 20 | import { Store } from "@asgardeo/auth-js"; 21 | import AsyncStorage from "@react-native-async-storage/async-storage"; 22 | 23 | /** 24 | * Create a Store class to store the authentication data. 25 | * The following implementation uses the async-storage. 26 | */ 27 | export class LocalStorage implements Store { 28 | 29 | /** 30 | * Get the data from the store. 31 | * 32 | * @param {string} key - key. 33 | * 34 | */ 35 | async getData(key: string): Promise { 36 | 37 | const _value = await AsyncStorage.getItem(key); 38 | 39 | return _value; 40 | } 41 | 42 | /** 43 | * Save the data into the store. 44 | * 45 | * @param {string} key - key. 46 | * @param {string} value - value. 47 | * 48 | * @return {Promise} 49 | */ 50 | async setData(key: string, value: string): Promise { 51 | 52 | try { 53 | await AsyncStorage.setItem(key, value); 54 | } 55 | catch(error) { 56 | // TODO: Add logs when a logger is available. 57 | // Tracked here https://github.com/asgardeo/asgardeo-auth-js-sdk/issues/151. 58 | } 59 | } 60 | 61 | /** 62 | * Remove the data from the store. 63 | * 64 | * @param {string} key - key. 65 | * @return {Promise} 66 | */ 67 | async removeData(key: string): Promise { 68 | 69 | try { 70 | await AsyncStorage.removeItem(key); 71 | } 72 | catch(error) { 73 | // TODO: Add logs when a logger is available. 74 | // Tracked here https://github.com/asgardeo/asgardeo-auth-js-sdk/issues/151. 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/src/models.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import { 20 | AuthClientConfig, 21 | BasicUserInfo, 22 | CustomGrantConfig, 23 | DataLayer, 24 | DecodedIDTokenPayload, 25 | GetAuthURLConfig, 26 | OIDCEndpoints, 27 | TokenResponse 28 | } from "@asgardeo/auth-js"; 29 | 30 | export interface AuthStateInterface { 31 | accessToken: string; 32 | idToken: string; 33 | expiresIn: string; 34 | scope: string; 35 | refreshToken: string; 36 | tokenType: string; 37 | isAuthenticated: boolean; 38 | authResponseError?: {errorCode?: string, errorMessage?: string}; 39 | } 40 | 41 | export interface AuthContextInterface { 42 | state: AuthStateInterface; 43 | isSignOutSuccessful: (signOutRedirectURL: string) => boolean; 44 | initialize: (config: AuthClientConfig) => Promise; 45 | getDataLayer: () => Promise>; 46 | getAuthorizationURL: (config?: GetAuthURLConfig) => Promise; 47 | signIn: (config?: GetAuthURLConfig) => Promise; 48 | refreshAccessToken: () => Promise; 49 | getSignOutURL: () => Promise; 50 | signOut: () => Promise; 51 | getOIDCServiceEndpoints: () => Promise; 52 | getDecodedIDToken: () => Promise; 53 | getBasicUserInfo: () => Promise; 54 | revokeAccessToken: () => Promise; 55 | getAccessToken: () => Promise; 56 | getIDToken: () => Promise; 57 | isAuthenticated: () => Promise; 58 | updateConfig: (config: Partial) => Promise; 59 | requestCustomGrant: (config: CustomGrantConfig) => Promise; 60 | clearAuthResponseError: () => void; 61 | } 62 | 63 | export type AuthUrl = { 64 | url: string 65 | } 66 | -------------------------------------------------------------------------------- /sample/ios/sample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"sample" 37 | initialProperties:nil]; 38 | 39 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 40 | 41 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 42 | UIViewController *rootViewController = [UIViewController new]; 43 | rootViewController.view = rootView; 44 | self.window.rootViewController = rootViewController; 45 | [self.window makeKeyAndVisible]; 46 | return YES; 47 | } 48 | 49 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 50 | { 51 | #if DEBUG 52 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 53 | #else 54 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 55 | #endif 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | > Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc. 3 | 4 | ## Goals 5 | > Describe the solutions that this feature/fix will introduce to resolve the problems described above 6 | 7 | ## Approach 8 | > Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here. 9 | 10 | ## User stories 11 | > Summary of user stories addressed by this change> 12 | 13 | ## Release note 14 | > Brief description of the new feature or bug fix as it will appear in the release notes 15 | 16 | ## Documentation 17 | > Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact 18 | 19 | ## Training 20 | > Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable 21 | 22 | ## Certification 23 | > Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why. 24 | 25 | ## Marketing 26 | > Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable 27 | 28 | ## Automation tests 29 | - Unit tests 30 | > Code coverage information 31 | - Integration tests 32 | > Details about the test cases and coverage 33 | 34 | ## Security checks 35 | - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no 36 | - Ran FindSecurityBugs plugin and verified report? yes/no 37 | - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no 38 | 39 | ## Samples 40 | > Provide high-level details about the samples related to this feature 41 | 42 | ## Related PRs 43 | > List any other related PRs 44 | 45 | ## Migrations (if applicable) 46 | > Describe migration steps and platforms on which migration has been tested 47 | 48 | ## Test environment 49 | > List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested 50 | 51 | ## Learning 52 | > Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem. 53 | -------------------------------------------------------------------------------- /lib/src/crypto-utils.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import { CryptoUtils, DecodedIDTokenPayload, JWKInterface, SUPPORTED_SIGNATURE_ALGORITHMS } from "@asgardeo/auth-js"; 20 | import { AsgardeoAuthException } from "@asgardeo/auth-js/src/exception"; 21 | import { decode as atob } from "base-64"; 22 | import Base64 from "crypto-js/enc-base64"; 23 | import utf8 from "crypto-js/enc-utf8"; 24 | import WordArray from "crypto-js/lib-typedarrays"; 25 | import sha256 from "crypto-js/sha256"; 26 | import { KEYUTIL, KJUR } from "jsrsasign"; 27 | 28 | export class ReactNativeCryptoUtils implements CryptoUtils { 29 | /** 30 | * Get URL encoded string. 31 | * 32 | * @param {CryptoJS.WordArray} value. 33 | * @returns {string} base 64 url encoded value. 34 | */ 35 | public base64URLEncode(value: WordArray): string { 36 | return Base64.stringify(value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); 37 | } 38 | 39 | public base64URLDecode(data: string): string { 40 | return Base64.parse(data).toString(utf8); 41 | } 42 | 43 | public hashSha256(data: string): WordArray { 44 | return sha256(data); 45 | } 46 | 47 | public generateRandomBytes(length: number): WordArray { 48 | return WordArray.random(length); 49 | } 50 | 51 | public parseJwk(key: Partial): Promise { 52 | return KEYUTIL.getKey({ 53 | alg: key.alg, 54 | e: key.e, 55 | kty: key.kty, 56 | n: key.n 57 | }); 58 | } 59 | 60 | public verifyJwt( 61 | idToken: string, 62 | jwk: any, 63 | algorithms: string[], 64 | clientID: string, 65 | issuer: string, 66 | subject: string, 67 | clockTolerance?: number 68 | ): Promise { 69 | const verification = KJUR.jws.JWS.verifyJWT(idToken, jwk, { 70 | alg: SUPPORTED_SIGNATURE_ALGORITHMS, 71 | aud: clientID, 72 | gracePeriod: clockTolerance, 73 | iss: [issuer], 74 | sub: subject 75 | }); 76 | 77 | return Promise.resolve(verification); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/com/sample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.sample; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for example: 28 | // packages.add(new MyReactNativePackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 53 | * 54 | * @param context 55 | * @param reactInstanceManager 56 | */ 57 | private static void initializeFlipper( 58 | Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | We use reflection here to pick up the class that initializes Flipper, 63 | since Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("com.sample.ReactNativeFlipper"); 66 | aClass 67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 68 | .invoke(null, context, reactInstanceManager); 69 | } catch (ClassNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) { 74 | e.printStackTrace(); 75 | } catch (InvocationTargetException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /sample/components/styles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import { StyleSheet } from "react-native"; 20 | 21 | const styles = StyleSheet.create({ 22 | body: { 23 | margin: 10 24 | }, 25 | 26 | button: { 27 | marginLeft: "35%", 28 | width: "30%" 29 | }, 30 | 31 | deco: { 32 | fontWeight: "bold", 33 | margin: 10, 34 | textAlign: "center" 35 | }, 36 | 37 | flex: { 38 | backgroundColor: "#e2e2e2", 39 | borderColor: "#c5c5c5", 40 | borderWidth: 1 41 | }, 42 | 43 | flexBody: { 44 | fontWeight: "bold", 45 | marginLeft: 10 46 | }, 47 | 48 | flexContainer: { 49 | flex: 1, 50 | flexDirection: "column", 51 | paddingBottom: 70 52 | }, 53 | 54 | flexDetails: { 55 | marginBottom: 10, 56 | marginLeft: 10 57 | }, 58 | 59 | flexHeading: { 60 | fontWeight: "bold", 61 | marginTop: 10, 62 | textAlign: "center" 63 | }, 64 | 65 | footer: { 66 | alignItems: "center", 67 | paddingTop: 45 68 | }, 69 | 70 | footerAlign: { 71 | height: 20, 72 | width: 50 73 | }, 74 | 75 | image: { 76 | borderRadius: 30, 77 | height: "60%", 78 | resizeMode: "contain", 79 | width: "85%" 80 | }, 81 | 82 | imageAlign: { 83 | alignItems: "center" 84 | }, 85 | 86 | loading: { 87 | alignItems: "center", 88 | backgroundColor: "#F5FCFF88", 89 | bottom: 0, 90 | justifyContent: "center", 91 | left: 0, 92 | position: "absolute", 93 | right: 0, 94 | top: 0 95 | }, 96 | 97 | mainBody: { 98 | backgroundColor: "#0000" 99 | }, 100 | 101 | refBody: { 102 | textAlign: "center" 103 | }, 104 | 105 | refToken: { 106 | marginBottom: 10, 107 | textAlign: "center" 108 | }, 109 | 110 | text: { 111 | backgroundColor: "#f47421", 112 | borderBottomColor: "#e2e2e2", 113 | borderBottomWidth: 2, 114 | color: "white", 115 | fontSize: 25, 116 | justifyContent: "center", 117 | textAlign: "center" 118 | }, 119 | 120 | textStyle: { 121 | color: "blue", 122 | textDecorationLine: "underline" 123 | }, 124 | 125 | textpara: { 126 | borderBottomColor: "#282c34", 127 | color: "#2A2A2A", 128 | fontSize: 18, 129 | justifyContent: "center", 130 | paddingLeft: 20, 131 | paddingRight: 20, 132 | textAlign: "justify" 133 | } 134 | }); 135 | 136 | export { styles }; 137 | -------------------------------------------------------------------------------- /sample/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%" == "0" goto init 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 init 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 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /sample/android/app/src/debug/java/com/sample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its 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.sample; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sample/ios/sample.xcodeproj/xcshareddata/xcschemes/sample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /sample/ios/sample.xcodeproj/xcshareddata/xcschemes/sample-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /.github/workflows/notification.yml: -------------------------------------------------------------------------------- 1 | name: Send Notification 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | pull_request: 7 | types: [opened] 8 | 9 | jobs: 10 | notify: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Send notification on issue creation 14 | if: ${{github.event.issue}} 15 | run: | 16 | curl --location --request POST '${{secrets.WEBHOOK_CHAT}}' \ 17 | --header 'Content-Type: application/json' \ 18 | --data-raw '{ 19 | "cards": [ 20 | { 21 | "header": { 22 | "title": "ISSUE: ${{ github.event.issue.title }}", 23 | "subtitle": "By ${{ github.event.issue.user.login }} in Asgardeo React Native SDK Repo", 24 | "imageUrl": "https://avatars.githubusercontent.com/u/583231?v=4", 25 | "imageStyle": "IMAGE" 26 | }, 27 | "sections": { 28 | "widgets": [ 29 | { 30 | "buttons": [ 31 | { 32 | "textButton": { 33 | "text": "Open Issue", 34 | "onClick": { 35 | "openLink": { 36 | "url": "${{ github.event.issue.html_url }}" 37 | } 38 | } 39 | } 40 | } 41 | ], 42 | "textParagraph": { 43 | "text": "${{ github.event.issue.body }}" 44 | } 45 | } 46 | ] 47 | } 48 | } 49 | ] 50 | }' 51 | 52 | - name: Send notification on pull request creation 53 | if: ${{github.event.pull_request}} 54 | run: | 55 | curl --location --request POST '${{secrets.WEBHOOK_CHAT}}' \ 56 | --header 'Content-Type: application/json' \ 57 | --data-raw '{ 58 | "cards": [ 59 | { 60 | "header": { 61 | "title": "PR: ${{ github.event.pull_request.title }}", 62 | "subtitle": "By ${{ github.event.pull_request.user.login }} in Asgardeo React Native SDK Repo", 63 | "imageUrl": "https://avatars.githubusercontent.com/u/583231?v=4", 64 | "imageStyle": "IMAGE" 65 | }, 66 | "sections": { 67 | "widgets": [ 68 | { 69 | "buttons": [ 70 | { 71 | "textButton": { 72 | "text": "Open PR", 73 | "onClick": { 74 | "openLink": { 75 | "url": "${{ github.event.pull_request.html_url }}" 76 | } 77 | } 78 | } 79 | } 80 | ], 81 | "textParagraph": { 82 | "text": "${{ github.event.pull_request.body }}" 83 | } 84 | } 85 | ] 86 | } 87 | } 88 | ] 89 | }' 90 | -------------------------------------------------------------------------------- /sample/screen/HomeScreen.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import { useAuthContext } from "@asgardeo/auth-react-native"; 20 | import React from "react"; 21 | import { ActivityIndicator, Text, View } from "react-native"; 22 | import { ScrollView } from "react-native-gesture-handler"; 23 | import { Button, ButtonContainer } from "../components"; 24 | import { styles } from "../components/styles"; 25 | import { useLoginContext } from "../context/LoginContext"; 26 | 27 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 28 | const HomeScreen = () => { 29 | 30 | const { loginState, setLoginState, loading, setLoading } = useLoginContext(); 31 | const { state, signOut, refreshAccessToken } = useAuthContext(); 32 | 33 | /** 34 | * This function will handle the refresh button click. 35 | */ 36 | const handleRefreshtoken = async () => { 37 | 38 | setLoading(true); 39 | refreshAccessToken() 40 | .catch((error) => { 41 | setLoading(false); 42 | // eslint-disable-next-line no-console 43 | console.log(error); 44 | }); 45 | }; 46 | 47 | /** 48 | * This function will handle the sign out button click. 49 | */ 50 | const handleSignOut = async () => { 51 | 52 | setLoginState({ 53 | ...loginState, ...state, hasLogoutInitiated: true 54 | }); 55 | 56 | signOut() 57 | .catch((error) => { 58 | setLoading(false); 59 | // eslint-disable-next-line no-console 60 | console.log(error); 61 | }); 62 | }; 63 | 64 | return ( 65 | 66 | 67 | 68 | 69 | Hi { loginState.username } ! 70 | 71 | 72 | AllowedScopes : { loginState.allowedScopes } 73 | 74 | SessionState : 75 | 76 | { loginState.sessionState } 77 | 78 | 79 | 80 | 81 | 82 | 83 | Refresh token 84 | { loginState.refreshToken } 85 | 86 | 87 | 88 | 89 | 90 | Decoded ID token 91 | amr : { loginState.amr }, { "\n" }at_hash : 92 | { loginState.at_hash }, { "\n" }aud: { loginState.aud }, { "\n" }azp : 93 | { loginState.azp }, { "\n" }c_hash : { loginState.c_hash }, { "\n" }exp : 94 | { loginState.exp }, { "\n" }iat : { loginState.iat }, { "\n" }iss : 95 | { loginState.iss }, { "\n" }nbf : { loginState.nbf }, { "\n" }sub : 96 | { loginState.sub } 97 | 98 | 99 | 100 | 101 | 102 | 103 | ID token 104 | { loginState.idToken } 105 | 106 | 107 | 108 | 109 | { 110 | loading ? 111 | ( 112 | 113 | ) : null 114 | } 115 | 116 | 117 |