@erikey/react 0.4.34 → 0.4.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erikey/react",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "React SDK for Erikey - B2B authentication and user management. UI components based on better-auth-ui.",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -40,7 +40,8 @@ export interface AuthFlowProps
40
40
  initialView?: AuthFlowView
41
41
  /**
42
42
  * URL to redirect to after successful authentication.
43
- * In "internal" mode, called after AUTH_SUCCESS event.
43
+ * Used by OAuth callbacks and underlying auth forms.
44
+ * In "internal" mode, session state change triggers re-render automatically.
44
45
  */
45
46
  redirectTo?: string
46
47
  /**
@@ -246,13 +247,27 @@ export function AuthFlow({
246
247
  // In route mode, or for non-auth paths, let the link work normally
247
248
  }
248
249
 
249
- // If external Link provided (e.g., react-router), use it
250
+ // In internal mode for auth paths, ALWAYS use plain <a> that we control
251
+ // This avoids relying on external Link components forwarding onClick
252
+ if (mode === "internal" && isAuthPath(href)) {
253
+ return (
254
+ <a
255
+ href={href}
256
+ className={linkClassName}
257
+ onClick={handleClick}
258
+ {...rest}
259
+ >
260
+ {children}
261
+ </a>
262
+ )
263
+ }
264
+
265
+ // For non-auth paths or route mode, use external Link if provided
250
266
  if (ExternalLink) {
251
267
  return (
252
268
  <ExternalLink
253
269
  href={href}
254
270
  className={linkClassName}
255
- onClick={handleClick}
256
271
  {...rest}
257
272
  >
258
273
  {children}
@@ -281,16 +296,11 @@ export function AuthFlow({
281
296
  // Forward to user's handler
282
297
  onEvent?.(event)
283
298
 
284
- // In internal mode, handle AUTH_SUCCESS by redirecting
285
- if (mode === "internal" && event.type === "AUTH_SUCCESS") {
286
- if (externalNavigate) {
287
- externalNavigate(redirectTo)
288
- } else {
289
- window.location.href = redirectTo
290
- }
291
- }
299
+ // In internal mode, don't auto-redirect on AUTH_SUCCESS
300
+ // Let React re-render based on session state (useSession hook)
301
+ // User can handle AUTH_SUCCESS in onEvent if custom behavior needed
292
302
  },
293
- [onEvent, mode, redirectTo, externalNavigate]
303
+ [onEvent]
294
304
  )
295
305
 
296
306
  // Get the view key for AuthView component