{"id":4588,"url":"https://github.com/naoufal/react-native-passcode-auth","last_synced_at":"2025-03-17T15:13:01.084Z","repository":{"id":50477265,"uuid":"49471230","full_name":"naoufal/react-native-passcode-auth","owner":"naoufal","description":"React Native authentication with iOS Passcode.","archived":false,"fork":false,"pushed_at":"2020-05-04T10:01:17.000Z","size":94,"stargazers_count":104,"open_issues_count":14,"forks_count":52,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T00:16:37.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naoufal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-12T03:09:03.000Z","updated_at":"2024-09-09T01:58:38.000Z","dependencies_parsed_at":"2022-08-05T13:33:48.516Z","dependency_job_id":null,"html_url":"https://github.com/naoufal/react-native-passcode-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoufal%2Freact-native-passcode-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoufal%2Freact-native-passcode-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoufal%2Freact-native-passcode-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoufal%2Freact-native-passcode-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naoufal","download_url":"https://codeload.github.com/naoufal/react-native-passcode-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056425,"owners_count":20390719,"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":[],"created_at":"2024-01-05T20:17:17.207Z","updated_at":"2025-03-17T15:13:01.064Z","avatar_url":"https://github.com/naoufal.png","language":"Objective-C","readme":"# React Native Passcode Auth\n\n[![npm version](https://img.shields.io/npm/v/react-native-passcode-auth.svg?style=flat-square)](https://www.npmjs.com/package/react-native-passcode-auth)\n[![npm downloads](https://img.shields.io/npm/dm/react-native-passcode-auth.svg?style=flat-square)](https://www.npmjs.com/package/react-native-passcode-auth)\n\nReact Native Passcode Auth is a [React Native](http://facebook.github.io/react-native/) library for authenticating users with iOS Passcode.  It is an excellent fallback for when [Touch ID](https://github.com/naoufal/react-native-touch-id) is not available.\n\n![react-native-passcode-auth](https://cloud.githubusercontent.com/assets/1627824/12255178/ed7b46e2-b8be-11e5-8552-f7b60959b43c.gif)\n\n## Documentation\n- [Install](https://github.com/naoufal/react-native-passcode-auth#install)\n- [Usage](https://github.com/naoufal/react-native-passcode-auth#usage)\n- [Example](https://github.com/naoufal/react-native-passcode-auth#example)\n- [Methods](https://github.com/naoufal/react-native-passcode-auth#methods)\n- [Errors](https://github.com/naoufal/react-native-passcode-auth#errors)\n- [License](https://github.com/naoufal/react-native-passcode-auth#license)\n\n## Install\nReact Native Passcode Auth __requires iOS 9.0 or later__.\n\n```shell\nnpm i --save react-native-passcode-auth\n```\n\n## Usage\n### Linking the Library\nIn order to use Passcode Auth, you must first link the library to your project.  There's excellent documentation on how to do this in the [React Native Docs](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).\n\n### Requesting Passcode Authentication\nOnce you've linked the library, you'll want to make it available to your app by requiring it:\n\n```js\nimport PasscodeAuth from 'react-native-passcode-auth';\n```\n\nRequesting Passcode authentication is as simple as calling:\n```js\nPasscodeAuth.authenticate('to demo this react-native component')\n  .then(success =\u003e {\n    // Success code\n  })\n  .catch(error =\u003e {\n    // Failure code\n  });\n```\n\n## Example\nUsing PasscodeAuth in your app will usually look like this:\n```js\nimport React, { Component, AlertIOS, TouchableHighlight, View, Text } from 'react-native';\nimport PasscodeAuth form 'react-native-passcode-auth';\n\nclass YourComponent extends Component {\n  _pressHandler() {\n    PasscodeAuth.authenticate('to demo this react-native component')\n      .then(success =\u003e {\n        AlertIOS.alert('Authenticated Successfully');\n      })\n      .catch(error =\u003e {\n        AlertIOS.alert('Authentication Failed');\n      });\n  }\n\n  render() {\n    return (\n      \u003cView\u003e\n        ...\n        \u003cTouchableHighlight onPress={this._pressHandler}\u003e\n          \u003cText\u003e\n            Authenticate with Passcode\n          \u003c/Text\u003e\n        \u003c/TouchableHighlight\u003e\n      \u003c/View\u003e\n    );\n  }\n});\n```\n\n## Methods\n### authenticate(reason)\nAttempts to authenticate with Passcode.\nReturns a `Promise` object.\n\n__Arguments__\n- `reason` - An _optional_ `String` that provides a clear reason for requesting authentication.\n\n__Examples__\n```js\nPasscodeAuth.authenticate('to demo this react-native component')\n  .then(success =\u003e {\n    // Success code\n    console.log('User authenticated with Passcode');\n  })\n  .catch(error =\u003e {\n    // Failure code\n    console.log(error);\n  });\n```\n\n### isSupported()\nVerify's that Passcode Auth is supported and that Passcode is set.\nReturns a `Promise` object.\n\n__Examples__\n```js\nPasscodeAuth.isSupported()\n  .then(supported =\u003e {\n    // Success code\n    console.log('Passcode Auth is supported.');\n  })\n  .catch(error =\u003e {\n    // Failure code\n    console.log(error);\n  });\n```\n\n## Errors\nThere are various reasons why authenticating with Passcode may fail.  Whenever calling Passcode authentication fails, `PasscodeAuth.authenticate` will return an error code representing the reason.\n\nBelow is a list of error codes that can be returned:\n\n| Code | Description |\n|---|---|\n| `LAErrorAuthenticationFailed` | Authentication was not successful because the user failed to provide valid credentials. |\n| `LAErrorUserCancel` | Authentication was canceled by the user—for example, the user tapped Cancel in the dialog. |\n| `LAErrorUserFallback` | Authentication was canceled because the user tapped the fallback button (Enter Password). |\n| `LAErrorSystemCancel` | Authentication was canceled by system—for example, if another application came to foreground while the authentication dialog was up. |\n| `LAErrorPasscodeNotSet` | Authentication could not start because the passcode is not set on the device. |\n| `PasscodeAuthNotSet` | Authentication could not start because the passcode is not set on the device. |\n| `PasscodeAuthNotSupported` | Device does not support Passcode Auth. |\n\n_More information on errors can be found in [Apple's Documentation](https://developer.apple.com/library/prerelease/ios/documentation/LocalAuthentication/Reference/LAContext_Class/index.html#//apple_ref/c/tdef/LAError)._\n\n## License\nCopyright (c) 2015, [Naoufal Kadhom](http://naoufal.com/)\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","funding_links":[],"categories":["Components"],"sub_categories":["System"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoufal%2Freact-native-passcode-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaoufal%2Freact-native-passcode-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoufal%2Freact-native-passcode-auth/lists"}