{"id":26103242,"url":"https://github.com/4cc3ssX/react-native-nitro-totp","last_synced_at":"2025-03-09T20:05:56.180Z","repository":{"id":257804510,"uuid":"864791842","full_name":"4cc3ssX/react-native-nitro-totp","owner":"4cc3ssX","description":"A full-featured React Native TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password) authentication.","archived":false,"fork":false,"pushed_at":"2024-10-18T08:11:22.000Z","size":3290,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T20:51:13.915Z","etag":null,"topics":["hotp","nitro-modules","nitrogen","react-native","totp"],"latest_commit_sha":null,"homepage":"","language":"C++","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/4cc3ssX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.MD","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-29T07:07:19.000Z","updated_at":"2024-10-18T08:11:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"1452e097-8241-42b8-a6f1-78ba43db1542","html_url":"https://github.com/4cc3ssX/react-native-nitro-totp","commit_stats":null,"previous_names":["4cc3ssx/react-native-nitro-totp"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4cc3ssX%2Freact-native-nitro-totp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4cc3ssX%2Freact-native-nitro-totp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4cc3ssX%2Freact-native-nitro-totp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4cc3ssX%2Freact-native-nitro-totp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4cc3ssX","download_url":"https://codeload.github.com/4cc3ssX/react-native-nitro-totp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242744101,"owners_count":20178174,"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":["hotp","nitro-modules","nitrogen","react-native","totp"],"created_at":"2025-03-09T20:05:54.812Z","updated_at":"2025-03-09T20:05:56.170Z","avatar_url":"https://github.com/4cc3ssX.png","language":"C++","funding_links":[],"categories":["Published"],"sub_categories":[],"readme":"# react-native-nitro-totp\n\n## Installation\n```\n# npm\nnpm install react-native-nitro-totp\n\n# yarn\nyarn add react-native-nitro-totp\n```\nExtra installation steps for [Nitro Modules](https://mrousavy.github.io/nitro/) can be found [here](https://mrousavy.github.io/nitro/docs/for-users)\n\n## Usage\n```ts\nimport {\n  formatOTP,\n  formatSecretKey,\n  isSecretKeyValid,\n  NitroSecret,\n  NitroTotp,\n  parseSecretKey,\n} from 'react-native-nitro-totp';\n\nconst secret = NitroSecret.generate();\n\n// TOTP\nconst otp = NitroTotp.generate(secret);\nconst isValid = NitroTotp.validate(secret, otp);\nconst generatedAuthURL = NitroTotp.generateAuthURL({\n  secret,\n  issuer: 'NitroTotp',\n  label: 'NitroTotp',\n  period: defaultOptions.period,\n  digits: defaultOptions.digits,\n  issuerInLabel: false,\n  algorithm: SupportedAlgorithm.SHA1,\n});\n\n// HOTP\nconst otp = NitroHOTP.generate(secret);\nconst isValid = NitroHOTP.validate(secret, otp);\nconst generatedAuthURL = NitroHOTP.generateAuthURL({\n  secret,\n  issuer: 'NitroHotp',\n  label: 'NitroHotp',\n  counter: defaultOptions.counter,\n  digits: defaultOptions.digits,\n  issuerInLabel: false,\n  algorithm: SupportedAlgorithm.SHA1,\n});\n\n```\n\n## Generation Options\n```ts\nexport interface BaseGenerateOptions {\n  /**\n   * The number of digits in the OTP.\n   * @type {number}\n   * @default 6\n   */\n  digits?: number\n\n  /**\n   * The algorithm to use for generating the OTP.\n   * @type {SupportedAlgorithm}\n   * @default 'SHA1'\n   */\n  algorithm?: SupportedAlgorithm\n}\n\nexport interface NitroTotpGenerateOptions extends BaseGenerateOptions {\n  /**\n   * The period in seconds.\n   * @type {number}\n   * @default 30\n   */\n  period?: number\n}\n\nexport interface NitroHOTPGenerateOptions extends BaseGenerateOptions {\n  /**\n   * The counter to use for generating the OTP.\n   * @type {number}\n   * @default 0\n   */\n  counter?: number\n}\n```\n\n## Validation Options\n```ts\nexport interface BaseValidateOptions extends BaseGenerateOptions {\n  /**\n   * The window of time steps to allow for OTP validation.\n   * @type {number}\n   * @default 1\n   */\n  window?: number\n}\n\nexport interface NitroHOTPValidateOptions extends BaseValidateOptions {\n  /**\n   * The counter to use for validating the OTP.\n   * @type {number}\n   * @default 0\n   */\n  counter?: number\n}\n\nexport interface NitroTotpValidateOptions extends BaseValidateOptions {\n  /**\n   * The period in seconds.\n   * @type {number}\n   * @default 30\n   */\n  period?: number\n}\n```\n\n## OTP Auth URL Options\n```ts\nexport interface OTPAuthURLOptions extends BaseGenerateOptions {\n  /**\n   * The issuer of the secret key.\n   * @type {string}\n   */\n  issuer?: string\n\n  /**\n   * The label of the secret key.\n   * @type {string}\n   */\n  label?: string\n\n  /**\n   * The secret key to use for generating the OTP.\n   * @type {string}\n   */\n  secret: string\n\n  /**\n   * Whether to include the issuer in the label.\n   * @type {boolean}\n   * @default false\n   */\n  issuerInLabel?: boolean\n\n  /**\n   * The period in seconds.\n   * @type {number}\n   * @default 30\n   */\n  period?: number\n\n  /**\n   * The counter to use for generating the OTP.\n   * @type {number}\n   * @default 0\n   */\n  counter?: number\n}\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n\n---\n\nMade with [react-native-nitro-modules](https://github.com/callstack/react-native-builder-bob)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4cc3ssX%2Freact-native-nitro-totp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4cc3ssX%2Freact-native-nitro-totp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4cc3ssX%2Freact-native-nitro-totp/lists"}