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 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,
@@ -1363,6 +1384,48 @@ var styles = {
1363
1384
  letterSpacing: "0.5px"
1364
1385
  }
1365
1386
  };
1387
+ var SphereAvatar = ({
1388
+ src,
1389
+ name,
1390
+ size = 40,
1391
+ style,
1392
+ className
1393
+ }) => {
1394
+ const [imageError, setImageError] = react.useState(false);
1395
+ const containerStyle = {
1396
+ width: `${size}px`,
1397
+ height: `${size}px`,
1398
+ borderRadius: "50%",
1399
+ display: "flex",
1400
+ alignItems: "center",
1401
+ justifyContent: "center",
1402
+ overflow: "hidden",
1403
+ backgroundColor: "#2d3748",
1404
+ color: "white",
1405
+ fontWeight: "600",
1406
+ fontSize: `${size * 0.4}px`,
1407
+ userSelect: "none",
1408
+ ...style
1409
+ };
1410
+ const initials = name ? name.charAt(0).toUpperCase() : "?";
1411
+ if (src && !imageError) {
1412
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
1413
+ "img",
1414
+ {
1415
+ src,
1416
+ alt: name || "Avatar",
1417
+ referrerPolicy: "no-referrer",
1418
+ onError: () => setImageError(true),
1419
+ style: {
1420
+ width: "100%",
1421
+ height: "100%",
1422
+ objectFit: "cover"
1423
+ }
1424
+ }
1425
+ ) });
1426
+ }
1427
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: containerStyle, children: initials });
1428
+ };
1366
1429
 
1367
1430
  Object.defineProperty(exports, "Account", {
1368
1431
  enumerable: true,
@@ -1398,6 +1461,7 @@ exports.KeyDerivation = KeyDerivation;
1398
1461
  exports.SecureStorage = SecureStorage;
1399
1462
  exports.SessionManager = SessionManager;
1400
1463
  exports.SphereAccountAbstraction = SphereAccountAbstraction;
1464
+ exports.SphereAvatar = SphereAvatar;
1401
1465
  exports.SphereModal = SphereModal;
1402
1466
  exports.SphereProvider = SphereProvider;
1403
1467
  exports.SphereSDKError = SphereSDKError;