Comparing version 12.0.0-0 to 12.0.0-1
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
{ | ||
"name": "otplib", | ||
"version": "12.0.0-0", | ||
"version": "12.0.0-1", | ||
"description": "HMAC-based (HOTP) and Time-based (TOTP) One-Time Password library", | ||
@@ -84,3 +84,4 @@ "main": "./core/index.js", | ||
"!packages/tests-*/*", | ||
"!packages/otplib-preset-browser/*" | ||
"!packages/otplib-preset-browser/*", | ||
"!packages/package-cache/*" | ||
], | ||
@@ -102,3 +103,4 @@ "coverageDirectory": "./coverage/", | ||
"/packages/tests-data/", | ||
"/packages/tests-suites/" | ||
"/packages/tests-suites/", | ||
"/packages/package-cache/" | ||
], | ||
@@ -113,5 +115,5 @@ "testURL": "http://localhost", | ||
"name": "otplib", | ||
"module": "./builds/otplib/node" | ||
"module": "./builds/otplib/preset-default" | ||
} | ||
] | ||
} |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -20,4 +20,5 @@ # otplib | ||
- [In Browser](#in-browser) | ||
- [Migration Guide](#migration-guide) | ||
- [Migration and Versioning Guide](#migration-and-versioning-guide) | ||
- [Migrating from v11.x](#migrating-from-v11x) | ||
- [Downloading Master Builds](#downloading-master-builds) | ||
- [Getting Started](#getting-started) | ||
@@ -113,3 +114,5 @@ - [Install the Package](#install-the-package) | ||
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD'; | ||
// Alternative: const secret = authenticator.generateSecret(); | ||
// Alternative: | ||
// const secret = authenticator.generateSecret(); | ||
// Note: .generateSecret() is only available for authenticator and not totp/hotp | ||
@@ -130,2 +133,20 @@ const token = authenticator.generate(secret); | ||
Please replace "authenticator" with totp or hotp depending on your requirements. | ||
```js | ||
// For TOTP | ||
import { totp } from 'otplib/preset-default'; | ||
const token = totp.generate(secret); | ||
const isValid = totp.check(token, secret); | ||
const isValid = totp.verify({ token, secret }); | ||
// For HOTP | ||
import { hotp } from 'otplib/preset-default'; | ||
const token = hotp.generate(secret, counter); | ||
const isValid = hotp.check(token, secret, counter); | ||
const isValid = hotp.verify({ token, secret, counter }); | ||
``` | ||
For all available APIs, please refer to [API Documentation][project-api]. | ||
### In Browser | ||
@@ -154,3 +175,3 @@ | ||
## Migration Guide | ||
## Migration and Versioning Guide | ||
@@ -164,2 +185,8 @@ This library follows `semver`. As such, major version bumps usually mean API changes or behavior changes. | ||
| Release Type | Version Pattern | Command | | | ||
| :------------------- | --------------- | ---------------------------------------------------------------- | :------------------------------------ | | ||
| Current / Stable | 0.0.0 | `npm install otplib` | [![npm][badge-npm]][project-npm] | | ||
| Release Candidate | 0.0.0-0 | `npm install otplib@next` | [![npm][badge-npm-next]][project-npm] | | ||
| Master Branch Builds | 0.0.0-ci.{hash} | See: [Downloading Master Builds][docs-downloading-master-builds] | | | ||
### Migrating from v11.x | ||
@@ -182,2 +209,16 @@ | ||
### Downloading Master Builds | ||
From 12.x onwards, pre-release builds of master is also uploaded as an artifact on GitHub Actions. | ||
To download: | ||
1. Go to otplib's [Github Actions][project-github-actions]. | ||
2. Click on `dev-builds`. | ||
3. Select the latest `master` workflow run. | ||
4. Click on the `Artifacts` dropdown near the top-right. | ||
5. Download `otplib-ci-package.zip`. | ||
6. Unzip the zip file, you should see a `otplib-ci-{hash}.tar.gz` file. | ||
7. You can now run `npm install ./otplib-ci-{hash}.tar.gz` to install it into your project. | ||
## Getting Started | ||
@@ -197,7 +238,2 @@ | ||
| Release Type | Version | Command | | ||
| :---------------- | :------------------------------------ | ------------------------- | | ||
| Current / Stable | [![npm][badge-npm]][project-npm] | `npm install otplib` | | ||
| Release Candidate | [![npm][badge-npm-next]][project-npm] | `npm install otplib@next` | | ||
### Choose Your Plugins | ||
@@ -313,15 +349,18 @@ | ||
```js | ||
import { authenticator } from 'otplib/preset-default'; | ||
import { authenticator, totp, hotp } from 'otplib/preset-default'; | ||
// setting | ||
authenticator.options = { | ||
step: 30, | ||
window: 1 | ||
}; | ||
authenticator.options = { digits: 6 }; | ||
totp.options = { digits: 6 }; | ||
hotp.options = { digits: 6 }; | ||
// getting | ||
const opts = authenticator.options; | ||
const opts = totp.options; | ||
const opts = hotp.options; | ||
// reset to default | ||
authenticator.resetOptions(); | ||
totp.resetOptions(); | ||
hotp.resetOptions(); | ||
@@ -331,2 +370,4 @@ // getting all options, with validation | ||
const opts = authenticator.allOptions(); | ||
const opts = totp.allOptions(); | ||
const opts = hotp.allOptions(); | ||
``` | ||
@@ -400,3 +441,3 @@ | ||
The following options are modified for `functions` and `classes` which are postfixed with `Async`. | ||
The following options are modified for `functions` and `classes` which are suffixed with `Async`. | ||
@@ -555,2 +596,3 @@ eg: `AuthenticatorAsync`, `totpDigestAsync`, `hotpTokenAsync` etc. | ||
Check the [API Documentation][project-api] for the full list of async functions. | ||
All async functions are suffixed with `Async` except for class methods. | ||
@@ -697,3 +739,3 @@ ### Browser Compatiblity | ||
```bash | ||
$ npm install | ||
$ npm run setup | ||
$ npm run build | ||
@@ -731,2 +773,3 @@ | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -750,2 +793,3 @@ | ||
[docs-browser-compatiblity]: #browser-compatiblity | ||
[docs-downloading-master-builds]: #downloading-master-builds | ||
[docs-plugins-base32]: #base32-plugins | ||
@@ -765,2 +809,3 @@ [docs-plugins-crypto]: #crypto-plugins | ||
[project-docs]: https://otplib.yeojz.com/api | ||
[project-github-actions]: https://github.com/yeojz/otplib/actions | ||
[project-npm]: https://www.npmjs.com/package/otplib | ||
@@ -767,0 +812,0 @@ [project-v11-api]: https://5d4d0cc4c85e00000788a456--otplib.netlify.com/docs |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
@@ -5,3 +5,3 @@ /** | ||
* @author Gerald Yeo <contact@fusedthought.com> | ||
* @version: 12.0.0-0 | ||
* @version: 12.0.0-1 | ||
* @license: MIT | ||
@@ -8,0 +8,0 @@ **/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
207112
808
0