@drmhse/authos-vue 0.2.3 → 0.2.5

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/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 hashParams = new URLSearchParams(window.location.hash.substring(1));
1593
+ const queryParams = new URLSearchParams(window.location.search);
1594
+ const accessToken = hashParams.get("access_token") || queryParams.get("access_token");
1595
+ const refreshToken = hashParams.get("refresh_token") || queryParams.get("refresh_token");
1596
+ const errorParam = hashParams.get("error") || queryParams.get("error");
1597
+ const errorDescription = hashParams.get("error_description") || queryParams.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 hashParams = new URLSearchParams(window.location.hash.substring(1));
1564
+ const queryParams = new URLSearchParams(window.location.search);
1565
+ const accessToken = hashParams.get("access_token") || queryParams.get("access_token");
1566
+ const refreshToken = hashParams.get("refresh_token") || queryParams.get("refresh_token");
1567
+ const errorParam = hashParams.get("error") || queryParams.get("error");
1568
+ const errorDescription = hashParams.get("error_description") || queryParams.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 };
@@ -0,0 +1,3 @@
1
+ export { s as parseJSON5, c as stringifyJSON5 } from './chunk-T7GBCGRZ.mjs';
2
+ import './chunk-5OCDR7QV.mjs';
3
+ import './chunk-6DZX6EAA.mjs';
@@ -0,0 +1,3 @@
1
+ export { r as parseJSONC, i as stringifyJSONC } from './chunk-I3MWU7CX.mjs';
2
+ import './chunk-5OCDR7QV.mjs';
3
+ import './chunk-6DZX6EAA.mjs';
package/dist/nuxt.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
1
  import * as nuxt_app from 'nuxt/app';
3
2
 
4
3
  interface AuthOSModuleOptions {
@@ -24,7 +23,7 @@ interface AuthOSModuleOptions {
24
23
  */
25
24
  sameSite?: 'strict' | 'lax' | 'none';
26
25
  }
27
- declare const _default: _nuxt_schema.NuxtModule<AuthOSModuleOptions, AuthOSModuleOptions, false>;
26
+ declare const _default: NuxtModule<TOptions, TOptions, false>;
28
27
 
29
28
  interface AuthMiddlewareOptions {
30
29
  redirectTo?: string;
package/dist/nuxt.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
1
  import * as nuxt_app from 'nuxt/app';
3
2
 
4
3
  interface AuthOSModuleOptions {
@@ -24,7 +23,7 @@ interface AuthOSModuleOptions {
24
23
  */
25
24
  sameSite?: 'strict' | 'lax' | 'none';
26
25
  }
27
- declare const _default: _nuxt_schema.NuxtModule<AuthOSModuleOptions, AuthOSModuleOptions, false>;
26
+ declare const _default: NuxtModule<TOptions, TOptions, false>;
28
27
 
29
28
  interface AuthMiddlewareOptions {
30
29
  redirectTo?: string;