@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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auth",
3
3
  "configKey": "auth",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
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: pkg.dependencies["@witchcraft/ui"],
54
+ version: "^0.3.5",
61
55
  optional: true
62
56
  },
63
57
  "nuxt-security": {
64
- version: pkg.dependencies["nuxt-security"],
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) | (() => Promise<string>) | undefined,
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): (action: "login" | "logout", url: string) => Promise<boolean>;
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 async (action, url) => {
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
- let origin = typeof serverUrl === "function" ? serverUrl() : serverUrl;
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
- "name": "@witchcraft/nuxt-auth",
3
- "version": "0.2.0",
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
- "scripts": {
27
- "prepare": "husky && pnpm nuxt-module-build prepare && pnpm build:only && cd playground && pnpm i --ignore-scripts --ignore-workspace",
28
- "build": "cross-env-shell DISABLE_POSTGRES_ENSURE_ENV=true 'nuxt-module-build prepare && nuxt-module-build build && pnpm nuxi build playground'",
29
- "build:only": "nuxt-module-build build",
30
- "//": "drizzle requires we run from playground",
31
- "dev:playground": "cd playground && pnpm dev",
32
- "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'",
33
- "lint": "pnpm lint:eslint && pnpm lint:types && pnpm lint:commits",
34
- "lint:eslint": "eslint \"{src,test,playground/app}/**/*.{ts,vue}\" \"*.{js,cjs,mjs,ts}\"",
35
- "lint:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
36
- "lint:commits": "commitlint --from-last-tag --to HEAD --verbose",
37
- "test": "echo no tests and not working yet vitest run --exclude .direnv",
38
- "test:watch": "vitest watch --exclude .direnv"
39
- },
40
- "peerDependencies": {
41
- "drizzle-orm": "^0.44.3"
42
- },
43
- "@comments": {
44
- "dependencies": {
45
- "@witchcraft/nuxt-logger": "This is only for some types for the logger, but is otherwise unused."
46
- }
47
- },
48
- "dependencies": {
49
- "@alanscodelog/tsconfigs": "^6.2.0",
50
- "@alanscodelog/utils": "^6.0.2",
51
- "@iconify/json": "^2.2.393",
52
- "@nuxt/kit": "^4.1.3",
53
- "@oslojs/crypto": "^1.0.1",
54
- "@oslojs/encoding": "^1.1.0",
55
- "@types/jsonwebtoken": "^9.0.10",
56
- "@vueuse/core": "^13.9.0",
57
- "@witchcraft/nuxt-logger": "^0.0.6",
58
- "@witchcraft/ui": "^0.3.5",
59
- "arctic": "~3.7.0",
60
- "cookie-es": "^2.0.0",
61
- "defu": "latest",
62
- "h3": "1.15.4",
63
- "jsonwebtoken": "^9.0.2",
64
- "ms": "^2.1.3",
65
- "nuxt-security": "^2.4.0",
66
- "unplugin-icons": "^22.4.2",
67
- "unplugin-vue-components": "^29.1.0",
68
- "zod": "^4.1.12"
69
- },
70
- "devDependencies": {
71
- "@alanscodelog/eslint-config": "^6.3.1",
72
- "@alanscodelog/semantic-release-config": "^5.0.4",
73
- "@commitlint/cli": "^20.1.0",
74
- "@nuxt/eslint-config": "^1.9.0",
75
- "@nuxt/module-builder": "^1.0.2",
76
- "@nuxt/schema": "^4.1.3",
77
- "@nuxt/test-utils": "^3.19.2",
78
- "@tailwindcss/cli": "^4.1.14",
79
- "@types/node": "latest",
80
- "changelogen": "^0.6.2",
81
- "cross-env": "^10.1.0",
82
- "drizzle-orm": "^0.44.6",
83
- "electron": "^38.2.2",
84
- "eslint": "^9.37.0",
85
- "husky": "^9.1.7",
86
- "nuxt": "^4.1.3",
87
- "reka-ui": "^2.5.1",
88
- "tailwindcss": "^4.1.14",
89
- "typescript": "^5.9.3",
90
- "vitest": "^3.2.4",
91
- "vue-tsc": "^3.1.1"
92
- },
93
- "release": {
94
- "extends": [
95
- "@alanscodelog/semantic-release-config"
96
- ]
97
- },
98
- "commitlint": {
99
- "extends": [
100
- "@alanscodelog"
101
- ]
102
- },
103
- "publishConfig": {
104
- "access": "public"
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
+ }