@crpdo/time
Version:
Provides methods for performing time-based operations including token verification, hash generation, and NTP calculations. It primarily deals with time-based one-time password (TOTP) functions
85 lines (57 loc) • 2.76 kB
Markdown
# @crpdo/time
> time is the key to all mysteries
[](https://www.npmjs.com/package/@crpdo/time)
[](https://gitlab.com/frenware/core/crpdo/time/-/pipelines)
[](https://gitlab.com/frenware/core/crpdo/time/-/blob/master/LICENSE)
[](https://www.npmjs.com/package/@crpdo/time)
[](https://gitlab.com/frenware/core/crpdo/time)
[](https://twitter.com/basdwon)
[](https://discordapp.com/users/basedwon)
This module provides time-related utilities for the parent project, primarily dealing with time-based one-time password (TOTP) generation, verification, and Network Time Protocol (NTP) calculations. `@crpdo/time` is a submodule of the larger `crpdo` project, a comprehensive cryptographic library for Node.js and the browser, which leverages TweetNaCl for various cryptographic functions.
## Installation
```sh
npm install @crpdo/time
```
## Usage
```js
const Time = require('@crpdo/time')
// Generate a TOTP
const secret = 'my_secret'
const totpGap = 10
const now = Date.now()
const totp = Time.code(secret, totpGap, now)
// Verify a token
const token = 'my_token'
const hashed = true
const range = 1
const result = Time.verify(token, secret, now, hashed, range, totpGap)
```
## Documentation
- [API Reference](/docs/api.md)
## Parent Project
`@crpdo/time` is part of the `crpdo` project. For more information on `crpdo` and its other submodules, please see [the main `crpdo` repository](https://github.com/basedwon/crpdo).
## Tests
In order to run the test suite, simply clone the repository and install its dependencies:
```bash
git clone https://gitlab.com/frenware/core/crpdo/time.git
cd basd
npm install
```
To run the tests:
```bash
npm test
```
## Contributing
Thank you! Please see our [contributing guidelines](/docs/contributing.md) for details.
## Donations
If you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!
**Bitcoin (BTC):**
```
1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF
```
**Monero (XMR):**
```
46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ
```
## License
@crpdo/time is [MIT licensed](https://gitlab.com/frenware/core/crpdo/time/-/blob/master/LICENSE).