@proveanything/smartlinks-auth-ui 0.1.43 → 0.1.44
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/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.esm.js +29 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;AAgI7I,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CA+CjD,CAAC;AAyFF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AA8B/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;AAgI7I,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CA+CjD,CAAC;AAyFF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AA8B/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmmD5D,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -12192,7 +12192,7 @@ const useAuth = () => {
|
|
|
12192
12192
|
};
|
|
12193
12193
|
|
|
12194
12194
|
// VERSION: Update this when making changes to help identify which version is running
|
|
12195
|
-
const AUTH_UI_VERSION = '
|
|
12195
|
+
const AUTH_UI_VERSION = '38';
|
|
12196
12196
|
const LOG_PREFIX = `[SmartlinksAuthUI:v${AUTH_UI_VERSION}]`;
|
|
12197
12197
|
// Helper to calculate expiration from AuthResponse
|
|
12198
12198
|
const getExpirationFromResponse = (response) => {
|
|
@@ -12707,7 +12707,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12707
12707
|
const authResponse = await api.loginWithGoogle(result.idToken);
|
|
12708
12708
|
if (authResponse.token) {
|
|
12709
12709
|
console.log(`${LOG_PREFIX} 🔇 Silent sign-in successful!`);
|
|
12710
|
-
auth.login(authResponse.token, authResponse.user, authResponse.accountData, false, getExpirationFromResponse(authResponse));
|
|
12710
|
+
await auth.login(authResponse.token, authResponse.user, authResponse.accountData, false, getExpirationFromResponse(authResponse));
|
|
12711
12711
|
setAuthSuccess(true);
|
|
12712
12712
|
setSuccessMessage('Signed in automatically with Google!');
|
|
12713
12713
|
onAuthSuccess(authResponse.token, authResponse.user, authResponse.accountData);
|
|
@@ -12779,7 +12779,8 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12779
12779
|
const verificationMode = response.emailVerificationMode || config?.emailVerification?.mode || 'verify-auto-login';
|
|
12780
12780
|
if ((verificationMode === 'verify-auto-login' || verificationMode === 'immediate') && response.token) {
|
|
12781
12781
|
// Auto-login modes: Log the user in immediately if token is provided
|
|
12782
|
-
|
|
12782
|
+
// MUST await to ensure token is persisted to storage before any redirect
|
|
12783
|
+
await auth.login(response.token, response.user, response.accountData, true, getExpirationFromResponse(response));
|
|
12783
12784
|
setAuthSuccess(true);
|
|
12784
12785
|
setSuccessMessage('Email verified successfully! You are now logged in.');
|
|
12785
12786
|
onAuthSuccess(response.token, response.user, response.accountData);
|
|
@@ -12828,7 +12829,8 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12828
12829
|
const response = await api.verifyMagicLink(token);
|
|
12829
12830
|
// Auto-login with magic link if token is provided
|
|
12830
12831
|
if (response.token) {
|
|
12831
|
-
|
|
12832
|
+
// MUST await to ensure token is persisted to storage before any redirect
|
|
12833
|
+
await auth.login(response.token, response.user, response.accountData, true, getExpirationFromResponse(response));
|
|
12832
12834
|
setAuthSuccess(true);
|
|
12833
12835
|
setSuccessMessage('Magic link verified! You are now logged in.');
|
|
12834
12836
|
onAuthSuccess(response.token, response.user, response.accountData);
|
|
@@ -12897,7 +12899,8 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12897
12899
|
// Exchange authorization code for tokens
|
|
12898
12900
|
const response = await api.loginWithGoogleCode(code, redirectUri);
|
|
12899
12901
|
if (response.token) {
|
|
12900
|
-
|
|
12902
|
+
// Await login to ensure token is persisted before any navigation
|
|
12903
|
+
await auth.login(response.token, response.user, response.accountData, response.isNewUser, getExpirationFromResponse(response));
|
|
12901
12904
|
setAuthSuccess(true);
|
|
12902
12905
|
setSuccessMessage('Google login successful!');
|
|
12903
12906
|
onAuthSuccess(response.token, response.user, response.accountData);
|
|
@@ -12945,7 +12948,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12945
12948
|
// Handle different verification modes
|
|
12946
12949
|
if (verificationMode === 'immediate' && response.token) {
|
|
12947
12950
|
// Immediate mode: Log in right away if token is provided (isNewUser=true for registration)
|
|
12948
|
-
auth.login(response.token, response.user, response.accountData, true, getExpirationFromResponse(response));
|
|
12951
|
+
await auth.login(response.token, response.user, response.accountData, true, getExpirationFromResponse(response));
|
|
12949
12952
|
setAuthSuccess(true);
|
|
12950
12953
|
const deadline = response.emailVerificationDeadline
|
|
12951
12954
|
? new Date(response.emailVerificationDeadline).toLocaleString()
|
|
@@ -12999,7 +13002,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12999
13002
|
if (response.requiresEmailVerification) {
|
|
13000
13003
|
throw new Error('Please verify your email before logging in. Check your inbox for the verification link.');
|
|
13001
13004
|
}
|
|
13002
|
-
auth.login(response.token, response.user, response.accountData, false, getExpirationFromResponse(response));
|
|
13005
|
+
await auth.login(response.token, response.user, response.accountData, false, getExpirationFromResponse(response));
|
|
13003
13006
|
setAuthSuccess(true);
|
|
13004
13007
|
setSuccessMessage('Login successful!');
|
|
13005
13008
|
onAuthSuccess(response.token, response.user, response.accountData);
|
|
@@ -13059,14 +13062,23 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13059
13062
|
setLoading(true);
|
|
13060
13063
|
setError(undefined);
|
|
13061
13064
|
try {
|
|
13062
|
-
await api.requestPasswordReset(resetRequestEmail, getRedirectUrl());
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
+
const result = await api.requestPasswordReset(resetRequestEmail, getRedirectUrl());
|
|
13066
|
+
// Use resetSuccess (not authSuccess) to show password reset confirmation, not "Login successful"
|
|
13067
|
+
setResetSuccess(true);
|
|
13068
|
+
// Use backend message if available, otherwise default
|
|
13069
|
+
setSuccessMessage(result?.message || 'Password reset email sent! Please check your inbox.');
|
|
13065
13070
|
setShowRequestNewReset(false);
|
|
13066
13071
|
setResetRequestEmail('');
|
|
13067
13072
|
}
|
|
13068
13073
|
catch (err) {
|
|
13069
|
-
|
|
13074
|
+
// Extract error message - handle both Error objects and API error responses
|
|
13075
|
+
let errorMessage = 'Failed to send password reset email';
|
|
13076
|
+
if (err instanceof Error) {
|
|
13077
|
+
errorMessage = err.message;
|
|
13078
|
+
}
|
|
13079
|
+
else if (err && typeof err === 'object' && 'message' in err) {
|
|
13080
|
+
errorMessage = err.message;
|
|
13081
|
+
}
|
|
13070
13082
|
setError(errorMessage);
|
|
13071
13083
|
onAuthError?.(err instanceof Error ? err : new Error(errorMessage));
|
|
13072
13084
|
}
|
|
@@ -13157,7 +13169,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13157
13169
|
});
|
|
13158
13170
|
if (authResponse.token) {
|
|
13159
13171
|
console.log(`${LOG_PREFIX} 🎉 Login successful! Calling auth.login and onAuthSuccess...`);
|
|
13160
|
-
auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13172
|
+
await auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13161
13173
|
setAuthSuccess(true);
|
|
13162
13174
|
setSuccessMessage('Google login successful!');
|
|
13163
13175
|
onAuthSuccess(authResponse.token, authResponse.user, authResponse.accountData);
|
|
@@ -13316,7 +13328,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13316
13328
|
});
|
|
13317
13329
|
if (authResponse.token) {
|
|
13318
13330
|
// Google OAuth can be login or signup - use isNewUser flag from backend if available
|
|
13319
|
-
auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13331
|
+
await auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13320
13332
|
setAuthSuccess(true);
|
|
13321
13333
|
setSuccessMessage('Google login successful!');
|
|
13322
13334
|
onAuthSuccess(authResponse.token, authResponse.user, authResponse.accountData);
|
|
@@ -13362,7 +13374,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13362
13374
|
const authResponse = await api.loginWithGoogle(idToken);
|
|
13363
13375
|
if (authResponse.token) {
|
|
13364
13376
|
// Google OAuth can be login or signup - use isNewUser flag from backend if available
|
|
13365
|
-
auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13377
|
+
await auth.login(authResponse.token, authResponse.user, authResponse.accountData, authResponse.isNewUser, getExpirationFromResponse(authResponse));
|
|
13366
13378
|
setAuthSuccess(true);
|
|
13367
13379
|
setSuccessMessage('Google login successful!');
|
|
13368
13380
|
onAuthSuccess(authResponse.token, authResponse.user, authResponse.accountData);
|
|
@@ -13419,7 +13431,8 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13419
13431
|
// Update auth context with account data if token is provided
|
|
13420
13432
|
if (response.token) {
|
|
13421
13433
|
// Phone auth can be login or signup - use isNewUser flag from backend if available
|
|
13422
|
-
|
|
13434
|
+
// MUST await to ensure token is persisted to storage before any redirect
|
|
13435
|
+
await auth.login(response.token, response.user, response.accountData, response.isNewUser, getExpirationFromResponse(response));
|
|
13423
13436
|
onAuthSuccess(response.token, response.user, response.accountData);
|
|
13424
13437
|
if (redirectUrl) {
|
|
13425
13438
|
performRedirect(redirectUrl, 'phone-verified');
|
|
@@ -13461,7 +13474,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13461
13474
|
try {
|
|
13462
13475
|
const loginResponse = await api.login(resetEmail, emailOrPassword);
|
|
13463
13476
|
if (loginResponse.token) {
|
|
13464
|
-
auth.login(loginResponse.token, loginResponse.user, loginResponse.accountData, false);
|
|
13477
|
+
await auth.login(loginResponse.token, loginResponse.user, loginResponse.accountData, false);
|
|
13465
13478
|
setAuthSuccess(true);
|
|
13466
13479
|
setSuccessMessage('Password reset successful! You are now signed in.');
|
|
13467
13480
|
onAuthSuccess(loginResponse.token, loginResponse.user, loginResponse.accountData);
|