@proveanything/smartlinks-auth-ui 0.1.32 → 0.1.34
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 +2 -0
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +185 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +185 -11
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SmartlinksAuthUIProps } from '../types';
|
|
3
|
+
declare const signOutGoogleNative: () => Promise<void>;
|
|
4
|
+
export { signOutGoogleNative };
|
|
3
5
|
export declare const SmartlinksAuthUI: React.FC<SmartlinksAuthUIProps>;
|
|
4
6
|
//# sourceMappingURL=SmartlinksAuthUI.d.ts.map
|
|
@@ -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,EAAuD,MAAM,UAAU,CAAC;
|
|
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,EAAuD,MAAM,UAAU,CAAC;AAgI3G,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAgDjD,CAAC;AA0FF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AA8B/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAw3C5D,C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E,GAAG,CAAC,CAAC,CAAC;IACnD,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,uBAAuB,KAAK,MAAM,IAAI,CAAC;IACrE,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3C;AAID,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA62BpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -11851,6 +11851,19 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
|
|
|
11851
11851
|
const currentUser = user;
|
|
11852
11852
|
const currentContactId = contactId;
|
|
11853
11853
|
try {
|
|
11854
|
+
// Clear Google Sign-In session on native side (fire-and-forget with timeout)
|
|
11855
|
+
// This ensures the next login shows the account picker instead of auto-signing in
|
|
11856
|
+
console.log('[AuthContext] Checking for native Google sign-out...');
|
|
11857
|
+
try {
|
|
11858
|
+
// Dynamic import to avoid circular dependency
|
|
11859
|
+
const { signOutGoogleNative } = await Promise.resolve().then(function () { return SmartlinksAuthUI$1; });
|
|
11860
|
+
await signOutGoogleNative();
|
|
11861
|
+
console.log('[AuthContext] Native Google sign-out completed');
|
|
11862
|
+
}
|
|
11863
|
+
catch (err) {
|
|
11864
|
+
// signOutGoogleNative is fire-and-forget, errors are expected if no native bridge
|
|
11865
|
+
console.log('[AuthContext] Native Google sign-out skipped or failed (non-blocking):', err);
|
|
11866
|
+
}
|
|
11854
11867
|
// Only clear persistent storage in standalone mode
|
|
11855
11868
|
if (!proxyMode) {
|
|
11856
11869
|
await tokenStorage.clearAll();
|
|
@@ -12139,7 +12152,7 @@ const useAuth = () => {
|
|
|
12139
12152
|
};
|
|
12140
12153
|
|
|
12141
12154
|
// VERSION: Update this when making changes to help identify which version is running
|
|
12142
|
-
const AUTH_UI_VERSION = '
|
|
12155
|
+
const AUTH_UI_VERSION = '34';
|
|
12143
12156
|
const LOG_PREFIX = `[SmartlinksAuthUI:v${AUTH_UI_VERSION}]`;
|
|
12144
12157
|
// Helper to calculate expiration from AuthResponse
|
|
12145
12158
|
const getExpirationFromResponse = (response) => {
|
|
@@ -12227,19 +12240,120 @@ const detectWebView = () => {
|
|
|
12227
12240
|
console.log(`${LOG_PREFIX} ❌ Not a WebView environment`);
|
|
12228
12241
|
return false;
|
|
12229
12242
|
};
|
|
12230
|
-
// Helper to detect native bridge for Google Sign-In delegation
|
|
12231
|
-
// Android apps can expose SmartlinksNative.signInWithGoogle() to handle OAuth natively
|
|
12232
12243
|
const getNativeBridge = () => {
|
|
12233
12244
|
console.log(`${LOG_PREFIX} 🔍 getNativeBridge checking for SmartlinksNative...`);
|
|
12234
12245
|
console.log(`${LOG_PREFIX} 🔍 window.SmartlinksNative:`, window.SmartlinksNative);
|
|
12235
12246
|
const native = window.SmartlinksNative;
|
|
12236
12247
|
if (native?.signInWithGoogle) {
|
|
12237
|
-
console.log(`${LOG_PREFIX} ✅ Native bridge found
|
|
12248
|
+
console.log(`${LOG_PREFIX} ✅ Native bridge found!`, {
|
|
12249
|
+
signInWithGoogle: !!native.signInWithGoogle,
|
|
12250
|
+
signOutGoogle: !!native.signOutGoogle,
|
|
12251
|
+
checkGoogleSignIn: !!native.checkGoogleSignIn,
|
|
12252
|
+
});
|
|
12238
12253
|
return native;
|
|
12239
12254
|
}
|
|
12240
12255
|
console.log(`${LOG_PREFIX} ❌ No native bridge found (SmartlinksNative.signInWithGoogle not available)`);
|
|
12241
12256
|
return null;
|
|
12242
12257
|
};
|
|
12258
|
+
// Sign out from Google on the native side (clears cached Google account)
|
|
12259
|
+
// This is fire-and-forget with a timeout - gracefully degrades if not supported
|
|
12260
|
+
const signOutGoogleNative = async () => {
|
|
12261
|
+
const nativeBridge = getNativeBridge();
|
|
12262
|
+
if (!nativeBridge?.signOutGoogle) {
|
|
12263
|
+
console.log(`${LOG_PREFIX} 🚪 signOutGoogleNative: no native bridge or signOutGoogle not available`);
|
|
12264
|
+
return;
|
|
12265
|
+
}
|
|
12266
|
+
// Store reference to the method (TypeScript now knows it's defined)
|
|
12267
|
+
const signOutMethod = nativeBridge.signOutGoogle;
|
|
12268
|
+
const callbackId = `google_signout_${Date.now()}`;
|
|
12269
|
+
console.log(`${LOG_PREFIX} 🚪 Initiating native Google sign-out, callbackId:`, callbackId);
|
|
12270
|
+
return new Promise((resolve) => {
|
|
12271
|
+
// Timeout after 3 seconds - don't block logout on native response
|
|
12272
|
+
const timeout = setTimeout(() => {
|
|
12273
|
+
console.log(`${LOG_PREFIX} 🚪 Native sign-out timed out (continuing anyway)`);
|
|
12274
|
+
resolve();
|
|
12275
|
+
}, 3000);
|
|
12276
|
+
// Store original callback to restore later
|
|
12277
|
+
const originalCallback = window.smartlinksNativeCallback;
|
|
12278
|
+
window.smartlinksNativeCallback = (result) => {
|
|
12279
|
+
if (result.callbackId === callbackId) {
|
|
12280
|
+
clearTimeout(timeout);
|
|
12281
|
+
console.log(`${LOG_PREFIX} 🚪 Native Google sign-out result:`, result);
|
|
12282
|
+
// Restore original callback
|
|
12283
|
+
window.smartlinksNativeCallback = originalCallback;
|
|
12284
|
+
resolve();
|
|
12285
|
+
}
|
|
12286
|
+
else if (originalCallback) {
|
|
12287
|
+
// Pass through to original callback for other messages
|
|
12288
|
+
originalCallback(result);
|
|
12289
|
+
}
|
|
12290
|
+
};
|
|
12291
|
+
const payload = JSON.stringify({
|
|
12292
|
+
type: 'GOOGLE_SIGN_OUT',
|
|
12293
|
+
callbackId,
|
|
12294
|
+
});
|
|
12295
|
+
console.log(`${LOG_PREFIX} 🚪 Calling nativeBridge.signOutGoogle with payload:`, payload);
|
|
12296
|
+
signOutMethod(payload);
|
|
12297
|
+
});
|
|
12298
|
+
};
|
|
12299
|
+
const checkSilentGoogleSignIn = async (clientId, googleClientId) => {
|
|
12300
|
+
const nativeBridge = getNativeBridge();
|
|
12301
|
+
if (!nativeBridge?.checkGoogleSignIn) {
|
|
12302
|
+
console.log(`${LOG_PREFIX} 🔇 checkSilentGoogleSignIn: no native bridge or checkGoogleSignIn not available`);
|
|
12303
|
+
return null;
|
|
12304
|
+
}
|
|
12305
|
+
// Store reference to the method (TypeScript now knows it's defined)
|
|
12306
|
+
const checkMethod = nativeBridge.checkGoogleSignIn;
|
|
12307
|
+
const callbackId = `google_check_${Date.now()}`;
|
|
12308
|
+
console.log(`${LOG_PREFIX} 🔇 Checking for silent Google sign-in, callbackId:`, callbackId);
|
|
12309
|
+
return new Promise((resolve) => {
|
|
12310
|
+
// Timeout after 5 seconds
|
|
12311
|
+
const timeout = setTimeout(() => {
|
|
12312
|
+
console.log(`${LOG_PREFIX} 🔇 Silent sign-in check timed out`);
|
|
12313
|
+
resolve(null);
|
|
12314
|
+
}, 5000);
|
|
12315
|
+
// Store original callback to restore later
|
|
12316
|
+
const originalCallback = window.smartlinksNativeCallback;
|
|
12317
|
+
window.smartlinksNativeCallback = (result) => {
|
|
12318
|
+
if (result.callbackId === callbackId) {
|
|
12319
|
+
clearTimeout(timeout);
|
|
12320
|
+
console.log(`${LOG_PREFIX} 🔇 Silent sign-in check result:`, {
|
|
12321
|
+
success: result.success,
|
|
12322
|
+
isSignedIn: result.isSignedIn,
|
|
12323
|
+
hasIdToken: !!result.idToken,
|
|
12324
|
+
email: result.email,
|
|
12325
|
+
});
|
|
12326
|
+
// Restore original callback
|
|
12327
|
+
window.smartlinksNativeCallback = originalCallback;
|
|
12328
|
+
if (result.success) {
|
|
12329
|
+
resolve({
|
|
12330
|
+
isSignedIn: result.isSignedIn || false,
|
|
12331
|
+
idToken: result.idToken,
|
|
12332
|
+
email: result.email,
|
|
12333
|
+
name: result.name,
|
|
12334
|
+
picture: result.picture,
|
|
12335
|
+
});
|
|
12336
|
+
}
|
|
12337
|
+
else {
|
|
12338
|
+
resolve(null);
|
|
12339
|
+
}
|
|
12340
|
+
}
|
|
12341
|
+
else if (originalCallback) {
|
|
12342
|
+
// Pass through to original callback for other messages
|
|
12343
|
+
originalCallback(result);
|
|
12344
|
+
}
|
|
12345
|
+
};
|
|
12346
|
+
const payload = JSON.stringify({
|
|
12347
|
+
type: 'GOOGLE_CHECK_SIGN_IN',
|
|
12348
|
+
clientId,
|
|
12349
|
+
googleClientId,
|
|
12350
|
+
serverClientId: googleClientId, // Alias for Android SDK
|
|
12351
|
+
callbackId,
|
|
12352
|
+
});
|
|
12353
|
+
console.log(`${LOG_PREFIX} 🔇 Calling nativeBridge.checkGoogleSignIn with payload:`, payload);
|
|
12354
|
+
checkMethod(payload);
|
|
12355
|
+
});
|
|
12356
|
+
};
|
|
12243
12357
|
// Helper to convert generic SDK errors to user-friendly messages
|
|
12244
12358
|
const getFriendlyErrorMessage = (errorMessage) => {
|
|
12245
12359
|
// Check for common HTTP status codes in the error message
|
|
@@ -12267,7 +12381,7 @@ const getFriendlyErrorMessage = (errorMessage) => {
|
|
|
12267
12381
|
// Return original message if no pattern matches
|
|
12268
12382
|
return errorMessage;
|
|
12269
12383
|
};
|
|
12270
|
-
const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, disableConfigCache = false, }) => {
|
|
12384
|
+
const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, disableConfigCache = false, enableSilentGoogleSignIn = false, }) => {
|
|
12271
12385
|
const [mode, setMode] = useState(initialMode);
|
|
12272
12386
|
const [loading, setLoading] = useState(false);
|
|
12273
12387
|
const [error, setError] = useState();
|
|
@@ -12285,6 +12399,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12285
12399
|
const [showEmailForm, setShowEmailForm] = useState(false); // Track if email form should be shown when emailDisplayMode is 'button'
|
|
12286
12400
|
const [sdkReady, setSdkReady] = useState(false); // Track SDK initialization state
|
|
12287
12401
|
const [contactSchema, setContactSchema] = useState(null); // Schema for registration fields
|
|
12402
|
+
const [silentSignInChecked, setSilentSignInChecked] = useState(false); // Track if silent sign-in has been checked
|
|
12288
12403
|
const log = useMemo(() => createLoggerWrapper(logger), [logger]);
|
|
12289
12404
|
const api = new AuthAPI(apiEndpoint, clientId, clientName, logger);
|
|
12290
12405
|
const auth = useAuth();
|
|
@@ -12486,6 +12601,50 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12486
12601
|
};
|
|
12487
12602
|
fetchSchema();
|
|
12488
12603
|
}, [collectionId, sdkReady]);
|
|
12604
|
+
// Silent Google Sign-In check on mount (for native Android apps)
|
|
12605
|
+
// When enabled, checks if user is already signed in via Google on the native side
|
|
12606
|
+
useEffect(() => {
|
|
12607
|
+
if (!enableSilentGoogleSignIn || silentSignInChecked || !sdkReady || auth.isAuthenticated) {
|
|
12608
|
+
return;
|
|
12609
|
+
}
|
|
12610
|
+
const googleClientId = config?.googleClientId || DEFAULT_GOOGLE_CLIENT_ID;
|
|
12611
|
+
const performSilentSignIn = async () => {
|
|
12612
|
+
console.log(`${LOG_PREFIX} 🔇 Silent Google Sign-In check enabled, checking native session...`);
|
|
12613
|
+
try {
|
|
12614
|
+
const result = await checkSilentGoogleSignIn(clientId, googleClientId);
|
|
12615
|
+
setSilentSignInChecked(true);
|
|
12616
|
+
if (result?.isSignedIn && result.idToken) {
|
|
12617
|
+
console.log(`${LOG_PREFIX} 🔇 Silent sign-in found existing Google session, authenticating...`);
|
|
12618
|
+
setLoading(true);
|
|
12619
|
+
try {
|
|
12620
|
+
const authResponse = await api.loginWithGoogle(result.idToken);
|
|
12621
|
+
if (authResponse.token) {
|
|
12622
|
+
console.log(`${LOG_PREFIX} 🔇 Silent sign-in successful!`);
|
|
12623
|
+
auth.login(authResponse.token, authResponse.user, authResponse.accountData, false, getExpirationFromResponse(authResponse));
|
|
12624
|
+
setAuthSuccess(true);
|
|
12625
|
+
setSuccessMessage('Signed in automatically with Google!');
|
|
12626
|
+
onAuthSuccess(authResponse.token, authResponse.user, authResponse.accountData);
|
|
12627
|
+
}
|
|
12628
|
+
}
|
|
12629
|
+
catch (err) {
|
|
12630
|
+
console.warn(`${LOG_PREFIX} 🔇 Silent sign-in backend auth failed:`, err);
|
|
12631
|
+
// Don't show error - user can still log in manually
|
|
12632
|
+
}
|
|
12633
|
+
finally {
|
|
12634
|
+
setLoading(false);
|
|
12635
|
+
}
|
|
12636
|
+
}
|
|
12637
|
+
else {
|
|
12638
|
+
console.log(`${LOG_PREFIX} 🔇 No existing Google session found`);
|
|
12639
|
+
}
|
|
12640
|
+
}
|
|
12641
|
+
catch (err) {
|
|
12642
|
+
console.warn(`${LOG_PREFIX} 🔇 Silent sign-in check failed:`, err);
|
|
12643
|
+
setSilentSignInChecked(true);
|
|
12644
|
+
}
|
|
12645
|
+
};
|
|
12646
|
+
performSilentSignIn();
|
|
12647
|
+
}, [enableSilentGoogleSignIn, silentSignInChecked, sdkReady, auth.isAuthenticated, clientId, config?.googleClientId, api, auth, onAuthSuccess]);
|
|
12489
12648
|
// Reset showEmailForm when mode changes away from login/register
|
|
12490
12649
|
useEffect(() => {
|
|
12491
12650
|
if (mode !== 'login' && mode !== 'register') {
|
|
@@ -12930,17 +13089,26 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12930
13089
|
};
|
|
12931
13090
|
console.log(`${LOG_PREFIX} ✅ window.smartlinksNativeCallback registered`);
|
|
12932
13091
|
// Invoke native sign-in
|
|
12933
|
-
|
|
13092
|
+
// Pass comprehensive payload for Android to configure Google Sign-In correctly
|
|
13093
|
+
const payloadObj = {
|
|
12934
13094
|
type: 'GOOGLE_SIGN_IN',
|
|
12935
|
-
clientId,
|
|
12936
|
-
googleClientId,
|
|
13095
|
+
clientId, // Smartlinks Auth Kit client ID
|
|
13096
|
+
googleClientId, // Web/Server Client ID - use this for requestIdToken()
|
|
13097
|
+
serverClientId: googleClientId, // Explicit alias - Android should use this for GoogleSignInOptions.requestIdToken()
|
|
12937
13098
|
callbackId,
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
13099
|
+
// Additional context that might help Android configuration
|
|
13100
|
+
scopes: ['email', 'profile'], // Requested OAuth scopes
|
|
13101
|
+
requestIdToken: true, // We need an ID token for backend verification
|
|
13102
|
+
requestServerAuthCode: false, // We don't need server auth code
|
|
13103
|
+
};
|
|
13104
|
+
const payload = JSON.stringify(payloadObj);
|
|
13105
|
+
console.log(`${LOG_PREFIX} 📤 Calling nativeBridge.signInWithGoogle with payload object:`, payloadObj);
|
|
13106
|
+
console.log(`${LOG_PREFIX} 📤 Payload JSON string:`, payload);
|
|
13107
|
+
log.log('Invoking native signInWithGoogle with payload:', payloadObj);
|
|
12941
13108
|
nativeBridge.signInWithGoogle(payload);
|
|
12942
13109
|
console.log(`${LOG_PREFIX} ✅ nativeBridge.signInWithGoogle called successfully`);
|
|
12943
13110
|
console.log(`${LOG_PREFIX} ⏳ Waiting for native callback...`);
|
|
13111
|
+
console.log(`${LOG_PREFIX} 💡 Android should use serverClientId for GoogleSignInOptions.Builder().requestIdToken(serverClientId)`);
|
|
12944
13112
|
// Don't set loading to false - waiting for native callback
|
|
12945
13113
|
return;
|
|
12946
13114
|
}
|
|
@@ -13329,6 +13497,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13329
13497
|
})() })) })) : null }));
|
|
13330
13498
|
};
|
|
13331
13499
|
|
|
13500
|
+
var SmartlinksAuthUI$1 = /*#__PURE__*/Object.freeze({
|
|
13501
|
+
__proto__: null,
|
|
13502
|
+
SmartlinksAuthUI: SmartlinksAuthUI,
|
|
13503
|
+
signOutGoogleNative: signOutGoogleNative
|
|
13504
|
+
});
|
|
13505
|
+
|
|
13332
13506
|
const AccountManagement = ({ apiEndpoint, clientId, collectionId, onError, className = '', customization = {}, }) => {
|
|
13333
13507
|
const auth = useAuth();
|
|
13334
13508
|
const [loading, setLoading] = useState(false);
|