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.d.mts CHANGED
@@ -209,6 +209,10 @@ interface AccountAbstractionSDK {
209
209
  getCurrentWallet(): SphereWalletMethods | null;
210
210
  /** Get current user email (if authenticated) */
211
211
  getUserEmail(): string | null;
212
+ /** Get current user name (if authenticated) */
213
+ getUserName(): string | null;
214
+ /** Get current user picture URL (if authenticated) */
215
+ getUserPicture(): string | null;
212
216
  /** Get the ephemeral public key for the current session */
213
217
  getEphemeralPublicKey(): string | null;
214
218
  /** Update network and RPC endpoint */
@@ -269,6 +273,8 @@ declare class SphereAccountAbstraction extends EventEmitter implements AccountAb
269
273
  isAuthenticated(): boolean;
270
274
  getCurrentWallet(): SphereWalletMethods | null;
271
275
  getUserEmail(): string | null;
276
+ getUserName(): string | null;
277
+ getUserPicture(): string | null;
272
278
  getEphemeralPublicKey(): string | null;
273
279
  updateNetwork(network: Network, rpcEndpoint: string): Promise<void>;
274
280
  getIndexerUrl(): string | undefined;
@@ -526,7 +532,11 @@ interface SphereContextType {
526
532
  wallet: SphereWalletMethods | null;
527
533
  walletInfo: WalletInfo | null;
528
534
  balance: BalanceInfo | null;
535
+ /** @deprecated Use userEmail instead */
529
536
  email: string | null;
537
+ userEmail: string | null;
538
+ userName: string | null;
539
+ userPicture: string | null;
530
540
  indexerUrl: string | undefined;
531
541
  isAuthenticated: boolean;
532
542
  isLoading: boolean;
@@ -550,4 +560,13 @@ interface SphereModalProps {
550
560
  }
551
561
  declare const SphereModal: React.FC<SphereModalProps>;
552
562
 
553
- export { type AccountAbstractionSDK, type BalanceInfo, ErrorCode, type ErrorResponse, type FungibleAssetMetadata, GoogleAuthProvider, type GoogleAuthResponse, KeyDerivation, type KeyDerivationOptions, type KeylessConfig, type Network, type SDKConfig, SecureStorage, type SessionData, SessionManager, SphereAccountAbstraction, SphereModal, SphereProvider, SphereSDKError, SphereWallet, type SphereWalletMethods, type StorageProvider, type TransactionHistoryItem, type TransactionOptions, type TransactionResult, type WalletInfo, useSphere };
563
+ interface SphereAvatarProps {
564
+ src?: string | null;
565
+ name?: string | null;
566
+ size?: number;
567
+ style?: React.CSSProperties;
568
+ className?: string;
569
+ }
570
+ declare const SphereAvatar: React.FC<SphereAvatarProps>;
571
+
572
+ export { type AccountAbstractionSDK, type BalanceInfo, ErrorCode, type ErrorResponse, type FungibleAssetMetadata, GoogleAuthProvider, type GoogleAuthResponse, KeyDerivation, type KeyDerivationOptions, type KeylessConfig, type Network, type SDKConfig, SecureStorage, type SessionData, SessionManager, SphereAccountAbstraction, SphereAvatar, SphereModal, SphereProvider, SphereSDKError, SphereWallet, type SphereWalletMethods, type StorageProvider, type TransactionHistoryItem, type TransactionOptions, type TransactionResult, type WalletInfo, useSphere };
package/dist/index.d.ts CHANGED
@@ -209,6 +209,10 @@ interface AccountAbstractionSDK {
209
209
  getCurrentWallet(): SphereWalletMethods | null;
210
210
  /** Get current user email (if authenticated) */
211
211
  getUserEmail(): string | null;
212
+ /** Get current user name (if authenticated) */
213
+ getUserName(): string | null;
214
+ /** Get current user picture URL (if authenticated) */
215
+ getUserPicture(): string | null;
212
216
  /** Get the ephemeral public key for the current session */
213
217
  getEphemeralPublicKey(): string | null;
214
218
  /** Update network and RPC endpoint */
@@ -269,6 +273,8 @@ declare class SphereAccountAbstraction extends EventEmitter implements AccountAb
269
273
  isAuthenticated(): boolean;
270
274
  getCurrentWallet(): SphereWalletMethods | null;
271
275
  getUserEmail(): string | null;
276
+ getUserName(): string | null;
277
+ getUserPicture(): string | null;
272
278
  getEphemeralPublicKey(): string | null;
273
279
  updateNetwork(network: Network, rpcEndpoint: string): Promise<void>;
274
280
  getIndexerUrl(): string | undefined;
@@ -526,7 +532,11 @@ interface SphereContextType {
526
532
  wallet: SphereWalletMethods | null;
527
533
  walletInfo: WalletInfo | null;
528
534
  balance: BalanceInfo | null;
535
+ /** @deprecated Use userEmail instead */
529
536
  email: string | null;
537
+ userEmail: string | null;
538
+ userName: string | null;
539
+ userPicture: string | null;
530
540
  indexerUrl: string | undefined;
531
541
  isAuthenticated: boolean;
532
542
  isLoading: boolean;
@@ -550,4 +560,13 @@ interface SphereModalProps {
550
560
  }
551
561
  declare const SphereModal: React.FC<SphereModalProps>;
552
562
 
553
- export { type AccountAbstractionSDK, type BalanceInfo, ErrorCode, type ErrorResponse, type FungibleAssetMetadata, GoogleAuthProvider, type GoogleAuthResponse, KeyDerivation, type KeyDerivationOptions, type KeylessConfig, type Network, type SDKConfig, SecureStorage, type SessionData, SessionManager, SphereAccountAbstraction, SphereModal, SphereProvider, SphereSDKError, SphereWallet, type SphereWalletMethods, type StorageProvider, type TransactionHistoryItem, type TransactionOptions, type TransactionResult, type WalletInfo, useSphere };
563
+ interface SphereAvatarProps {
564
+ src?: string | null;
565
+ name?: string | null;
566
+ size?: number;
567
+ style?: React.CSSProperties;
568
+ className?: string;
569
+ }
570
+ declare const SphereAvatar: React.FC<SphereAvatarProps>;
571
+
572
+ export { type AccountAbstractionSDK, type BalanceInfo, ErrorCode, type ErrorResponse, type FungibleAssetMetadata, GoogleAuthProvider, type GoogleAuthResponse, KeyDerivation, type KeyDerivationOptions, type KeylessConfig, type Network, type SDKConfig, SecureStorage, type SessionData, SessionManager, SphereAccountAbstraction, SphereAvatar, SphereModal, SphereProvider, SphereSDKError, SphereWallet, type SphereWalletMethods, type StorageProvider, type TransactionHistoryItem, type TransactionOptions, type TransactionResult, type WalletInfo, useSphere };
package/dist/index.js CHANGED
@@ -1012,6 +1012,14 @@ var SphereAccountAbstraction = class extends EventEmitter {
1012
1012
  const session = this.sessionManager.getCachedSession();
1013
1013
  return session?.userInfo.email || null;
1014
1014
  }
1015
+ getUserName() {
1016
+ const session = this.sessionManager.getCachedSession();
1017
+ return session?.userInfo.name || null;
1018
+ }
1019
+ getUserPicture() {
1020
+ const session = this.sessionManager.getCachedSession();
1021
+ return session?.userInfo.picture || null;
1022
+ }
1015
1023
  getEphemeralPublicKey() {
1016
1024
  return this.currentWallet?.getPublicKey() || null;
1017
1025
  }
@@ -1058,7 +1066,9 @@ var SphereProvider = ({ children, config }) => {
1058
1066
  const [wallet, setWallet] = react.useState(null);
1059
1067
  const [walletInfo, setWalletInfo] = react.useState(null);
1060
1068
  const [balance, setBalance] = react.useState(null);
1061
- const [email, setEmail] = react.useState(null);
1069
+ const [userEmail, setUserEmail] = react.useState(null);
1070
+ const [userName, setUserName] = react.useState(null);
1071
+ const [userPicture, setUserPicture] = react.useState(null);
1062
1072
  const [isLoading, setIsLoading] = react.useState(true);
1063
1073
  const [error, setError] = react.useState(null);
1064
1074
  const refreshData = react.useCallback(async (activeWallet) => {
@@ -1076,12 +1086,17 @@ var SphereProvider = ({ children, config }) => {
1076
1086
  react.useEffect(() => {
1077
1087
  const onAuth = ({ wallet: wallet2 }) => {
1078
1088
  setWallet(wallet2);
1079
- setEmail(sdk.getUserEmail());
1089
+ const email = sdk.getUserEmail();
1090
+ setUserEmail(email);
1091
+ setUserName(sdk.getUserName());
1092
+ setUserPicture(sdk.getUserPicture());
1080
1093
  refreshData(wallet2);
1081
1094
  };
1082
1095
  const onLogout = () => {
1083
1096
  setWallet(null);
1084
- setEmail(null);
1097
+ setUserEmail(null);
1098
+ setUserName(null);
1099
+ setUserPicture(null);
1085
1100
  setWalletInfo(null);
1086
1101
  setBalance(null);
1087
1102
  };
@@ -1093,7 +1108,9 @@ var SphereProvider = ({ children, config }) => {
1093
1108
  const restored = await sdk.restoreSession();
1094
1109
  if (restored) {
1095
1110
  setWallet(restored);
1096
- setEmail(sdk.getUserEmail());
1111
+ setUserEmail(sdk.getUserEmail());
1112
+ setUserName(sdk.getUserName());
1113
+ setUserPicture(sdk.getUserPicture());
1097
1114
  await refreshData(restored);
1098
1115
  }
1099
1116
  } catch (err) {
@@ -1146,7 +1163,11 @@ var SphereProvider = ({ children, config }) => {
1146
1163
  wallet,
1147
1164
  walletInfo,
1148
1165
  balance,
1149
- email,
1166
+ email: userEmail,
1167
+ // Restore email for backward compatibility
1168
+ userEmail,
1169
+ userName,
1170
+ userPicture,
1150
1171
  indexerUrl: sdk.getIndexerUrl(),
1151
1172
  isAuthenticated: !!wallet,
1152
1173
  isLoading,
@@ -1193,19 +1214,18 @@ var SphereModal = ({ isOpen, onClose }) => {
1193
1214
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.header, children: [
1194
1215
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: 32 } }),
1195
1216
  " ",
1217
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles.title, children: "Login or sign up" }),
1196
1218
  /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles.closeBtn, onClick: onClose, "aria-label": "Close", children: "\xD7" })
1197
1219
  ] }),
1198
1220
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.content, children: [
1199
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles.title, children: "Connect to Sphere" }),
1200
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.description, children: "Experience the next generation of account abstraction. Secure, fast, and effortless." }),
1201
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.errorBanner, children: error }),
1202
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.actionContainer, children: /* @__PURE__ */ jsxRuntime.jsxs(
1221
+ /* @__PURE__ */ jsxRuntime.jsxs(
1203
1222
  "button",
1204
1223
  {
1205
1224
  style: {
1206
- ...styles.customButton,
1225
+ ...styles.socialButton,
1207
1226
  opacity: isLoading || localLoading ? 0.7 : 1,
1208
- cursor: isLoading || localLoading ? "not-allowed" : "pointer"
1227
+ cursor: isLoading || localLoading ? "not-allowed" : "pointer",
1228
+ marginBottom: 0
1209
1229
  },
1210
1230
  onClick: handleLogin,
1211
1231
  disabled: isLoading || localLoading,
@@ -1213,15 +1233,16 @@ var SphereModal = ({ isOpen, onClose }) => {
1213
1233
  isLoading || localLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.spinner }) : /* @__PURE__ */ jsxRuntime.jsx(
1214
1234
  "img",
1215
1235
  {
1216
- src: "https://www.gstatic.com/images/branding/product/1x/gsa_512dp.png",
1236
+ src: "https://www.gstatic.com/marketing-cms/assets/images/d5/dc/cfe9ce8b4425b410b49b7f2dd3f3/g.webp=s48-fcrop64=1,00000000ffffffff-rw",
1217
1237
  alt: "Google",
1218
- style: styles.googleIcon
1238
+ style: styles.socialIcon
1219
1239
  }
1220
1240
  ),
1221
- isLoading || localLoading ? "Connecting..." : "Continue with Google"
1241
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.socialText, children: "Google" })
1222
1242
  ]
1223
1243
  }
1224
- ) }),
1244
+ ),
1245
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.errorBanner, children: error }),
1225
1246
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
1226
1247
  @keyframes sphere-spin {
1227
1248
  0% { transform: rotate(0deg); }
@@ -1229,8 +1250,8 @@ var SphereModal = ({ isOpen, onClose }) => {
1229
1250
  }
1230
1251
  ` }),
1231
1252
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.footer, children: [
1232
- "Securely powered by ",
1233
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Sphere SDK" })
1253
+ "Protected by ",
1254
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Sphere" })
1234
1255
  ] })
1235
1256
  ] })
1236
1257
  ] }) });
@@ -1253,62 +1274,73 @@ var styles = {
1253
1274
  backgroundColor: "#0c0c0c",
1254
1275
  color: "#ffffff",
1255
1276
  width: "90%",
1256
- maxWidth: "400px",
1257
- aspectRatio: "1/1",
1277
+ maxWidth: "360px",
1258
1278
  borderRadius: "0",
1259
1279
  position: "relative",
1260
1280
  boxShadow: "0 0 0 1px #222, 0 25px 60px rgba(0, 0, 0, 0.7)",
1261
1281
  overflow: "hidden",
1262
1282
  fontFamily: "Inter, -apple-system, system-ui, sans-serif",
1263
1283
  display: "flex",
1264
- flexDirection: "column"
1284
+ flexDirection: "column",
1285
+ padding: "24px",
1286
+ boxSizing: "border-box"
1265
1287
  },
1266
1288
  header: {
1267
1289
  display: "flex",
1268
1290
  justifyContent: "space-between",
1269
1291
  alignItems: "center",
1270
- padding: "24px 24px 0 24px"
1292
+ marginBottom: "24px"
1293
+ },
1294
+ title: {
1295
+ fontSize: "14px",
1296
+ fontWeight: "500",
1297
+ color: "#94a3b8",
1298
+ textAlign: "center",
1299
+ margin: 0,
1300
+ flex: 1
1271
1301
  },
1272
1302
  closeBtn: {
1273
1303
  background: "rgba(255, 255, 255, 0.05)",
1274
1304
  border: "none",
1275
1305
  color: "#888",
1276
- fontSize: "24px",
1306
+ fontSize: "20px",
1277
1307
  cursor: "pointer",
1278
- lineHeight: 1,
1279
- width: "32px",
1280
- height: "32px",
1308
+ width: "28px",
1309
+ height: "28px",
1281
1310
  borderRadius: "50%",
1282
1311
  display: "flex",
1283
1312
  alignItems: "center",
1284
- justifyContent: "center",
1285
- transition: "all 0.2s"
1313
+ justifyContent: "center"
1286
1314
  },
1287
1315
  content: {
1288
1316
  display: "flex",
1289
1317
  flexDirection: "column",
1290
- padding: "20px",
1291
1318
  alignItems: "center",
1292
- flex: 1,
1293
- justifyContent: "center",
1294
- width: "100%",
1295
- boxSizing: "border-box"
1319
+ width: "100%"
1296
1320
  },
1297
- title: {
1298
- fontSize: "1.5rem",
1299
- fontWeight: "700",
1300
- color: "#ffffff",
1301
- textAlign: "center",
1321
+ socialButton: {
1322
+ display: "flex",
1323
+ alignItems: "center",
1324
+ width: "100%",
1325
+ height: "48px",
1326
+ backgroundColor: "transparent",
1327
+ border: "1px solid #333",
1328
+ borderRadius: "0",
1329
+ padding: "0 16px",
1302
1330
  marginBottom: "10px",
1303
- margin: 0
1331
+ cursor: "pointer",
1332
+ fontSize: "14px",
1333
+ color: "#fff",
1334
+ boxSizing: "border-box",
1335
+ transition: "background 0.2s"
1304
1336
  },
1305
- description: {
1306
- fontSize: "0.7rem",
1307
- color: "#94a3b8",
1308
- textAlign: "center",
1309
- lineHeight: "1.5",
1310
- marginBottom: "32px",
1311
- margin: 0
1337
+ socialIcon: {
1338
+ width: "18px",
1339
+ height: "18px"
1340
+ },
1341
+ socialText: {
1342
+ marginLeft: "12px",
1343
+ fontWeight: "500"
1312
1344
  },
1313
1345
  errorBanner: {
1314
1346
  backgroundColor: "rgba(239, 68, 68, 0.1)",
@@ -1321,47 +1353,62 @@ var styles = {
1321
1353
  textAlign: "center",
1322
1354
  width: "100%"
1323
1355
  },
1324
- actionContainer: {
1325
- display: "flex",
1326
- flexDirection: "column",
1327
- width: "100%"
1328
- },
1329
- customButton: {
1330
- display: "flex",
1331
- alignItems: "center",
1332
- justifyContent: "center",
1333
- gap: "12px",
1334
- width: "100%",
1335
- height: "52px",
1336
- backgroundColor: "#0c0c0c",
1337
- border: "1px solid #333",
1338
- borderRadius: "0",
1339
- cursor: "pointer",
1340
- fontSize: "15px",
1341
- fontWeight: "600",
1342
- color: "#ffffff",
1343
- transition: "transform 0.1s, opacity 0.2s",
1344
- boxSizing: "border-box"
1345
- },
1346
- googleIcon: {
1347
- width: "20px",
1348
- height: "20px"
1349
- },
1350
1356
  spinner: {
1351
- width: "20px",
1352
- height: "20px",
1357
+ width: "18px",
1358
+ height: "18px",
1353
1359
  border: "2px solid rgba(255, 255, 255, 0.1)",
1354
1360
  borderTop: "2px solid #ffffff",
1355
1361
  borderRadius: "50%",
1356
1362
  animation: "sphere-spin 0.8s linear infinite"
1357
1363
  },
1358
1364
  footer: {
1359
- marginTop: "32px",
1365
+ marginTop: "20px",
1360
1366
  textAlign: "center",
1361
1367
  fontSize: "11px",
1362
- color: "#475569",
1363
- letterSpacing: "0.5px"
1368
+ color: "#475569"
1369
+ }
1370
+ };
1371
+ var SphereAvatar = ({
1372
+ src,
1373
+ name,
1374
+ size = 40,
1375
+ style,
1376
+ className
1377
+ }) => {
1378
+ const [imageError, setImageError] = react.useState(false);
1379
+ const containerStyle = {
1380
+ width: `${size}px`,
1381
+ height: `${size}px`,
1382
+ borderRadius: "50%",
1383
+ display: "flex",
1384
+ alignItems: "center",
1385
+ justifyContent: "center",
1386
+ overflow: "hidden",
1387
+ backgroundColor: "#2d3748",
1388
+ color: "white",
1389
+ fontWeight: "600",
1390
+ fontSize: `${size * 0.4}px`,
1391
+ userSelect: "none",
1392
+ ...style
1393
+ };
1394
+ const initials = name ? name.charAt(0).toUpperCase() : "?";
1395
+ if (src && !imageError) {
1396
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
1397
+ "img",
1398
+ {
1399
+ src,
1400
+ alt: name || "Avatar",
1401
+ referrerPolicy: "no-referrer",
1402
+ onError: () => setImageError(true),
1403
+ style: {
1404
+ width: "100%",
1405
+ height: "100%",
1406
+ objectFit: "cover"
1407
+ }
1408
+ }
1409
+ ) });
1364
1410
  }
1411
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: containerStyle, children: initials });
1365
1412
  };
1366
1413
 
1367
1414
  Object.defineProperty(exports, "Account", {
@@ -1398,6 +1445,7 @@ exports.KeyDerivation = KeyDerivation;
1398
1445
  exports.SecureStorage = SecureStorage;
1399
1446
  exports.SessionManager = SessionManager;
1400
1447
  exports.SphereAccountAbstraction = SphereAccountAbstraction;
1448
+ exports.SphereAvatar = SphereAvatar;
1401
1449
  exports.SphereModal = SphereModal;
1402
1450
  exports.SphereProvider = SphereProvider;
1403
1451
  exports.SphereSDKError = SphereSDKError;