@unicitylabs/sphere-sdk 0.1.3 → 0.1.4

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.ts CHANGED
@@ -17,8 +17,8 @@ import { MintTransactionData } from '@unicitylabs/state-transition-sdk/lib/trans
17
17
  import { MintCommitment } from '@unicitylabs/state-transition-sdk/lib/transaction/MintCommitment';
18
18
  import { TransferTransaction } from '@unicitylabs/state-transition-sdk/lib/transaction/TransferTransaction';
19
19
  import { SigningService } from '@unicitylabs/state-transition-sdk/lib/sign/SigningService';
20
- import { ProxyAddress } from '@unicitylabs/state-transition-sdk/lib/address/ProxyAddress';
21
20
  import { AddressScheme } from '@unicitylabs/state-transition-sdk/lib/address/AddressScheme';
21
+ import { hashNametag } from '@unicitylabs/nostr-js-sdk';
22
22
 
23
23
  /**
24
24
  * Cryptographic utilities for SDK2
@@ -407,11 +407,12 @@ interface BaseProvider extends ProviderMetadata {
407
407
  getStatus(): ProviderStatus;
408
408
  }
409
409
  interface Identity {
410
- readonly publicKey: string;
410
+ /** 33-byte compressed secp256k1 public key (for L3 chain) */
411
+ readonly chainPubkey: string;
411
412
  /** L1 address (alpha1...) */
412
- readonly address: string;
413
- /** L3 predicate address (DIRECT://...) */
414
- readonly predicateAddress?: string;
413
+ readonly l1Address: string;
414
+ /** L3 DIRECT address (DIRECT://...) */
415
+ readonly directAddress?: string;
415
416
  readonly ipnsName?: string;
416
417
  readonly nametag?: string;
417
418
  }
@@ -601,7 +602,7 @@ interface BroadcastMessage {
601
602
  readonly timestamp: number;
602
603
  readonly tags?: string[];
603
604
  }
604
- type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'identity:changed';
605
+ type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed';
605
606
  interface SphereEventMap {
606
607
  'transfer:incoming': IncomingTransfer;
607
608
  'transfer:confirmed': TransferResult;
@@ -639,10 +640,13 @@ interface SphereEventMap {
639
640
  nametag: string;
640
641
  addressIndex: number;
641
642
  };
643
+ 'nametag:recovered': {
644
+ nametag: string;
645
+ };
642
646
  'identity:changed': {
643
- address: string;
644
- predicateAddress?: string;
645
- publicKey: string;
647
+ l1Address: string;
648
+ directAddress?: string;
649
+ chainPubkey: string;
646
650
  nametag?: string;
647
651
  addressIndex: number;
648
652
  };
@@ -748,6 +752,253 @@ interface WalletJSONExportOptions$1 {
748
752
  addressCount?: number;
749
753
  }
750
754
 
755
+ /**
756
+ * Transport Provider Interface
757
+ * Platform-independent P2P messaging abstraction
758
+ */
759
+
760
+ /**
761
+ * P2P messaging transport provider
762
+ */
763
+ interface TransportProvider extends BaseProvider {
764
+ /**
765
+ * Set identity for signing/encryption
766
+ */
767
+ setIdentity(identity: FullIdentity): void;
768
+ /**
769
+ * Send encrypted direct message
770
+ * @param recipientTransportPubkey - Transport-specific pubkey for messaging
771
+ * @returns Event ID
772
+ */
773
+ sendMessage(recipientTransportPubkey: string, content: string): Promise<string>;
774
+ /**
775
+ * Subscribe to incoming direct messages
776
+ * @returns Unsubscribe function
777
+ */
778
+ onMessage(handler: MessageHandler): () => void;
779
+ /**
780
+ * Send token transfer payload
781
+ * @param recipientTransportPubkey - Transport-specific pubkey for messaging
782
+ * @returns Event ID
783
+ */
784
+ sendTokenTransfer(recipientTransportPubkey: string, payload: TokenTransferPayload): Promise<string>;
785
+ /**
786
+ * Subscribe to incoming token transfers
787
+ * @returns Unsubscribe function
788
+ */
789
+ onTokenTransfer(handler: TokenTransferHandler): () => void;
790
+ /**
791
+ * Resolve nametag to public key
792
+ */
793
+ resolveNametag?(nametag: string): Promise<string | null>;
794
+ /**
795
+ * Resolve nametag to full address information
796
+ * Returns transportPubkey, chainPubkey, l1Address, directAddress, proxyAddress
797
+ */
798
+ resolveNametagInfo?(nametag: string): Promise<NametagInfo | null>;
799
+ /**
800
+ * Recover nametag for current identity by decrypting stored encrypted nametag
801
+ * Used after wallet import to recover associated nametag
802
+ * @returns Decrypted nametag or null if none found
803
+ */
804
+ recoverNametag?(): Promise<string | null>;
805
+ /**
806
+ * Register a nametag for this identity
807
+ * @param nametag - Nametag to register
808
+ * @param chainPubkey - 33-byte compressed secp256k1 public key (for L1/L3)
809
+ * @param directAddress - L3 DIRECT address (DIRECT://...)
810
+ * @returns true if successful, false if already taken
811
+ */
812
+ registerNametag?(nametag: string, chainPubkey: string, directAddress: string): Promise<boolean>;
813
+ /**
814
+ * Publish nametag binding
815
+ */
816
+ publishNametag?(nametag: string, address: string): Promise<void>;
817
+ /**
818
+ * Subscribe to broadcast messages (global/channel)
819
+ */
820
+ subscribeToBroadcast?(tags: string[], handler: BroadcastHandler): () => void;
821
+ /**
822
+ * Publish broadcast message
823
+ */
824
+ publishBroadcast?(content: string, tags?: string[]): Promise<string>;
825
+ /**
826
+ * Send payment request to a recipient
827
+ * @param recipientTransportPubkey - Transport-specific pubkey for messaging
828
+ * @returns Event ID
829
+ */
830
+ sendPaymentRequest?(recipientTransportPubkey: string, request: PaymentRequestPayload): Promise<string>;
831
+ /**
832
+ * Subscribe to incoming payment requests
833
+ * @returns Unsubscribe function
834
+ */
835
+ onPaymentRequest?(handler: PaymentRequestHandler): () => void;
836
+ /**
837
+ * Send response to a payment request
838
+ * @param recipientTransportPubkey - Transport-specific pubkey for messaging
839
+ * @returns Event ID
840
+ */
841
+ sendPaymentRequestResponse?(recipientTransportPubkey: string, response: PaymentRequestResponsePayload): Promise<string>;
842
+ /**
843
+ * Subscribe to incoming payment request responses
844
+ * @returns Unsubscribe function
845
+ */
846
+ onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
847
+ /**
848
+ * Get list of configured relay URLs
849
+ */
850
+ getRelays?(): string[];
851
+ /**
852
+ * Get list of currently connected relay URLs
853
+ */
854
+ getConnectedRelays?(): string[];
855
+ /**
856
+ * Add a relay dynamically
857
+ * @returns true if added successfully
858
+ */
859
+ addRelay?(relayUrl: string): Promise<boolean>;
860
+ /**
861
+ * Remove a relay dynamically
862
+ * @returns true if removed successfully
863
+ */
864
+ removeRelay?(relayUrl: string): Promise<boolean>;
865
+ /**
866
+ * Check if a relay is configured
867
+ */
868
+ hasRelay?(relayUrl: string): boolean;
869
+ /**
870
+ * Check if a relay is currently connected
871
+ */
872
+ isRelayConnected?(relayUrl: string): boolean;
873
+ }
874
+ interface IncomingMessage {
875
+ id: string;
876
+ /** Transport-specific pubkey of sender */
877
+ senderTransportPubkey: string;
878
+ /** Sender's nametag (if known from NIP-17 unwrap) */
879
+ senderNametag?: string;
880
+ content: string;
881
+ timestamp: number;
882
+ encrypted: boolean;
883
+ }
884
+ type MessageHandler = (message: IncomingMessage) => void;
885
+ interface TokenTransferPayload {
886
+ /** Serialized token data */
887
+ token: string;
888
+ /** Inclusion proof */
889
+ proof: unknown;
890
+ /** Optional memo */
891
+ memo?: string;
892
+ /** Sender info */
893
+ sender?: {
894
+ /** Transport-specific pubkey */
895
+ transportPubkey: string;
896
+ nametag?: string;
897
+ };
898
+ }
899
+ interface IncomingTokenTransfer {
900
+ id: string;
901
+ /** Transport-specific pubkey of sender */
902
+ senderTransportPubkey: string;
903
+ payload: TokenTransferPayload;
904
+ timestamp: number;
905
+ }
906
+ type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void;
907
+ interface PaymentRequestPayload {
908
+ /** Amount requested (in smallest units) */
909
+ amount: string | bigint;
910
+ /** Coin/token type ID */
911
+ coinId: string;
912
+ /** Message/memo for recipient */
913
+ message?: string;
914
+ /** Recipient's nametag (who should pay) */
915
+ recipientNametag?: string;
916
+ /** Custom metadata */
917
+ metadata?: Record<string, unknown>;
918
+ }
919
+ interface IncomingPaymentRequest {
920
+ /** Event ID */
921
+ id: string;
922
+ /** Transport-specific pubkey of sender */
923
+ senderTransportPubkey: string;
924
+ /** Parsed request data */
925
+ request: {
926
+ requestId: string;
927
+ amount: string;
928
+ coinId: string;
929
+ message?: string;
930
+ recipientNametag?: string;
931
+ metadata?: Record<string, unknown>;
932
+ };
933
+ /** Timestamp */
934
+ timestamp: number;
935
+ }
936
+ type PaymentRequestHandler = (request: IncomingPaymentRequest) => void;
937
+ type PaymentRequestResponseType = 'accepted' | 'rejected' | 'paid';
938
+ interface PaymentRequestResponsePayload {
939
+ /** Original request ID */
940
+ requestId: string;
941
+ /** Response type */
942
+ responseType: PaymentRequestResponseType;
943
+ /** Optional message */
944
+ message?: string;
945
+ /** Transfer ID (if paid) */
946
+ transferId?: string;
947
+ }
948
+ interface IncomingPaymentRequestResponse {
949
+ /** Event ID */
950
+ id: string;
951
+ /** Transport-specific pubkey of responder */
952
+ responderTransportPubkey: string;
953
+ /** Parsed response data */
954
+ response: {
955
+ requestId: string;
956
+ responseType: PaymentRequestResponseType;
957
+ message?: string;
958
+ transferId?: string;
959
+ };
960
+ /** Timestamp */
961
+ timestamp: number;
962
+ }
963
+ type PaymentRequestResponseHandler = (response: IncomingPaymentRequestResponse) => void;
964
+ interface IncomingBroadcast {
965
+ id: string;
966
+ /** Transport-specific pubkey of author */
967
+ authorTransportPubkey: string;
968
+ content: string;
969
+ tags: string[];
970
+ timestamp: number;
971
+ }
972
+ type BroadcastHandler = (broadcast: IncomingBroadcast) => void;
973
+ type TransportEventType = 'transport:connected' | 'transport:disconnected' | 'transport:reconnecting' | 'transport:error' | 'transport:relay_added' | 'transport:relay_removed' | 'message:received' | 'message:sent' | 'transfer:received' | 'transfer:sent';
974
+ interface TransportEvent {
975
+ type: TransportEventType;
976
+ timestamp: number;
977
+ data?: unknown;
978
+ error?: string;
979
+ }
980
+ type TransportEventCallback = (event: TransportEvent) => void;
981
+ /**
982
+ * Full nametag address information
983
+ * Used for resolving nametag to all address formats
984
+ */
985
+ interface NametagInfo {
986
+ /** Nametag name (without @) */
987
+ nametag: string;
988
+ /** Transport-specific pubkey (for messaging/encryption) */
989
+ transportPubkey: string;
990
+ /** 33-byte compressed secp256k1 public key (for L3 chain) */
991
+ chainPubkey: string;
992
+ /** L1 address (alpha1...) */
993
+ l1Address: string;
994
+ /** L3 DIRECT address (DIRECT://...) */
995
+ directAddress: string;
996
+ /** L3 PROXY address derived from nametag hash (PROXY:...) */
997
+ proxyAddress: string;
998
+ /** Event timestamp */
999
+ timestamp: number;
1000
+ }
1001
+
751
1002
  /**
752
1003
  * L1 Payments Sub-Module
753
1004
  *
@@ -817,6 +1068,8 @@ interface L1PaymentsModuleDependencies {
817
1068
  identity: FullIdentity;
818
1069
  chainCode?: string;
819
1070
  addresses?: string[];
1071
+ /** Transport provider for nametag resolution (optional) */
1072
+ transport?: TransportProvider;
820
1073
  }
821
1074
  /**
822
1075
  * L1 Payments Module - Full Implementation
@@ -831,9 +1084,23 @@ declare class L1PaymentsModule$1 {
831
1084
  private _chainCode?;
832
1085
  private _addresses;
833
1086
  private _wallet?;
1087
+ private _transport?;
834
1088
  constructor(config?: L1PaymentsModuleConfig);
835
1089
  initialize(deps: L1PaymentsModuleDependencies): Promise<void>;
836
1090
  destroy(): void;
1091
+ /**
1092
+ * Check if a string looks like an L1 address (alpha1... or alphat1...)
1093
+ */
1094
+ private isL1Address;
1095
+ /**
1096
+ * Resolve recipient to L1 address
1097
+ * Supports: L1 address (alpha1...), nametag (with or without @)
1098
+ */
1099
+ private resolveL1Address;
1100
+ /**
1101
+ * Resolve nametag to L1 address using transport provider
1102
+ */
1103
+ private resolveNametagToL1Address;
837
1104
  send(request: L1SendRequest): Promise<L1SendResult>;
838
1105
  getBalance(): Promise<L1Balance>;
839
1106
  getUtxos(): Promise<L1Utxo[]>;
@@ -1043,209 +1310,6 @@ interface TxfInvalidEntry {
1043
1310
  detectedAt: number;
1044
1311
  }
1045
1312
 
1046
- /**
1047
- * Transport Provider Interface
1048
- * Platform-independent P2P messaging abstraction
1049
- */
1050
-
1051
- /**
1052
- * P2P messaging transport provider
1053
- */
1054
- interface TransportProvider extends BaseProvider {
1055
- /**
1056
- * Set identity for signing/encryption
1057
- */
1058
- setIdentity(identity: FullIdentity): void;
1059
- /**
1060
- * Send encrypted direct message
1061
- * @returns Event ID
1062
- */
1063
- sendMessage(recipientPubkey: string, content: string): Promise<string>;
1064
- /**
1065
- * Subscribe to incoming direct messages
1066
- * @returns Unsubscribe function
1067
- */
1068
- onMessage(handler: MessageHandler): () => void;
1069
- /**
1070
- * Send token transfer payload
1071
- * @returns Event ID
1072
- */
1073
- sendTokenTransfer(recipientPubkey: string, payload: TokenTransferPayload): Promise<string>;
1074
- /**
1075
- * Subscribe to incoming token transfers
1076
- * @returns Unsubscribe function
1077
- */
1078
- onTokenTransfer(handler: TokenTransferHandler): () => void;
1079
- /**
1080
- * Resolve nametag to public key
1081
- */
1082
- resolveNametag?(nametag: string): Promise<string | null>;
1083
- /**
1084
- * Register a nametag for this identity
1085
- * @returns true if successful, false if already taken
1086
- */
1087
- registerNametag?(nametag: string, publicKey: string): Promise<boolean>;
1088
- /**
1089
- * Publish nametag binding
1090
- */
1091
- publishNametag?(nametag: string, address: string): Promise<void>;
1092
- /**
1093
- * Subscribe to broadcast messages (global/channel)
1094
- */
1095
- subscribeToBroadcast?(tags: string[], handler: BroadcastHandler): () => void;
1096
- /**
1097
- * Publish broadcast message
1098
- */
1099
- publishBroadcast?(content: string, tags?: string[]): Promise<string>;
1100
- /**
1101
- * Send payment request to a recipient
1102
- * @returns Event ID
1103
- */
1104
- sendPaymentRequest?(recipientPubkey: string, request: PaymentRequestPayload): Promise<string>;
1105
- /**
1106
- * Subscribe to incoming payment requests
1107
- * @returns Unsubscribe function
1108
- */
1109
- onPaymentRequest?(handler: PaymentRequestHandler): () => void;
1110
- /**
1111
- * Send response to a payment request
1112
- * @returns Event ID
1113
- */
1114
- sendPaymentRequestResponse?(recipientPubkey: string, response: PaymentRequestResponsePayload): Promise<string>;
1115
- /**
1116
- * Subscribe to incoming payment request responses
1117
- * @returns Unsubscribe function
1118
- */
1119
- onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
1120
- /**
1121
- * Get list of configured relay URLs
1122
- */
1123
- getRelays?(): string[];
1124
- /**
1125
- * Get list of currently connected relay URLs
1126
- */
1127
- getConnectedRelays?(): string[];
1128
- /**
1129
- * Add a relay dynamically
1130
- * @returns true if added successfully
1131
- */
1132
- addRelay?(relayUrl: string): Promise<boolean>;
1133
- /**
1134
- * Remove a relay dynamically
1135
- * @returns true if removed successfully
1136
- */
1137
- removeRelay?(relayUrl: string): Promise<boolean>;
1138
- /**
1139
- * Check if a relay is configured
1140
- */
1141
- hasRelay?(relayUrl: string): boolean;
1142
- /**
1143
- * Check if a relay is currently connected
1144
- */
1145
- isRelayConnected?(relayUrl: string): boolean;
1146
- }
1147
- interface IncomingMessage {
1148
- id: string;
1149
- senderPubkey: string;
1150
- content: string;
1151
- timestamp: number;
1152
- encrypted: boolean;
1153
- }
1154
- type MessageHandler = (message: IncomingMessage) => void;
1155
- interface TokenTransferPayload {
1156
- /** Serialized token data */
1157
- token: string;
1158
- /** Inclusion proof */
1159
- proof: unknown;
1160
- /** Optional memo */
1161
- memo?: string;
1162
- /** Sender info */
1163
- sender?: {
1164
- pubkey: string;
1165
- nametag?: string;
1166
- };
1167
- }
1168
- interface IncomingTokenTransfer {
1169
- id: string;
1170
- senderPubkey: string;
1171
- payload: TokenTransferPayload;
1172
- timestamp: number;
1173
- }
1174
- type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void;
1175
- interface PaymentRequestPayload {
1176
- /** Amount requested (in smallest units) */
1177
- amount: string | bigint;
1178
- /** Coin/token type ID */
1179
- coinId: string;
1180
- /** Message/memo for recipient */
1181
- message?: string;
1182
- /** Recipient's nametag (who should pay) */
1183
- recipientNametag?: string;
1184
- /** Custom metadata */
1185
- metadata?: Record<string, unknown>;
1186
- }
1187
- interface IncomingPaymentRequest {
1188
- /** Event ID */
1189
- id: string;
1190
- /** Sender's public key */
1191
- senderPubkey: string;
1192
- /** Parsed request data */
1193
- request: {
1194
- requestId: string;
1195
- amount: string;
1196
- coinId: string;
1197
- message?: string;
1198
- recipientNametag?: string;
1199
- metadata?: Record<string, unknown>;
1200
- };
1201
- /** Timestamp */
1202
- timestamp: number;
1203
- }
1204
- type PaymentRequestHandler = (request: IncomingPaymentRequest) => void;
1205
- type PaymentRequestResponseType = 'accepted' | 'rejected' | 'paid';
1206
- interface PaymentRequestResponsePayload {
1207
- /** Original request ID */
1208
- requestId: string;
1209
- /** Response type */
1210
- responseType: PaymentRequestResponseType;
1211
- /** Optional message */
1212
- message?: string;
1213
- /** Transfer ID (if paid) */
1214
- transferId?: string;
1215
- }
1216
- interface IncomingPaymentRequestResponse {
1217
- /** Event ID */
1218
- id: string;
1219
- /** Responder's public key */
1220
- responderPubkey: string;
1221
- /** Parsed response data */
1222
- response: {
1223
- requestId: string;
1224
- responseType: PaymentRequestResponseType;
1225
- message?: string;
1226
- transferId?: string;
1227
- };
1228
- /** Timestamp */
1229
- timestamp: number;
1230
- }
1231
- type PaymentRequestResponseHandler = (response: IncomingPaymentRequestResponse) => void;
1232
- interface IncomingBroadcast {
1233
- id: string;
1234
- authorPubkey: string;
1235
- content: string;
1236
- tags: string[];
1237
- timestamp: number;
1238
- }
1239
- type BroadcastHandler = (broadcast: IncomingBroadcast) => void;
1240
- type TransportEventType = 'transport:connected' | 'transport:disconnected' | 'transport:reconnecting' | 'transport:error' | 'transport:relay_added' | 'transport:relay_removed' | 'message:received' | 'message:sent' | 'transfer:received' | 'transfer:sent';
1241
- interface TransportEvent {
1242
- type: TransportEventType;
1243
- timestamp: number;
1244
- data?: unknown;
1245
- error?: string;
1246
- }
1247
- type TransportEventCallback = (event: TransportEvent) => void;
1248
-
1249
1313
  /**
1250
1314
  * Oracle Provider Interface
1251
1315
  * Platform-independent Unicity oracle abstraction
@@ -1743,6 +1807,15 @@ declare class PaymentsModule$1 {
1743
1807
  * Get pending transfers
1744
1808
  */
1745
1809
  getPendingTransfers(): TransferResult[];
1810
+ /**
1811
+ * Detect if a string is an L3 address (not a nametag)
1812
+ * Returns true for: hex pubkeys (64+ chars), PROXY:, DIRECT: prefixed addresses
1813
+ */
1814
+ private isL3Address;
1815
+ /**
1816
+ * Resolve recipient to Nostr pubkey for messaging
1817
+ * Supports: nametag (with or without @), hex pubkey
1818
+ */
1746
1819
  private resolveRecipient;
1747
1820
  /**
1748
1821
  * Create SDK TransferCommitment for a token transfer
@@ -1753,7 +1826,17 @@ declare class PaymentsModule$1 {
1753
1826
  */
1754
1827
  private createSigningService;
1755
1828
  /**
1756
- * Resolve recipient to IAddress
1829
+ * Create DirectAddress from a public key using UnmaskedPredicateReference
1830
+ */
1831
+ private createDirectAddressFromPubkey;
1832
+ /**
1833
+ * Resolve nametag to 33-byte compressed public key using resolveNametagInfo
1834
+ * Returns null if nametag not found or publicKey not available
1835
+ */
1836
+ private resolveNametagToPublicKey;
1837
+ /**
1838
+ * Resolve recipient to IAddress for L3 transfers
1839
+ * Supports: nametag (with or without @), PROXY:, DIRECT:, hex pubkey
1757
1840
  */
1758
1841
  private resolveRecipientAddress;
1759
1842
  private handleIncomingTransfer;
@@ -1941,7 +2024,7 @@ declare const DEFAULT_IPFS_GATEWAYS: readonly ["https://ipfs.unicity.network", "
1941
2024
  /** Unicity IPFS bootstrap peers */
1942
2025
  declare const DEFAULT_IPFS_BOOTSTRAP_PEERS: readonly ["/dns4/unicity-ipfs2.dyndns.org/tcp/4001/p2p/12D3KooWLNi5NDPPHbrfJakAQqwBqymYTTwMQXQKEWuCrJNDdmfh", "/dns4/unicity-ipfs3.dyndns.org/tcp/4001/p2p/12D3KooWQ4aujVE4ShLjdusNZBdffq3TbzrwT2DuWZY9H1Gxhwn6", "/dns4/unicity-ipfs4.dyndns.org/tcp/4001/p2p/12D3KooWJ1ByPfUzUrpYvgxKU8NZrR8i6PU1tUgMEbQX9Hh2DEn1", "/dns4/unicity-ipfs5.dyndns.org/tcp/4001/p2p/12D3KooWB1MdZZGHN5B8TvWXntbycfe7Cjcz7n6eZ9eykZadvmDv"];
1943
2026
  /** Default BIP32 derivation path (full path with chain/index) */
1944
- declare const DEFAULT_DERIVATION_PATH$1: "m/44'/0'/0'/0/0";
2027
+ declare const DEFAULT_DERIVATION_PATH: "m/44'/0'/0'/0/0";
1945
2028
  /** Coin types */
1946
2029
  declare const COIN_TYPES: {
1947
2030
  /** ALPHA token (L1 blockchain) */
@@ -2571,6 +2654,13 @@ declare class Sphere$1 {
2571
2654
  * Check if nametag is registered
2572
2655
  */
2573
2656
  hasNametag(): boolean;
2657
+ /**
2658
+ * Get the PROXY address for the current nametag
2659
+ * PROXY addresses are derived from the nametag hash and require
2660
+ * the nametag token to claim funds sent to them
2661
+ * @returns PROXY address string or undefined if no nametag
2662
+ */
2663
+ getProxyAddress(): string | undefined;
2574
2664
  /**
2575
2665
  * Register a nametag for the current active address
2576
2666
  * Each address can have its own independent nametag
@@ -2628,6 +2718,12 @@ declare class Sphere$1 {
2628
2718
  * If local nametag exists but not registered on Nostr, re-register it
2629
2719
  */
2630
2720
  private syncNametagWithNostr;
2721
+ /**
2722
+ * Recover nametag from Nostr after wallet import
2723
+ * Searches for encrypted nametag events authored by this wallet's pubkey
2724
+ * and decrypts them to restore the nametag association
2725
+ */
2726
+ private recoverNametagFromNostr;
2631
2727
  /**
2632
2728
  * Validate nametag format
2633
2729
  */
@@ -4806,6 +4902,7 @@ var L1PaymentsModule = class {
4806
4902
  _chainCode;
4807
4903
  _addresses = [];
4808
4904
  _wallet;
4905
+ _transport;
4809
4906
  constructor(config) {
4810
4907
  this._config = {
4811
4908
  electrumUrl: config?.electrumUrl ?? "wss://fulcrum.alpha.unicity.network:50004",
@@ -4818,13 +4915,14 @@ var L1PaymentsModule = class {
4818
4915
  this._identity = deps.identity;
4819
4916
  this._chainCode = deps.chainCode;
4820
4917
  this._addresses = deps.addresses ?? [];
4918
+ this._transport = deps.transport;
4821
4919
  this._wallet = {
4822
4920
  masterPrivateKey: deps.identity.privateKey,
4823
4921
  chainCode: deps.chainCode,
4824
4922
  addresses: [
4825
4923
  {
4826
- address: deps.identity.address,
4827
- publicKey: deps.identity.publicKey,
4924
+ address: deps.identity.l1Address,
4925
+ publicKey: deps.identity.chainPubkey,
4828
4926
  privateKey: deps.identity.privateKey,
4829
4927
  path: "m/0",
4830
4928
  index: 0
@@ -4832,7 +4930,7 @@ var L1PaymentsModule = class {
4832
4930
  ]
4833
4931
  };
4834
4932
  for (const addr of this._addresses) {
4835
- if (addr !== deps.identity.address) {
4933
+ if (addr !== deps.identity.l1Address) {
4836
4934
  this._wallet.addresses.push({
4837
4935
  address: addr,
4838
4936
  path: null,
@@ -4855,18 +4953,64 @@ var L1PaymentsModule = class {
4855
4953
  this._addresses = [];
4856
4954
  this._wallet = void 0;
4857
4955
  }
4956
+ /**
4957
+ * Check if a string looks like an L1 address (alpha1... or alphat1...)
4958
+ */
4959
+ isL1Address(value) {
4960
+ return value.startsWith("alpha1") || value.startsWith("alphat1");
4961
+ }
4962
+ /**
4963
+ * Resolve recipient to L1 address
4964
+ * Supports: L1 address (alpha1...), nametag (with or without @)
4965
+ */
4966
+ async resolveL1Address(recipient) {
4967
+ if (recipient.startsWith("@")) {
4968
+ const nametag = recipient.slice(1);
4969
+ return this.resolveNametagToL1Address(nametag);
4970
+ }
4971
+ if (this.isL1Address(recipient)) {
4972
+ return recipient;
4973
+ }
4974
+ try {
4975
+ const l1Address = await this.resolveNametagToL1Address(recipient);
4976
+ return l1Address;
4977
+ } catch {
4978
+ throw new Error(
4979
+ `Recipient "${recipient}" is not a valid nametag or L1 address. Use @nametag for explicit nametag or a valid alpha1... address.`
4980
+ );
4981
+ }
4982
+ }
4983
+ /**
4984
+ * Resolve nametag to L1 address using transport provider
4985
+ */
4986
+ async resolveNametagToL1Address(nametag) {
4987
+ if (!this._transport?.resolveNametagInfo) {
4988
+ throw new Error("Transport provider does not support nametag resolution");
4989
+ }
4990
+ const info = await this._transport.resolveNametagInfo(nametag);
4991
+ if (!info) {
4992
+ throw new Error(`Nametag not found: ${nametag}`);
4993
+ }
4994
+ if (!info.l1Address) {
4995
+ throw new Error(
4996
+ `Nametag @${nametag} does not have L1 address information. The owner needs to update their nametag registration.`
4997
+ );
4998
+ }
4999
+ return info.l1Address;
5000
+ }
4858
5001
  async send(request) {
4859
5002
  this.ensureInitialized();
4860
5003
  if (!this._wallet || !this._identity) {
4861
5004
  return { success: false, error: "No wallet available" };
4862
5005
  }
4863
5006
  try {
5007
+ const recipientAddress = await this.resolveL1Address(request.to);
4864
5008
  const amountAlpha = parseInt(request.amount, 10) / 1e8;
4865
5009
  const results = await sendAlpha$1(
4866
5010
  this._wallet,
4867
- request.to,
5011
+ recipientAddress,
4868
5012
  amountAlpha,
4869
- this._identity.address
5013
+ this._identity.l1Address
4870
5014
  );
4871
5015
  if (results && results.length > 0) {
4872
5016
  const txids = results.map((r) => r.txid);
@@ -5088,8 +5232,8 @@ var L1PaymentsModule = class {
5088
5232
  }
5089
5233
  _getWatchedAddresses() {
5090
5234
  const addresses = [...this._addresses];
5091
- if (this._identity?.address && !addresses.includes(this._identity.address)) {
5092
- addresses.unshift(this._identity.address);
5235
+ if (this._identity?.l1Address && !addresses.includes(this._identity.l1Address)) {
5236
+ addresses.unshift(this._identity.l1Address);
5093
5237
  }
5094
5238
  return addresses;
5095
5239
  }
@@ -5578,7 +5722,6 @@ var STORAGE_KEYS = {
5578
5722
  FORKED_TOKENS: `${STORAGE_PREFIX}forked_tokens`
5579
5723
  };
5580
5724
  var DEFAULT_BASE_PATH = "m/44'/0'/0'";
5581
- var DEFAULT_DERIVATION_PATH = `${DEFAULT_BASE_PATH}/0/0`;
5582
5725
  var LIMITS = {
5583
5726
  /** Min nametag length */
5584
5727
  NAMETAG_MIN_LENGTH: 3,
@@ -6181,7 +6324,8 @@ var PaymentsModule = class {
6181
6324
  this.l1.initialize({
6182
6325
  identity: deps.identity,
6183
6326
  chainCode: deps.chainCode,
6184
- addresses: deps.l1Addresses
6327
+ addresses: deps.l1Addresses,
6328
+ transport: deps.transport
6185
6329
  });
6186
6330
  }
6187
6331
  this.unsubscribeTransfers = deps.transport.onTokenTransfer((transfer) => {
@@ -6578,7 +6722,7 @@ var PaymentsModule = class {
6578
6722
  }
6579
6723
  const request = {
6580
6724
  id: transportRequest.id,
6581
- senderPubkey: transportRequest.senderPubkey,
6725
+ senderPubkey: transportRequest.senderTransportPubkey,
6582
6726
  amount: transportRequest.request.amount,
6583
6727
  coinId: transportRequest.request.coinId,
6584
6728
  symbol: transportRequest.request.coinId,
@@ -6690,7 +6834,7 @@ var PaymentsModule = class {
6690
6834
  }
6691
6835
  const response = {
6692
6836
  id: transportResponse.id,
6693
- responderPubkey: transportResponse.responderPubkey,
6837
+ responderPubkey: transportResponse.responderTransportPubkey,
6694
6838
  requestId: transportResponse.response.requestId,
6695
6839
  responseType: transportResponse.response.responseType,
6696
6840
  message: transportResponse.response.message,
@@ -7444,6 +7588,23 @@ var PaymentsModule = class {
7444
7588
  // ===========================================================================
7445
7589
  // Private: Transfer Operations
7446
7590
  // ===========================================================================
7591
+ /**
7592
+ * Detect if a string is an L3 address (not a nametag)
7593
+ * Returns true for: hex pubkeys (64+ chars), PROXY:, DIRECT: prefixed addresses
7594
+ */
7595
+ isL3Address(value) {
7596
+ if (value.startsWith("PROXY:") || value.startsWith("DIRECT:")) {
7597
+ return true;
7598
+ }
7599
+ if (value.length >= 64 && /^[0-9a-fA-F]+$/.test(value)) {
7600
+ return true;
7601
+ }
7602
+ return false;
7603
+ }
7604
+ /**
7605
+ * Resolve recipient to Nostr pubkey for messaging
7606
+ * Supports: nametag (with or without @), hex pubkey
7607
+ */
7447
7608
  async resolveRecipient(recipient) {
7448
7609
  if (recipient.startsWith("@")) {
7449
7610
  const nametag = recipient.slice(1);
@@ -7453,7 +7614,19 @@ var PaymentsModule = class {
7453
7614
  }
7454
7615
  return pubkey;
7455
7616
  }
7456
- return recipient;
7617
+ if (this.isL3Address(recipient)) {
7618
+ return recipient;
7619
+ }
7620
+ if (this.deps?.transport.resolveNametag) {
7621
+ const pubkey = await this.deps.transport.resolveNametag(recipient);
7622
+ if (pubkey) {
7623
+ this.log(`Resolved "${recipient}" as nametag to pubkey`);
7624
+ return pubkey;
7625
+ }
7626
+ }
7627
+ throw new Error(
7628
+ `Recipient "${recipient}" is not a valid nametag or address. Use @nametag for explicit nametag or a valid hex pubkey/PROXY:/DIRECT: address.`
7629
+ );
7457
7630
  }
7458
7631
  /**
7459
7632
  * Create SDK TransferCommitment for a token transfer
@@ -7485,19 +7658,74 @@ var PaymentsModule = class {
7485
7658
  return SigningService.createFromSecret(privateKeyBytes);
7486
7659
  }
7487
7660
  /**
7488
- * Resolve recipient to IAddress
7661
+ * Create DirectAddress from a public key using UnmaskedPredicateReference
7662
+ */
7663
+ async createDirectAddressFromPubkey(pubkeyHex) {
7664
+ const { UnmaskedPredicateReference: UnmaskedPredicateReference3 } = await import('@unicitylabs/state-transition-sdk/lib/predicate/embedded/UnmaskedPredicateReference');
7665
+ const { TokenType: TokenType3 } = await import('@unicitylabs/state-transition-sdk/lib/token/TokenType');
7666
+ const UNICITY_TOKEN_TYPE_HEX3 = "f8aa13834268d29355ff12183066f0cb902003629bbc5eb9ef0efbe397867509";
7667
+ const tokenType = new TokenType3(Buffer.from(UNICITY_TOKEN_TYPE_HEX3, "hex"));
7668
+ const pubkeyBytes = new Uint8Array(
7669
+ pubkeyHex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))
7670
+ );
7671
+ const addressRef = await UnmaskedPredicateReference3.create(
7672
+ tokenType,
7673
+ "secp256k1",
7674
+ pubkeyBytes,
7675
+ HashAlgorithm.SHA256
7676
+ );
7677
+ return addressRef.toAddress();
7678
+ }
7679
+ /**
7680
+ * Resolve nametag to 33-byte compressed public key using resolveNametagInfo
7681
+ * Returns null if nametag not found or publicKey not available
7682
+ */
7683
+ async resolveNametagToPublicKey(nametag) {
7684
+ if (!this.deps?.transport.resolveNametagInfo) {
7685
+ this.log("resolveNametagInfo not available on transport");
7686
+ return null;
7687
+ }
7688
+ const info = await this.deps.transport.resolveNametagInfo(nametag);
7689
+ if (!info) {
7690
+ this.log(`Nametag "${nametag}" not found`);
7691
+ return null;
7692
+ }
7693
+ if (!info.chainPubkey) {
7694
+ this.log(`Nametag "${nametag}" has no 33-byte chainPubkey (legacy event)`);
7695
+ return null;
7696
+ }
7697
+ return info.chainPubkey;
7698
+ }
7699
+ /**
7700
+ * Resolve recipient to IAddress for L3 transfers
7701
+ * Supports: nametag (with or without @), PROXY:, DIRECT:, hex pubkey
7489
7702
  */
7490
7703
  async resolveRecipientAddress(recipient) {
7704
+ const { AddressFactory } = await import('@unicitylabs/state-transition-sdk/lib/address/AddressFactory');
7491
7705
  if (recipient.startsWith("@")) {
7492
7706
  const nametag = recipient.slice(1);
7493
- const tokenId2 = await TokenId.fromNameTag(nametag);
7494
- return ProxyAddress.fromTokenId(tokenId2);
7707
+ const publicKey2 = await this.resolveNametagToPublicKey(nametag);
7708
+ if (publicKey2) {
7709
+ this.log(`Resolved @${nametag} to 33-byte publicKey for DirectAddress`);
7710
+ return this.createDirectAddressFromPubkey(publicKey2);
7711
+ }
7712
+ throw new Error(`Nametag "${nametag}" not found or missing publicKey`);
7495
7713
  }
7496
- const pubkeyBytes = new Uint8Array(
7497
- recipient.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))
7714
+ if (recipient.startsWith("PROXY:") || recipient.startsWith("DIRECT:")) {
7715
+ return AddressFactory.createAddress(recipient);
7716
+ }
7717
+ if (recipient.length === 66 && /^[0-9a-fA-F]+$/.test(recipient)) {
7718
+ this.log(`Creating DirectAddress from 33-byte compressed pubkey`);
7719
+ return this.createDirectAddressFromPubkey(recipient);
7720
+ }
7721
+ const publicKey = await this.resolveNametagToPublicKey(recipient);
7722
+ if (publicKey) {
7723
+ this.log(`Resolved "${recipient}" as nametag to 33-byte publicKey for DirectAddress`);
7724
+ return this.createDirectAddressFromPubkey(publicKey);
7725
+ }
7726
+ throw new Error(
7727
+ `Recipient "${recipient}" is not a valid nametag or L3 address. Use @nametag for explicit nametag or a valid 33-byte hex pubkey/PROXY:/DIRECT: address.`
7498
7728
  );
7499
- const tokenId = new TokenId(pubkeyBytes.slice(0, 32));
7500
- return ProxyAddress.fromTokenId(tokenId);
7501
7729
  }
7502
7730
  async handleIncomingTransfer(transfer) {
7503
7731
  try {
@@ -7555,7 +7783,39 @@ var PaymentsModule = class {
7555
7783
  }
7556
7784
  }
7557
7785
  } else {
7558
- tokenData = sourceTokenInput;
7786
+ this.log("Finalizing DIRECT address transfer for state tracking...");
7787
+ try {
7788
+ const signingService = await this.createSigningService();
7789
+ const transferSalt = transferTx.data.salt;
7790
+ const recipientPredicate = await UnmaskedPredicate.create(
7791
+ sourceToken.id,
7792
+ sourceToken.type,
7793
+ signingService,
7794
+ HashAlgorithm.SHA256,
7795
+ transferSalt
7796
+ );
7797
+ const recipientState = new TokenState$1(recipientPredicate, null);
7798
+ const stClient = this.deps.oracle.getStateTransitionClient?.();
7799
+ const trustBase = this.deps.oracle.getTrustBase?.();
7800
+ if (!stClient || !trustBase) {
7801
+ this.log("Cannot finalize DIRECT transfer - missing client, using source token");
7802
+ tokenData = sourceTokenInput;
7803
+ } else {
7804
+ finalizedSdkToken = await stClient.finalizeTransaction(
7805
+ trustBase,
7806
+ sourceToken,
7807
+ recipientState,
7808
+ transferTx,
7809
+ []
7810
+ // No nametag tokens needed for DIRECT
7811
+ );
7812
+ tokenData = finalizedSdkToken.toJSON();
7813
+ this.log("DIRECT transfer finalized successfully");
7814
+ }
7815
+ } catch (finalizeError) {
7816
+ this.log("DIRECT finalization failed, using source token:", finalizeError);
7817
+ tokenData = sourceTokenInput;
7818
+ }
7559
7819
  }
7560
7820
  } else if (payload.token) {
7561
7821
  tokenData = payload.token;
@@ -7589,7 +7849,7 @@ var PaymentsModule = class {
7589
7849
  await this.addToken(token);
7590
7850
  const incomingTransfer = {
7591
7851
  id: transfer.id,
7592
- senderPubkey: transfer.senderPubkey,
7852
+ senderPubkey: transfer.senderTransportPubkey,
7593
7853
  tokens: [token],
7594
7854
  memo: payload.memo,
7595
7855
  receivedAt: transfer.timestamp
@@ -7657,7 +7917,7 @@ var PaymentsModule = class {
7657
7917
  tokens,
7658
7918
  {
7659
7919
  version: 1,
7660
- address: this.deps.identity.address,
7920
+ address: this.deps.identity.l1Address,
7661
7921
  ipnsName: this.deps.identity.ipnsName ?? ""
7662
7922
  },
7663
7923
  {
@@ -7761,7 +8021,7 @@ var CommunicationsModule = class {
7761
8021
  const eventId = await this.deps.transport.sendMessage(recipientPubkey, content);
7762
8022
  const message = {
7763
8023
  id: eventId,
7764
- senderPubkey: this.deps.identity.publicKey,
8024
+ senderPubkey: this.deps.identity.chainPubkey,
7765
8025
  senderNametag: this.deps.identity.nametag,
7766
8026
  recipientPubkey,
7767
8027
  content,
@@ -7788,7 +8048,7 @@ var CommunicationsModule = class {
7788
8048
  getConversations() {
7789
8049
  const conversations = /* @__PURE__ */ new Map();
7790
8050
  for (const message of this.messages.values()) {
7791
- const peer = message.senderPubkey === this.deps?.identity.publicKey ? message.recipientPubkey : message.senderPubkey;
8051
+ const peer = message.senderPubkey === this.deps?.identity.chainPubkey ? message.recipientPubkey : message.senderPubkey;
7792
8052
  if (!conversations.has(peer)) {
7793
8053
  conversations.set(peer, []);
7794
8054
  }
@@ -7818,7 +8078,7 @@ var CommunicationsModule = class {
7818
8078
  */
7819
8079
  getUnreadCount(peerPubkey) {
7820
8080
  let messages = Array.from(this.messages.values()).filter(
7821
- (m) => !m.isRead && m.senderPubkey !== this.deps?.identity.publicKey
8081
+ (m) => !m.isRead && m.senderPubkey !== this.deps?.identity.chainPubkey
7822
8082
  );
7823
8083
  if (peerPubkey) {
7824
8084
  messages = messages.filter((m) => m.senderPubkey === peerPubkey);
@@ -7843,7 +8103,7 @@ var CommunicationsModule = class {
7843
8103
  const eventId = await this.deps.transport.publishBroadcast?.(content, tags);
7844
8104
  const message = {
7845
8105
  id: eventId ?? crypto.randomUUID(),
7846
- authorPubkey: this.deps.identity.publicKey,
8106
+ authorPubkey: this.deps.identity.chainPubkey,
7847
8107
  authorNametag: this.deps.identity.nametag,
7848
8108
  content,
7849
8109
  timestamp: Date.now(),
@@ -7894,11 +8154,12 @@ var CommunicationsModule = class {
7894
8154
  // Private: Message Handling
7895
8155
  // ===========================================================================
7896
8156
  handleIncomingMessage(msg) {
7897
- if (msg.senderPubkey === this.deps?.identity.publicKey) return;
8157
+ if (msg.senderTransportPubkey === this.deps?.identity.chainPubkey) return;
7898
8158
  const message = {
7899
8159
  id: msg.id,
7900
- senderPubkey: msg.senderPubkey,
7901
- recipientPubkey: this.deps.identity.publicKey,
8160
+ senderPubkey: msg.senderTransportPubkey,
8161
+ senderNametag: msg.senderNametag,
8162
+ recipientPubkey: this.deps.identity.chainPubkey,
7902
8163
  content: msg.content,
7903
8164
  timestamp: msg.timestamp,
7904
8165
  isRead: false
@@ -7920,7 +8181,7 @@ var CommunicationsModule = class {
7920
8181
  handleIncomingBroadcast(incoming) {
7921
8182
  const message = {
7922
8183
  id: incoming.id,
7923
- authorPubkey: incoming.authorPubkey,
8184
+ authorPubkey: incoming.authorTransportPubkey,
7924
8185
  content: incoming.content,
7925
8186
  timestamp: incoming.timestamp,
7926
8187
  tags: incoming.tags
@@ -8769,6 +9030,8 @@ var Sphere = class _Sphere {
8769
9030
  _Sphere.instance = sphere;
8770
9031
  if (options.nametag) {
8771
9032
  await sphere.registerNametag(options.nametag);
9033
+ } else {
9034
+ await sphere.recoverNametagFromNostr();
8772
9035
  }
8773
9036
  return sphere;
8774
9037
  }
@@ -8831,6 +9094,9 @@ var Sphere = class _Sphere {
8831
9094
  }
8832
9095
  await sphere.initializeProviders();
8833
9096
  await sphere.initializeModules();
9097
+ if (!options.nametag) {
9098
+ await sphere.recoverNametagFromNostr();
9099
+ }
8834
9100
  await sphere.finalizeWalletCreation();
8835
9101
  sphere._initialized = true;
8836
9102
  _Sphere.instance = sphere;
@@ -8904,9 +9170,9 @@ var Sphere = class _Sphere {
8904
9170
  get identity() {
8905
9171
  if (!this._identity) return null;
8906
9172
  return {
8907
- publicKey: this._identity.publicKey,
8908
- address: this._identity.address,
8909
- predicateAddress: this._identity.predicateAddress,
9173
+ chainPubkey: this._identity.chainPubkey,
9174
+ l1Address: this._identity.l1Address,
9175
+ directAddress: this._identity.directAddress,
8910
9176
  ipnsName: this._identity.ipnsName,
8911
9177
  nametag: this._identity.nametag
8912
9178
  };
@@ -9023,7 +9289,7 @@ var Sphere = class _Sphere {
9023
9289
  if (this._masterKey) {
9024
9290
  address0 = this.deriveAddress(0).address;
9025
9291
  } else if (this._identity) {
9026
- address0 = this._identity.address;
9292
+ address0 = this._identity.l1Address;
9027
9293
  }
9028
9294
  } catch {
9029
9295
  }
@@ -9070,8 +9336,8 @@ var Sphere = class _Sphere {
9070
9336
  } catch {
9071
9337
  if (i === 0 && this._identity) {
9072
9338
  addresses.push({
9073
- address: this._identity.address,
9074
- publicKey: this._identity.publicKey,
9339
+ address: this._identity.l1Address,
9340
+ publicKey: this._identity.chainPubkey,
9075
9341
  path: this.getDefaultAddressPath(),
9076
9342
  index: 0
9077
9343
  });
@@ -9150,7 +9416,7 @@ var Sphere = class _Sphere {
9150
9416
  } catch {
9151
9417
  if (i === 0 && this._identity) {
9152
9418
  addresses.push({
9153
- address: this._identity.address,
9419
+ address: this._identity.l1Address,
9154
9420
  path: this.getDefaultAddressPath(),
9155
9421
  index: 0,
9156
9422
  isChange: false
@@ -9504,9 +9770,9 @@ var Sphere = class _Sphere {
9504
9770
  const nametag = this._addressNametags.get(index);
9505
9771
  this._identity = {
9506
9772
  privateKey: addressInfo.privateKey,
9507
- publicKey: addressInfo.publicKey,
9508
- address: addressInfo.address,
9509
- predicateAddress,
9773
+ chainPubkey: addressInfo.publicKey,
9774
+ l1Address: addressInfo.address,
9775
+ directAddress: predicateAddress,
9510
9776
  ipnsName: "12D3KooW" + ipnsHash,
9511
9777
  nametag
9512
9778
  };
@@ -9519,13 +9785,13 @@ var Sphere = class _Sphere {
9519
9785
  }
9520
9786
  await this.reinitializeModulesForNewAddress();
9521
9787
  this.emitEvent("identity:changed", {
9522
- address: this._identity.address,
9523
- predicateAddress: this._identity.predicateAddress,
9524
- publicKey: this._identity.publicKey,
9788
+ l1Address: this._identity.l1Address,
9789
+ directAddress: this._identity.directAddress,
9790
+ chainPubkey: this._identity.chainPubkey,
9525
9791
  nametag: this._identity.nametag,
9526
9792
  addressIndex: index
9527
9793
  });
9528
- console.log(`[Sphere] Switched to address ${index}:`, this._identity.address);
9794
+ console.log(`[Sphere] Switched to address ${index}:`, this._identity.l1Address);
9529
9795
  }
9530
9796
  /**
9531
9797
  * Re-initialize modules after address switch
@@ -9583,7 +9849,7 @@ var Sphere = class _Sphere {
9583
9849
  );
9584
9850
  return {
9585
9851
  ...info,
9586
- address: "alpha1" + info.address.slice(0, 38)
9852
+ address: publicKeyToAddress(info.publicKey, "alpha")
9587
9853
  };
9588
9854
  }
9589
9855
  /**
@@ -9610,11 +9876,10 @@ var Sphere = class _Sphere {
9610
9876
  path
9611
9877
  );
9612
9878
  const publicKey = getPublicKey(derived.privateKey);
9613
- const addressHash = hash160(publicKey);
9614
9879
  return {
9615
9880
  privateKey: derived.privateKey,
9616
9881
  publicKey,
9617
- address: "alpha1" + addressHash.slice(0, 38),
9882
+ address: publicKeyToAddress(publicKey, "alpha"),
9618
9883
  path,
9619
9884
  index
9620
9885
  };
@@ -9702,6 +9967,17 @@ var Sphere = class _Sphere {
9702
9967
  hasNametag() {
9703
9968
  return !!this._identity?.nametag;
9704
9969
  }
9970
+ /**
9971
+ * Get the PROXY address for the current nametag
9972
+ * PROXY addresses are derived from the nametag hash and require
9973
+ * the nametag token to claim funds sent to them
9974
+ * @returns PROXY address string or undefined if no nametag
9975
+ */
9976
+ getProxyAddress() {
9977
+ const nametag = this._identity?.nametag;
9978
+ if (!nametag) return void 0;
9979
+ return `PROXY:${hashNametag(nametag)}`;
9980
+ }
9705
9981
  /**
9706
9982
  * Register a nametag for the current active address
9707
9983
  * Each address can have its own independent nametag
@@ -9730,7 +10006,11 @@ var Sphere = class _Sphere {
9730
10006
  throw new Error(`Nametag already registered for address ${this._currentAddressIndex}: @${this._identity.nametag}`);
9731
10007
  }
9732
10008
  if (this._transport.registerNametag) {
9733
- const success = await this._transport.registerNametag(cleanNametag, this._identity.publicKey);
10009
+ const success = await this._transport.registerNametag(
10010
+ cleanNametag,
10011
+ this._identity.chainPubkey,
10012
+ this._identity.directAddress || ""
10013
+ );
9734
10014
  if (!success) {
9735
10015
  throw new Error("Failed to register nametag. It may already be taken.");
9736
10016
  }
@@ -9824,7 +10104,11 @@ var Sphere = class _Sphere {
9824
10104
  return;
9825
10105
  }
9826
10106
  try {
9827
- const success = await this._transport.registerNametag(nametag, this._identity.publicKey);
10107
+ const success = await this._transport.registerNametag(
10108
+ nametag,
10109
+ this._identity.chainPubkey,
10110
+ this._identity.directAddress || ""
10111
+ );
9828
10112
  if (success) {
9829
10113
  console.log(`[Sphere] Nametag @${nametag} synced with Nostr`);
9830
10114
  } else {
@@ -9834,6 +10118,38 @@ var Sphere = class _Sphere {
9834
10118
  console.warn(`[Sphere] Nametag sync failed:`, error);
9835
10119
  }
9836
10120
  }
10121
+ /**
10122
+ * Recover nametag from Nostr after wallet import
10123
+ * Searches for encrypted nametag events authored by this wallet's pubkey
10124
+ * and decrypts them to restore the nametag association
10125
+ */
10126
+ async recoverNametagFromNostr() {
10127
+ if (this._identity?.nametag) {
10128
+ return;
10129
+ }
10130
+ if (!this._transport.recoverNametag) {
10131
+ return;
10132
+ }
10133
+ try {
10134
+ const recoveredNametag = await this._transport.recoverNametag();
10135
+ if (recoveredNametag) {
10136
+ if (this._identity) {
10137
+ this._identity.nametag = recoveredNametag;
10138
+ }
10139
+ this._addressNametags.set(this._currentAddressIndex, recoveredNametag);
10140
+ await this._storage.set(STORAGE_KEYS.NAMETAG, recoveredNametag);
10141
+ if (this._transport.registerNametag) {
10142
+ await this._transport.registerNametag(
10143
+ recoveredNametag,
10144
+ this._identity.chainPubkey,
10145
+ this._identity.directAddress || ""
10146
+ );
10147
+ }
10148
+ this.emitEvent("nametag:recovered", { nametag: recoveredNametag });
10149
+ }
10150
+ } catch {
10151
+ }
10152
+ }
9837
10153
  /**
9838
10154
  * Validate nametag format
9839
10155
  */
@@ -9960,57 +10276,64 @@ var Sphere = class _Sphere {
9960
10276
  const nametag = this._addressNametags.get(this._currentAddressIndex);
9961
10277
  this._identity = {
9962
10278
  privateKey: addressInfo.privateKey,
9963
- publicKey: addressInfo.publicKey,
9964
- address: addressInfo.address,
9965
- predicateAddress,
10279
+ chainPubkey: addressInfo.publicKey,
10280
+ l1Address: addressInfo.address,
10281
+ directAddress: predicateAddress,
9966
10282
  ipnsName: "12D3KooW" + ipnsHash,
9967
10283
  nametag
9968
10284
  };
9969
10285
  this._storage.setIdentity(this._identity);
9970
- console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
10286
+ console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.l1Address);
9971
10287
  } else {
9972
10288
  if (savedNametag && this._identity) {
9973
- this._identity.nametag = savedNametag;
10289
+ let nametag = savedNametag;
10290
+ if (savedNametag.startsWith("{")) {
10291
+ try {
10292
+ const parsed = JSON.parse(savedNametag);
10293
+ nametag = parsed["0"] || parsed[0] || Object.values(parsed)[0];
10294
+ } catch {
10295
+ }
10296
+ }
10297
+ this._identity.nametag = nametag;
9974
10298
  if (!this._addressNametags.has(0)) {
9975
- this._addressNametags.set(0, savedNametag);
10299
+ this._addressNametags.set(0, nametag);
9976
10300
  }
9977
- console.log("[Sphere] Restored nametag:", savedNametag);
9978
10301
  } else if (this._identity) {
9979
10302
  const nametag = this._addressNametags.get(0);
9980
10303
  if (nametag) {
9981
10304
  this._identity.nametag = nametag;
9982
- console.log("[Sphere] Restored nametag from map:", nametag);
9983
10305
  }
9984
10306
  }
9985
10307
  }
9986
10308
  }
9987
10309
  async initializeIdentityFromMnemonic(mnemonic, derivationPath) {
9988
- const path = derivationPath ?? DEFAULT_DERIVATION_PATH;
10310
+ const basePath = derivationPath ?? DEFAULT_BASE_PATH;
10311
+ const fullPath = `${basePath}/0/0`;
9989
10312
  const masterKey = identityFromMnemonicSync(mnemonic);
9990
10313
  const derivedKey = deriveKeyAtPath$1(
9991
10314
  masterKey.privateKey,
9992
10315
  masterKey.chainCode,
9993
- `${path}/0/0`
10316
+ fullPath
9994
10317
  );
9995
10318
  const publicKey = getPublicKey(derivedKey.privateKey);
9996
- const addressHash = hash160(publicKey);
10319
+ const address = publicKeyToAddress(publicKey, "alpha");
9997
10320
  const ipnsHash = sha256(publicKey, "hex").slice(0, 40);
9998
10321
  const predicateAddress = await deriveL3PredicateAddress(derivedKey.privateKey);
9999
10322
  this._identity = {
10000
10323
  privateKey: derivedKey.privateKey,
10001
- publicKey,
10002
- address: "alpha1" + addressHash.slice(0, 38),
10003
- predicateAddress,
10324
+ chainPubkey: publicKey,
10325
+ l1Address: address,
10326
+ directAddress: predicateAddress,
10004
10327
  ipnsName: "12D3KooW" + ipnsHash
10005
10328
  };
10006
10329
  this._masterKey = masterKey;
10007
- console.log("[Sphere] Identity initialized from mnemonic, path:", path);
10008
10330
  }
10009
10331
  async initializeIdentityFromMasterKey(masterKey, chainCode, derivationPath) {
10010
- const path = derivationPath ?? DEFAULT_DERIVATION_PATH;
10332
+ const basePath = derivationPath ?? DEFAULT_BASE_PATH;
10333
+ const fullPath = `${basePath}/0/0`;
10011
10334
  let privateKey;
10012
10335
  if (chainCode) {
10013
- const derivedKey = deriveKeyAtPath$1(masterKey, chainCode, `${path}/0/0`);
10336
+ const derivedKey = deriveKeyAtPath$1(masterKey, chainCode, fullPath);
10014
10337
  privateKey = derivedKey.privateKey;
10015
10338
  this._masterKey = {
10016
10339
  privateKey: masterKey,
@@ -10021,17 +10344,16 @@ var Sphere = class _Sphere {
10021
10344
  this._masterKey = null;
10022
10345
  }
10023
10346
  const publicKey = getPublicKey(privateKey);
10024
- const addressHash = hash160(publicKey);
10347
+ const address = publicKeyToAddress(publicKey, "alpha");
10025
10348
  const ipnsHash = sha256(publicKey, "hex").slice(0, 40);
10026
10349
  const predicateAddress = await deriveL3PredicateAddress(privateKey);
10027
10350
  this._identity = {
10028
10351
  privateKey,
10029
- publicKey,
10030
- address: "alpha1" + addressHash.slice(0, 38),
10031
- predicateAddress,
10352
+ chainPubkey: publicKey,
10353
+ l1Address: address,
10354
+ directAddress: predicateAddress,
10032
10355
  ipnsName: "12D3KooW" + ipnsHash
10033
10356
  };
10034
- console.log("[Sphere] Identity initialized from master key, path:", path, "chainCode:", !!chainCode);
10035
10357
  }
10036
10358
  // ===========================================================================
10037
10359
  // Private: Provider & Module Initialization
@@ -10526,4 +10848,4 @@ declare namespace index {
10526
10848
  export { type index_BlockHeader as BlockHeader, CHARSET$1 as CHARSET, type index_ClassificationResult as ClassificationResult, type index_ClassifiedUTXO as ClassifiedUTXO, type index_ExportOptions as ExportOptions, type index_RestoreWalletResult as RestoreWalletResult, type index_StoredWallet as StoredWallet, type index_Transaction as Transaction, type index_TransactionDetail as TransactionDetail, type index_TransactionHistoryItem as TransactionHistoryItem, type index_TransactionInput as TransactionInput, type index_TransactionOutput as TransactionOutput, type index_TransactionPlan as TransactionPlan, type index_UTXO as UTXO, index_VESTING_THRESHOLD as VESTING_THRESHOLD, type index_VestingBalances as VestingBalances, type index_VestingMode as VestingMode, type index_Wallet as Wallet, type index_WalletAddress as WalletAddress, index_WalletAddressHelper as WalletAddressHelper, type index_WalletJSON as WalletJSON, type index_WalletJSONAddress as WalletJSONAddress, type index_WalletJSONDerivationMode as WalletJSONDerivationMode, type index_WalletJSONExportOptions as WalletJSONExportOptions, type index_WalletJSONImportResult as WalletJSONImportResult, type index_WalletJSONSource as WalletJSONSource, addressToScriptHash$1 as addressToScriptHash, index_broadcast as broadcast, index_buildSegWitTransaction as buildSegWitTransaction, index_collectUtxosForAmount as collectUtxosForAmount, computeHash160$1 as computeHash160, index_connect as connect, convertBits$1 as convertBits, index_createAndSignTransaction as createAndSignTransaction, createBech32$1 as createBech32, index_createScriptPubKey as createScriptPubKey, index_createTransactionPlan as createTransactionPlan, decodeBech32$1 as decodeBech32, decrypt$1 as decrypt, decryptWallet$1 as decryptWallet, index_deriveChildKey as deriveChildKey, index_deriveChildKeyBIP32 as deriveChildKeyBIP32, index_deriveKeyAtPath as deriveKeyAtPath, index_disconnect as disconnect, domIdToPath$1 as domIdToPath, ec$1 as ec, encodeBech32$1 as encodeBech32, encrypt$1 as encrypt, encryptWallet$1 as encryptWallet, index_generateAddressFromMasterKey as generateAddressFromMasterKey, generateAddressInfo$1 as generateAddressInfo, index_generateHDAddress as generateHDAddress, index_generateHDAddressBIP32 as generateHDAddressBIP32, index_generateMasterKeyFromSeed as generateMasterKeyFromSeed, generatePrivateKey$1 as generatePrivateKey, index_getBalance as getBalance, index_getBlockHeader as getBlockHeader, index_getCurrentBlockHeight as getCurrentBlockHeight, getIndexFromPath$1 as getIndexFromPath, index_getTransaction as getTransaction, index_getTransactionHistory as getTransactionHistory, index_getUtxo as getUtxo, hash160$1 as hash160, hash160ToBytes$1 as hash160ToBytes, hexToWIF$1 as hexToWIF, isChangePath$1 as isChangePath, index_isWebSocketConnected as isWebSocketConnected, parsePathComponents$1 as parsePathComponents, pathToDOMId$1 as pathToDOMId, privateKeyToAddressInfo$1 as privateKeyToAddressInfo, publicKeyToAddress$1 as publicKeyToAddress, index_rpc as rpc, index_sendAlpha as sendAlpha, index_subscribeBlocks as subscribeBlocks, index_vestingClassifier as vestingClassifier, index_vestingState as vestingState, index_waitForConnection as waitForConnection };
10527
10849
  }
10528
10850
 
10529
- export { type AddressInfo, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, CommunicationsModule$1 as CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH$1 as DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule$1 as L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS$1 as LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NOSTR_EVENT_KINDS, type NametagData, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, PaymentsModule$1 as PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type ProviderMetadata, type ProviderStatus, STORAGE_KEYS$1 as STORAGE_KEYS, STORAGE_PREFIX$1 as STORAGE_PREFIX, type SaveResult, type SpentTokenInfo, type SpentTokenResult, Sphere$1 as Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenBalance, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TransferCommitment, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId$1 as archivedKeyFromTokenId, base58Decode$1 as base58Decode, base58Encode$1 as base58Encode, buildTxfStorageData$1 as buildTxfStorageData, bytesToHex$1 as bytesToHex, countCommittedTransactions, createAddress, createCommunicationsModule$1 as createCommunicationsModule, createKeyPair, createL1PaymentsModule, createPaymentsModule$1 as createPaymentsModule, createSphere, createTokenValidator, decodeBech32$1 as decodeBech32, decryptCMasterKey$1 as decryptCMasterKey, decryptPrivateKey$1 as decryptPrivateKey, decryptTextFormatKey$1 as decryptTextFormatKey, deriveAddressInfo$1 as deriveAddressInfo, deriveChildKey$2 as deriveChildKey, deriveKeyAtPath$2 as deriveKeyAtPath, doubleSha256, encodeBech32$1 as encodeBech32, extractFromText$1 as extractFromText, findPattern$1 as findPattern, forkedKeyFromTokenIdAndState$1 as forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey$1 as generateMasterKey, generateMnemonic, getAddressHrp, getCurrentStateHash$1 as getCurrentStateHash, getPublicKey$1 as getPublicKey, getSphere, getTokenId, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160$1 as hash160, hexToBytes, identityFromMnemonicSync$1 as identityFromMnemonicSync, initSphere, isArchivedKey$1 as isArchivedKey, isForkedKey$1 as isForkedKey, isSQLiteDatabase$1 as isSQLiteDatabase, isTextWalletEncrypted$1 as isTextWalletEncrypted, isTokenKey$1 as isTokenKey, isValidBech32, isValidPrivateKey$1 as isValidPrivateKey, isValidTokenId, isWalletDatEncrypted$1 as isWalletDatEncrypted, isWalletTextFormat$1 as isWalletTextFormat, keyFromTokenId$1 as keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage$1 as normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat$1 as parseAndDecryptWalletDat, parseAndDecryptWalletText$1 as parseAndDecryptWalletText, parseForkedKey$1 as parseForkedKey, parseTxfStorageData$1 as parseTxfStorageData, parseWalletDat$1 as parseWalletDat, parseWalletText$1 as parseWalletText, randomBytes, randomHex, randomUUID, ripemd160$1 as ripemd160, sha256$1 as sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey$1 as tokenIdFromArchivedKey, tokenIdFromKey$1 as tokenIdFromKey, tokenToTxf$1 as tokenToTxf, txfToToken$1 as txfToToken, validateMnemonic };
10851
+ export { type AddressInfo, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, CommunicationsModule$1 as CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule$1 as L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS$1 as LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NOSTR_EVENT_KINDS, type NametagData, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, PaymentsModule$1 as PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type ProviderMetadata, type ProviderStatus, STORAGE_KEYS$1 as STORAGE_KEYS, STORAGE_PREFIX$1 as STORAGE_PREFIX, type SaveResult, type SpentTokenInfo, type SpentTokenResult, Sphere$1 as Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenBalance, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TransferCommitment, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId$1 as archivedKeyFromTokenId, base58Decode$1 as base58Decode, base58Encode$1 as base58Encode, buildTxfStorageData$1 as buildTxfStorageData, bytesToHex$1 as bytesToHex, countCommittedTransactions, createAddress, createCommunicationsModule$1 as createCommunicationsModule, createKeyPair, createL1PaymentsModule, createPaymentsModule$1 as createPaymentsModule, createSphere, createTokenValidator, decodeBech32$1 as decodeBech32, decryptCMasterKey$1 as decryptCMasterKey, decryptPrivateKey$1 as decryptPrivateKey, decryptTextFormatKey$1 as decryptTextFormatKey, deriveAddressInfo$1 as deriveAddressInfo, deriveChildKey$2 as deriveChildKey, deriveKeyAtPath$2 as deriveKeyAtPath, doubleSha256, encodeBech32$1 as encodeBech32, extractFromText$1 as extractFromText, findPattern$1 as findPattern, forkedKeyFromTokenIdAndState$1 as forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey$1 as generateMasterKey, generateMnemonic, getAddressHrp, getCurrentStateHash$1 as getCurrentStateHash, getPublicKey$1 as getPublicKey, getSphere, getTokenId, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160$1 as hash160, hexToBytes, identityFromMnemonicSync$1 as identityFromMnemonicSync, initSphere, isArchivedKey$1 as isArchivedKey, isForkedKey$1 as isForkedKey, isSQLiteDatabase$1 as isSQLiteDatabase, isTextWalletEncrypted$1 as isTextWalletEncrypted, isTokenKey$1 as isTokenKey, isValidBech32, isValidPrivateKey$1 as isValidPrivateKey, isValidTokenId, isWalletDatEncrypted$1 as isWalletDatEncrypted, isWalletTextFormat$1 as isWalletTextFormat, keyFromTokenId$1 as keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage$1 as normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat$1 as parseAndDecryptWalletDat, parseAndDecryptWalletText$1 as parseAndDecryptWalletText, parseForkedKey$1 as parseForkedKey, parseTxfStorageData$1 as parseTxfStorageData, parseWalletDat$1 as parseWalletDat, parseWalletText$1 as parseWalletText, randomBytes, randomHex, randomUUID, ripemd160$1 as ripemd160, sha256$1 as sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey$1 as tokenIdFromArchivedKey, tokenIdFromKey$1 as tokenIdFromKey, tokenToTxf$1 as tokenToTxf, txfToToken$1 as txfToToken, validateMnemonic };