@proveanything/smartlinks-auth-ui 0.1.8 → 0.1.10
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/api.d.ts +3 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +75 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +75 -25
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthResponse, AuthFormData, AuthUIConfig } from './types';
|
|
1
|
+
import type { AuthResponse, AuthFormData, AuthUIConfig, AuthLogger } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* AuthAPI - Thin wrapper around Smartlinks SDK authKit namespace
|
|
4
4
|
* All authentication operations now use the global Smartlinks SDK
|
|
@@ -6,7 +6,8 @@ import type { AuthResponse, AuthFormData, AuthUIConfig } from './types';
|
|
|
6
6
|
export declare class AuthAPI {
|
|
7
7
|
private clientId;
|
|
8
8
|
private clientName?;
|
|
9
|
-
|
|
9
|
+
private log;
|
|
10
|
+
constructor(_apiEndpoint: string, clientId: string, clientName?: string, logger?: AuthLogger);
|
|
10
11
|
login(email: string, password: string): Promise<AuthResponse>;
|
|
11
12
|
register(data: AuthFormData): Promise<AuthResponse>;
|
|
12
13
|
loginWithGoogle(idToken: string): Promise<AuthResponse>;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGpF;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAyC;gBAExC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU;IAQtF,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7D,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IASnD,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIvD,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IAIvE,eAAe,CACnB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAIlB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAQxG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAIlH,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAIzG,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IASzH,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAIhF,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAStH,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAuBpC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAOjG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,EAAyC,MAAM,UAAU,CAAC;AAkD7F,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA27B5D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export { ProtectedRoute } from './components/ProtectedRoute';
|
|
|
6
6
|
export { tokenStorage } from './utils/tokenStorage';
|
|
7
7
|
export { AuthUIPreview } from './components/AuthUIPreview';
|
|
8
8
|
export type * from './types';
|
|
9
|
+
export type { AuthLogger } from './types';
|
|
9
10
|
export { SmartlinksAuthUI as FirebaseAuthUI } from './components/SmartlinksAuthUI';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,mBAAmB,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,mBAAmB,SAAS,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -10589,16 +10589,51 @@ const MagicLinkForm = ({ onSubmit, onCancel, loading = false, error, }) => {
|
|
|
10589
10589
|
return (jsxs("form", { onSubmit: handleSubmit, className: "auth-form", children: [jsxs("div", { className: "auth-form-group", children: [jsx("label", { htmlFor: "magic-link-email", className: "auth-label", children: "Email Address" }), jsx("input", { id: "magic-link-email", type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "auth-input", placeholder: "you@example.com", required: true, disabled: loading })] }), error && (jsx("div", { className: "auth-error-message", children: error })), jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading || !email, children: loading ? (jsxs(Fragment, { children: [jsx("span", { className: "auth-spinner" }), "Sending..."] })) : ('Send Magic Link') }), jsx("button", { type: "button", onClick: onCancel, className: "auth-button auth-button-secondary", disabled: loading, children: "Cancel" })] }));
|
|
10590
10590
|
};
|
|
10591
10591
|
|
|
10592
|
+
/**
|
|
10593
|
+
* Creates a normalized logger wrapper that works with different logger types
|
|
10594
|
+
* - If no logger provided, returns no-op logger (silent)
|
|
10595
|
+
* - If function logger, wraps it with level prefixes
|
|
10596
|
+
* - If console-like object, wraps methods with prefixes
|
|
10597
|
+
*/
|
|
10598
|
+
function createLoggerWrapper(logger) {
|
|
10599
|
+
if (!logger) {
|
|
10600
|
+
// No-op logger when not provided
|
|
10601
|
+
return {
|
|
10602
|
+
log: () => { },
|
|
10603
|
+
warn: () => { },
|
|
10604
|
+
error: () => { },
|
|
10605
|
+
debug: () => { },
|
|
10606
|
+
};
|
|
10607
|
+
}
|
|
10608
|
+
if (typeof logger === 'function') {
|
|
10609
|
+
// Function logger - call it for all levels
|
|
10610
|
+
return {
|
|
10611
|
+
log: (...args) => logger('[Auth]', ...args),
|
|
10612
|
+
warn: (...args) => logger('[Auth WARN]', ...args),
|
|
10613
|
+
error: (...args) => logger('[Auth ERROR]', ...args),
|
|
10614
|
+
debug: (...args) => logger('[Auth DEBUG]', ...args),
|
|
10615
|
+
};
|
|
10616
|
+
}
|
|
10617
|
+
// Console-like object logger
|
|
10618
|
+
return {
|
|
10619
|
+
log: logger.log ? (...args) => logger.log('[Auth]', ...args) : () => { },
|
|
10620
|
+
warn: logger.warn ? (...args) => logger.warn('[Auth WARN]', ...args) : () => { },
|
|
10621
|
+
error: logger.error ? (...args) => logger.error('[Auth ERROR]', ...args) : () => { },
|
|
10622
|
+
debug: logger.debug ? (...args) => logger.debug('[Auth DEBUG]', ...args) : () => { },
|
|
10623
|
+
};
|
|
10624
|
+
}
|
|
10625
|
+
|
|
10592
10626
|
/**
|
|
10593
10627
|
* AuthAPI - Thin wrapper around Smartlinks SDK authKit namespace
|
|
10594
10628
|
* All authentication operations now use the global Smartlinks SDK
|
|
10595
10629
|
*/
|
|
10596
10630
|
class AuthAPI {
|
|
10597
|
-
constructor(_apiEndpoint, clientId, clientName) {
|
|
10631
|
+
constructor(_apiEndpoint, clientId, clientName, logger) {
|
|
10598
10632
|
// apiEndpoint is kept for backward compatibility but not used
|
|
10599
10633
|
// Smartlinks SDK is pre-configured globally
|
|
10600
10634
|
this.clientId = clientId;
|
|
10601
10635
|
this.clientName = clientName;
|
|
10636
|
+
this.log = createLoggerWrapper(logger);
|
|
10602
10637
|
}
|
|
10603
10638
|
async login(email, password) {
|
|
10604
10639
|
return smartlinks.authKit.login(this.clientId, email, password);
|
|
@@ -10653,15 +10688,15 @@ class AuthAPI {
|
|
|
10653
10688
|
});
|
|
10654
10689
|
}
|
|
10655
10690
|
async fetchConfig() {
|
|
10656
|
-
|
|
10691
|
+
this.log.log('fetchConfig called with clientId:', this.clientId);
|
|
10657
10692
|
try {
|
|
10658
|
-
|
|
10693
|
+
this.log.log('Calling smartlinks.authKit.load...');
|
|
10659
10694
|
const result = await smartlinks.authKit.load(this.clientId);
|
|
10660
|
-
|
|
10695
|
+
this.log.log('smartlinks.authKit.load returned:', result);
|
|
10661
10696
|
return result;
|
|
10662
10697
|
}
|
|
10663
10698
|
catch (error) {
|
|
10664
|
-
|
|
10699
|
+
this.log.warn('Failed to fetch UI config, using defaults:', error);
|
|
10665
10700
|
return {
|
|
10666
10701
|
branding: {
|
|
10667
10702
|
title: 'Smartlinks Auth',
|
|
@@ -11458,7 +11493,7 @@ const loadGoogleIdentityServices = () => {
|
|
|
11458
11493
|
document.head.appendChild(script);
|
|
11459
11494
|
});
|
|
11460
11495
|
};
|
|
11461
|
-
const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, }) => {
|
|
11496
|
+
const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, logger, }) => {
|
|
11462
11497
|
const [mode, setMode] = useState(initialMode);
|
|
11463
11498
|
const [loading, setLoading] = useState(false);
|
|
11464
11499
|
const [error, setError] = useState();
|
|
@@ -11474,7 +11509,9 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11474
11509
|
const [config, setConfig] = useState(null);
|
|
11475
11510
|
const [configLoading, setConfigLoading] = useState(!skipConfigFetch);
|
|
11476
11511
|
const [showEmailForm, setShowEmailForm] = useState(false); // Track if email form should be shown when emailDisplayMode is 'button'
|
|
11477
|
-
const
|
|
11512
|
+
const [sdkReady, setSdkReady] = useState(false); // Track SDK initialization state
|
|
11513
|
+
const log = useMemo(() => createLoggerWrapper(logger), [logger]);
|
|
11514
|
+
const api = new AuthAPI(apiEndpoint, clientId, clientName, logger);
|
|
11478
11515
|
const auth = useAuth();
|
|
11479
11516
|
// Dark mode detection and theme management
|
|
11480
11517
|
useEffect(() => {
|
|
@@ -11492,30 +11529,37 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11492
11529
|
// Reinitialize Smartlinks SDK when apiEndpoint changes (for test/dev scenarios)
|
|
11493
11530
|
// IMPORTANT: Preserve bearer token during reinitialization
|
|
11494
11531
|
useEffect(() => {
|
|
11495
|
-
|
|
11532
|
+
log.log('SDK reinitialize useEffect triggered', { apiEndpoint });
|
|
11533
|
+
setSdkReady(false); // Mark SDK as not ready during reinitialization
|
|
11496
11534
|
const reinitializeWithToken = async () => {
|
|
11497
11535
|
if (apiEndpoint) {
|
|
11498
|
-
|
|
11536
|
+
log.log('Reinitializing SDK with baseURL:', apiEndpoint);
|
|
11499
11537
|
// Get current token before reinitializing
|
|
11500
11538
|
const currentToken = await auth.getToken();
|
|
11501
11539
|
smartlinks.initializeApi({
|
|
11502
11540
|
baseURL: apiEndpoint,
|
|
11503
11541
|
proxyMode: false, // Direct API calls when custom endpoint is provided
|
|
11504
11542
|
ngrokSkipBrowserWarning: true,
|
|
11543
|
+
logger: logger, // Pass logger to SDK for verbose SDK logging
|
|
11505
11544
|
});
|
|
11545
|
+
log.log('SDK reinitialized successfully');
|
|
11506
11546
|
// Restore bearer token after reinitialization using auth.verifyToken
|
|
11507
11547
|
if (currentToken) {
|
|
11508
11548
|
smartlinks.auth.verifyToken(currentToken).catch(err => {
|
|
11509
|
-
|
|
11549
|
+
log.warn('Failed to restore bearer token after reinit:', err);
|
|
11510
11550
|
});
|
|
11511
11551
|
}
|
|
11552
|
+
// Mark SDK as ready
|
|
11553
|
+
setSdkReady(true);
|
|
11512
11554
|
}
|
|
11513
11555
|
else {
|
|
11514
|
-
|
|
11556
|
+
log.log('No apiEndpoint, SDK already initialized by App');
|
|
11557
|
+
// SDK was initialized by App component, mark as ready
|
|
11558
|
+
setSdkReady(true);
|
|
11515
11559
|
}
|
|
11516
11560
|
};
|
|
11517
11561
|
reinitializeWithToken();
|
|
11518
|
-
}, [apiEndpoint, auth]);
|
|
11562
|
+
}, [apiEndpoint, auth, logger, log]);
|
|
11519
11563
|
// Get the effective redirect URL (use prop or default to current page)
|
|
11520
11564
|
const getRedirectUrl = () => {
|
|
11521
11565
|
if (redirectUrl)
|
|
@@ -11527,22 +11571,28 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11527
11571
|
};
|
|
11528
11572
|
// Fetch UI configuration
|
|
11529
11573
|
useEffect(() => {
|
|
11530
|
-
|
|
11574
|
+
log.log('Config fetch useEffect triggered', {
|
|
11531
11575
|
skipConfigFetch,
|
|
11532
11576
|
clientId,
|
|
11533
11577
|
clientIdType: typeof clientId,
|
|
11534
11578
|
clientIdTruthy: !!clientId,
|
|
11535
|
-
apiEndpoint
|
|
11579
|
+
apiEndpoint,
|
|
11580
|
+
sdkReady
|
|
11536
11581
|
});
|
|
11582
|
+
// Wait for SDK to be ready before fetching config
|
|
11583
|
+
if (!sdkReady) {
|
|
11584
|
+
log.log('SDK not ready yet, waiting...');
|
|
11585
|
+
return;
|
|
11586
|
+
}
|
|
11537
11587
|
if (skipConfigFetch) {
|
|
11538
|
-
|
|
11588
|
+
log.log('Skipping config fetch - skipConfigFetch is true');
|
|
11539
11589
|
setConfig(customization || {});
|
|
11540
11590
|
return;
|
|
11541
11591
|
}
|
|
11542
11592
|
const fetchConfig = async () => {
|
|
11543
11593
|
// If no clientId provided, use default config immediately without API call
|
|
11544
11594
|
if (!clientId) {
|
|
11545
|
-
|
|
11595
|
+
log.log('No clientId provided, using default config');
|
|
11546
11596
|
const defaultConfig = {
|
|
11547
11597
|
...DEFAULT_AUTH_CONFIG,
|
|
11548
11598
|
enabledProviders: enabledProviders || ['email', 'google', 'phone']
|
|
@@ -11573,9 +11623,9 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11573
11623
|
}
|
|
11574
11624
|
}
|
|
11575
11625
|
// Fetch from API
|
|
11576
|
-
|
|
11626
|
+
log.log('Fetching config from API for clientId:', clientId);
|
|
11577
11627
|
const fetchedConfig = await api.fetchConfig();
|
|
11578
|
-
|
|
11628
|
+
log.log('Received config:', fetchedConfig);
|
|
11579
11629
|
// Merge with customization props (props take precedence)
|
|
11580
11630
|
const mergedConfig = { ...fetchedConfig, ...customization };
|
|
11581
11631
|
setConfig(mergedConfig);
|
|
@@ -11586,7 +11636,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11586
11636
|
}));
|
|
11587
11637
|
}
|
|
11588
11638
|
catch (err) {
|
|
11589
|
-
|
|
11639
|
+
log.error('Failed to fetch config:', err);
|
|
11590
11640
|
setConfig(customization || {});
|
|
11591
11641
|
}
|
|
11592
11642
|
finally {
|
|
@@ -11594,7 +11644,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11594
11644
|
}
|
|
11595
11645
|
};
|
|
11596
11646
|
fetchConfig();
|
|
11597
|
-
}, [apiEndpoint, clientId, customization, skipConfigFetch]);
|
|
11647
|
+
}, [apiEndpoint, clientId, customization, skipConfigFetch, sdkReady, log]);
|
|
11598
11648
|
// Reset showEmailForm when mode changes away from login/register
|
|
11599
11649
|
useEffect(() => {
|
|
11600
11650
|
if (mode !== 'login' && mode !== 'register') {
|
|
@@ -11619,7 +11669,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11619
11669
|
const params = getUrlParams();
|
|
11620
11670
|
const urlMode = params.get('mode');
|
|
11621
11671
|
const token = params.get('token');
|
|
11622
|
-
|
|
11672
|
+
log.log('URL params detected:', { urlMode, token, hash: window.location.hash, search: window.location.search });
|
|
11623
11673
|
if (urlMode && token) {
|
|
11624
11674
|
handleURLBasedAuth(urlMode, token);
|
|
11625
11675
|
}
|
|
@@ -11629,7 +11679,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11629
11679
|
setError(undefined);
|
|
11630
11680
|
try {
|
|
11631
11681
|
if (urlMode === 'verifyEmail') {
|
|
11632
|
-
|
|
11682
|
+
log.log('Verifying email with token:', token);
|
|
11633
11683
|
const response = await api.verifyEmailWithToken(token);
|
|
11634
11684
|
// Get email verification mode from response or config
|
|
11635
11685
|
const verificationMode = response.emailVerificationMode || config?.emailVerification?.mode || 'verify-then-auto-login';
|
|
@@ -11664,7 +11714,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11664
11714
|
}
|
|
11665
11715
|
}
|
|
11666
11716
|
else if (urlMode === 'resetPassword') {
|
|
11667
|
-
|
|
11717
|
+
log.log('Verifying reset token:', token);
|
|
11668
11718
|
// Verify token is valid, then show password reset form
|
|
11669
11719
|
await api.verifyResetToken(token);
|
|
11670
11720
|
setResetToken(token); // Store token for use in password reset
|
|
@@ -11674,7 +11724,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11674
11724
|
window.history.replaceState({}, document.title, cleanUrl);
|
|
11675
11725
|
}
|
|
11676
11726
|
else if (urlMode === 'magicLink') {
|
|
11677
|
-
|
|
11727
|
+
log.log('Verifying magic link token:', token);
|
|
11678
11728
|
const response = await api.verifyMagicLink(token);
|
|
11679
11729
|
// Auto-login with magic link if token is provided
|
|
11680
11730
|
if (response.token) {
|
|
@@ -11698,7 +11748,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11698
11748
|
}
|
|
11699
11749
|
}
|
|
11700
11750
|
catch (err) {
|
|
11701
|
-
|
|
11751
|
+
log.error('URL-based auth error:', err);
|
|
11702
11752
|
const errorMessage = err instanceof Error ? err.message : 'An error occurred';
|
|
11703
11753
|
// If it's an email verification error (expired/invalid token), show resend option
|
|
11704
11754
|
if (urlMode === 'verifyEmail') {
|