sphere-connect 1.0.1 → 1.0.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.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +69 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1007,6 +1007,14 @@ var SphereAccountAbstraction = class extends EventEmitter {
|
|
|
1007
1007
|
const session = this.sessionManager.getCachedSession();
|
|
1008
1008
|
return session?.userInfo.email || null;
|
|
1009
1009
|
}
|
|
1010
|
+
getUserName() {
|
|
1011
|
+
const session = this.sessionManager.getCachedSession();
|
|
1012
|
+
return session?.userInfo.name || null;
|
|
1013
|
+
}
|
|
1014
|
+
getUserPicture() {
|
|
1015
|
+
const session = this.sessionManager.getCachedSession();
|
|
1016
|
+
return session?.userInfo.picture || null;
|
|
1017
|
+
}
|
|
1010
1018
|
getEphemeralPublicKey() {
|
|
1011
1019
|
return this.currentWallet?.getPublicKey() || null;
|
|
1012
1020
|
}
|
|
@@ -1053,7 +1061,9 @@ var SphereProvider = ({ children, config }) => {
|
|
|
1053
1061
|
const [wallet, setWallet] = useState(null);
|
|
1054
1062
|
const [walletInfo, setWalletInfo] = useState(null);
|
|
1055
1063
|
const [balance, setBalance] = useState(null);
|
|
1056
|
-
const [
|
|
1064
|
+
const [userEmail, setUserEmail] = useState(null);
|
|
1065
|
+
const [userName, setUserName] = useState(null);
|
|
1066
|
+
const [userPicture, setUserPicture] = useState(null);
|
|
1057
1067
|
const [isLoading, setIsLoading] = useState(true);
|
|
1058
1068
|
const [error, setError] = useState(null);
|
|
1059
1069
|
const refreshData = useCallback(async (activeWallet) => {
|
|
@@ -1071,12 +1081,17 @@ var SphereProvider = ({ children, config }) => {
|
|
|
1071
1081
|
useEffect(() => {
|
|
1072
1082
|
const onAuth = ({ wallet: wallet2 }) => {
|
|
1073
1083
|
setWallet(wallet2);
|
|
1074
|
-
|
|
1084
|
+
const email = sdk.getUserEmail();
|
|
1085
|
+
setUserEmail(email);
|
|
1086
|
+
setUserName(sdk.getUserName());
|
|
1087
|
+
setUserPicture(sdk.getUserPicture());
|
|
1075
1088
|
refreshData(wallet2);
|
|
1076
1089
|
};
|
|
1077
1090
|
const onLogout = () => {
|
|
1078
1091
|
setWallet(null);
|
|
1079
|
-
|
|
1092
|
+
setUserEmail(null);
|
|
1093
|
+
setUserName(null);
|
|
1094
|
+
setUserPicture(null);
|
|
1080
1095
|
setWalletInfo(null);
|
|
1081
1096
|
setBalance(null);
|
|
1082
1097
|
};
|
|
@@ -1088,7 +1103,9 @@ var SphereProvider = ({ children, config }) => {
|
|
|
1088
1103
|
const restored = await sdk.restoreSession();
|
|
1089
1104
|
if (restored) {
|
|
1090
1105
|
setWallet(restored);
|
|
1091
|
-
|
|
1106
|
+
setUserEmail(sdk.getUserEmail());
|
|
1107
|
+
setUserName(sdk.getUserName());
|
|
1108
|
+
setUserPicture(sdk.getUserPicture());
|
|
1092
1109
|
await refreshData(restored);
|
|
1093
1110
|
}
|
|
1094
1111
|
} catch (err) {
|
|
@@ -1141,7 +1158,11 @@ var SphereProvider = ({ children, config }) => {
|
|
|
1141
1158
|
wallet,
|
|
1142
1159
|
walletInfo,
|
|
1143
1160
|
balance,
|
|
1144
|
-
email,
|
|
1161
|
+
email: userEmail,
|
|
1162
|
+
// Restore email for backward compatibility
|
|
1163
|
+
userEmail,
|
|
1164
|
+
userName,
|
|
1165
|
+
userPicture,
|
|
1145
1166
|
indexerUrl: sdk.getIndexerUrl(),
|
|
1146
1167
|
isAuthenticated: !!wallet,
|
|
1147
1168
|
isLoading,
|
|
@@ -1358,7 +1379,49 @@ var styles = {
|
|
|
1358
1379
|
letterSpacing: "0.5px"
|
|
1359
1380
|
}
|
|
1360
1381
|
};
|
|
1382
|
+
var SphereAvatar = ({
|
|
1383
|
+
src,
|
|
1384
|
+
name,
|
|
1385
|
+
size = 40,
|
|
1386
|
+
style,
|
|
1387
|
+
className
|
|
1388
|
+
}) => {
|
|
1389
|
+
const [imageError, setImageError] = useState(false);
|
|
1390
|
+
const containerStyle = {
|
|
1391
|
+
width: `${size}px`,
|
|
1392
|
+
height: `${size}px`,
|
|
1393
|
+
borderRadius: "50%",
|
|
1394
|
+
display: "flex",
|
|
1395
|
+
alignItems: "center",
|
|
1396
|
+
justifyContent: "center",
|
|
1397
|
+
overflow: "hidden",
|
|
1398
|
+
backgroundColor: "#2d3748",
|
|
1399
|
+
color: "white",
|
|
1400
|
+
fontWeight: "600",
|
|
1401
|
+
fontSize: `${size * 0.4}px`,
|
|
1402
|
+
userSelect: "none",
|
|
1403
|
+
...style
|
|
1404
|
+
};
|
|
1405
|
+
const initials = name ? name.charAt(0).toUpperCase() : "?";
|
|
1406
|
+
if (src && !imageError) {
|
|
1407
|
+
return /* @__PURE__ */ jsx("div", { className, style: containerStyle, children: /* @__PURE__ */ jsx(
|
|
1408
|
+
"img",
|
|
1409
|
+
{
|
|
1410
|
+
src,
|
|
1411
|
+
alt: name || "Avatar",
|
|
1412
|
+
referrerPolicy: "no-referrer",
|
|
1413
|
+
onError: () => setImageError(true),
|
|
1414
|
+
style: {
|
|
1415
|
+
width: "100%",
|
|
1416
|
+
height: "100%",
|
|
1417
|
+
objectFit: "cover"
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
) });
|
|
1421
|
+
}
|
|
1422
|
+
return /* @__PURE__ */ jsx("div", { className, style: containerStyle, children: initials });
|
|
1423
|
+
};
|
|
1361
1424
|
|
|
1362
|
-
export { ErrorCode, GoogleAuthProvider, KeyDerivation, SecureStorage, SessionManager, SphereAccountAbstraction, SphereModal, SphereProvider, SphereSDKError, SphereWallet, useSphere };
|
|
1425
|
+
export { ErrorCode, GoogleAuthProvider, KeyDerivation, SecureStorage, SessionManager, SphereAccountAbstraction, SphereAvatar, SphereModal, SphereProvider, SphereSDKError, SphereWallet, useSphere };
|
|
1363
1426
|
//# sourceMappingURL=index.mjs.map
|
|
1364
1427
|
//# sourceMappingURL=index.mjs.map
|