@bagelink/auth 1.7.78 → 1.7.80

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.cjs CHANGED
@@ -1105,6 +1105,8 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
1105
1105
  var _a;
1106
1106
  const { state, redirect: redirect2 } = route.query;
1107
1107
  provider.value = sessionStorage.getItem(`oauth_provider:${state}`);
1108
+ console.log("[Callback] Query params:", { state, redirect: redirect2 });
1109
+ console.log("[Callback] Full route query:", route.query);
1108
1110
  try {
1109
1111
  const response = await sso2.handleCallback();
1110
1112
  if (response === null) {
@@ -1112,8 +1114,10 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
1112
1114
  } else {
1113
1115
  authResponse.value = response;
1114
1116
  success.value = true;
1117
+ console.log("[Callback] Login successful, redirect param:", redirect2);
1115
1118
  setTimeout(() => {
1116
1119
  const redirectPath = typeof redirect2 === "string" ? redirect2 : "/";
1120
+ console.log("[Callback] Manual fallback redirecting to:", redirectPath);
1117
1121
  router2.push(redirectPath);
1118
1122
  }, timeout);
1119
1123
  }
@@ -1425,11 +1429,15 @@ function isValidRedirect(redirectUrl, allowedPaths) {
1425
1429
  }
1426
1430
  async function performRedirect(router2, config) {
1427
1431
  const redirect2 = getRedirectUrl(router2, config);
1432
+ console.log("[PerformRedirect] Current route query:", router2.currentRoute.value.query);
1433
+ console.log("[PerformRedirect] Redirect URL:", redirect2);
1434
+ console.log("[PerformRedirect] Config fallback:", config.fallback);
1428
1435
  if (redirect2 !== config.fallback && !isValidRedirect(redirect2, config.allowedPaths)) {
1429
1436
  console.warn("[Auth] Invalid redirect URL detected, using fallback:", redirect2);
1430
1437
  await router2.push(config.fallback);
1431
1438
  return;
1432
1439
  }
1440
+ console.log("[PerformRedirect] Redirecting to:", redirect2);
1433
1441
  await router2.push(redirect2);
1434
1442
  }
1435
1443
  function buildLoginQuery(currentPath, config) {
@@ -1595,7 +1603,10 @@ function createSSOProvider(config) {
1595
1603
  const currentParams = queryParams();
1596
1604
  const redirectUrl = currentParams.redirect;
1597
1605
  if (redirectUrl) {
1606
+ console.log("[SSO] Preserving redirect URL:", redirectUrl, "with state:", state);
1598
1607
  sessionStorage.setItem(`oauth_redirect:${state}`, redirectUrl);
1608
+ } else {
1609
+ console.log("[SSO] No redirect URL found in current params:", currentParams);
1599
1610
  }
1600
1611
  }
1601
1612
  if (typeof sessionStorage !== "undefined") {
@@ -1842,10 +1853,15 @@ function handleOAuthCallback() {
1842
1853
  if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
1843
1854
  const storedRedirect = sessionStorage.getItem(`oauth_redirect:${state}`);
1844
1855
  if (storedRedirect) {
1856
+ console.log("[SSO] Restoring redirect URL:", storedRedirect);
1845
1857
  const url = new URL(window.location.href);
1846
1858
  url.searchParams.set("redirect", storedRedirect);
1847
1859
  window.history.replaceState({}, "", url.toString());
1860
+ console.log("[SSO] URL updated to:", url.toString());
1848
1861
  sessionStorage.removeItem(`oauth_redirect:${state}`);
1862
+ } else {
1863
+ console.log("[SSO] No stored redirect URL found for state:", state);
1864
+ console.log("[SSO] SessionStorage keys:", Object.keys(sessionStorage));
1849
1865
  }
1850
1866
  }
1851
1867
  return ssoProviders[provider].callback(code, state);
package/dist/index.mjs CHANGED
@@ -1103,6 +1103,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1103
1103
  var _a;
1104
1104
  const { state, redirect: redirect2 } = route.query;
1105
1105
  provider.value = sessionStorage.getItem(`oauth_provider:${state}`);
1106
+ console.log("[Callback] Query params:", { state, redirect: redirect2 });
1107
+ console.log("[Callback] Full route query:", route.query);
1106
1108
  try {
1107
1109
  const response = await sso2.handleCallback();
1108
1110
  if (response === null) {
@@ -1110,8 +1112,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1110
1112
  } else {
1111
1113
  authResponse.value = response;
1112
1114
  success.value = true;
1115
+ console.log("[Callback] Login successful, redirect param:", redirect2);
1113
1116
  setTimeout(() => {
1114
1117
  const redirectPath = typeof redirect2 === "string" ? redirect2 : "/";
1118
+ console.log("[Callback] Manual fallback redirecting to:", redirectPath);
1115
1119
  router2.push(redirectPath);
1116
1120
  }, timeout);
1117
1121
  }
@@ -1423,11 +1427,15 @@ function isValidRedirect(redirectUrl, allowedPaths) {
1423
1427
  }
1424
1428
  async function performRedirect(router2, config) {
1425
1429
  const redirect2 = getRedirectUrl(router2, config);
1430
+ console.log("[PerformRedirect] Current route query:", router2.currentRoute.value.query);
1431
+ console.log("[PerformRedirect] Redirect URL:", redirect2);
1432
+ console.log("[PerformRedirect] Config fallback:", config.fallback);
1426
1433
  if (redirect2 !== config.fallback && !isValidRedirect(redirect2, config.allowedPaths)) {
1427
1434
  console.warn("[Auth] Invalid redirect URL detected, using fallback:", redirect2);
1428
1435
  await router2.push(config.fallback);
1429
1436
  return;
1430
1437
  }
1438
+ console.log("[PerformRedirect] Redirecting to:", redirect2);
1431
1439
  await router2.push(redirect2);
1432
1440
  }
1433
1441
  function buildLoginQuery(currentPath, config) {
@@ -1593,7 +1601,10 @@ function createSSOProvider(config) {
1593
1601
  const currentParams = queryParams();
1594
1602
  const redirectUrl = currentParams.redirect;
1595
1603
  if (redirectUrl) {
1604
+ console.log("[SSO] Preserving redirect URL:", redirectUrl, "with state:", state);
1596
1605
  sessionStorage.setItem(`oauth_redirect:${state}`, redirectUrl);
1606
+ } else {
1607
+ console.log("[SSO] No redirect URL found in current params:", currentParams);
1597
1608
  }
1598
1609
  }
1599
1610
  if (typeof sessionStorage !== "undefined") {
@@ -1840,10 +1851,15 @@ function handleOAuthCallback() {
1840
1851
  if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
1841
1852
  const storedRedirect = sessionStorage.getItem(`oauth_redirect:${state}`);
1842
1853
  if (storedRedirect) {
1854
+ console.log("[SSO] Restoring redirect URL:", storedRedirect);
1843
1855
  const url = new URL(window.location.href);
1844
1856
  url.searchParams.set("redirect", storedRedirect);
1845
1857
  window.history.replaceState({}, "", url.toString());
1858
+ console.log("[SSO] URL updated to:", url.toString());
1846
1859
  sessionStorage.removeItem(`oauth_redirect:${state}`);
1860
+ } else {
1861
+ console.log("[SSO] No stored redirect URL found for state:", state);
1862
+ console.log("[SSO] SessionStorage keys:", Object.keys(sessionStorage));
1847
1863
  }
1848
1864
  }
1849
1865
  return ssoProviders[provider].callback(code, state);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/auth",
3
3
  "type": "module",
4
- "version": "1.7.78",
4
+ "version": "1.7.80",
5
5
  "description": "Bagelink auth package",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -45,6 +45,8 @@ async function linkCallback() {
45
45
  async function handleCallback() {
46
46
  const { state, redirect } = route.query
47
47
  provider.value = sessionStorage.getItem(`oauth_provider:${state}`) as SSOProvider
48
+ console.log('[Callback] Query params:', { state, redirect })
49
+ console.log('[Callback] Full route query:', route.query)
48
50
 
49
51
  try {
50
52
  const response = await sso.handleCallback()
@@ -53,10 +55,12 @@ async function handleCallback() {
53
55
  } else {
54
56
  authResponse.value = response
55
57
  success.value = true
58
+ console.log('[Callback] Login successful, redirect param:', redirect)
56
59
  // Auto-redirect will handle navigation, but fallback to manual redirect
57
60
  // if auto-redirect is disabled or router not connected
58
61
  setTimeout(() => {
59
62
  const redirectPath = typeof redirect === 'string' ? redirect : '/'
63
+ console.log('[Callback] Manual fallback redirecting to:', redirectPath)
60
64
  router.push(redirectPath)
61
65
  }, timeout)
62
66
  }
package/src/redirect.ts CHANGED
@@ -64,6 +64,9 @@ export async function performRedirect(
64
64
  config: NormalizedRedirectConfig,
65
65
  ): Promise<void> {
66
66
  const redirect = getRedirectUrl(router, config)
67
+ console.log('[PerformRedirect] Current route query:', router.currentRoute.value.query)
68
+ console.log('[PerformRedirect] Redirect URL:', redirect)
69
+ console.log('[PerformRedirect] Config fallback:', config.fallback)
67
70
 
68
71
  // Always validate redirect URL for security
69
72
  if (redirect !== config.fallback && !isValidRedirect(redirect, config.allowedPaths)) {
@@ -72,6 +75,7 @@ export async function performRedirect(
72
75
  return
73
76
  }
74
77
 
78
+ console.log('[PerformRedirect] Redirecting to:', redirect)
75
79
  await router.push(redirect)
76
80
  }
77
81
 
package/src/sso.ts CHANGED
@@ -320,7 +320,10 @@ function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
320
320
  const redirectUrl = currentParams.redirect
321
321
  if (redirectUrl) {
322
322
  // Store redirect URL to restore after OAuth callback
323
+ console.log('[SSO] Preserving redirect URL:', redirectUrl, 'with state:', state)
323
324
  sessionStorage.setItem(`oauth_redirect:${state}`, redirectUrl)
325
+ } else {
326
+ console.log('[SSO] No redirect URL found in current params:', currentParams)
324
327
  }
325
328
  }
326
329
 
@@ -640,11 +643,16 @@ function handleOAuthCallback(): Promise<AuthenticationResponse | null> {
640
643
  const storedRedirect = sessionStorage.getItem(`oauth_redirect:${state}`)
641
644
  if (storedRedirect) {
642
645
  // Add redirect param back to URL so auto-redirect can pick it up
646
+ console.log('[SSO] Restoring redirect URL:', storedRedirect)
643
647
  const url = new URL(window.location.href)
644
648
  url.searchParams.set('redirect', storedRedirect)
645
649
  window.history.replaceState({}, '', url.toString())
650
+ console.log('[SSO] URL updated to:', url.toString())
646
651
  // Clean up
647
652
  sessionStorage.removeItem(`oauth_redirect:${state}`)
653
+ } else {
654
+ console.log('[SSO] No stored redirect URL found for state:', state)
655
+ console.log('[SSO] SessionStorage keys:', Object.keys(sessionStorage))
648
656
  }
649
657
  }
650
658