@witchcraft/nuxt-auth 0.2.0 → 0.2.2
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,12 +2,6 @@ import { crop } from '@alanscodelog/utils/crop';
|
|
|
2
2
|
import { defineNuxtModule, useLogger, createResolver, addComponentsDir, addImportsDir, addServerScanDir, addServerImportsDir, addServerImports, addTemplate, addRouteMiddleware } from '@nuxt/kit';
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
|
|
5
|
-
const dependencies = {
|
|
6
|
-
"@witchcraft/ui": "^0.3.5",
|
|
7
|
-
"nuxt-security": "^2.4.0"};
|
|
8
|
-
const pkg = {
|
|
9
|
-
dependencies: dependencies};
|
|
10
|
-
|
|
11
5
|
const module = defineNuxtModule({
|
|
12
6
|
meta: {
|
|
13
7
|
name: "auth",
|
|
@@ -57,11 +51,11 @@ const module = defineNuxtModule({
|
|
|
57
51
|
},
|
|
58
52
|
moduleDependencies: {
|
|
59
53
|
"@witchcraft/ui": {
|
|
60
|
-
version:
|
|
54
|
+
version: "^0.3.5",
|
|
61
55
|
optional: true
|
|
62
56
|
},
|
|
63
57
|
"nuxt-security": {
|
|
64
|
-
version:
|
|
58
|
+
version: "^2.4.0",
|
|
65
59
|
optional: true
|
|
66
60
|
}
|
|
67
61
|
},
|
|
@@ -116,15 +116,15 @@ const props = defineProps({
|
|
|
116
116
|
body: {
|
|
117
117
|
username: username2
|
|
118
118
|
}
|
|
119
|
-
}).catch((e) => {
|
|
119
|
+
}).catch(async (e) => {
|
|
120
|
+
error2.value = `Registration Error: ${e.data.message}`;
|
|
120
121
|
if (e?.data?.code === AUTH_ERROR.USER_ALREADY_REGISTERED) {
|
|
121
122
|
useAuth().setFetchUserOnNavigation(true);
|
|
122
|
-
navigateTo(redirectUrl, { external: true });
|
|
123
|
+
await navigateTo(redirectUrl, { external: true });
|
|
123
124
|
}
|
|
124
|
-
error2.value = `Registration Error: ${e.data.message}`;
|
|
125
125
|
});
|
|
126
126
|
if (typeof res === "object" && res.redirectUrl) {
|
|
127
|
-
navigateTo(res.redirectUrl, { external: true });
|
|
127
|
+
await navigateTo(res.redirectUrl, { external: true });
|
|
128
128
|
}
|
|
129
129
|
} },
|
|
130
130
|
id: { type: String, required: false }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActionHandler } from "../types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Creates an external (e.g. desktop) auth login handler. A logout one doesn't exist as that is very platform dependant.
|
|
3
4
|
*/
|
|
@@ -21,7 +22,7 @@ isExternal: () => boolean,
|
|
|
21
22
|
*
|
|
22
23
|
* This is allowed to be undefined because it might only be available in some environments, BUT, it cannot be undefined when isExternal returns true.
|
|
23
24
|
*/
|
|
24
|
-
serverUrl: string | (() => string) |
|
|
25
|
+
serverUrl: string | (() => string) | undefined,
|
|
25
26
|
/**
|
|
26
27
|
* The function on the external **platform** to open the url on a browser.
|
|
27
28
|
*
|
|
@@ -33,4 +34,4 @@ open: ((url: string) => void | Promise<void>) | undefined,
|
|
|
33
34
|
*
|
|
34
35
|
* @default runctimeConfig().public.auth.authRoutes.deeplink
|
|
35
36
|
*/
|
|
36
|
-
deeplinkCallbackPath?: string):
|
|
37
|
+
deeplinkCallbackPath?: string): ActionHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { navigateTo, useRuntimeConfig } from "#imports";
|
|
2
2
|
export function createExternalAuthLoginHandler(name, isExternal, serverUrl, open, deeplinkCallbackPath = useRuntimeConfig().public.auth.authRoutes.deeplink) {
|
|
3
|
-
return
|
|
3
|
+
return (action, url) => {
|
|
4
4
|
if (action !== "login") return false;
|
|
5
5
|
if (!isExternal()) return false;
|
|
6
6
|
if (deeplinkCallbackPath === void 0) {
|
|
@@ -8,10 +8,7 @@ export function createExternalAuthLoginHandler(name, isExternal, serverUrl, open
|
|
|
8
8
|
}
|
|
9
9
|
if (!serverUrl) throw new Error("createExternalAuthLoginHandler: serverUrl cannot be undefined when isExternal returns true. See docs for more info.");
|
|
10
10
|
if (!open) throw new Error("createExternalAuthLoginHandler: open cannot be undefined when isExternal returns true. See docs for more info.");
|
|
11
|
-
|
|
12
|
-
if (origin instanceof Promise) {
|
|
13
|
-
origin = await origin;
|
|
14
|
-
}
|
|
11
|
+
const origin = typeof serverUrl === "function" ? serverUrl() : serverUrl;
|
|
15
12
|
const serverAuth = new URL(url, origin);
|
|
16
13
|
serverAuth.searchParams.set("deeplink", name);
|
|
17
14
|
const serverAuthUri = encodeURIComponent(serverAuth.toString());
|
package/package.json
CHANGED
|
@@ -1,106 +1,105 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
2
|
+
"name": "@witchcraft/nuxt-auth",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Nuxt module for logging.",
|
|
5
|
+
"repository": "witchcraftjs/nuxt-auth",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"//exports": {
|
|
10
|
+
"require in ./*": "Temporary for drizzle."
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types.d.mts",
|
|
15
|
+
"import": "./dist/module.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./*": {
|
|
18
|
+
"types": "./dist/runtime/*.d.ts",
|
|
19
|
+
"import": "./dist/runtime/*.js",
|
|
20
|
+
"require": "./dist/runtime/*.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"drizzle-orm": "^0.44.6"
|
|
28
|
+
},
|
|
29
|
+
"@comments": {
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@witchcraft/nuxt-logger": "This is only for some types for the logger, but is otherwise unused."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@alanscodelog/tsconfigs": "^6.2.0",
|
|
36
|
+
"@alanscodelog/utils": "^6.0.2",
|
|
37
|
+
"@iconify/json": "^2.2.393",
|
|
38
|
+
"@nuxt/kit": "^4.1.3",
|
|
39
|
+
"@oslojs/crypto": "^1.0.1",
|
|
40
|
+
"@oslojs/encoding": "^1.1.0",
|
|
41
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
42
|
+
"@vueuse/core": "^13.9.0",
|
|
43
|
+
"@witchcraft/nuxt-logger": "^0.0.9",
|
|
44
|
+
"@witchcraft/ui": "^0.3.7",
|
|
45
|
+
"arctic": "^3.7.0",
|
|
46
|
+
"cookie-es": "^2.0.0",
|
|
47
|
+
"defu": "^6.1.4",
|
|
48
|
+
"h3": "1.15.4",
|
|
49
|
+
"jsonwebtoken": "^9.0.2",
|
|
50
|
+
"ms": "^2.1.3",
|
|
51
|
+
"nuxt-security": "^2.4.0",
|
|
52
|
+
"unplugin-icons": "^22.4.2",
|
|
53
|
+
"unplugin-vue-components": "^29.1.0",
|
|
54
|
+
"zod": "^4.1.12"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@alanscodelog/eslint-config": "^6.3.1",
|
|
58
|
+
"@alanscodelog/semantic-release-config": "^6.0.0",
|
|
59
|
+
"@commitlint/cli": "^20.1.0",
|
|
60
|
+
"@nuxt/eslint-config": "^1.9.0",
|
|
61
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
62
|
+
"@nuxt/schema": "^4.1.3",
|
|
63
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
64
|
+
"@tailwindcss/cli": "^4.1.14",
|
|
65
|
+
"@types/node": "latest",
|
|
66
|
+
"changelogen": "^0.6.2",
|
|
67
|
+
"cross-env": "^10.1.0",
|
|
68
|
+
"drizzle-orm": "^0.44.6",
|
|
69
|
+
"electron": "^38.2.2",
|
|
70
|
+
"eslint": "^9.37.0",
|
|
71
|
+
"husky": "^9.1.7",
|
|
72
|
+
"nuxt": "^4.1.3",
|
|
73
|
+
"reka-ui": "^2.5.1",
|
|
74
|
+
"tailwindcss": "^4.1.14",
|
|
75
|
+
"typescript": "^5.9.3",
|
|
76
|
+
"vitest": "^3.2.4",
|
|
77
|
+
"vue-tsc": "^3.1.1"
|
|
78
|
+
},
|
|
79
|
+
"release": {
|
|
80
|
+
"extends": [
|
|
81
|
+
"@alanscodelog/semantic-release-config"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"commitlint": {
|
|
85
|
+
"extends": [
|
|
86
|
+
"@alanscodelog"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"access": "public"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "cross-env-shell DISABLE_POSTGRES_ENSURE_ENV=true 'nuxt-module-build prepare && nuxt-module-build build && pnpm nuxi build playground'",
|
|
94
|
+
"build:only": "nuxt-module-build build",
|
|
95
|
+
"//": "drizzle requires we run from playground",
|
|
96
|
+
"dev:playground": "cd playground && pnpm dev",
|
|
97
|
+
"dev:prepare": "cross-env-shell DISABLE_POSTGRES_ENSURE_ENV=true 'pnpm nuxt-module-build build --stub && pnpm nuxt-module-build prepare && pnpm nuxi prepare playground'",
|
|
98
|
+
"lint": "pnpm lint:eslint && pnpm lint:types && pnpm lint:commits",
|
|
99
|
+
"lint:eslint": "eslint \"{src,test,playground/app}/**/*.{ts,vue}\" \"*.{js,cjs,mjs,ts}\"",
|
|
100
|
+
"lint:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
101
|
+
"lint:commits": "commitlint --from-last-tag --to HEAD --verbose",
|
|
102
|
+
"test": "echo no tests and not working yet vitest run --exclude .direnv",
|
|
103
|
+
"test:watch": "vitest watch --exclude .direnv"
|
|
104
|
+
}
|
|
105
|
+
}
|