<commit_before># Steam TOTP
[![npm version](https://img.shields.io/npm/v/steam-totp.svg)](https://npmjs.com/package/steam-totp)
[![npm downloads](https://img.shields.io/npm/dm/steam-totp.svg)](https://npmjs.com/package/steam-totp)
[![license](https://img.shields.io/npm/l/steam-totp.svg)](https://github.com/DoctorMcKay/node-steam-totp/blob/master/LICENSE)
[![paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N36YVAT42CZ4G&item_name=node%2dsteam%2dtotp&currency_code=USD)

This lightweight module generates Steam-style 5-digit alphanumeric two-factor authentication codes given a shared secret.

Usage is simple:

```js
var SteamTotp = require('steam-totp');
var code = SteamTotp.generateAuthCode('cnOgv/KdpLoP6Nbh0GMkXkPXALQ=');
```

## time([timeOffset])
- `timeOffset` - Default 0 if omitted. This many seconds will be added to the returned value.

**v1.2.0 or later is required to use this function**

Simply returns the current local time in Unix time. This is just `Math.floor(Date.now() / 1000) + timeOffset`.

## getAuthCode(secret[, timeOffset][, callback])
- `secret` - Your `shared_secret`, as a `Buffer`, hex string, or base64 string
- `timeOffset` - Optional. If you know your clock's offset from the Steam servers, you can provide it here. This number of seconds will be added to the current time to produce the final time. Default 0.
- `callback` - Optional. If you provide a callback, then the auth code will **not** be returned and it will be provided to the callback. If provided, the module will also account for time discrepancies with the Steam servers. If you use this, **do not** provide a `timeOffset`.
    - `err` - An `Error` object on failure, or `null` on success
    - `code` - Your auth code, as a string
    - `offset` - Your time offset, in seconds. You can pass this to `time` later if you need to, for example to get confirmation keys.
    - `latency` - The time in milliseconds between when we sent our request and when we received a response from the Steam time server.

**v1.4.0 or later is required to use `callback`.**
<commit_msg>Added Node support note to readme<commit_after># Steam TOTP
[![npm version](https://img.shields.io/npm/v/steam-totp.svg)](https://npmjs.com/package/steam-totp)
[![npm downloads](https://img.shields.io/npm/dm/steam-totp.svg)](https://npmjs.com/package/steam-totp)
[![license](https://img.shields.io/npm/l/steam-totp.svg)](https://github.com/DoctorMcKay/node-steam-totp/blob/master/LICENSE)
[![paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N36YVAT42CZ4G&item_name=node%2dsteam%2dtotp&currency_code=USD)

This lightweight module generates Steam-style 5-digit alphanumeric two-factor authentication codes given a shared secret.

**As of v2.0.0, Node.js v6.0.0 or later is REQUIRED. This LTS Node.js release will be supported by this module for the duration of Node's LTS support.**

Usage is simple:

```js
var SteamTotp = require('steam-totp');
var code = SteamTotp.generateAuthCode('cnOgv/KdpLoP6Nbh0GMkXkPXALQ=');
```

## time([timeOffset])
- `timeOffset` - Default 0 if omitted. This many seconds will be added to the returned value.

**v1.2.0 or later is required to use this function**

Simply returns the current local time in Unix time. This is just `Math.floor(Date.now() / 1000) + timeOffset`.

## getAuthCode(secret[, timeOffset][, callback])
- `secret` - Your `shared_secret`, as a `Buffer`, hex string, or base64 string
- `timeOffset` - Optional. If you know your clock's offset from the Steam servers, you can provide it here. This number of seconds will be added to the current time to produce the final time. Default 0.
- `callback` - Optional. If you provide a callback, then the auth code will **not** be returned and it will be provided to the callback. If provided, the module will also account for time discrepancies with the Steam servers. If you use this, **do not** provide a `timeOffset`.
    - `err` - An `Error` object on failure, or `null` on success
    - `code` - Your auth code, as a string
    - `offset` - Your time offset, in seconds. You can pass this to `time` later if you need to, for example to get confirmation keys.
    - `latency` - The time in milliseconds between when we sent our request and when we received a response from the Steam time server.

**v1.4.0 or later is required to use `callback`.**

{'fraction_non_alphanumeric': 0.12399283795881827, 'fraction_numerical': 0.012085944494180842, 'mean_word_length': 4.364945978391357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 16, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3642882', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1393, 'n_words': 507}