@witchcraft/nuxt-auth 0.2.0 → 0.2.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/dist/module.json
CHANGED
|
@@ -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());
|