@proveanything/smartlinks-auth-ui 0.6.1 → 0.6.2

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
@@ -14143,7 +14143,13 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14143
14143
  if (urlMode === 'verifyEmail') {
14144
14144
  log.log('Verifying email with token:', token);
14145
14145
  const response = await api.verifyEmailWithToken(token);
14146
- log.log('Email verification response:', { hasToken: !!response.token, hasUser: !!response.user, emailVerificationMode: response.emailVerificationMode, isNewUser: response.isNewUser });
14146
+ log.log('Email verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, emailVerificationMode: response?.emailVerificationMode, isNewUser: response?.isNewUser });
14147
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14148
+ // Common case: sign-up intent claim / verification token already consumed → route to login.
14149
+ const resolvedErrorMessage = getActionResultErrorMessage(response);
14150
+ if (resolvedErrorMessage || !response) {
14151
+ throw new Error(resolvedErrorMessage || 'This verification link has already been used or has expired.');
14152
+ }
14147
14153
  // Get email verification mode from response or config
14148
14154
  const verificationMode = response.emailVerificationMode || config?.emailVerification?.mode || 'verify-auto-login';
14149
14155
  if ((verificationMode === 'verify-auto-login' || verificationMode === 'immediate') && response.token) {
@@ -14205,7 +14211,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14205
14211
  else if (urlMode === 'magicLink') {
14206
14212
  log.log('Verifying magic link token:', token);
14207
14213
  const response = await api.verifyMagicLink(token);
14208
- log.log('Magic link verification response:', { hasToken: !!response.token, hasUser: !!response.user, isNewUser: response.isNewUser });
14214
+ log.log('Magic link verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, isNewUser: response?.isNewUser });
14215
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14216
+ const resolvedMagicError = getActionResultErrorMessage(response);
14217
+ if (resolvedMagicError || !response) {
14218
+ throw new Error(resolvedMagicError || 'This magic link has already been used or has expired.');
14219
+ }
14209
14220
  // Auto-login with magic link if token is provided
14210
14221
  if (response.token) {
14211
14222
  // Always await - auth.login now waits for parent ack automatically in iframe mode