@proveanything/smartlinks-auth-ui 0.1.13 → 0.1.15
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/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +18 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAKnG,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAElE,UAAU,gBAAgB;IACxB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACxC,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3F,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACrE,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACnD,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,uBAAuB,KAAK,MAAM,IAAI,CAAC;CACtE;AAID,UAAU,iBAAiB;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA2YpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useEffect, useState, useRef, useCallback, useMemo, createContext, useContext } from 'react';
|
|
3
3
|
import * as smartlinks from '@proveanything/smartlinks';
|
|
4
|
+
import { iframe } from '@proveanything/smartlinks';
|
|
4
5
|
|
|
5
6
|
const AuthContainer = ({ children, theme = 'light', className = '', config, minimal = false, }) => {
|
|
6
7
|
// Apply CSS variables for customization
|
|
@@ -11246,18 +11247,15 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
|
|
|
11246
11247
|
const initializeAuth = async () => {
|
|
11247
11248
|
try {
|
|
11248
11249
|
if (proxyMode) {
|
|
11249
|
-
// PROXY MODE:
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
try {
|
|
11255
|
-
// Fetch account details from parent via proxied API call
|
|
11256
|
-
const accountResponse = await smartlinks.auth.getAccount();
|
|
11250
|
+
// PROXY MODE: Check for existing session via parent's auth.getAccount()
|
|
11251
|
+
console.log('[AuthContext] Proxy mode: checking for existing session via auth.getAccount()');
|
|
11252
|
+
try {
|
|
11253
|
+
const accountResponse = await smartlinks.auth.getAccount();
|
|
11254
|
+
if (accountResponse) {
|
|
11257
11255
|
// Build user object from account response
|
|
11258
11256
|
const accountAny = accountResponse;
|
|
11259
11257
|
const userFromAccount = {
|
|
11260
|
-
uid: userId,
|
|
11258
|
+
uid: accountAny?.uid || accountAny?.id || accountAny?.userId,
|
|
11261
11259
|
email: accountAny?.email,
|
|
11262
11260
|
displayName: accountAny?.displayName || accountAny?.name,
|
|
11263
11261
|
phoneNumber: accountAny?.phoneNumber,
|
|
@@ -11268,13 +11266,13 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
|
|
|
11268
11266
|
console.log('[AuthContext] Proxy mode: initialized from parent account');
|
|
11269
11267
|
notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse);
|
|
11270
11268
|
}
|
|
11271
|
-
|
|
11272
|
-
console.
|
|
11273
|
-
// No session - that's ok, user may need to login
|
|
11269
|
+
else {
|
|
11270
|
+
console.log('[AuthContext] Proxy mode: no existing session, awaiting login');
|
|
11274
11271
|
}
|
|
11275
11272
|
}
|
|
11276
|
-
|
|
11277
|
-
console.log('[AuthContext] Proxy mode: no
|
|
11273
|
+
catch (error) {
|
|
11274
|
+
console.log('[AuthContext] Proxy mode: no existing session (auth.getAccount returned error), awaiting login');
|
|
11275
|
+
// No session - that's ok, user may need to login
|
|
11278
11276
|
}
|
|
11279
11277
|
setIsLoading(false);
|
|
11280
11278
|
return;
|
|
@@ -11428,9 +11426,9 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
|
|
|
11428
11426
|
setAccountData(authAccountData || null);
|
|
11429
11427
|
// Cross-iframe auth state synchronization
|
|
11430
11428
|
// Always notify parent frame of login (both modes, but especially important in proxy mode)
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11429
|
+
if (iframe.isIframe()) {
|
|
11430
|
+
console.log('[AuthContext] Notifying parent of login via postMessage');
|
|
11431
|
+
iframe.sendParentCustom('smartlinks:authkit:login', {
|
|
11434
11432
|
token: authToken,
|
|
11435
11433
|
user: authUser,
|
|
11436
11434
|
accountData: authAccountData || null
|
|
@@ -11463,9 +11461,9 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
|
|
|
11463
11461
|
setAccountInfo(null);
|
|
11464
11462
|
// Cross-iframe auth state synchronization
|
|
11465
11463
|
// Always notify parent frame of logout
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11464
|
+
if (iframe.isIframe()) {
|
|
11465
|
+
console.log('[AuthContext] Notifying parent of logout via postMessage');
|
|
11466
|
+
iframe.sendParentCustom('smartlinks:authkit:logout', {});
|
|
11469
11467
|
}
|
|
11470
11468
|
notifyAuthStateChange('LOGOUT', null, null, null);
|
|
11471
11469
|
}
|