{"name":"otpauth","version":"3.2.5","keywords":["otp","hotp","totp","one time password","2fa","2 factor","two factor","two-factor","2step","2 step","two step","two-step","auth","authenticator","google authenticator"],"author":{"name":"Héctor Molinero Fernández","email":"hector@molinero.dev"},"license":"MIT","_id":"otpauth@3.2.5","maintainers":[{"name":"zant95","email":"hector@molinero.xyz"}],"homepage":"https://github.com/hectorm/otpauth","bugs":{"url":"https://github.com/hectorm/otpauth/issues"},"dist":{"shasum":"928c2694b3b67c0ba7841eb00eec167895755dc5","tarball":"http://registry-npm.ywwl.com/otpauth/download/otpauth-3.2.5.tgz","fileCount":13,"integrity":"sha512-USIWIGgkTnvbLR2q2rcPH7wS2c3YaLRe+nwOJrVGPThcju9QuuP8BYkc37Yah8htw5pWBLNVfYnMWej9eOu2Vw==","signatures":[{"sig":"MEUCIQD3bBUvnRdA7D5ygbhwe6vQasxJvJ/n6bjYf0ptJgF6WwIgNvonVl1Zh8jRX30r9r7HqXpuztW1YZeRjCXxVNQbQgI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":475048,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc5aLLCRA9TVsSAnZWagAA59cP/iJLLTlA3Psp0SWeyZ3G\nbAt8MrGrfjp/xaG7O/3IvIUV6SqWlZr4/jT7ZTa7dyvTYKQRW5PIn/UM9HOV\ngzonCckpgQaTE0lGw5pA2ufivl4+Cys3zLDQFkar3+7hianJnEU1QCT47xqe\na3muvq8CZPTWxjw4oYgceXWSJSa2miDnPGv16E45rtSgUzxzfy0u/vOuB6fA\nNq6S2r5eV+rVtDZ6RJTFrD1GNL7cSh1RwWXLeWLzY9zueM1UTbNzzoznTtT6\npPQRJoz57kG97qIwWb8smy+3YZeyInFlnnnIFWYUpqzeblXU7eM8ha248jt5\npSI9Vqj8uZElV9Y2XXskHn3km47nYcFvYik0em40ns1IRVqBTdQNCDJzYGL+\nWJLkMNw/wCqtpkKIr2gei1rQNUMIm6fhySf4qzP8UilzA84Ywu3fuP8RUgEO\nUPB9OGAIyTVhDnwFx4P5ldc7v4gn4vbPKEpSfjInqtymM0ecd3FUqNao77vb\nYX4kcS4BM2LwNdOSNiA5gWEvIZ20urxTX8xEgMcBHWoQRByMV1IzcpF+RzzL\n1rjqMkTZLMCFxFcAb2/t2gM4Lj+d23sDpui8PGscwgoGI7RoxrWWRsZMGFea\nvnzHxycv2g55wNPZoebhYc5ERb6L3ZnBywiU1G1UKlv2hQLoTRbttMh3HCI3\nngkj\r\n=BTgG\r\n-----END PGP SIGNATURE-----\r\n","size":122399,"noattachment":false,"key":"/otpauth/-/otpauth-3.2.5.tgz"},"main":"dist/otpauth.js","gitHead":"6adb2887e2c242875dd336d83a0e73c9e017cfee","scripts":{"dist":"run-s lint build test docs","docs":"rimraf docs && esdoc2","lint":"eslint --fix .","test":"run-s test:*","build":"webpack --display-reasons","version":"run-s dist && git add -A dist docs","test:node":"run-s test:node:*","test:browser":"run-s test:browser:*","test:node:minified":"IS_MINIFIED=true mocha --reporter dot","test:node:unminified":"mocha --reporter dot","test:browser:minified":"IS_MINIFIED=true karma start","test:browser:unminified":"karma start"},"_npmUser":{"name":"hectormolinero","email":"hector@molinero.dev"},"repository":{"url":"git+https://github.com/hectorm/otpauth.git","type":"git"},"_npmVersion":"6.9.0","description":"One Time Password (HOTP/TOTP) library for Node.js and browser","directories":{},"_nodeVersion":"12.2.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"tmp":"~0.1.0","chai":"~4.2.0","sjcl":"1.0.8","karma":"~4.1.0","mocha":"~6.1.4","esdoc2":"~2.1.5","eslint":"~5.16.0","rimraf":"~2.6.3","webpack":"~4.32.1","karma-chai":"~0.1.0","karma-mocha":"~1.3.0","npm-run-all":"~4.1.5","webpack-cli":"~3.3.2","eslint-plugin-import":"~2.17.2","eslint-config-hectorm":"~1.0.0","karma-chrome-launcher":"~2.2.0","closure-webpack-plugin":"~2.0.1","esdoc2-standard-plugin":"~2.1.2","karma-firefox-launcher":"~1.1.0","google-closure-compiler":"~20190513.0.0","eslint-config-airbnb-base":"~13.1.0"},"_npmOperationalInternal":{"tmp":"tmp/otpauth_3.2.5_1558553290554_0.4695422016541779","host":"s3://npm-registry-packages"},"readme":"[![Last version](https://img.shields.io/github/v/tag/hectorm/otpauth?label=version)](https://github.com/hectorm/otpauth/tags)\n[![npm downloads](https://img.shields.io/npm/dm/otpauth?label=npm%20downloads)](https://www.npmjs.com/package/otpauth)\n\n<p align=\"center\">\n  <img alt=\"OTPAuth\" src=\"./resources/logo/OTPAuth-Color-Reduced.svg\" height=\"192\" />\n</p>\n\n# OTPAuth\n\nOne Time Password library for Node.js, Deno, Bun and browsers.\n\nIt supports the generation and validation of\nHMAC-Based One-Time Passwords (HOTP) as specified in [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226) and\nTime-Based One-Time Passwords (TOTP) as specified in [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238).\nFrequently used in Multi-Factor Authentication (MFA) / Two-Factor Authentication (2FA) systems.\n\n> [!TIP]\n> You can try the library with the demo application available at [otpauth.molinero.dev](https://otpauth.molinero.dev).\n>\n> If you wish to interact with the library in your browser console, the following snippet can be used:\n>\n> ```javascript\n> const OTPAuth = await import(\"otpauth\");\n> ```\n\n## Usage\n\nThis section presents an overview of the most common usage patterns, along with some security recommendations.\n\n### [Node.js / Bun](https://www.npmjs.com/package/otpauth)\n\n```javascript\nimport * as OTPAuth from \"otpauth\";\n// import * as OTPAuth from \"otpauth/slim\"; // Slim build without bundled dependencies.\n// import * as OTPAuth from \"otpauth/bare\"; // Bare build with no bundled crypto (requires providing a custom HMAC function).\n\n// Create a new TOTP object.\nlet totp = new OTPAuth.TOTP({\n  // Provider or service the account is associated with.\n  issuer: \"ACME\",\n  // Account identifier.\n  label: \"Alice\",\n  // Algorithm used for the HMAC function, possible values are:\n  //   \"SHA1\", \"SHA224\", \"SHA256\", \"SHA384\", \"SHA512\",\n  //   \"SHA3-224\", \"SHA3-256\", \"SHA3-384\" and \"SHA3-512\".\n  algorithm: \"SHA1\",\n  // Length of the generated tokens.\n  digits: 6,\n  // Interval of time for which a token is valid, in seconds.\n  period: 30,\n  // Arbitrary key encoded in base32 or `OTPAuth.Secret` instance\n  // (if omitted, a cryptographically secure random secret is generated).\n  secret: \"US3WHSG7X5KAPV27VANWKQHF3SH3HULL\",\n  //   or: `OTPAuth.Secret.fromBase32(\"US3WHSG7X5KAPV27VANWKQHF3SH3HULL\")`\n  //   or: `new OTPAuth.Secret()`\n  // Custom HMAC function (required for bare build, optional otherwise).\n  // hmac: (algorithm, key, message) => Uint8Array,\n});\n\n// Unless you know what you are doing, it is recommended to use the default\n// values for the algorithm, digits, and period options, as these are the most\n// common values used by most services.\n\n// Generate a cryptographically secure random secret.\n// It is NOT recommended to use less than 128 bits (16 bytes).\nlet secret = new OTPAuth.Secret({ size: 20 });\n\n// Generate a token (returns the current token as a string).\nlet token = totp.generate();\n\n// Validate a token (returns the token delta or null if it is not found in the\n// search window, in which case it should be considered invalid).\n//\n// A search window is useful to account for clock drift between the client and\n// server; however, it should be kept as small as possible to prevent brute\n// force attacks. In most cases, a value of 1 is sufficient. Furthermore, it is\n// essential to implement a throttling mechanism on the server.\n//\n// For further details on the security considerations, it is advised to refer\n// to Section 7 of RFC 4226 and Section 5 of RFC 6238:\n//   https://datatracker.ietf.org/doc/html/rfc4226#section-7\n//   https://datatracker.ietf.org/doc/html/rfc6238#section-5\nlet delta = totp.validate({ token, window: 1 });\n\n// Get the counter value (number of intervals since the Unix epoch).\n// Useful for implementing techniques against token reuse during the validity\n// period.\nlet counter = totp.counter();\n\n// Get the remaining milliseconds until the current token changes.\nlet remaining = totp.remaining();\n\n// Convert to Google Authenticator key URI format.\n// Usually the URI is encoded in a QR code that can be scanned by the user.\n// This functionality is outside the scope of the project, but there are many\n// libraries that can be used for this purpose, such as npmjs.com/package/qr\nlet uri = totp.toString();\n//   or:      `OTPAuth.URI.stringify(totp)`\n//   returns: `otpauth://totp/ACME:Alice?issuer=ACME&secret=US3WHSG7X5KAPV27VANWKQHF3SH3HULL&algorithm=SHA1&digits=6&period=30`\n\n// Convert from Google Authenticator key URI format.\ntotp = OTPAuth.URI.parse(uri);\n```\n\n### [Deno](https://jsr.io/@hectorm/otpauth)\n\n```javascript\nimport * as OTPAuth from \"jsr:@hectorm/otpauth\";\n\n// Same as above.\n```\n\n### [Browsers (ESM)](https://www.jsdelivr.com/package/npm/otpauth)\n\n```html\n<script type=\"importmap\">\n  {\n    \"imports\": { \"otpauth\": \"https://cdn.jsdelivr.net/npm/otpauth@%VERSION%/dist/otpauth.esm.min.js\" },\n    \"integrity\": { \"https://cdn.jsdelivr.net/npm/otpauth@%VERSION%/dist/otpauth.esm.min.js\": \"%HASH%\" }\n  }\n</script>\n<script type=\"module\">\n  import * as OTPAuth from \"otpauth\";\n\n  // Same as above.\n</script>\n```\n\n### [Browsers (UMD)](https://www.jsdelivr.com/package/npm/otpauth)\n\n```html\n<script\n  src=\"https://cdn.jsdelivr.net/npm/otpauth@%VERSION%/dist/otpauth.umd.min.js\"\n  integrity=\"%HASH%\"\n  crossorigin=\"anonymous\"\n  referrerpolicy=\"no-referrer\"\n></script>\n<script>\n  // Same as above.\n</script>\n```\n\n## Documentation\n\nFor additional information, please refer to the documentation page at [hectorm.github.io/otpauth/](https://hectorm.github.io/otpauth/).\n\n## License\n\n[MIT License](https://github.com/hectorm/otpauth/blob/master/LICENSE.md)\n© [Héctor Molinero Fernández](https://hector.molinero.dev/).\n","publish_time":1558553290694,"_cnpm_publish_time":1558553290694,"dist-tags":{"latest":"9.6.0"}}