{"_id":"@bpm-sekeh/react-native-sms-user-consent","_rev":"2-c42a41799c6b62efa9be0dd194d8d3ef","name":"@bpm-sekeh/react-native-sms-user-consent","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.0":{"name":"@bpm-sekeh/react-native-sms-user-consent","version":"1.2.0","keywords":["react-native","android","otp","one time","verification","code","mobile","2fa","two factor","auth","authentication"],"author":{"name":"Ahmadreza Salehvand","email":"ahmadreza.salehvand@outlook.com"},"license":"MIT","_id":"@bpm-sekeh/react-native-sms-user-consent@1.2.0","maintainers":[{"name":"ahmadreza.s","email":"ahmadreza.salehvand@gmail.com"}],"homepage":"https://github.com/bpm-sekeh/react-native-sms-user-consent#readme","bugs":{"url":"https://github.com/bpm-sekeh/react-native-sms-user-consent/issues"},"dist":{"shasum":"4a7415f06a30bdec00fcd1ea3c2214b6881ca15e","tarball":"https://registry.npmjs.org/@bpm-sekeh/react-native-sms-user-consent/-/react-native-sms-user-consent-1.2.0.tgz","fileCount":32,"integrity":"sha512-9tJ9d95S81FNyqke73RZWmHjz1vutrCdsdu5TWY+O4WtiMdN+dYA8jXL2GN34lxNtATR5VgZhNAFTCrTYrKpOg==","signatures":[{"sig":"MEQCIBlSRKCFcUVgBb/7ebUsjhCnByJsvglpDuQyjJcK0BKiAiBuVUuPXQ1YybGknYmDFRay2F0d+4zb/ZwqteyP4t6C+g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100245},"main":"index.js","title":"React Native Sms User Consent","types":"index.d.ts","gitHead":"4a1d1f5271fe5550b249a248dbb0a3f71d815549","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ahmadreza.s","email":"ahmadreza.salehvand@gmail.com"},"repository":{"url":"git+https://github.com/bpm-sekeh/react-native-sms-user-consent.git","type":"git","baseUrl":"https://github.com/bpm-sekeh/react-native-sms-user-consent"},"_npmVersion":"10.2.4","description":"React Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"react":"^17","eslint":"^8","prettier":"^3","react-native":"^0.66.5","@react-native-community/eslint-config":"^3"},"licenseFilename":"LICENSE","peerDependencies":{"react":"^16 || ^17 || ^18","react-native":">=0.66.5 <1.0.x"},"_npmOperationalInternal":{"tmp":"tmp/react-native-sms-user-consent_1.2.0_1721391986178_0.6851842404922968","host":"s3://npm-registry-packages"}},"1.2.1":{"name":"@bpm-sekeh/react-native-sms-user-consent","version":"1.2.1","keywords":["react-native","android","otp","one time","verification","code","mobile","2fa","two factor","auth","authentication"],"author":{"name":"Ahmadreza Salehvand","email":"ahmadreza.salehvand@outlook.com"},"license":"MIT","_id":"@bpm-sekeh/react-native-sms-user-consent@1.2.1","maintainers":[{"name":"ahmadreza.s","email":"ahmadreza.salehvand@gmail.com"}],"homepage":"https://github.com/bpm-sekeh/react-native-sms-user-consent#readme","bugs":{"url":"https://github.com/bpm-sekeh/react-native-sms-user-consent/issues"},"dist":{"shasum":"b41585dab53f4bc6957b0d5fbcb2b5a418ad4098","tarball":"https://registry.npmjs.org/@bpm-sekeh/react-native-sms-user-consent/-/react-native-sms-user-consent-1.2.1.tgz","fileCount":32,"integrity":"sha512-eEnqUdg2BZuggudcPa4V078V8zUuJNHh+/nqPwjWU289Nx5nF7j+a2S+wdB1JqcTdAwKWhvkVG1Ml14LDSRJ5Q==","signatures":[{"sig":"MEUCIQCf98rHvykRpB5nuttOvEsOT75pfYHAZ4h3JtzJ/rmh1AIgc8o0kJh9B+uyZvGQca1hlscMJZwJXG1C55+b3Mt3N74=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100255},"main":"index.js","title":"React Native Sms User Consent","types":"index.d.ts","gitHead":"4a803feb2c661adda3d86dc1bb80c4f119ab4752","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ahmadreza.s","email":"ahmadreza.salehvand@gmail.com"},"repository":{"url":"git+https://github.com/bpm-sekeh/react-native-sms-user-consent.git","type":"git","baseUrl":"https://github.com/bpm-sekeh/react-native-sms-user-consent"},"_npmVersion":"6.14.8","description":"React Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort","directories":{},"_nodeVersion":"14.10.0","_hasShrinkwrap":false,"devDependencies":{"react":"^17","eslint":"^8","prettier":"^3","react-native":"^0.66.5","@react-native-community/eslint-config":"^3"},"licenseFilename":"LICENSE","peerDependencies":{"react":"^16 || ^17 || ^18","react-native":">=0.66.5 <1.0.x"},"_npmOperationalInternal":{"tmp":"tmp/react-native-sms-user-consent_1.2.1_1721397529147_0.33157588831608464","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-07-19T12:26:26.057Z","modified":"2024-08-01T13:14:38.580Z","1.2.0":"2024-07-19T12:26:26.416Z","1.2.1":"2024-07-19T13:58:49.317Z"},"bugs":{"url":"https://github.com/bpm-sekeh/react-native-sms-user-consent/issues"},"author":{"name":"Ahmadreza Salehvand","email":"ahmadreza.salehvand@outlook.com"},"license":"MIT","homepage":"https://github.com/bpm-sekeh/react-native-sms-user-consent#readme","keywords":["react-native","android","otp","one time","verification","code","mobile","2fa","two factor","auth","authentication"],"repository":{"url":"git+https://github.com/bpm-sekeh/react-native-sms-user-consent.git","type":"git","baseUrl":"https://github.com/bpm-sekeh/react-native-sms-user-consent"},"description":"React Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort","maintainers":[{"email":"a.hosseinkarimi82@gmail.com","name":"amir-hossein-karimi"},{"email":"ahmadreza.salehvand@gmail.com","name":"ahmadreza.s"}],"readme":"this is just a from from: https://github.com/akvelon/react-native-sms-user-consent\n\n# React Native SMS User Consent\n\nReact Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort. The purpose of SMS User Consent API is to provide one-tap auto-filling of SMS verification codes.\n\n## iOS\n\nSMS User Consent API exists only on Android, so this package is Android-only. Calling this package's APIs on iOS is no-op.\n\nIf you want auto-filling on iOS, `textContentType=\"oneTimeCode\"` for `TextInput` is the way to go. Basically, this is the only way for iOS.\n\n## Getting started\n\nInstall [the package](https://www.npmjs.com/package/@bpm-sekeh/react-native-sms-user-consent):\n\n```\nyarn add @bpm-sekeh/react-native-sms-user-consent\n```\n\nor\n\n```\nnpm install @bpm-sekeh/react-native-sms-user-consent\n```\n\n## Basic usage\n\n```javascript\nimport React, { useEffect, useState } from 'react';\nimport { TextInput } from 'react-native';\n\nimport { useSmsUserConsent } from '@bpm-sekeh/react-native-sms-user-consent';\n\nconst Example = () => {\n  const [code, setCode] = useState();\n\n  const retrievedCode = useSmsUserConsent();\n\n  useEffect(() => {\n    if (retrievedCode) setCode(retrievedCode);\n  }, [retrievedCode]);\n\n  return <TextInput value={code} onChangeText={setCode} />;\n};\n```\n\nIn the example we use a controlled `TextInput` for the code entry. `retrievedCode` equals to the empty string initially, and whenever an SMS is handled `retrievedCode` receives the code from it. We use the `useEffect` to update the input value when an SMS is handled.\n\n### Customise verification code parser\n\nSet the length of the validation code:\n\n```typescript\nconst retrievedCode = useSmsUserConsent(4);\n// e.g. code = 1234\n```\n\nProvide a custom regular expression:\n\n```typescript\nconst retrievedCode = useSmsUserConsent('[A-Z0-9]{5}');\n// e.g. code = A12B3\n```\n\n## API\n\n### useSmsUserConsent()\n\n```typescript\nuseSmsUserConsent(config: number | string): string\n```\n\nReact hook that starts SMS handling and provides the received code as its return value, which is the empty string initially. Stops handling SMS messages on unmount. Uses `startSmsHandling` and `retrieveVerificationCode` internally.\n\nThis hook is the way to go in most cases. Alternatively, you can use `startSmsHandling` and `retrieveVerificationCode` directly if dealing with something that is not a functional component or you need some more flexibility.\n\nOn iOS it just returns the empty string, so no additional code to handle iOS is needed.\n\nAccepts an optional `config` parameter. In case if it's a number, it defines the length of the code. In case if it is a string, it defines a custom RegExp to parse the code.\n\n### startSmsHandling()\n\n```typescript\nstartSmsHandling(onSmsReceived: (event: {sms?: string}) => void): (\n  stopSmsHandling(): void\n)\n```\n\nStarts the native SMS listener that will show the SMS User Consent system prompt. If the user allowed reading the SMS, then the `onSmsReceived` callback is called. `onSmsReceived` receives the event object containing the SMS.\n\nReturns `stopSmsHandling` function that stops showing the system prompt and stops SMS handling.\n\n### retrieveVerificationCode()\n\n```typescript\nretrieveVerificationCode(sms: string, config: number | string): string | null\n```\n\nRetrieves the verification code from an SMS if there is any.\n\nAccepts an optional `config` parameter. In case if it's a number, it defines the length of the code. In case if it is a string, it defines a custom RegExp to parse the code.\n\n---\n\n*You can import the whole API as one object if you prefer*\n\n```javascript\nimport SmsUserConsent from 'react-native-sms-user-consent';\n\n// ...\nSmsUserConsent.useSmsUserConsent();\n// ...\n```\n\n## Contribution\n\nplease contribute to the original repo :)\nhttps://github.com/akvelon/react-native-sms-user-consent\n","readmeFilename":"README.md"}