{"id":15607895,"url":"https://github.com/mukhammadali/react-native-auth0-guardian","last_synced_at":"2025-06-11T19:39:11.819Z","repository":{"id":38850754,"uuid":"232342295","full_name":"Mukhammadali/react-native-auth0-guardian","owner":"Mukhammadali","description":"Auth0 Guardian React Native (iOS \u0026 Android)","archived":false,"fork":false,"pushed_at":"2024-09-12T20:35:03.000Z","size":357,"stargazers_count":9,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-02T02:48:19.899Z","etag":null,"topics":["auth0","auth0-guardian","guardian","react-native","react-native-auth0","react-native-auth0-guardian"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mukhammadali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-07T14:29:40.000Z","updated_at":"2024-07-17T20:26:00.000Z","dependencies_parsed_at":"2025-01-05T00:12:25.672Z","dependency_job_id":"ac1ee6d6-ff48-40f4-93a6-fa8f65641749","html_url":"https://github.com/Mukhammadali/react-native-auth0-guardian","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.4864864864864865,"last_synced_commit":"46af48c2ca439ef3c73add5c855569815d4fc15f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Mukhammadali/react-native-auth0-guardian","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukhammadali%2Freact-native-auth0-guardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukhammadali%2Freact-native-auth0-guardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukhammadali%2Freact-native-auth0-guardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukhammadali%2Freact-native-auth0-guardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mukhammadali","download_url":"https://codeload.github.com/Mukhammadali/react-native-auth0-guardian/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukhammadali%2Freact-native-auth0-guardian/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259325670,"owners_count":22841061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","auth0-guardian","guardian","react-native","react-native-auth0","react-native-auth0-guardian"],"created_at":"2024-10-03T05:04:58.653Z","updated_at":"2025-06-11T19:39:11.759Z","avatar_url":"https://github.com/Mukhammadali.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# React Native Auth0 Guardian (iOS \u0026 Android)\n\n[![npm version](https://badge.fury.io/js/react-native-auth0-guardian.svg)](https://www.npmjs.com/package/react-native-auth0-guardian)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://www.npmjs.com/package/react-native-auth0-guardian)\n\n## Installation\n\n### NPM\n\n`npm install --save react-native-auth0-guardian`\n\n### Yarn\n\n`yarn add react-native-auth0-guardian`\n\n\n\n### Linking the library\n\n**React Native 0.60+**:  CLI autolink feature links the module while building the app. No any extra steps needed.\n\n**React Native \u003c= 0.59**: You need to link manually   \n`$ react-native link react-native-auth0-guardian`\n\n\nUse CocoaPods to add the native RNAuth0Guardian to your project:   \n`$ npx pod-install`\n\n### Manual installation\n\u003cdetails\u003e\n\u003csummary\u003eShow Steps\u003c/summary\u003e\n\u003cbr\u003e\n\n\n\n\n#### iOS\n\n1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Go to `node_modules` ➜ `react-native-auth0-guardian` and add `RNAuth0Guardian.xcodeproj`\n3. In XCode, in the project navigator, select your project. Add `libRNAuth0Guardian.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`\n4. Run your project (`Cmd+R`)\u003c\n\n#### Android\n\n1. Open up `android/app/src/main/java/[...]/MainActivity.java`\n  - Add `import com.reactlibrary.RNAuth0GuardianPackage;` to the imports at the top of the file\n  - Add `new RNAuth0GuardianPackage()` to the list returned by the `getPackages()` method\n2. Append the following lines to `android/settings.gradle`:\n  \t```\n  \tinclude ':react-native-auth0-guardian'\n  \tproject(':react-native-auth0-guardian').projectDir = new File(rootProject.projectDir, \t'../node_modules/react-native-auth0-guardian/android')\n  \t```\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n  \t```\n      implementation project(':react-native-auth0-guardian')\n  \t```\n\u003c/details\u003e\n\n## Usage\n### Initialization\n```javascript\nimport Auth0Guardian from 'react-native-auth0-guardian';\n\n// Before using `Auth0Guardian`, you should call `initialize` method \n// with `auth0Domain` as a parameter. Calling this in the root file is recommended Ex: root index.js or App.js\n\nconst auth0Domain = \"yourtenant.guardian.auth0.com\" // replace it with your own\n\nAuth0Guardian.initialize(auth0Domain)\n\t.then(result =\u003e console.log('Auth0 Guardian initialized 😎'))\n\t.catch(err =\u003e console.log(err))\n```\n\n### Enrolling the device\n\nAn enrollment is a link between the second factor and an Auth0 account. When an account is enrolled you'll need it to provide the second factor required to verify the identity.\n\nFor an enrollment you need the following things, besides your Guardian Domain:\n\n`enrollmentUri` - this is the url parsed from qr code. You can use *react-native-qrcode-scanner* library to scan the qrcode and parse it.   \n\n`deviceToken` - unique device token (aka FCM token for android, APNS token for iOS). You can get it using react-native push notification libraries\n\n```javascript\ntry {\n\tconst isEnrolled = await Auth0Guardian.enroll(enrollmentUri, deviceToken);\n\tconsole.log({ isEnrolled })\n} catch (err)  {\n\tconsole.log(err)\n}\n```\n\n### Get TOTP code for current enrollment. (Returns only if the device is enrolled successfully) \nYou can also get TOTP code and show it inside your application if this use case is required. User will have 2 options: notification based authentication or totp based authentication (like *Google Authenticator*)\n\n```javascript\ntry {\n\tconst totpCode = await Auth0Guardian.getTOTP();\n\tconsole.log({ totpCode })\n} catch (err) {\n\tconsole.log(err)\n}\n```\n\n### Allow a login request.\nOnce you have the enrollment in place, you will receive a push notification every time the user has to validate his identity with MFA.\n\n`notificationData` - body of notification received through push notification libraries (firebase, push-notification-ios or etc.)\n\n```javascript\ntry {\n\tconst isAllowed = await Auth0Guardian.allow(notificationData);\n\tconsole.log({ isAllowed })\n} catch (err) {\n\tconsole.log(err)\n}\n```\n\n### Reject a login request.\nTo deny an authentication request use the method below.\n\n`notificationData` - body of notification received through push notification libraries (firebase, push-notification-ios or etc.)\n\n```javascript\ntry {\n\tconst isRejected = await Auth0Guardian.reject(notificationData);\n\tconsole.log({ isRejected })\n} catch (err) {\n\tconsole.log(err)\n}\n```\n\n### Removing  device enrollment\nIf you want to delete an enrollment -for example if you want to disable MFA\n\n```javascript\ntry {\n\tconst isUnenrolled = await Auth0Guardian.unenroll();\n\tconsole.log({ isUnenrolled })\n} catch (err) {\n\tconsole.log(err)\n}\n```\n\n\n## Native libraries used:\n\n[Auth0 Guardian Java](https://github.com/auth0/Guardian.java)   \n[Auth0 Guardian Swift](https://github.com/auth0/Guardian.swift)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukhammadali%2Freact-native-auth0-guardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmukhammadali%2Freact-native-auth0-guardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukhammadali%2Freact-native-auth0-guardian/lists"}