@erikey/react 0.4.29 → 0.4.31

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.29",
3
+ "version": "0.4.31",
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",
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  import { createAuthClient as createBetterAuthClient } from 'better-auth/react';
16
- import { siweClient } from 'better-auth/client/plugins';
16
+ import { siweClient, emailOTPClient } from 'better-auth/client/plugins';
17
17
  import {
18
18
  shouldUseBearerAuth,
19
19
  storeToken,
@@ -145,8 +145,8 @@ export function createAuthClient(config: AuthClientConfig) {
145
145
  fetchOptions,
146
146
  // For same-origin, include cookies (cross-origin uses Bearer from fetchOptions.auth)
147
147
  ...(!useBearerAuth && { credentials: 'include' as const }),
148
- // Enable SIWE (Sign-In with Ethereum) support
149
- plugins: [siweClient()],
148
+ // Enable SIWE (Sign-In with Ethereum) and email OTP support
149
+ plugins: [siweClient(), emailOTPClient()],
150
150
  });
151
151
 
152
152
  return client;
@@ -384,13 +384,25 @@ export function SignUpForm({
384
384
  fetchOptions
385
385
  })
386
386
 
387
- if ("token" in data && data.token) {
387
+ // Check for 2FA redirect first (same pattern as sign-in form)
388
+ if ((data as { twoFactorRedirect?: boolean }).twoFactorRedirect) {
389
+ navigate(
390
+ `${basePath}/${viewPaths.TWO_FACTOR}${window.location.search}`
391
+ )
392
+ } else if ("token" in data && data.token) {
393
+ // Token present = verified or no verification required
388
394
  await onSuccess()
389
- } else if (emailVerification?.otp) {
395
+ } else if (
396
+ data.user &&
397
+ (data.user as { emailVerified?: boolean }).emailVerified === false
398
+ ) {
399
+ // No token + emailVerified: false = needs verification
400
+ // This is response-based (Better Auth pattern), not config-based
390
401
  navigate(
391
402
  `${basePath}/${viewPaths.EMAIL_VERIFICATION}?email=${encodeURIComponent(email as string)}`
392
403
  )
393
404
  } else {
405
+ // Fallback: redirect to sign-in (e.g., link-based verification sent)
394
406
  navigate(
395
407
  `${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
396
408
  )