browserify-steam-totp
v1.0.2
Published
Steam-style generate totp codes by secret
Downloads
11
Maintainers
Readme
Browserify Steam TOTP
This is a library for creating a 2fa Steam code, as well as for creating a confirmation code. The library can be used both in Node.js and in the Browser.
Installation
npm install browserify-steam-totp
Usage
import { SteamTotp } from 'browserify-steam-totp';
const code = SteamTotp.generateAuthCode('uB08PipZey9znlgjywrQbId3doc=');
console.log('Steam Guard Code: ', code);
Arguments
secret
- The secret key as a string.timeOffset?
- Time offset in seconds (optional).
Return value
If the code has been generated, the method will return it.
code
- The auth code.
SteamTotp
const { SteamTotp } = requier('browserify-steam-totp');
import { SteamTotp } from 'browserify-steam-totp';
This class can be used to generate steam auth code or generate steam confirm key.
Propeties
ALPHABET
Constant with symbols for generating steam auth code.
DIGITS
Steam auth code length constant.
PERIOD
Constant with steam auth code update time.
Methods
bufferizeSecret(secret: string): WordArray
Convert the secret string into a format that can be used by CryptoJS.
Parameters:
- secret: string - The secret string (in hex or base64).
Returns: WordArray
The parsed secret as a CryptoJS WordArray.
generateAuthCode(secret: string, timeOffset?: number): string
Generate a one-time authentication code (TOTP).
Parameters:
- secret: string - The secret key as a string.
Default Value
timeOffset: number = 0 - Time offset in seconds (optional).
Returns: string
The generated one-time authentication code string.
generateConfirmationKey(identitySecret: string, time: number, tag: string): string
Generate a confirmation key for Steam.
Parameters:
- identitySecret: string - The secret key for Steam authentication.
- time: number - Unix time in seconds.
- tag: string - The tag for the key (e.g., 'conf').
Returns: string
The confirmation key string.
getDeviceId(steamid: string): string
Generate the device ID based on the SteamID.
Parameters:
- steamid: string - The user's SteamID.
Returns: string
The device ID string.
getTime(timeOffset?: number): number
Get the current time in seconds, optionally with a time offset.
Parameters:
Optional
timeOffset: number - Time offset in seconds (optional).
Returns: number
The current time in seconds number.
getTimeOffset(callback: (error?: Error, offset?: number, time?: number) => void): void
Get the time offset from Steam servers using a callback.
Parameters:
callback: (error?: Error, offset?: number, time?: number) => void - The callback function to return the error or result.
Parameters:
Optional
error: ErrorOptional
offset: numberOptional
time: number
Returns: void
Returns: void
getTimeOffsetAsync(): Promise<{ offset: number; time: number }>
Asynchronously get the time offset from Steam servers.
Returns: Promise<{ offset: number; time: number }>
An object with the time offset and the request time.
Documentation
Consult the Documentation
Contributing
Please check the contributing guidelines
License
Copyright (c) 2019 Eugene
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.