adminforth 1.1.75 → 1.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/utils.js +1 -1
- package/dist/plugins/S3UploadPlugin/custom/s3uploader.vue +1 -1
- package/dist/plugins/S3UploadPlugin/package.json +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/.package-lock.json +61 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/LICENSE +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/package.json +217 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/LICENSE +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/package.json +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/LICENSE +201 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/README.md +68 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.js +51 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.js +2 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/package.json +58 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/.travis.yml +6 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/LICENSE +22 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/Readme.md +135 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP-verify.js +33 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP.js +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/index.js +221 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/package.json +22 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/mocha.opts +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/notp.js +217 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/LICENSE.txt +19 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/Makefile +24 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/index.js +23 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/index.js +26 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/thirty-two.js +128 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/package.json +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/spec/thirty-two_spec.js +63 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/LICENSE.txt +12 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/README.md +164 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/SECURITY.md +41 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.js +68 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/package.json +3 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/package.json +47 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.html +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.js +374 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.mjs +373 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.html +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.js +424 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/README.md +6 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/package.json +55 -0
- package/dist/plugins/TwoFactorsAuthPlugin/package-lock.json +69 -0
- package/dist/plugins/TwoFactorsAuthPlugin/package.json +15 -0
- package/dist/spa/spa/.eslintrc.cjs +14 -0
- package/dist/spa/spa/.vscode/extensions.json +6 -0
- package/dist/spa/spa/README.md +39 -0
- package/dist/spa/spa/env.d.ts +1 -0
- package/dist/spa/spa/index.html +23 -0
- package/dist/spa/spa/package-lock.json +4470 -0
- package/dist/spa/spa/package.json +48 -0
- package/dist/spa/spa/postcss.config.js +6 -0
- package/dist/spa/spa/public/assets/favicon.png +0 -0
- package/dist/spa/spa/src/App.vue +316 -0
- package/dist/spa/spa/src/assets/base.css +0 -0
- package/dist/spa/spa/src/assets/logo.svg +19 -0
- package/dist/spa/spa/src/components/AcceptModal.vue +45 -0
- package/dist/spa/spa/src/components/Breadcrumbs.vue +40 -0
- package/dist/spa/spa/src/components/BreadcrumbsWithButtons.vue +26 -0
- package/dist/spa/spa/src/components/CustomDatePicker.vue +174 -0
- package/dist/spa/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/spa/src/components/CustomRangePicker.vue +148 -0
- package/dist/spa/spa/src/components/Dropdown.vue +168 -0
- package/dist/spa/spa/src/components/Filters.vue +211 -0
- package/dist/spa/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/spa/src/components/MenuLink.vue +24 -0
- package/dist/spa/spa/src/components/ResourceForm.vue +265 -0
- package/dist/spa/spa/src/components/ResourceListTable.vue +404 -0
- package/dist/spa/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/spa/src/components/SkeleteLoader.vue +23 -0
- package/dist/spa/spa/src/components/Toast.vue +66 -0
- package/dist/spa/spa/src/components/ValueRenderer.vue +59 -0
- package/dist/spa/spa/src/components/icons/IconCalendar.vue +5 -0
- package/dist/spa/spa/src/components/icons/IconCommunity.vue +7 -0
- package/dist/spa/spa/src/components/icons/IconDocumentation.vue +7 -0
- package/dist/spa/spa/src/components/icons/IconEcosystem.vue +7 -0
- package/dist/spa/spa/src/components/icons/IconSupport.vue +7 -0
- package/dist/spa/spa/src/components/icons/IconTime.vue +5 -0
- package/dist/spa/spa/src/components/icons/IconTooling.vue +19 -0
- package/dist/spa/spa/src/composables/useFrontendApi.ts +26 -0
- package/dist/spa/spa/src/composables/useStores.ts +126 -0
- package/dist/spa/spa/src/index.scss +26 -0
- package/dist/spa/spa/src/main.ts +18 -0
- package/dist/spa/spa/src/router/index.ts +63 -0
- package/dist/spa/spa/src/spa_types/core.ts +51 -0
- package/dist/spa/spa/src/stores/core.ts +144 -0
- package/dist/spa/spa/src/stores/filters.ts +22 -0
- package/dist/spa/spa/src/stores/modal.ts +48 -0
- package/dist/spa/spa/src/stores/toast.ts +15 -0
- package/dist/spa/spa/src/stores/user.ts +54 -0
- package/dist/spa/spa/src/utils.ts +101 -0
- package/dist/spa/spa/src/views/CreateView.vue +155 -0
- package/dist/spa/spa/src/views/EditView.vue +157 -0
- package/dist/spa/spa/src/views/ListView.vue +266 -0
- package/dist/spa/spa/src/views/LoginView.vue +139 -0
- package/dist/spa/spa/src/views/ResourceParent.vue +17 -0
- package/dist/spa/spa/src/views/ShowView.vue +180 -0
- package/dist/spa/spa/tailwind.config.js +17 -0
- package/dist/spa/spa/tsconfig.app.json +14 -0
- package/dist/spa/spa/tsconfig.json +11 -0
- package/dist/spa/spa/tsconfig.node.json +19 -0
- package/dist/spa/spa/vite.config.ts +49 -0
- package/modules/utils.ts +1 -1
- package/package.json +1 -3
- package/plugins/S3UploadPlugin/custom/s3uploader.vue +1 -1
- package/plugins/S3UploadPlugin/package.json +1 -0
- package/plugins/S3UploadPlugin/types.ts +1 -1
- package/plugins/TwoFactorsAuthPlugin/node_modules/.package-lock.json +61 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/LICENSE +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/assert.d.ts +1040 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/buffer.d.ts +2363 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/child_process.d.ts +1544 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/cluster.d.ts +578 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/console.d.ts +452 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/constants.d.ts +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/crypto.d.ts +4523 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dgram.d.ts +596 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dns.d.ts +864 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dom-events.d.ts +124 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/domain.d.ts +170 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/events.d.ts +931 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/fs.d.ts +4317 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/globals.d.ts +412 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/globals.global.d.ts +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/http.d.ts +1908 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/http2.d.ts +2418 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/https.d.ts +550 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/index.d.ts +89 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/inspector.d.ts +2746 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/module.d.ts +315 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/net.d.ts +999 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/os.d.ts +495 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/package.json +217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/path.d.ts +191 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/perf_hooks.d.ts +905 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/process.d.ts +1754 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/punycode.d.ts +117 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/querystring.d.ts +153 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/readline.d.ts +540 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/repl.d.ts +430 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/sea.d.ts +153 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/web.d.ts +367 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream.d.ts +1707 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/test.d.ts +1718 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/timers.d.ts +240 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/tls.d.ts +1217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/trace_events.d.ts +197 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/tty.d.ts +208 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/url.d.ts +952 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/util.d.ts +2292 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/v8.d.ts +808 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/vm.d.ts +924 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/wasi.d.ts +181 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/worker_threads.d.ts +694 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/zlib.d.ts +530 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/LICENSE +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/index.d.ts +127 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/package.json +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/LICENSE +201 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/README.md +68 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.d.ts +11 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.js +51 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.d.ts +4 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.js +2 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/package.json +58 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/.travis.yml +6 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/LICENSE +22 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/Readme.md +135 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP-verify.js +33 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP.js +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/index.js +221 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/package.json +22 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/mocha.opts +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/notp.js +217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/LICENSE.txt +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/Makefile +24 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/index.js +23 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/index.js +26 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/thirty-two.js +128 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/package.json +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/spec/thirty-two_spec.js +63 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/LICENSE.txt +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/README.md +164 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/SECURITY.md +41 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.d.ts +37 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.js +68 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/package.json +3 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/package.json +47 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.d.ts +453 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.html +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.js +374 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.mjs +373 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.html +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.js +424 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/README.md +6 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/agent.d.ts +31 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/api.d.ts +43 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/cache.d.ts +36 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/client.d.ts +97 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/connector.d.ts +34 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/content-type.d.ts +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/cookies.d.ts +28 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/errors.d.ts +128 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/fetch.d.ts +209 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/file.d.ts +39 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/filereader.d.ts +54 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/formdata.d.ts +108 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/global-origin.d.ts +7 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/handlers.d.ts +9 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/header.d.ts +4 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/index.d.ts +63 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/interceptors.d.ts +5 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-client.d.ts +25 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/package.json +55 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/patch.d.ts +71 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/pool.d.ts +28 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/readable.d.ts +61 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/webidl.d.ts +220 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/websocket.d.ts +131 -0
- package/plugins/TwoFactorsAuthPlugin/package-lock.json +69 -0
- package/plugins/TwoFactorsAuthPlugin/package.json +15 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# node-2fa
|
|
2
|
+
|
|
3
|
+
Easy 2-Factor Integration For Node.js
|
|
4
|
+
|
|
5
|
+
There are a number of applications which support 2-Factor Authentication, namely
|
|
6
|
+
|
|
7
|
+
- Authy [iPhone](https://itunes.apple.com/us/app/authy/id494168017?mt=8) | [Android](https://play.google.com/store/apps/details?id=com.authy.authy&hl=en) | [Chrome](https://chrome.google.com/webstore/detail/authy/gaedmjdfmmahhbjefcbgaolhhanlaolb?hl=en) | [Linux](https://www.authy.com/personal/) | [OS X](https://www.authy.com/personal/) | [BlackBerry](https://appworld.blackberry.com/webstore/content/38831914/?countrycode=US&lang=en)
|
|
8
|
+
- Google Authenticator [iPhone](https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8) | [Android](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en)
|
|
9
|
+
- Microsoft Authenticator [Windows Phone](https://www.microsoft.com/en-us/store/apps/authenticator/9wzdncrfj3rj) | [Android](https://play.google.com/store/apps/details?id=com.microsoft.msa.authenticator)
|
|
10
|
+
|
|
11
|
+
This module uses [`notp`](https://github.com/guyht/notp) which implements `TOTP` [(RFC 6238)](https://www.ietf.org/rfc/rfc6238.txt)
|
|
12
|
+
(the _Authenticator_ standard), which is based on `HOTP` [(RFC 4226)](https://www.ietf.org/rfc/rfc4226.txt)
|
|
13
|
+
to provide codes that are exactly compatible with all other _Authenticator_ apps and services that use them.
|
|
14
|
+
|
|
15
|
+
Usage
|
|
16
|
+
=====
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install node-2fa --save
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
const twofactor = require("node-2fa");
|
|
24
|
+
|
|
25
|
+
const newSecret = twofactor.generateSecret({ name: "My Awesome App", account: "johndoe" });
|
|
26
|
+
/*
|
|
27
|
+
{ secret: 'XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W',
|
|
28
|
+
uri: 'otpauth://totp/My%20Awesome%20App:johndoe?secret=XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W&issuer=My%20Awesome%20App',
|
|
29
|
+
qr: 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=otpauth://totp/My%20Awesome%20App:johndoe%3Fsecret=XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W%26issuer=My%20Awesome%20App'
|
|
30
|
+
}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const newToken = twofactor.generateToken("XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W");
|
|
34
|
+
// => { token: '630618' }
|
|
35
|
+
|
|
36
|
+
twofactor.verifyToken("XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W", "630618");
|
|
37
|
+
// => { delta: 0 }
|
|
38
|
+
|
|
39
|
+
twofactor.verifyToken("XDQXYCP5AC6FA32FQXDGJSPBIDYNKK5W", "00");
|
|
40
|
+
// => null
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### generateSecret(options)
|
|
46
|
+
|
|
47
|
+
returns an object containing a 32-character secret (keep user specific, store in DB), a uri (if you want to make your own QR / barcode) and a direct link to a QR code served via HTTPS by the Google Chart API
|
|
48
|
+
|
|
49
|
+
options is an object containing `name` which is the name of your app that will show up when the user scans the QR code and `account` which can be the username and will also show up in the user's app. Both parameters are optional
|
|
50
|
+
|
|
51
|
+
### generateToken(secret)
|
|
52
|
+
|
|
53
|
+
returns an object containing a 6-character token
|
|
54
|
+
|
|
55
|
+
### verifyToken(secret, token, window)
|
|
56
|
+
|
|
57
|
+
checks if a time-based token matches a token from secret key within a +/- _window_ (default: 4) minute window
|
|
58
|
+
|
|
59
|
+
returns either `null` if the token does not match, or an object containing delta key, which is an integer of how for behind / forward the code time sync is in terms of how many new codes have been generated since entry
|
|
60
|
+
|
|
61
|
+
ex.
|
|
62
|
+
`{delta: -1}` means that the client entered the key too late (a newer key was meant to be used).
|
|
63
|
+
`{delta: 1}` means the client entered the key too early (an older key was meant to be used).
|
|
64
|
+
`{delta: 0}` means the client was within the time frame of the current key.
|
|
65
|
+
|
|
66
|
+
## _n_-Minute Window
|
|
67
|
+
|
|
68
|
+
The window is set to 4 by default. Each token is valid for a total of _n_ minutes to account for time drift.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyToken = exports.generateToken = exports.generateSecret = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const notp_1 = tslib_1.__importDefault(require("notp"));
|
|
6
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
7
|
+
const thirty_two_1 = tslib_1.__importDefault(require("thirty-two"));
|
|
8
|
+
function generateSecret(options) {
|
|
9
|
+
var _a;
|
|
10
|
+
const config = {
|
|
11
|
+
name: encodeURIComponent((_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : "App"),
|
|
12
|
+
account: encodeURIComponent((options === null || options === void 0 ? void 0 : options.account) ? `:${options.account}` : ""),
|
|
13
|
+
};
|
|
14
|
+
const bin = crypto_1.default.randomBytes(20);
|
|
15
|
+
const base32 = thirty_two_1.default.encode(bin).toString("utf8").replace(/=/g, "");
|
|
16
|
+
const secret = base32
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replace(/(\w{4})/g, "$1 ")
|
|
19
|
+
.trim()
|
|
20
|
+
.split(" ")
|
|
21
|
+
.join("")
|
|
22
|
+
.toUpperCase();
|
|
23
|
+
const query = `?secret=${secret}&issuer=${config.name}`;
|
|
24
|
+
const encodedQuery = query.replace('?', '%3F').replace('&', '%26');
|
|
25
|
+
const uri = `otpauth://totp/${config.name}${config.account}`;
|
|
26
|
+
return {
|
|
27
|
+
secret,
|
|
28
|
+
uri: `${uri}${query}`,
|
|
29
|
+
qr: `https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=${uri}${encodedQuery}`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.generateSecret = generateSecret;
|
|
33
|
+
function generateToken(secret) {
|
|
34
|
+
if (!secret || !secret.length)
|
|
35
|
+
return null;
|
|
36
|
+
const unformatted = secret.replace(/\W+/g, "").toUpperCase();
|
|
37
|
+
const bin = thirty_two_1.default.decode(unformatted);
|
|
38
|
+
return { token: notp_1.default.totp.gen(bin) };
|
|
39
|
+
}
|
|
40
|
+
exports.generateToken = generateToken;
|
|
41
|
+
function verifyToken(secret, token, window = 4) {
|
|
42
|
+
if (!token || !token.length)
|
|
43
|
+
return null;
|
|
44
|
+
const unformatted = secret.replace(/\W+/g, "").toUpperCase();
|
|
45
|
+
const bin = thirty_two_1.default.decode(unformatted);
|
|
46
|
+
return notp_1.default.totp.verify(token.replace(/\W+/g, ""), bin, {
|
|
47
|
+
window,
|
|
48
|
+
time: 30,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.verifyToken = verifyToken;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-2fa",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "Easy 2-Factor Integration For Node.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "eslint . --fix&&jest",
|
|
10
|
+
"prepublishOnly": "npm run test&&npm run build",
|
|
11
|
+
"build": "tsc"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"package.json",
|
|
16
|
+
"readme.md"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/jeremyscalpello/node-2fa"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"auth",
|
|
24
|
+
"2fa",
|
|
25
|
+
"mfa",
|
|
26
|
+
"token",
|
|
27
|
+
"key",
|
|
28
|
+
"base32",
|
|
29
|
+
"code",
|
|
30
|
+
"generator"
|
|
31
|
+
],
|
|
32
|
+
"contributors": [
|
|
33
|
+
"Jeremy Scalpello <jeremy@scalpello.info>",
|
|
34
|
+
"Alistair Smith <hey@alistair.cloud>"
|
|
35
|
+
],
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"homepage": "https://github.com/jeremyscalpello/node-2fa#readme",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@types/notp": "^2.0.0",
|
|
40
|
+
"notp": "^2.0.3",
|
|
41
|
+
"thirty-two": "1.0.2",
|
|
42
|
+
"tslib": "^2.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/jest": "^26.0.20",
|
|
46
|
+
"@types/node": "^14.14.20",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^4.12.0",
|
|
48
|
+
"@typescript-eslint/parser": "^4.12.0",
|
|
49
|
+
"eslint": "^7.17.0",
|
|
50
|
+
"jest": "^26.6.3",
|
|
51
|
+
"prettier": "^2.2.1",
|
|
52
|
+
"ts-jest": "^26.4.4",
|
|
53
|
+
"typescript": "^4.1.3"
|
|
54
|
+
},
|
|
55
|
+
"prettier": {
|
|
56
|
+
"printWidth": 120
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011 Guy Halford-Thompson <guy@cach.me>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
[](https://travis-ci.org/guyht/notp)
|
|
2
|
+
|
|
3
|
+
# Node One Time Password library
|
|
4
|
+
Simple to use, fast, and with zero dependencies. The Node One Time Password library is fully compliant with [HOTP](http://tools.ietf.org/html/rfc4226) (counter based one time passwords) and [TOTP](http://tools.ietf.org/html/rfc6238) (time based one time passwords). It can be used in conjunction with the [Google Authenticator](http://code.google.com/p/google-authenticator/) which has free apps for iOS, Android and BlackBerry.
|
|
5
|
+
|
|
6
|
+
# Installation
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm install notp
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
# Usage
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
var notp = require('notp');
|
|
16
|
+
|
|
17
|
+
//.... some initial login code, that receives the user details and TOTP / HOTP token
|
|
18
|
+
|
|
19
|
+
var key = 'secret key for user... could be stored in DB';
|
|
20
|
+
var token = 'user supplied one time use token';
|
|
21
|
+
|
|
22
|
+
// Check TOTP is correct (HOTP if hotp pass type)
|
|
23
|
+
var login = notp.totp.verify(token, key);
|
|
24
|
+
|
|
25
|
+
// invalid token if login is null
|
|
26
|
+
if (!login) {
|
|
27
|
+
return console.log('Token invalid');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// valid token
|
|
31
|
+
console.log('Token valid, sync value is %s', login.delta);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Google Authenticator
|
|
35
|
+
|
|
36
|
+
[Google authenticator](https://code.google.com/p/google-authenticator/) requires that keys be base32 encoded before being used. This includes manual entry into the app as well as preparing a QR code URI.
|
|
37
|
+
|
|
38
|
+
To base32 encode a utf8 key you can use the `thirty-two` module.
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
var base32 = require('thirty-two');
|
|
42
|
+
|
|
43
|
+
var key = 'secret key for the user';
|
|
44
|
+
|
|
45
|
+
// encoded will be the secret key, base32 encoded
|
|
46
|
+
var encoded = base32.encode(key);
|
|
47
|
+
|
|
48
|
+
// Google authenticator doesn't like equal signs
|
|
49
|
+
var encodedForGoogle = encoded.toString().replace(/=/g,'');
|
|
50
|
+
|
|
51
|
+
// to create a URI for a qr code (change totp to hotp is using hotp)
|
|
52
|
+
var uri = 'otpauth://totp/somelabel?secret=' + encodedForGoogle;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note: If your label has spaces or other invalid uri characters you will need to encode it accordingly using `encodeURIComponent` More details about the uri key format can be found on the [google auth wiki](https://code.google.com/p/google-authenticator/wiki/KeyUriFormat)
|
|
56
|
+
|
|
57
|
+
# API
|
|
58
|
+
##hotp.verify(token, key, opt)
|
|
59
|
+
|
|
60
|
+
Check a counter based one time password for validity.
|
|
61
|
+
|
|
62
|
+
Returns null if token is not valid for given key and options.
|
|
63
|
+
|
|
64
|
+
Returns an object `{delta: #}` if the token is valid. `delta` is the count skew between client and server.
|
|
65
|
+
|
|
66
|
+
### opt
|
|
67
|
+
**window**
|
|
68
|
+
> The allowable margin for the counter. The function will check `window` codes in the future against the provided token.
|
|
69
|
+
> i.e. if `window = 100` and `counter = 5` all tokens between 5 and 105 will be checked against the supplied token
|
|
70
|
+
> Default - 50
|
|
71
|
+
|
|
72
|
+
**counter**
|
|
73
|
+
> Counter value. This should be stored by the application on a per user basis. It is up to the application to track and increment this value as needed. It is also up to the application to increment this value if there is a skew between the client and server (`delta`)
|
|
74
|
+
|
|
75
|
+
##totp.verify(token, key, opt)
|
|
76
|
+
|
|
77
|
+
Check a time based one time password for validity
|
|
78
|
+
|
|
79
|
+
Returns null if token is not valid for given key and options.
|
|
80
|
+
|
|
81
|
+
Returns an object `{delta: #}` if the token is valid. `delta` is the count skew between client and server.
|
|
82
|
+
|
|
83
|
+
### opt
|
|
84
|
+
**window**
|
|
85
|
+
> The allowable margin for the counter. The function will check `window` codes in the future against the provided token.
|
|
86
|
+
> i.e. if `window = 5` and `counter = 1000` all tokens between 995 and 1005 will be checked against the supplied token
|
|
87
|
+
> Default - 6
|
|
88
|
+
|
|
89
|
+
**time**
|
|
90
|
+
> The time step of the counter. This must be the same for every request and is used to calculate C.
|
|
91
|
+
> Default - 30
|
|
92
|
+
|
|
93
|
+
##hotp.gen(key, opt)
|
|
94
|
+
|
|
95
|
+
Return a counter based one time password
|
|
96
|
+
|
|
97
|
+
### opt
|
|
98
|
+
**counter**
|
|
99
|
+
> Counter value. This should be stored by the application, must be user specific, and be incremented for each request.
|
|
100
|
+
|
|
101
|
+
##totp.gen(key, opt)
|
|
102
|
+
|
|
103
|
+
Return a time based one time password
|
|
104
|
+
|
|
105
|
+
### opt
|
|
106
|
+
**time**
|
|
107
|
+
> The time step of the counter. This must be the same for every request and is used to calculate C.
|
|
108
|
+
> Default - 30
|
|
109
|
+
|
|
110
|
+
# Migrating from 1.x to 2.x
|
|
111
|
+
|
|
112
|
+
## Removed
|
|
113
|
+
The `encBase32` and `decBase32` methods have been removed. If you wish to encode/decode base32 you should install a module to do so. We recommend the `thirty-two` npm module.
|
|
114
|
+
|
|
115
|
+
## Changed
|
|
116
|
+
|
|
117
|
+
All of the APIs have been changed to return values directly instead of using callbacks. This reflects the fact that the functions are actually synchronous and perform no I/O.
|
|
118
|
+
|
|
119
|
+
Some of the required arguments to the functions have also been removed from the `args` parameter and are passed as separate function parameters. See the above API docs for details.
|
|
120
|
+
|
|
121
|
+
* `notp.checkHOTP(args, err, cb)` -> `notp.hotp.verify(token, key, opt)`
|
|
122
|
+
* `notp.checkTOTP(args, err, cb)` -> `notp.totp.verify(token, key, opt)`
|
|
123
|
+
* `notp.getHOTP(args, err, cb)` -> `notp.gotp.gen(key, opt)`
|
|
124
|
+
* `notp.getTOTP(args, err, cb)` -> `notp.totp.gen(key, opt)`
|
|
125
|
+
|
|
126
|
+
## Args
|
|
127
|
+
|
|
128
|
+
The argument names have also changed to better describe the purpose of the argument.
|
|
129
|
+
|
|
130
|
+
* `K` -> no longer in args/opt but passed directly as a function argument
|
|
131
|
+
* `P` -> no longer in args/opt but passed directly as a function argument
|
|
132
|
+
* `W` -> `window`
|
|
133
|
+
* `C` -> `counter`
|
|
134
|
+
* `T` -> `time`
|
|
135
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
var notp = require('../index'),
|
|
3
|
+
t2 = require('thirty-two'),
|
|
4
|
+
K = '12345678901234567890',
|
|
5
|
+
b32 = t2.encode(K);
|
|
6
|
+
|
|
7
|
+
console.log('Click on this link to gennerate a QR code, and use Google Authenticator on your phone to read it:');
|
|
8
|
+
console.log('http://qrcode.kaywa.com/img.php?s=8&d=' + encodeURIComponent('otpauth://totp/notp@example.com?secret=' + b32));
|
|
9
|
+
verify();
|
|
10
|
+
|
|
11
|
+
function verify() {
|
|
12
|
+
ask('Enter a code to verify', function(code) {
|
|
13
|
+
if(notp.totp.verify(code, K, {})) {
|
|
14
|
+
console.log('Success!!!');
|
|
15
|
+
}
|
|
16
|
+
console.log(notp.totp.verify(code, K, {}));
|
|
17
|
+
verify();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function ask(question, callback) {
|
|
24
|
+
var stdin = process.stdin, stdout = process.stdout;
|
|
25
|
+
|
|
26
|
+
stdin.resume();
|
|
27
|
+
stdout.write(question + ": ");
|
|
28
|
+
|
|
29
|
+
stdin.once('data', function(data) {
|
|
30
|
+
data = data.toString().trim();
|
|
31
|
+
callback(data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
var notp = require('../index'),
|
|
3
|
+
t2 = require('thirty-two'),
|
|
4
|
+
K = '12345678901234567890',
|
|
5
|
+
b32 = t2.encode(K);
|
|
6
|
+
|
|
7
|
+
console.log('Getting current counter value for K = 12345678901234567890');
|
|
8
|
+
console.log('This has a base32 value of ' + b32);
|
|
9
|
+
console.log('The base32 value should be entered in the Google Authenticator App');
|
|
10
|
+
console.log('');
|
|
11
|
+
console.log('Open the following URL for a QR code. Google Authenticator can read this QR code using your phone\'s camera:');
|
|
12
|
+
console.log('http://qrcode.kaywa.com/img.php?s=8&d=' + encodeURIComponent('otpauth://totp/notp@example.com?secret=' + b32));
|
|
13
|
+
|
|
14
|
+
console.log('The current TOTP value is ' + notp.totp.gen(K, {}));
|
|
15
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
|
|
2
|
+
var crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
var hotp = {};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generate a counter based One Time Password
|
|
8
|
+
*
|
|
9
|
+
* @return {String} the one time password
|
|
10
|
+
*
|
|
11
|
+
* Arguments:
|
|
12
|
+
*
|
|
13
|
+
* args
|
|
14
|
+
* key - Key for the one time password. This should be unique and secret for
|
|
15
|
+
* every user as this is the seed that is used to calculate the HMAC
|
|
16
|
+
*
|
|
17
|
+
* counter - Counter value. This should be stored by the application, must
|
|
18
|
+
* be user specific, and be incremented for each request.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
hotp.gen = function(key, opt) {
|
|
22
|
+
key = key || '';
|
|
23
|
+
opt = opt || {};
|
|
24
|
+
var counter = opt.counter || 0;
|
|
25
|
+
|
|
26
|
+
var p = 6;
|
|
27
|
+
|
|
28
|
+
// Create the byte array
|
|
29
|
+
var b = new Buffer(intToBytes(counter));
|
|
30
|
+
|
|
31
|
+
var hmac = crypto.createHmac('sha1', new Buffer(key));
|
|
32
|
+
|
|
33
|
+
// Update the HMAC with the byte array
|
|
34
|
+
var digest = hmac.update(b).digest('hex');
|
|
35
|
+
|
|
36
|
+
// Get byte array
|
|
37
|
+
var h = hexToBytes(digest);
|
|
38
|
+
|
|
39
|
+
// Truncate
|
|
40
|
+
var offset = h[19] & 0xf;
|
|
41
|
+
var v = (h[offset] & 0x7f) << 24 |
|
|
42
|
+
(h[offset + 1] & 0xff) << 16 |
|
|
43
|
+
(h[offset + 2] & 0xff) << 8 |
|
|
44
|
+
(h[offset + 3] & 0xff);
|
|
45
|
+
|
|
46
|
+
v = v + '';
|
|
47
|
+
|
|
48
|
+
return v.substr(v.length - p, p);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check a One Time Password based on a counter.
|
|
53
|
+
*
|
|
54
|
+
* @return {Object} null if failure, { delta: # } on success
|
|
55
|
+
* delta is the time step difference between the client and the server
|
|
56
|
+
*
|
|
57
|
+
* Arguments:
|
|
58
|
+
*
|
|
59
|
+
* args
|
|
60
|
+
* key - Key for the one time password. This should be unique and secret for
|
|
61
|
+
* every user as it is the seed used to calculate the HMAC
|
|
62
|
+
*
|
|
63
|
+
* token - Passcode to validate.
|
|
64
|
+
*
|
|
65
|
+
* window - The allowable margin for the counter. The function will check
|
|
66
|
+
* 'W' codes in the future against the provided passcode. Note,
|
|
67
|
+
* it is the calling applications responsibility to keep track of
|
|
68
|
+
* 'W' and increment it for each password check, and also to adjust
|
|
69
|
+
* it accordingly in the case where the client and server become
|
|
70
|
+
* out of sync (second argument returns non zero).
|
|
71
|
+
* E.g. if W = 100, and C = 5, this function will check the passcode
|
|
72
|
+
* against all One Time Passcodes between 5 and 105.
|
|
73
|
+
*
|
|
74
|
+
* Default - 50
|
|
75
|
+
*
|
|
76
|
+
* counter - Counter value. This should be stored by the application, must
|
|
77
|
+
* be user specific, and be incremented for each request.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
hotp.verify = function(token, key, opt) {
|
|
81
|
+
opt = opt || {};
|
|
82
|
+
var window = opt.window || 50;
|
|
83
|
+
var counter = opt.counter || 0;
|
|
84
|
+
|
|
85
|
+
// Now loop through from C to C + W to determine if there is
|
|
86
|
+
// a correct code
|
|
87
|
+
for(var i = counter - window; i <= counter + window; ++i) {
|
|
88
|
+
opt.counter = i;
|
|
89
|
+
if(this.gen(key, opt) === token) {
|
|
90
|
+
// We have found a matching code, trigger callback
|
|
91
|
+
// and pass offset
|
|
92
|
+
return { delta: i - counter };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// If we get to here then no codes have matched, return null
|
|
97
|
+
return null;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var totp = {};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Generate a time based One Time Password
|
|
104
|
+
*
|
|
105
|
+
* @return {String} the one time password
|
|
106
|
+
*
|
|
107
|
+
* Arguments:
|
|
108
|
+
*
|
|
109
|
+
* args
|
|
110
|
+
* key - Key for the one time password. This should be unique and secret for
|
|
111
|
+
* every user as it is the seed used to calculate the HMAC
|
|
112
|
+
*
|
|
113
|
+
* time - The time step of the counter. This must be the same for
|
|
114
|
+
* every request and is used to calculat C.
|
|
115
|
+
*
|
|
116
|
+
* Default - 30
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
totp.gen = function(key, opt) {
|
|
120
|
+
opt = opt || {};
|
|
121
|
+
var time = opt.time || 30;
|
|
122
|
+
var _t = new Date().getTime();;
|
|
123
|
+
|
|
124
|
+
// Time has been overwritten.
|
|
125
|
+
if(opt._t) {
|
|
126
|
+
if(process.env.NODE_ENV != 'test') {
|
|
127
|
+
throw new Error('cannot overwrite time in non-test environment!');
|
|
128
|
+
}
|
|
129
|
+
_t = opt._t;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Determine the value of the counter, C
|
|
133
|
+
// This is the number of time steps in seconds since T0
|
|
134
|
+
opt.counter = Math.floor((_t / 1000) / time);
|
|
135
|
+
|
|
136
|
+
return hotp.gen(key, opt);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Check a One Time Password based on a timer.
|
|
141
|
+
*
|
|
142
|
+
* @return {Object} null if failure, { delta: # } on success
|
|
143
|
+
* delta is the time step difference between the client and the server
|
|
144
|
+
*
|
|
145
|
+
* Arguments:
|
|
146
|
+
*
|
|
147
|
+
* args
|
|
148
|
+
* key - Key for the one time password. This should be unique and secret for
|
|
149
|
+
* every user as it is the seed used to calculate the HMAC
|
|
150
|
+
*
|
|
151
|
+
* token - Passcode to validate.
|
|
152
|
+
*
|
|
153
|
+
* window - The allowable margin for the counter. The function will check
|
|
154
|
+
* 'W' codes either side of the provided counter. Note,
|
|
155
|
+
* it is the calling applications responsibility to keep track of
|
|
156
|
+
* 'W' and increment it for each password check, and also to adjust
|
|
157
|
+
* it accordingly in the case where the client and server become
|
|
158
|
+
* out of sync (second argument returns non zero).
|
|
159
|
+
* E.g. if W = 5, and C = 1000, this function will check the passcode
|
|
160
|
+
* against all One Time Passcodes between 995 and 1005.
|
|
161
|
+
*
|
|
162
|
+
* Default - 6
|
|
163
|
+
*
|
|
164
|
+
* time - The time step of the counter. This must be the same for
|
|
165
|
+
* every request and is used to calculate C.
|
|
166
|
+
*
|
|
167
|
+
* Default - 30
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
totp.verify = function(token, key, opt) {
|
|
171
|
+
opt = opt || {};
|
|
172
|
+
var time = opt.time || 30;
|
|
173
|
+
var _t = new Date().getTime();
|
|
174
|
+
|
|
175
|
+
// Time has been overwritten.
|
|
176
|
+
if(opt._t) {
|
|
177
|
+
if(process.env.NODE_ENV != 'test') {
|
|
178
|
+
throw new Error('cannot overwrite time in non-test environment!');
|
|
179
|
+
}
|
|
180
|
+
_t = opt._t;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Determine the value of the counter, C
|
|
184
|
+
// This is the number of time steps in seconds since T0
|
|
185
|
+
opt.counter = Math.floor((_t / 1000) / time);
|
|
186
|
+
|
|
187
|
+
return hotp.verify(token, key, opt);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
module.exports.hotp = hotp;
|
|
191
|
+
module.exports.totp = totp;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* convert an integer to a byte array
|
|
195
|
+
* @param {Integer} num
|
|
196
|
+
* @return {Array} bytes
|
|
197
|
+
*/
|
|
198
|
+
var intToBytes = function(num) {
|
|
199
|
+
var bytes = [];
|
|
200
|
+
|
|
201
|
+
for(var i=7 ; i>=0 ; --i) {
|
|
202
|
+
bytes[i] = num & (255);
|
|
203
|
+
num = num >> 8;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return bytes;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* convert a hex value to a byte array
|
|
212
|
+
* @param {String} hex string of hex to convert to a byte array
|
|
213
|
+
* @return {Array} bytes
|
|
214
|
+
*/
|
|
215
|
+
var hexToBytes = function(hex) {
|
|
216
|
+
var bytes = [];
|
|
217
|
+
for(var c = 0; c < hex.length; c += 2) {
|
|
218
|
+
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
219
|
+
}
|
|
220
|
+
return bytes;
|
|
221
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Guy Halford-Thompson <guy@guy.ht> (http://guy.ht)",
|
|
3
|
+
"name": "notp",
|
|
4
|
+
"description": "Node One Time Password library, supports HOTP, TOTP and works with Google Authenticator",
|
|
5
|
+
"version": "2.0.3",
|
|
6
|
+
"homepage": "https://github.com/guyht/notp",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git://github.com/guyht/notp.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "NODE_ENV=test mocha"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "> v0.6.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"mocha": "~1.18.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--ui exports
|