two-factor-authentification-tools 0.0.1
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/README.md +84 -0
- package/dist/module.d.mts +8 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +21 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +4 -0
- package/dist/runtime/server/adapters/QRCodes.adapters.d.ts +2 -0
- package/dist/runtime/server/adapters/QRCodes.adapters.js +6 -0
- package/dist/runtime/server/adapters/twoFactorAuthentificator.adapters.d.ts +2 -0
- package/dist/runtime/server/adapters/twoFactorAuthentificator.adapters.js +19 -0
- package/dist/runtime/server/ports/QRCodes.ports.d.ts +3 -0
- package/dist/runtime/server/ports/QRCodes.ports.js +0 -0
- package/dist/runtime/server/ports/twoFactorAuthentificator.ports.d.ts +5 -0
- package/dist/runtime/server/ports/twoFactorAuthentificator.ports.js +0 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/src/twoAuth.service.d.ts +10 -0
- package/dist/runtime/src/twoAuth.service.js +20 -0
- package/dist/types.d.mts +3 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Get your module up and running quickly.
|
|
3
|
+
|
|
4
|
+
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
+
- Name: My Module
|
|
6
|
+
- Package name: my-module
|
|
7
|
+
- Description: My new Nuxt module
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# My Module
|
|
11
|
+
|
|
12
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
13
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
14
|
+
[![License][license-src]][license-href]
|
|
15
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
16
|
+
|
|
17
|
+
My new Nuxt module for doing amazing things.
|
|
18
|
+
|
|
19
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
20
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
|
|
21
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
<!-- Highlight some of the features your module provide here -->
|
|
26
|
+
- ⛰ Foo
|
|
27
|
+
- 🚠 Bar
|
|
28
|
+
- 🌲 Baz
|
|
29
|
+
|
|
30
|
+
## Quick Setup
|
|
31
|
+
|
|
32
|
+
Install the module to your Nuxt application with one command:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx nuxt module add my-module
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
That's it! You can now use My Module in your Nuxt app ✨
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Contribution
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary>Local development</summary>
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Install dependencies
|
|
48
|
+
npm install
|
|
49
|
+
|
|
50
|
+
# Generate type stubs
|
|
51
|
+
npm run dev:prepare
|
|
52
|
+
|
|
53
|
+
# Develop with the playground
|
|
54
|
+
npm run dev
|
|
55
|
+
|
|
56
|
+
# Build the playground
|
|
57
|
+
npm run dev:build
|
|
58
|
+
|
|
59
|
+
# Run ESLint
|
|
60
|
+
npm run lint
|
|
61
|
+
|
|
62
|
+
# Run Vitest
|
|
63
|
+
npm run test
|
|
64
|
+
npm run test:watch
|
|
65
|
+
|
|
66
|
+
# Release new version
|
|
67
|
+
npm run release
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
<!-- Badges -->
|
|
74
|
+
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
75
|
+
[npm-version-href]: https://npmjs.com/package/my-module
|
|
76
|
+
|
|
77
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=020420&colorB=00DC82
|
|
78
|
+
[npm-downloads-href]: https://npm.chart.dev/my-module
|
|
79
|
+
|
|
80
|
+
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=020420&colorB=00DC82
|
|
81
|
+
[license-href]: https://npmjs.com/package/my-module
|
|
82
|
+
|
|
83
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
|
|
84
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "two-authentification-tools-module",
|
|
6
|
+
configKey: "myModule"
|
|
7
|
+
},
|
|
8
|
+
// Default configuration options of the Nuxt module
|
|
9
|
+
defaults: {
|
|
10
|
+
enabled: true
|
|
11
|
+
},
|
|
12
|
+
setup(_options, _nuxt) {
|
|
13
|
+
if (!options.enabled) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const resolver = createResolver(import.meta.url);
|
|
17
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { generateURI, generateSecret, verify } from "otplib";
|
|
2
|
+
export const TwoFactorAuthentificatorAdapter = {
|
|
3
|
+
generateSecret() {
|
|
4
|
+
return generateSecret();
|
|
5
|
+
},
|
|
6
|
+
createKeyURI(userEmail, appName, secret) {
|
|
7
|
+
return generateURI({
|
|
8
|
+
issuer: appName,
|
|
9
|
+
label: userEmail,
|
|
10
|
+
secret
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
async verifyCode(token, secret) {
|
|
14
|
+
return verify({
|
|
15
|
+
token,
|
|
16
|
+
secret
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TwoFactorAuthentificatorAdapter } from "../server/adapters/twoFactorAuthentificator.adapters.js";
|
|
2
|
+
import { QRCodesAdapter } from "../server/adapters/QRCodes.adapters.js";
|
|
3
|
+
import { useRuntimeConfig } from "@nuxt/kit";
|
|
4
|
+
const activateTwoFactorAuth = async (user) => {
|
|
5
|
+
const secret = TwoFactorAuthentificatorAdapter.generateSecret();
|
|
6
|
+
const otpauth = TwoFactorAuthentificatorAdapter.createKeyURI(
|
|
7
|
+
user.email,
|
|
8
|
+
useRuntimeConfig().public.appName || "YourAppName",
|
|
9
|
+
secret
|
|
10
|
+
);
|
|
11
|
+
const qr = await QRCodesAdapter.generateQRCode(otpauth);
|
|
12
|
+
return { qr, secret, otpauth };
|
|
13
|
+
};
|
|
14
|
+
const verifyTwoFactorCode = async (token, secret) => {
|
|
15
|
+
return TwoFactorAuthentificatorAdapter.verifyCode(token, secret);
|
|
16
|
+
};
|
|
17
|
+
export const twoAuthService = {
|
|
18
|
+
activateTwoFactorAuth,
|
|
19
|
+
verifyTwoFactorCode
|
|
20
|
+
};
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "two-factor-authentification-tools",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "My new Nuxt module",
|
|
5
|
+
"repository": "your-org/my-module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.mts",
|
|
11
|
+
"import": "./dist/module.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/module.mjs",
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
".": [
|
|
18
|
+
"./dist/types.d.mts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"workspaces": [
|
|
26
|
+
"playground"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"prepack": "nuxt-module-build build",
|
|
30
|
+
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
31
|
+
"dev:build": "nuxt build playground",
|
|
32
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
33
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest watch",
|
|
37
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@nuxt/kit": "^4.4.5",
|
|
41
|
+
"otplib": "^13.4.0",
|
|
42
|
+
"qrcode": "^1.5.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@nuxt/devtools": "^3.2.4",
|
|
46
|
+
"@nuxt/eslint-config": "^1.15.2",
|
|
47
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
48
|
+
"@nuxt/schema": "^4.4.5",
|
|
49
|
+
"@nuxt/test-utils": "^4.0.3",
|
|
50
|
+
"@types/node": "latest",
|
|
51
|
+
"@types/qrcode": "^1.5.6",
|
|
52
|
+
"changelogen": "^0.6.2",
|
|
53
|
+
"eslint": "^10.3.0",
|
|
54
|
+
"nuxt": "^4.4.5",
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"vitest": "^4.1.5",
|
|
57
|
+
"vue-tsc": "^3.2.8"
|
|
58
|
+
}
|
|
59
|
+
}
|