@drmhse/authos-vue 0.2.3 → 0.2.4
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 +31 -0
- package/dist/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +72 -0
- package/dist/index.mjs +72 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -250,6 +250,37 @@ Individual OAuth provider button. Requires `org` and `service` in plugin options
|
|
|
250
250
|
</OAuthButton>
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
+
### Callback
|
|
254
|
+
|
|
255
|
+
Required for OAuth flows. Handles the redirect from the identity provider by parsing tokens from the URL fragment and setting the session.
|
|
256
|
+
|
|
257
|
+
```vue
|
|
258
|
+
<script setup>
|
|
259
|
+
import { Callback } from '@drmhse/authos-vue';
|
|
260
|
+
import { useRouter } from 'vue-router';
|
|
261
|
+
|
|
262
|
+
const router = useRouter();
|
|
263
|
+
|
|
264
|
+
function handleSuccess() {
|
|
265
|
+
router.push('/');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function handleError(error) {
|
|
269
|
+
console.error('Login failed:', error);
|
|
270
|
+
}
|
|
271
|
+
</script>
|
|
272
|
+
|
|
273
|
+
<template>
|
|
274
|
+
<Callback @success="handleSuccess" @error="handleError" />
|
|
275
|
+
</template>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Events:**
|
|
279
|
+
| Event | Payload | Description |
|
|
280
|
+
|-------|---------|-------------|
|
|
281
|
+
| `@success` | - | Fired after session is successfully set |
|
|
282
|
+
| `@error` | `Error` | Fired on error |
|
|
283
|
+
|
|
253
284
|
## Composables
|
|
254
285
|
|
|
255
286
|
### useAuthOS
|
package/dist/index.d.mts
CHANGED
|
@@ -755,4 +755,37 @@ declare const PasskeySignIn: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
755
755
|
showPasswordSignIn: boolean;
|
|
756
756
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
757
757
|
|
|
758
|
-
|
|
758
|
+
interface CallbackSlotProps {
|
|
759
|
+
error: string | null;
|
|
760
|
+
}
|
|
761
|
+
declare const Callback: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
762
|
+
onSuccess: {
|
|
763
|
+
type: PropType<() => void>;
|
|
764
|
+
default: undefined;
|
|
765
|
+
};
|
|
766
|
+
onError: {
|
|
767
|
+
type: PropType<(error: Error) => void>;
|
|
768
|
+
default: undefined;
|
|
769
|
+
};
|
|
770
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
771
|
+
[key: string]: any;
|
|
772
|
+
}> | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
773
|
+
[key: string]: any;
|
|
774
|
+
}>[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("success" | "error")[], "success" | "error", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
775
|
+
onSuccess: {
|
|
776
|
+
type: PropType<() => void>;
|
|
777
|
+
default: undefined;
|
|
778
|
+
};
|
|
779
|
+
onError: {
|
|
780
|
+
type: PropType<(error: Error) => void>;
|
|
781
|
+
default: undefined;
|
|
782
|
+
};
|
|
783
|
+
}>> & Readonly<{
|
|
784
|
+
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
785
|
+
onError?: ((...args: any[]) => any) | undefined;
|
|
786
|
+
}>, {
|
|
787
|
+
onSuccess: () => void;
|
|
788
|
+
onError: (error: Error) => void;
|
|
789
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
790
|
+
|
|
791
|
+
export { AUTH_OS_INJECTION_KEY, type AppearanceOptions, type AppearanceVariables, type AuthOSContext, type AuthOSPluginOptions, AuthOSProvider, type AuthOSState, Callback, type CallbackSlotProps, MagicLinkSignIn, OAuthButton, type OAuthButtonSlotProps, OrganizationSwitcher, type OrganizationSwitcherSlotProps, PasskeySignIn, Protect, SignIn, type SignInSlotProps, SignUp, type SignUpSlotProps, SignedIn, SignedOut, type SupportedOAuthProvider$1 as SupportedOAuthProvider, UserButton, type UserButtonSlotProps, createAuthOS, useAllPermissions, useAnyPermission, useAuthOS, useOrganization, usePermission, useUser };
|
package/dist/index.d.ts
CHANGED
|
@@ -755,4 +755,37 @@ declare const PasskeySignIn: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
755
755
|
showPasswordSignIn: boolean;
|
|
756
756
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
757
757
|
|
|
758
|
-
|
|
758
|
+
interface CallbackSlotProps {
|
|
759
|
+
error: string | null;
|
|
760
|
+
}
|
|
761
|
+
declare const Callback: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
762
|
+
onSuccess: {
|
|
763
|
+
type: PropType<() => void>;
|
|
764
|
+
default: undefined;
|
|
765
|
+
};
|
|
766
|
+
onError: {
|
|
767
|
+
type: PropType<(error: Error) => void>;
|
|
768
|
+
default: undefined;
|
|
769
|
+
};
|
|
770
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
771
|
+
[key: string]: any;
|
|
772
|
+
}> | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
773
|
+
[key: string]: any;
|
|
774
|
+
}>[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("success" | "error")[], "success" | "error", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
775
|
+
onSuccess: {
|
|
776
|
+
type: PropType<() => void>;
|
|
777
|
+
default: undefined;
|
|
778
|
+
};
|
|
779
|
+
onError: {
|
|
780
|
+
type: PropType<(error: Error) => void>;
|
|
781
|
+
default: undefined;
|
|
782
|
+
};
|
|
783
|
+
}>> & Readonly<{
|
|
784
|
+
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
785
|
+
onError?: ((...args: any[]) => any) | undefined;
|
|
786
|
+
}>, {
|
|
787
|
+
onSuccess: () => void;
|
|
788
|
+
onError: (error: Error) => void;
|
|
789
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
790
|
+
|
|
791
|
+
export { AUTH_OS_INJECTION_KEY, type AppearanceOptions, type AppearanceVariables, type AuthOSContext, type AuthOSPluginOptions, AuthOSProvider, type AuthOSState, Callback, type CallbackSlotProps, MagicLinkSignIn, OAuthButton, type OAuthButtonSlotProps, OrganizationSwitcher, type OrganizationSwitcherSlotProps, PasskeySignIn, Protect, SignIn, type SignInSlotProps, SignUp, type SignUpSlotProps, SignedIn, SignedOut, type SupportedOAuthProvider$1 as SupportedOAuthProvider, UserButton, type UserButtonSlotProps, createAuthOS, useAllPermissions, useAnyPermission, useAuthOS, useOrganization, usePermission, useUser };
|
package/dist/index.js
CHANGED
|
@@ -1568,6 +1568,77 @@ var PasskeySignIn = vue.defineComponent({
|
|
|
1568
1568
|
};
|
|
1569
1569
|
}
|
|
1570
1570
|
});
|
|
1571
|
+
var Callback = vue.defineComponent({
|
|
1572
|
+
name: "Callback",
|
|
1573
|
+
props: {
|
|
1574
|
+
onSuccess: {
|
|
1575
|
+
type: Function,
|
|
1576
|
+
default: void 0
|
|
1577
|
+
},
|
|
1578
|
+
onError: {
|
|
1579
|
+
type: Function,
|
|
1580
|
+
default: void 0
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
emits: ["success", "error"],
|
|
1584
|
+
setup(props, { slots, emit }) {
|
|
1585
|
+
const { client } = useAuthOS();
|
|
1586
|
+
const error = vue.ref(null);
|
|
1587
|
+
vue.onMounted(async () => {
|
|
1588
|
+
if (!client) {
|
|
1589
|
+
error.value = "AuthOS client not initialized";
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
const hash = window.location.hash.substring(1);
|
|
1593
|
+
const params = new URLSearchParams(hash);
|
|
1594
|
+
const accessToken = params.get("access_token");
|
|
1595
|
+
const refreshToken = params.get("refresh_token");
|
|
1596
|
+
const errorParam = params.get("error");
|
|
1597
|
+
const errorDescription = params.get("error_description");
|
|
1598
|
+
if (errorParam) {
|
|
1599
|
+
const msg = errorDescription || errorParam;
|
|
1600
|
+
error.value = msg;
|
|
1601
|
+
const e = new Error(msg);
|
|
1602
|
+
emit("error", e);
|
|
1603
|
+
props.onError?.(e);
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
if (accessToken) {
|
|
1607
|
+
try {
|
|
1608
|
+
await client.setSession({
|
|
1609
|
+
access_token: accessToken,
|
|
1610
|
+
refresh_token: refreshToken || void 0
|
|
1611
|
+
});
|
|
1612
|
+
emit("success");
|
|
1613
|
+
props.onSuccess?.();
|
|
1614
|
+
} catch (err) {
|
|
1615
|
+
const message = err.message || "Failed to set session";
|
|
1616
|
+
error.value = message;
|
|
1617
|
+
const e = err instanceof Error ? err : new Error(message);
|
|
1618
|
+
emit("error", e);
|
|
1619
|
+
props.onError?.(e);
|
|
1620
|
+
}
|
|
1621
|
+
} else {
|
|
1622
|
+
const message = "No authentication tokens found in callback URL.";
|
|
1623
|
+
error.value = message;
|
|
1624
|
+
const e = new Error(message);
|
|
1625
|
+
emit("error", e);
|
|
1626
|
+
props.onError?.(e);
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
return () => {
|
|
1630
|
+
const slotProps = {
|
|
1631
|
+
error: error.value
|
|
1632
|
+
};
|
|
1633
|
+
if (slots.default) {
|
|
1634
|
+
return slots.default(slotProps);
|
|
1635
|
+
}
|
|
1636
|
+
return vue.h("div", { "data-authos-callback": "" }, [
|
|
1637
|
+
error.value ? vue.h("div", { "data-authos-error": "" }, error.value) : vue.h("div", { "data-authos-loading": "" }, "Completing sign in...")
|
|
1638
|
+
]);
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1571
1642
|
|
|
1572
1643
|
Object.defineProperty(exports, "AuthErrorCodes", {
|
|
1573
1644
|
enumerable: true,
|
|
@@ -1587,6 +1658,7 @@ Object.defineProperty(exports, "SsoApiError", {
|
|
|
1587
1658
|
});
|
|
1588
1659
|
exports.AUTH_OS_INJECTION_KEY = AUTH_OS_INJECTION_KEY;
|
|
1589
1660
|
exports.AuthOSProvider = AuthOSProvider;
|
|
1661
|
+
exports.Callback = Callback;
|
|
1590
1662
|
exports.MagicLinkSignIn = MagicLinkSignIn;
|
|
1591
1663
|
exports.OAuthButton = OAuthButton;
|
|
1592
1664
|
exports.OrganizationSwitcher = OrganizationSwitcher;
|
package/dist/index.mjs
CHANGED
|
@@ -1539,5 +1539,76 @@ var PasskeySignIn = defineComponent({
|
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
1541
|
});
|
|
1542
|
+
var Callback = defineComponent({
|
|
1543
|
+
name: "Callback",
|
|
1544
|
+
props: {
|
|
1545
|
+
onSuccess: {
|
|
1546
|
+
type: Function,
|
|
1547
|
+
default: void 0
|
|
1548
|
+
},
|
|
1549
|
+
onError: {
|
|
1550
|
+
type: Function,
|
|
1551
|
+
default: void 0
|
|
1552
|
+
}
|
|
1553
|
+
},
|
|
1554
|
+
emits: ["success", "error"],
|
|
1555
|
+
setup(props, { slots, emit }) {
|
|
1556
|
+
const { client } = useAuthOS();
|
|
1557
|
+
const error = ref(null);
|
|
1558
|
+
onMounted(async () => {
|
|
1559
|
+
if (!client) {
|
|
1560
|
+
error.value = "AuthOS client not initialized";
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
const hash = window.location.hash.substring(1);
|
|
1564
|
+
const params = new URLSearchParams(hash);
|
|
1565
|
+
const accessToken = params.get("access_token");
|
|
1566
|
+
const refreshToken = params.get("refresh_token");
|
|
1567
|
+
const errorParam = params.get("error");
|
|
1568
|
+
const errorDescription = params.get("error_description");
|
|
1569
|
+
if (errorParam) {
|
|
1570
|
+
const msg = errorDescription || errorParam;
|
|
1571
|
+
error.value = msg;
|
|
1572
|
+
const e = new Error(msg);
|
|
1573
|
+
emit("error", e);
|
|
1574
|
+
props.onError?.(e);
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
if (accessToken) {
|
|
1578
|
+
try {
|
|
1579
|
+
await client.setSession({
|
|
1580
|
+
access_token: accessToken,
|
|
1581
|
+
refresh_token: refreshToken || void 0
|
|
1582
|
+
});
|
|
1583
|
+
emit("success");
|
|
1584
|
+
props.onSuccess?.();
|
|
1585
|
+
} catch (err) {
|
|
1586
|
+
const message = err.message || "Failed to set session";
|
|
1587
|
+
error.value = message;
|
|
1588
|
+
const e = err instanceof Error ? err : new Error(message);
|
|
1589
|
+
emit("error", e);
|
|
1590
|
+
props.onError?.(e);
|
|
1591
|
+
}
|
|
1592
|
+
} else {
|
|
1593
|
+
const message = "No authentication tokens found in callback URL.";
|
|
1594
|
+
error.value = message;
|
|
1595
|
+
const e = new Error(message);
|
|
1596
|
+
emit("error", e);
|
|
1597
|
+
props.onError?.(e);
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
return () => {
|
|
1601
|
+
const slotProps = {
|
|
1602
|
+
error: error.value
|
|
1603
|
+
};
|
|
1604
|
+
if (slots.default) {
|
|
1605
|
+
return slots.default(slotProps);
|
|
1606
|
+
}
|
|
1607
|
+
return h("div", { "data-authos-callback": "" }, [
|
|
1608
|
+
error.value ? h("div", { "data-authos-error": "" }, error.value) : h("div", { "data-authos-loading": "" }, "Completing sign in...")
|
|
1609
|
+
]);
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1542
1613
|
|
|
1543
|
-
export { AuthOSProvider, MagicLinkSignIn, OAuthButton, OrganizationSwitcher, PasskeySignIn, Protect, SignIn, SignUp, SignedIn, SignedOut, UserButton, createAuthOS, useAllPermissions, useAnyPermission, useOrganization, usePermission, useUser };
|
|
1614
|
+
export { AuthOSProvider, Callback, MagicLinkSignIn, OAuthButton, OrganizationSwitcher, PasskeySignIn, Protect, SignIn, SignUp, SignedIn, SignedOut, UserButton, createAuthOS, useAllPermissions, useAnyPermission, useOrganization, usePermission, useUser };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drmhse/authos-vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Vue and Nuxt adapter for AuthOS authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "tsup",
|