{"id":16578038,"url":"https://github.com/glynnbird/yub","last_synced_at":"2025-03-16T20:31:33.839Z","repository":{"id":10361604,"uuid":"12501871","full_name":"glynnbird/yub","owner":"glynnbird","description":"Yubico/Yubikey Client API Library for Node.js","archived":false,"fork":false,"pushed_at":"2017-05-24T16:10:13.000Z","size":81,"stargazers_count":47,"open_issues_count":20,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T13:23:43.976Z","etag":null,"topics":["nodejs","yubikey"],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/yub","language":"JavaScript","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/glynnbird.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":"2013-08-31T06:55:51.000Z","updated_at":"2025-02-13T16:09:09.000Z","dependencies_parsed_at":"2022-09-10T11:42:36.561Z","dependency_job_id":null,"html_url":"https://github.com/glynnbird/yub","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fyub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fyub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fyub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fyub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glynnbird","download_url":"https://codeload.github.com/glynnbird/yub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"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":["nodejs","yubikey"],"created_at":"2024-10-11T22:12:57.413Z","updated_at":"2025-03-16T20:31:33.387Z","avatar_url":"https://github.com/glynnbird.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YUB\n\n[![NPM](https://nodei.co/npm/yub.png)](https://nodei.co/npm/yub/)\n\n## Introduction\n\nWhat is Yub? It's a simple Yubico Yubikey API client that\n\n* authenticates a Yubkiey's OTP (one time password) using the Yubico API\n* signs the outgoing data\n* checks the incoming data's signature\n* extracts the Yubkey's unique identifier if the OTP is valid\n\n## What is a Yubikey?\n\nA Yubikey is a USB device manufactured by [Yubico](https://www.yubico.com/products/yubikey-hardware/yubikey/) that appears\nto your computer as a USB keyboard. \n\n![Yubikeys](https://raw.github.com/glynnbird/yub/master/img/yubikeys.jpg)\n\nIt generates one-time passwords consisting of:\n\n* your Yubikey's unique identity\n* a string of characters\n\nThis sequence of characters can be sent to Yubico's web service which will verify whether the string is valid or not. Your Yubikey\ncan be used for a variety of authentication tasks. This library is designed to allow simple integration with the Yubico web service\nso that you can interpret your Yubikey's one-time-password in your own Node.js scripts. e.g.\n\n* allow a user to authenticate via Yubikey in your web app\n* create command-line scripts that only operate with a valid Yubikey\n* etc\n\n## What do you need?\n\n* a [Yubikey](http://www.yubico.com/)\n* [node.js](http://nodejs.org/)\n* [npm](https://npmjs.org/)\n\n## Installation\n\nYub is published as an NPM module for your convenience:\n\n```\n  npm install yub\n```\n\nYou'll also need a Yubico API Key from here: [https://upgrade.yubico.com/getapikey/]([https://upgrade.yubico.com/getapikey/). This gives you the\nclient_id and secret_key that must be passed to \"yub.init()\", see below.\n\n## Example code\n\n```\nvar yub = require('yub');\n\n// initialise the yub library\nyub.init(\"\u003cclient id here\u003e\", \"\u003csecret here\u003e\");\n\n// attempt to verify the key\nyub.verify(\"\u003cotp here\u003e\", function(err,data) {\n  console.log(err, data)\n});\n```\n\n## What's in the 'data' returned by yub.verify?\n\nA typical 'data' return from yub.verify looks like this:\n\n```\n{\n    t: '2013-08-31T07: 13: 27Z0111',\n    otp: 'cccaccbtbvkwjjirhcctvdgbahdbijduldcjdurgjgfi',\n    nonce: '50fb8a88a327b4af16e6e7bd9ec4e4e6c692f2e5',\n    sl: '25',\n    status: 'OK',\n    signatureVerified: true,\n    nonceVerified: true,\n    identity: 'cccaccbtbvkw',\n    serial: 123456,\n    valid: true\n}\n```\n\n* t - the timestamp of the interaction\n* otp - the supplied one-time-password\n* nonce - a unique piece of information provided by the client to the server\n* sl - the percentage of servers responding. This library only picks one (of the 5) Yubico server to authenticate with, so this value should be 20 (percent)\n* status - whether the supplied one-time-password was valid or not. Common return values \n** 'OK' - everything's fine\n** 'BAD_OTP' - invalid password supplied\n** 'REPLAYED_OTP' - the password has been used before\n** further return values documented here https://code.google.com/p/yubikey-val-server-php/wiki/ValidationProtocolV20\n* signatureVerified - whether the reply from the Yubico server was correctly signed\n* nonceVerified - whether the reply 'nonce' was the same as the outgoing 'nonce'\n* identity - the unique identifier of the Yubikey that generated the password. If you want to write software the detects the presence of a specific Yubikey (not just any Yubikey), then data.identity is your friend.\n* encrypted - the 32 digit encrypted portion of the OTP in 'modhex' format\n* encryptedHex - the encrypted portion of the OTP in hexadecimal\n* serial - the serial number of the Yubikey. This is derived by decoding the identity's modhex encoding.\n* valid - this is true if the status = 'OK', the signature is verified and the nonce is verified\n\n## Offline verification\n\nYou can also call \"yub.verifyOffline\", which returns the same object in the same format but\nwithout contacting the Yubico servers i.e. it simply extracts the identity of the Yubikey \nfrom the OTP without any network access. This is, of course, far less secure, but is useful\nfor offline applications. As we cannot validate the status online, \"valid\" is always false in \noffline mode.\n\n## Further examples\n\nIn the 'example' directory is an example command-line utility (test.js) which exits with a different return code, depending\non whether the supplied OTP was valid or not. This could easily be plumbed into a command-line script to only allow execution\nto proceed with a valid OTP.\n\nIt takes the OTP as a command-line parameter i.e. type \"node test.js \", insert your Yubikey and press the gold button:\n\n```\n\u003e node test.js cccaccbtbvkwjjirhcctvdgbahdbijduldcjdurgjgfi\n{   t: '2013-08-31T07: 13: 27Z0111',\n    otp: 'cccaccbtbvkwjjirhcctvdgbahdbijduldcjdurgjgfi',\n    nonce: '50fb8a88a327b4af16e6e7bd9ec4e4e6c692f2e5',\n    sl: '25',\n    status: 'OK',\n    signatureVerified: true,\n    nonceVerified: true,\n    identity: 'cccaccbtbvkw',\n    valid: true }\n```\n\n## References\n\n* https://code.google.com/p/yubikey-val-server-php/wiki/GettingStartedWritingClients\n* https://code.google.com/p/yubikey-val-server-php/wiki/ValidationProtocolV20\n\n## Disclaimer\n\nThis software is open-source and is a personal project, not officially endorsed by Yubico in any way.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglynnbird%2Fyub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglynnbird%2Fyub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglynnbird%2Fyub/lists"}