New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yubico-node

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yubico-node

A NodeJS implementation of the Yubico OTP API

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Typescript (Javascript) Yubico API Implementation

This is a JS implementation of the Yubico Validation Protocol as outlined in their documentation. All of the extra security precautions are implemented such as using the client secret to hash the request on its way out, and validate the response on its way in. This library is also incredibly small and has no outside dependencies.

Features

  • Managed request hashing and response verification
  • Typescript types built in
  • Environment Variable Defaults

Environment Variables


YUBICO_CLIENT_ID    = Client ID from Yubico
YUBICO_SECRET       = Secret from Yubico
YUBICO_SL           = The SL to use (0 - 100, fast, or secure)
YUBICO_TIMEOUT      = The timeout for the request (number)
YUBICO_API_SERVERS  = If you run your own compliant verification servers, place the hosts  in a comma separated list (ex. api.yubico.com,api2.yubico.com, etc.)

Yubico

constructor(options?: IYubicoConstructor)

The options parameter contains all of the options you might want to set for the verification requests. Some parameters are requrired, but having an environment variable suffices for the requirement. The options parameter is not required at all of all parameters are met with environment variables.

optionrequiredtypedefaultexample
clientIdstringN/A"MyClientID"
secretstringN/A"MySecret"
slnumber (0-100),"fast","secure"none"secure"
timeoutnumbernone"secure"
apiServersstring[]Yubico API Servers"secure"
verify(otp: string): Promise<Response>

Verify the OTP against the verification servers. This will return a Response class that can be picked apart to get the data you need.

Response

getOneTimePassword(): string

Returns the same OTP that was passed into the verify function.

getTimestampUTC(): Date

Returns the UTC timestamp that was given in response from the verification server.

getTimestamp(): Date

Returns the timestamp from when the key was pressed.

getSessionCounter(): number

Returns the internal usage counter provided by the key from when it was pressed.

getSessionUse(): number

Returns the internal session usage counter provided by the key from when it was pressed.

getStatus(): ResponseStatus

Returns the response status of the request. This should always be ResponseStatus.OK as all other responses will throw an error.

getPublicId(): string

Returns the public ID of the key. This is unique to each key, but is encoded in ModHex. If you need the public ID as a number (aka. the serial number), use getSerialNumber().

getSerialNumber():number

Returns the serial number of the key. This is decoded from ModHex and represented as a UIntBE.

Keywords

FAQs

Package last updated on 15 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc