sphere-connect 1.0.1 → 1.0.3

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.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 [email, setEmail] = useState(null);
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
- setEmail(sdk.getUserEmail());
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
- setEmail(null);
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
- setEmail(sdk.getUserEmail());
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,
@@ -1188,19 +1209,18 @@ var SphereModal = ({ isOpen, onClose }) => {
1188
1209
  /* @__PURE__ */ jsxs("div", { style: styles.header, children: [
1189
1210
  /* @__PURE__ */ jsx("div", { style: { width: 32 } }),
1190
1211
  " ",
1212
+ /* @__PURE__ */ jsx("h2", { style: styles.title, children: "Login or sign up" }),
1191
1213
  /* @__PURE__ */ jsx("button", { style: styles.closeBtn, onClick: onClose, "aria-label": "Close", children: "\xD7" })
1192
1214
  ] }),
1193
1215
  /* @__PURE__ */ jsxs("div", { style: styles.content, children: [
1194
- /* @__PURE__ */ jsx("h2", { style: styles.title, children: "Connect to Sphere" }),
1195
- /* @__PURE__ */ jsx("p", { style: styles.description, children: "Experience the next generation of account abstraction. Secure, fast, and effortless." }),
1196
- error && /* @__PURE__ */ jsx("div", { style: styles.errorBanner, children: error }),
1197
- /* @__PURE__ */ jsx("div", { style: styles.actionContainer, children: /* @__PURE__ */ jsxs(
1216
+ /* @__PURE__ */ jsxs(
1198
1217
  "button",
1199
1218
  {
1200
1219
  style: {
1201
- ...styles.customButton,
1220
+ ...styles.socialButton,
1202
1221
  opacity: isLoading || localLoading ? 0.7 : 1,
1203
- cursor: isLoading || localLoading ? "not-allowed" : "pointer"
1222
+ cursor: isLoading || localLoading ? "not-allowed" : "pointer",
1223
+ marginBottom: 0
1204
1224
  },
1205
1225
  onClick: handleLogin,
1206
1226
  disabled: isLoading || localLoading,
@@ -1208,15 +1228,16 @@ var SphereModal = ({ isOpen, onClose }) => {
1208
1228
  isLoading || localLoading ? /* @__PURE__ */ jsx("div", { style: styles.spinner }) : /* @__PURE__ */ jsx(
1209
1229
  "img",
1210
1230
  {
1211
- src: "https://www.gstatic.com/images/branding/product/1x/gsa_512dp.png",
1231
+ src: "https://www.gstatic.com/marketing-cms/assets/images/d5/dc/cfe9ce8b4425b410b49b7f2dd3f3/g.webp=s48-fcrop64=1,00000000ffffffff-rw",
1212
1232
  alt: "Google",
1213
- style: styles.googleIcon
1233
+ style: styles.socialIcon
1214
1234
  }
1215
1235
  ),
1216
- isLoading || localLoading ? "Connecting..." : "Continue with Google"
1236
+ /* @__PURE__ */ jsx("span", { style: styles.socialText, children: "Google" })
1217
1237
  ]
1218
1238
  }
1219
- ) }),
1239
+ ),
1240
+ error && /* @__PURE__ */ jsx("div", { style: styles.errorBanner, children: error }),
1220
1241
  /* @__PURE__ */ jsx("style", { children: `
1221
1242
  @keyframes sphere-spin {
1222
1243
  0% { transform: rotate(0deg); }
@@ -1224,8 +1245,8 @@ var SphereModal = ({ isOpen, onClose }) => {
1224
1245
  }
1225
1246
  ` }),
1226
1247
  /* @__PURE__ */ jsxs("div", { style: styles.footer, children: [
1227
- "Securely powered by ",
1228
- /* @__PURE__ */ jsx("strong", { children: "Sphere SDK" })
1248
+ "Protected by ",
1249
+ /* @__PURE__ */ jsx("strong", { children: "Sphere" })
1229
1250
  ] })
1230
1251
  ] })
1231
1252
  ] }) });
@@ -1248,62 +1269,73 @@ var styles = {
1248
1269
  backgroundColor: "#0c0c0c",
1249
1270
  color: "#ffffff",
1250
1271
  width: "90%",
1251
- maxWidth: "400px",
1252
- aspectRatio: "1/1",
1272
+ maxWidth: "360px",
1253
1273
  borderRadius: "0",
1254
1274
  position: "relative",
1255
1275
  boxShadow: "0 0 0 1px #222, 0 25px 60px rgba(0, 0, 0, 0.7)",
1256
1276
  overflow: "hidden",
1257
1277
  fontFamily: "Inter, -apple-system, system-ui, sans-serif",
1258
1278
  display: "flex",
1259
- flexDirection: "column"
1279
+ flexDirection: "column",
1280
+ padding: "24px",
1281
+ boxSizing: "border-box"
1260
1282
  },
1261
1283
  header: {
1262
1284
  display: "flex",
1263
1285
  justifyContent: "space-between",
1264
1286
  alignItems: "center",
1265
- padding: "24px 24px 0 24px"
1287
+ marginBottom: "24px"
1288
+ },
1289
+ title: {
1290
+ fontSize: "14px",
1291
+ fontWeight: "500",
1292
+ color: "#94a3b8",
1293
+ textAlign: "center",
1294
+ margin: 0,
1295
+ flex: 1
1266
1296
  },
1267
1297
  closeBtn: {
1268
1298
  background: "rgba(255, 255, 255, 0.05)",
1269
1299
  border: "none",
1270
1300
  color: "#888",
1271
- fontSize: "24px",
1301
+ fontSize: "20px",
1272
1302
  cursor: "pointer",
1273
- lineHeight: 1,
1274
- width: "32px",
1275
- height: "32px",
1303
+ width: "28px",
1304
+ height: "28px",
1276
1305
  borderRadius: "50%",
1277
1306
  display: "flex",
1278
1307
  alignItems: "center",
1279
- justifyContent: "center",
1280
- transition: "all 0.2s"
1308
+ justifyContent: "center"
1281
1309
  },
1282
1310
  content: {
1283
1311
  display: "flex",
1284
1312
  flexDirection: "column",
1285
- padding: "20px",
1286
1313
  alignItems: "center",
1287
- flex: 1,
1288
- justifyContent: "center",
1289
- width: "100%",
1290
- boxSizing: "border-box"
1314
+ width: "100%"
1291
1315
  },
1292
- title: {
1293
- fontSize: "1.5rem",
1294
- fontWeight: "700",
1295
- color: "#ffffff",
1296
- textAlign: "center",
1316
+ socialButton: {
1317
+ display: "flex",
1318
+ alignItems: "center",
1319
+ width: "100%",
1320
+ height: "48px",
1321
+ backgroundColor: "transparent",
1322
+ border: "1px solid #333",
1323
+ borderRadius: "0",
1324
+ padding: "0 16px",
1297
1325
  marginBottom: "10px",
1298
- margin: 0
1326
+ cursor: "pointer",
1327
+ fontSize: "14px",
1328
+ color: "#fff",
1329
+ boxSizing: "border-box",
1330
+ transition: "background 0.2s"
1299
1331
  },
1300
- description: {
1301
- fontSize: "0.7rem",
1302
- color: "#94a3b8",
1303
- textAlign: "center",
1304
- lineHeight: "1.5",
1305
- marginBottom: "32px",
1306
- margin: 0
1332
+ socialIcon: {
1333
+ width: "18px",
1334
+ height: "18px"
1335
+ },
1336
+ socialText: {
1337
+ marginLeft: "12px",
1338
+ fontWeight: "500"
1307
1339
  },
1308
1340
  errorBanner: {
1309
1341
  backgroundColor: "rgba(239, 68, 68, 0.1)",
@@ -1316,49 +1348,64 @@ var styles = {
1316
1348
  textAlign: "center",
1317
1349
  width: "100%"
1318
1350
  },
1319
- actionContainer: {
1320
- display: "flex",
1321
- flexDirection: "column",
1322
- width: "100%"
1323
- },
1324
- customButton: {
1325
- display: "flex",
1326
- alignItems: "center",
1327
- justifyContent: "center",
1328
- gap: "12px",
1329
- width: "100%",
1330
- height: "52px",
1331
- backgroundColor: "#0c0c0c",
1332
- border: "1px solid #333",
1333
- borderRadius: "0",
1334
- cursor: "pointer",
1335
- fontSize: "15px",
1336
- fontWeight: "600",
1337
- color: "#ffffff",
1338
- transition: "transform 0.1s, opacity 0.2s",
1339
- boxSizing: "border-box"
1340
- },
1341
- googleIcon: {
1342
- width: "20px",
1343
- height: "20px"
1344
- },
1345
1351
  spinner: {
1346
- width: "20px",
1347
- height: "20px",
1352
+ width: "18px",
1353
+ height: "18px",
1348
1354
  border: "2px solid rgba(255, 255, 255, 0.1)",
1349
1355
  borderTop: "2px solid #ffffff",
1350
1356
  borderRadius: "50%",
1351
1357
  animation: "sphere-spin 0.8s linear infinite"
1352
1358
  },
1353
1359
  footer: {
1354
- marginTop: "32px",
1360
+ marginTop: "20px",
1355
1361
  textAlign: "center",
1356
1362
  fontSize: "11px",
1357
- color: "#475569",
1358
- letterSpacing: "0.5px"
1363
+ color: "#475569"
1364
+ }
1365
+ };
1366
+ var SphereAvatar = ({
1367
+ src,
1368
+ name,
1369
+ size = 40,
1370
+ style,
1371
+ className
1372
+ }) => {
1373
+ const [imageError, setImageError] = useState(false);
1374
+ const containerStyle = {
1375
+ width: `${size}px`,
1376
+ height: `${size}px`,
1377
+ borderRadius: "50%",
1378
+ display: "flex",
1379
+ alignItems: "center",
1380
+ justifyContent: "center",
1381
+ overflow: "hidden",
1382
+ backgroundColor: "#2d3748",
1383
+ color: "white",
1384
+ fontWeight: "600",
1385
+ fontSize: `${size * 0.4}px`,
1386
+ userSelect: "none",
1387
+ ...style
1388
+ };
1389
+ const initials = name ? name.charAt(0).toUpperCase() : "?";
1390
+ if (src && !imageError) {
1391
+ return /* @__PURE__ */ jsx("div", { className, style: containerStyle, children: /* @__PURE__ */ jsx(
1392
+ "img",
1393
+ {
1394
+ src,
1395
+ alt: name || "Avatar",
1396
+ referrerPolicy: "no-referrer",
1397
+ onError: () => setImageError(true),
1398
+ style: {
1399
+ width: "100%",
1400
+ height: "100%",
1401
+ objectFit: "cover"
1402
+ }
1403
+ }
1404
+ ) });
1359
1405
  }
1406
+ return /* @__PURE__ */ jsx("div", { className, style: containerStyle, children: initials });
1360
1407
  };
1361
1408
 
1362
- export { ErrorCode, GoogleAuthProvider, KeyDerivation, SecureStorage, SessionManager, SphereAccountAbstraction, SphereModal, SphereProvider, SphereSDKError, SphereWallet, useSphere };
1409
+ export { ErrorCode, GoogleAuthProvider, KeyDerivation, SecureStorage, SessionManager, SphereAccountAbstraction, SphereAvatar, SphereModal, SphereProvider, SphereSDKError, SphereWallet, useSphere };
1363
1410
  //# sourceMappingURL=index.mjs.map
1364
1411
  //# sourceMappingURL=index.mjs.map