@hsuite/native-connect-angular 2.1.5 → 2.2.0
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/README.md +1 -0
- package/dist/LICENSE +146 -0
- package/dist/README.md +1 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +1798 -2295
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
- package/dist/index.d.ts +413 -705
- package/package.json +15 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Signal,
|
|
2
|
+
import { Signal, EventEmitter, OnInit, OnDestroy, TemplateRef, InjectionToken, Provider } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import * as i2 from '@ionic/angular';
|
|
5
5
|
import { ModalController as ModalController$1 } from '@ionic/angular';
|
|
6
6
|
import { ModalController, AlertController, ToastController } from '@ionic/angular/standalone';
|
|
7
7
|
import * as _hsuite_native_connect_sdk from '@hsuite/native-connect-sdk';
|
|
8
|
-
import { SupportedLedger, AuthSigningScheme, TransportState, Logger, TransportProvider,
|
|
8
|
+
import { SupportedLedger, AuthSigningScheme, ChannelState, TransportState, Logger, TransportProvider, ChannelAccount, ChannelInvite, ChannelType } from '@hsuite/native-connect-sdk';
|
|
9
9
|
export { ChannelAccount, ChannelInvite, ChannelMessage, ChannelState, ChannelType, HederaTransactionEncoder, MessageType, TransportState, XrplTransactionEncoder } from '@hsuite/native-connect-sdk';
|
|
10
10
|
import * as _hsuite_native_connect_angular from '@hsuite/native-connect-angular';
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
@@ -29,7 +29,6 @@ import { ISignClient } from '@walletconnect/types';
|
|
|
29
29
|
* **Provider Types:**
|
|
30
30
|
* - `hsuite-native` - HSuite Native Connect protocol
|
|
31
31
|
* - `walletconnect-v2` - WalletConnect v2 protocol
|
|
32
|
-
* - `mobile-native` - P2P Native mobile connections
|
|
33
32
|
*
|
|
34
33
|
* **Connection Status Lifecycle:**
|
|
35
34
|
* ```
|
|
@@ -47,9 +46,8 @@ import { ISignClient } from '@walletconnect/types';
|
|
|
47
46
|
*
|
|
48
47
|
* - `hsuite-native` - Direct HSuite wallet connections via Nostr/WebRTC
|
|
49
48
|
* - `walletconnect-v2` - WalletConnect v2 protocol for mobile wallets
|
|
50
|
-
* - `mobile-native` - Direct P2P connections to mobile wallets
|
|
51
49
|
*/
|
|
52
|
-
type ProviderType = 'hsuite-native' | 'walletconnect-v2'
|
|
50
|
+
type ProviderType = 'hsuite-native' | 'walletconnect-v2';
|
|
53
51
|
/**
|
|
54
52
|
* Connection status for a provider.
|
|
55
53
|
*
|
|
@@ -119,6 +117,30 @@ interface HsuiteNativeConfig {
|
|
|
119
117
|
/** Wallet origin to open. Defaults to {@link DEFAULT_WALLET_URL} (production); set to a dev server for local testing. */
|
|
120
118
|
walletUrl?: string;
|
|
121
119
|
metadata?: Record<string, unknown>;
|
|
120
|
+
/**
|
|
121
|
+
* Manual invite delivery hook. When provided, the provider does NOT deliver
|
|
122
|
+
* the invite itself (no local discovery, no deep link, no wallet window) —
|
|
123
|
+
* the callback receives the encoded invite and the dApp delivers it, e.g.
|
|
124
|
+
* rendered as a QR code for a cross-device wallet to scan. The connect()
|
|
125
|
+
* promise still resolves on wallet approval with the same timeout and error
|
|
126
|
+
* semantics as automatic delivery. To abandon a pending invite (user closed
|
|
127
|
+
* the QR view), pass `sessionKey` to the provider's `disconnectSession()`.
|
|
128
|
+
*/
|
|
129
|
+
onInviteReady?: (invite: HsuiteNativeInviteReady) => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Payload handed to {@link HsuiteNativeConfig.onInviteReady} once the channel
|
|
133
|
+
* invite exists and the provider is waiting for the wallet to join.
|
|
134
|
+
*/
|
|
135
|
+
interface HsuiteNativeInviteReady {
|
|
136
|
+
/** Raw encoded channel invite (`hsc:connect?i=…`) — render this as the QR code. */
|
|
137
|
+
qrData: string;
|
|
138
|
+
/** Wallet URL carrying the invite (`…?hsuite_invite=…`) for link-based delivery. */
|
|
139
|
+
inviteUrl: string;
|
|
140
|
+
/** Channel id of the pending session. */
|
|
141
|
+
channelId: string;
|
|
142
|
+
/** Session key (`native-<channelId>`) for `disconnectSession()` / session UIs. */
|
|
143
|
+
sessionKey: string;
|
|
122
144
|
}
|
|
123
145
|
/**
|
|
124
146
|
* WalletConnect v2 configuration.
|
|
@@ -142,23 +164,6 @@ interface WalletConnectV2Config {
|
|
|
142
164
|
appDescription?: string;
|
|
143
165
|
appIconUrl?: string;
|
|
144
166
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Mobile Native P2P configuration.
|
|
147
|
-
*
|
|
148
|
-
* @description
|
|
149
|
-
* Configuration for direct P2P connections to mobile wallets. This protocol
|
|
150
|
-
* bypasses relay servers for direct device-to-device communication.
|
|
151
|
-
*
|
|
152
|
-
* All fields are optional as the P2P provider can operate with defaults.
|
|
153
|
-
*/
|
|
154
|
-
interface MobileNativeConfig {
|
|
155
|
-
type: 'mobile-native';
|
|
156
|
-
appId?: string;
|
|
157
|
-
appName?: string;
|
|
158
|
-
ledgerId?: string;
|
|
159
|
-
networkId?: string;
|
|
160
|
-
metadata?: Record<string, unknown>;
|
|
161
|
-
}
|
|
162
167
|
/**
|
|
163
168
|
* Union type of all connection configurations.
|
|
164
169
|
*
|
|
@@ -166,7 +171,7 @@ interface MobileNativeConfig {
|
|
|
166
171
|
* Represents any valid connection configuration for the supported wallet providers.
|
|
167
172
|
* Use type guards from connection-config.model.ts to narrow to specific config types.
|
|
168
173
|
*/
|
|
169
|
-
type ConnectionConfig$1 = HsuiteNativeConfig | WalletConnectV2Config
|
|
174
|
+
type ConnectionConfig$1 = HsuiteNativeConfig | WalletConnectV2Config;
|
|
170
175
|
|
|
171
176
|
/**
|
|
172
177
|
* HSuite Native Connect
|
|
@@ -247,7 +252,7 @@ interface AccountWithBalance extends UnifiedAccount {
|
|
|
247
252
|
* visit https://hsuite.finance/licensing
|
|
248
253
|
*/
|
|
249
254
|
/**
|
|
250
|
-
* @
|
|
255
|
+
* @file Configuration models for different connection protocols.
|
|
251
256
|
*
|
|
252
257
|
* @module models/connection-config
|
|
253
258
|
*
|
|
@@ -260,7 +265,6 @@ interface AccountWithBalance extends UnifiedAccount {
|
|
|
260
265
|
* **Configuration Types:**
|
|
261
266
|
* - {@link HsuiteNativeConfig} - HSuite Native Connect protocol
|
|
262
267
|
* - {@link WalletConnectV2Config} - WalletConnect v2 protocol
|
|
263
|
-
* - {@link MobileNativeConfig} - P2P Native mobile connections
|
|
264
268
|
*/
|
|
265
269
|
|
|
266
270
|
/**
|
|
@@ -303,10 +307,9 @@ declare function isWalletConnectV2Config(config: ConnectionConfig): config is Wa
|
|
|
303
307
|
* It ensures consistency across different wallet connection protocols while allowing
|
|
304
308
|
* provider-specific implementations.
|
|
305
309
|
*
|
|
306
|
-
* The Angular SDK includes
|
|
310
|
+
* The Angular SDK includes two built-in providers:
|
|
307
311
|
* - **HsuiteNativeProvider**: HSuite Native Connect protocol
|
|
308
312
|
* - **WalletConnectV2Provider**: WalletConnect v2 protocol
|
|
309
|
-
* - **P2PNativeProvider**: Direct P2P connections via WebRTC
|
|
310
313
|
*
|
|
311
314
|
* Custom providers can extend this class to integrate additional wallet types.
|
|
312
315
|
*
|
|
@@ -468,6 +471,44 @@ interface SignMessageResult {
|
|
|
468
471
|
/** Additional metadata from the wallet. */
|
|
469
472
|
metadata?: Record<string, unknown>;
|
|
470
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Session snapshot exposed by providers that manage multiple concurrent
|
|
476
|
+
* sessions (WalletConnect pairings, HSuite Native channels).
|
|
477
|
+
*/
|
|
478
|
+
interface ProviderSessionInfo {
|
|
479
|
+
/** Provider-scoped session key (e.g. `wc-...`, `native-<channelId>`). */
|
|
480
|
+
sessionKey: string;
|
|
481
|
+
/** Accounts belonging to this session. */
|
|
482
|
+
accounts: UnifiedAccount[];
|
|
483
|
+
/** Ledger scope, when the provider tracks one per session. */
|
|
484
|
+
ledgerId?: string;
|
|
485
|
+
/** Network scope, when the provider tracks one per session. */
|
|
486
|
+
networkId?: string;
|
|
487
|
+
/** WalletConnect pairing topic (WC providers only). */
|
|
488
|
+
topic?: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Capability contract for providers that hold N concurrent sessions.
|
|
492
|
+
* Implemented structurally by WalletConnectV2Provider and
|
|
493
|
+
* HsuiteNativeProvider; UnifiedWalletService detects it via
|
|
494
|
+
* {@link supportsSessionManagement} instead of hardcoding provider ids.
|
|
495
|
+
*/
|
|
496
|
+
interface SessionManagingProvider {
|
|
497
|
+
/** Snapshot of every live session. */
|
|
498
|
+
getActiveSessions(): ProviderSessionInfo[];
|
|
499
|
+
/**
|
|
500
|
+
* Disconnect a single session by key, leaving others untouched.
|
|
501
|
+
*
|
|
502
|
+
* @param sessionKey - Session key from {@link getActiveSessions}
|
|
503
|
+
*/
|
|
504
|
+
disconnectSession(sessionKey: string): Promise<void>;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Type guard: does this provider manage sessions individually?
|
|
508
|
+
*
|
|
509
|
+
* @param provider - Any registered wallet provider
|
|
510
|
+
*/
|
|
511
|
+
declare function supportsSessionManagement(provider: BaseWalletProvider): provider is BaseWalletProvider & SessionManagingProvider;
|
|
471
512
|
/**
|
|
472
513
|
* Abstract base class that all wallet providers must implement.
|
|
473
514
|
*
|
|
@@ -633,6 +674,112 @@ declare abstract class BaseWalletProvider {
|
|
|
633
674
|
isConnected(): boolean;
|
|
634
675
|
}
|
|
635
676
|
|
|
677
|
+
/**
|
|
678
|
+
* HSuite Native Connect
|
|
679
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
680
|
+
*
|
|
681
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
682
|
+
*
|
|
683
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
684
|
+
* visit https://hsuite.finance/licensing
|
|
685
|
+
*/
|
|
686
|
+
/**
|
|
687
|
+
* @file native-session.model.ts
|
|
688
|
+
* @description Shared types for the multi-session HSuite Native channel stack.
|
|
689
|
+
*
|
|
690
|
+
* A "native session" is one live `hsc:` channel between this dApp and one
|
|
691
|
+
* wallet. The dApp may hold several concurrently (up to
|
|
692
|
+
* {@link MAX_NATIVE_SESSIONS}); each is addressed by a branded
|
|
693
|
+
* {@link NativeSessionKey} derived from its channel id, mirroring the
|
|
694
|
+
* WalletConnect session-store keying scheme.
|
|
695
|
+
*/
|
|
696
|
+
|
|
697
|
+
/** Prefix carried by every native session key. */
|
|
698
|
+
declare const NATIVE_SESSION_KEY_PREFIX = "native-";
|
|
699
|
+
/**
|
|
700
|
+
* Maximum concurrent native channel sessions per dApp. Each session owns its
|
|
701
|
+
* own ChannelClient (and relay WebSockets), so the cap bounds resource use.
|
|
702
|
+
*/
|
|
703
|
+
declare const MAX_NATIVE_SESSIONS = 5;
|
|
704
|
+
/**
|
|
705
|
+
* Branded session key for native channel sessions.
|
|
706
|
+
* Format: `native-<channelId>` — exactly one key per live channel.
|
|
707
|
+
*/
|
|
708
|
+
type NativeSessionKey = string & {
|
|
709
|
+
readonly __brand: 'NativeSessionKey';
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* Derive the session key for a channel id.
|
|
713
|
+
*
|
|
714
|
+
* @param channelId - The channel id from the invite
|
|
715
|
+
* @returns The branded session key
|
|
716
|
+
*/
|
|
717
|
+
declare function nativeSessionKeyFor(channelId: string): NativeSessionKey;
|
|
718
|
+
/**
|
|
719
|
+
* Validate and narrow an externally supplied string (e.g. a duck-typed
|
|
720
|
+
* `disconnectSession(sessionKey)` call from UnifiedWalletService) to a
|
|
721
|
+
* {@link NativeSessionKey}.
|
|
722
|
+
*
|
|
723
|
+
* @param value - Candidate session key
|
|
724
|
+
* @returns The branded session key
|
|
725
|
+
* @throws {Error} If the value does not carry the native key prefix
|
|
726
|
+
*/
|
|
727
|
+
declare function parseNativeSessionKey(value: string): NativeSessionKey;
|
|
728
|
+
/**
|
|
729
|
+
* Extract the channel id back out of a session key.
|
|
730
|
+
*
|
|
731
|
+
* @param key - The branded session key
|
|
732
|
+
* @returns The channel id the key was derived from
|
|
733
|
+
*/
|
|
734
|
+
declare function channelIdFromSessionKey(key: NativeSessionKey): string;
|
|
735
|
+
/**
|
|
736
|
+
* Thrown when a session-creating entry point (`connect()` or `resumeSession()`)
|
|
737
|
+
* would exceed {@link MAX_NATIVE_SESSIONS}.
|
|
738
|
+
*/
|
|
739
|
+
declare class NativeSessionLimitError extends Error {
|
|
740
|
+
readonly limit: number;
|
|
741
|
+
/**
|
|
742
|
+
* Create a limit error naming the cap that was hit.
|
|
743
|
+
*
|
|
744
|
+
* @param limit - The configured session cap that was hit
|
|
745
|
+
*/
|
|
746
|
+
constructor(limit: number);
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Snapshot of one live native session, for session-management UIs and the
|
|
750
|
+
* duck-typed `getActiveSessions()` provider surface.
|
|
751
|
+
*/
|
|
752
|
+
interface NativeActiveSession {
|
|
753
|
+
/** Branded key addressing this session. */
|
|
754
|
+
sessionKey: NativeSessionKey;
|
|
755
|
+
/** Underlying channel id. */
|
|
756
|
+
channelId: string;
|
|
757
|
+
/** Current channel state. */
|
|
758
|
+
state: ChannelState;
|
|
759
|
+
/** Current transport state (nostr-only, p2p-connected, ...). */
|
|
760
|
+
transportState: TransportState;
|
|
761
|
+
/** Ledger scope from the invite context (usually 'multi-chain'). */
|
|
762
|
+
ledgerId: string;
|
|
763
|
+
/** Network scope from the invite context. */
|
|
764
|
+
networkId: string;
|
|
765
|
+
/** Approved accounts, tagged with this session's key in metadata. */
|
|
766
|
+
accounts: UnifiedAccount[];
|
|
767
|
+
/** Channel creation time (ms epoch), when known. */
|
|
768
|
+
createdAt: number | undefined;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Payload delivered to `onSessionRemoved` listeners when a session leaves the
|
|
772
|
+
* store for a non-user-initiated reason.
|
|
773
|
+
*/
|
|
774
|
+
interface NativeSessionRemovalEvent {
|
|
775
|
+
/** Key of the removed session. */
|
|
776
|
+
sessionKey: NativeSessionKey;
|
|
777
|
+
/** Accounts the session carried when it was removed (best effort). */
|
|
778
|
+
accounts: UnifiedAccount[];
|
|
779
|
+
/** Why the session was removed. */
|
|
780
|
+
reason: 'wallet_terminated' | 'error' | 'subsumed';
|
|
781
|
+
}
|
|
782
|
+
|
|
636
783
|
/**
|
|
637
784
|
* HSuite Native Connect Provider.
|
|
638
785
|
*
|
|
@@ -746,6 +893,10 @@ declare class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
746
893
|
* 1. Tries hsuite: deep link to open native wallet app
|
|
747
894
|
* 2. Falls back to opening wallet in same tab (PWA) or new tab
|
|
748
895
|
*
|
|
896
|
+
* **Manual delivery** (`config.onInviteReady` set): none of the above —
|
|
897
|
+
* the encoded invite is handed to the callback and the dApp delivers it
|
|
898
|
+
* itself (e.g. rendered as a QR code for a cross-device wallet to scan).
|
|
899
|
+
*
|
|
749
900
|
* The connection completes when the wallet user approves the session.
|
|
750
901
|
*
|
|
751
902
|
* @param config - HSuite Native connection configuration
|
|
@@ -777,11 +928,6 @@ declare class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
777
928
|
* @param url
|
|
778
929
|
*/
|
|
779
930
|
private isSameOrigin;
|
|
780
|
-
/**
|
|
781
|
-
* Wait for channel connection to be established
|
|
782
|
-
* @param timeoutMs
|
|
783
|
-
*/
|
|
784
|
-
private waitForConnection;
|
|
785
931
|
/**
|
|
786
932
|
* Disconnects from the HSuite Wallet.
|
|
787
933
|
*
|
|
@@ -902,553 +1048,39 @@ declare class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
902
1048
|
*/
|
|
903
1049
|
attemptReconnect(): Promise<boolean>;
|
|
904
1050
|
/**
|
|
905
|
-
*
|
|
906
|
-
* @param config
|
|
907
|
-
*/
|
|
908
|
-
private isHsuiteNativeConfig;
|
|
909
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<HsuiteNativeProvider, never>;
|
|
910
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<HsuiteNativeProvider>;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
/**
|
|
914
|
-
* HSuite Native Connect
|
|
915
|
-
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
916
|
-
*
|
|
917
|
-
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
918
|
-
*
|
|
919
|
-
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
920
|
-
* visit https://hsuite.finance/licensing
|
|
921
|
-
*/
|
|
922
|
-
/**
|
|
923
|
-
* @file p2p-session-manager.ts
|
|
924
|
-
* @description Session management for P2P Native connections (dApp-side)
|
|
925
|
-
*
|
|
926
|
-
* Manages Nostr-first P2P connections for wallet pairing (both mobile and desktop).
|
|
927
|
-
* The dApp creates a session invite QR code that the wallet scans.
|
|
928
|
-
* Communication starts via Nostr relays and upgrades to WebRTC P2P when possible.
|
|
929
|
-
*
|
|
930
|
-
* **Architecture Notes:**
|
|
931
|
-
* - Uses the unified ChannelClient for Nostr/P2P communication
|
|
932
|
-
* - Single QR code scanning (no 2-phase exchange)
|
|
933
|
-
* - Session negotiation via Nostr, then P2P upgrade
|
|
934
|
-
* - RPC communication over best available transport
|
|
935
|
-
* - Session ownership remains with the wallet
|
|
936
|
-
*/
|
|
937
|
-
|
|
938
|
-
/**
|
|
939
|
-
* Connection state for P2P native sessions.
|
|
940
|
-
*
|
|
941
|
-
* States:
|
|
942
|
-
* - idle: No connection attempt in progress
|
|
943
|
-
* - creating_offer: Generating session invite for QR code
|
|
944
|
-
* - awaiting_connection: QR displayed, waiting for wallet to scan and connect
|
|
945
|
-
* - pending_approval: Wallet connected, waiting for user to approve session
|
|
946
|
-
* - connected: Session approved and fully connected
|
|
947
|
-
* - disconnected: Previously connected, now disconnected
|
|
948
|
-
* - error: Connection or handshake error occurred
|
|
949
|
-
*/
|
|
950
|
-
type P2PConnectionState = 'idle' | 'creating_offer' | 'awaiting_connection' | 'pending_approval' | 'connected' | 'disconnected' | 'error';
|
|
951
|
-
/**
|
|
952
|
-
* Options for creating a pairing offer
|
|
953
|
-
*/
|
|
954
|
-
interface CreateOfferOptions {
|
|
955
|
-
appId: string;
|
|
956
|
-
appName: string;
|
|
957
|
-
ledgerId: string;
|
|
958
|
-
networkId: string;
|
|
959
|
-
metadata?: Record<string, unknown>;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Result of creating a pairing offer
|
|
963
|
-
*/
|
|
964
|
-
interface CreateOfferResult {
|
|
965
|
-
/** Encoded QR data (nostr+p2p://...) */
|
|
966
|
-
qrData: string;
|
|
967
|
-
/** Channel ID for this connection attempt */
|
|
968
|
-
sessionId: string;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Managed session data
|
|
972
|
-
*/
|
|
973
|
-
interface P2PSession {
|
|
974
|
-
id: string;
|
|
975
|
-
sessionId: string;
|
|
976
|
-
appId: string;
|
|
977
|
-
appName: string;
|
|
978
|
-
ledgerId: string;
|
|
979
|
-
networkId: string;
|
|
980
|
-
accounts: UnifiedAccount[];
|
|
981
|
-
permissions: string[];
|
|
982
|
-
connectedAt: number;
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
* Transaction options for RPC calls
|
|
986
|
-
*/
|
|
987
|
-
interface TransactionOptions {
|
|
988
|
-
accountAddress: string;
|
|
989
|
-
payload: string;
|
|
990
|
-
ledgerId?: string;
|
|
991
|
-
networkId?: string;
|
|
992
|
-
isBatch?: boolean;
|
|
993
|
-
batchKey?: string;
|
|
994
|
-
innerTransactions?: Array<{
|
|
995
|
-
payload: string;
|
|
996
|
-
description?: string;
|
|
997
|
-
}>;
|
|
998
|
-
}
|
|
999
|
-
/**
|
|
1000
|
-
* Message signing options
|
|
1001
|
-
*/
|
|
1002
|
-
interface MessageSigningOptions {
|
|
1003
|
-
accountAddress: string;
|
|
1004
|
-
message: string;
|
|
1005
|
-
encoding?: 'utf-8' | 'base64';
|
|
1006
|
-
ledgerId?: string;
|
|
1007
|
-
networkId?: string;
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Mobile Native Session Manager
|
|
1011
|
-
*
|
|
1012
|
-
* Manages Nostr-first P2P connections for mobile wallet pairing.
|
|
1013
|
-
* Creates and displays QR codes that mobile wallets can scan
|
|
1014
|
-
* to establish a direct, end-to-end encrypted connection.
|
|
1015
|
-
*
|
|
1016
|
-
* Uses single QR code scanning with Nostr for initial signaling
|
|
1017
|
-
* and automatic P2P upgrade when possible.
|
|
1018
|
-
*
|
|
1019
|
-
* This implementation uses the unified ChannelClient from the new channel protocol.
|
|
1020
|
-
*/
|
|
1021
|
-
declare class P2PSessionManager {
|
|
1022
|
-
private readonly _connectionState;
|
|
1023
|
-
private readonly _currentSession;
|
|
1024
|
-
private readonly _p2pState;
|
|
1025
|
-
private client?;
|
|
1026
|
-
private currentInvite?;
|
|
1027
|
-
private connectedCallbacks;
|
|
1028
|
-
private disconnectedCallbacks;
|
|
1029
|
-
private errorCallbacks;
|
|
1030
|
-
private accountsChangedCallbacks;
|
|
1031
|
-
private zone?;
|
|
1032
|
-
private sessionApprovalPromise?;
|
|
1033
|
-
/**
|
|
1034
|
-
*
|
|
1035
|
-
*/
|
|
1036
|
-
constructor();
|
|
1037
|
-
/**
|
|
1038
|
-
* Set NgZone for Angular change detection
|
|
1039
|
-
* @param zone
|
|
1040
|
-
*/
|
|
1041
|
-
setNgZone(zone: NgZone): void;
|
|
1042
|
-
/**
|
|
1043
|
-
* Current connection state
|
|
1044
|
-
*/
|
|
1045
|
-
get connectionState(): Signal<P2PConnectionState>;
|
|
1046
|
-
/**
|
|
1047
|
-
* Current session
|
|
1048
|
-
*/
|
|
1049
|
-
get currentSession(): Signal<P2PSession | null>;
|
|
1050
|
-
/**
|
|
1051
|
-
* Current P2P upgrade state
|
|
1052
|
-
*/
|
|
1053
|
-
get p2pState(): Signal<TransportState>;
|
|
1054
|
-
/**
|
|
1055
|
-
* Create a pairing offer for QR code display.
|
|
1056
|
-
*
|
|
1057
|
-
* Generates a compact session invite encoded for QR code display.
|
|
1058
|
-
* The invite contains the channel ID, encryption key, and Nostr relays.
|
|
1059
|
-
*
|
|
1060
|
-
* @param options - Offer creation options
|
|
1061
|
-
* @returns Promise resolving to offer result with QR data
|
|
1062
|
-
*/
|
|
1063
|
-
createPairingOffer(options: CreateOfferOptions): Promise<CreateOfferResult>;
|
|
1064
|
-
/**
|
|
1065
|
-
* Wait for wallet to connect and approve the session.
|
|
1066
|
-
*
|
|
1067
|
-
* This method blocks until the wallet scans the QR, connects via Nostr,
|
|
1068
|
-
* and the user approves the session.
|
|
1069
|
-
*
|
|
1070
|
-
* @returns Promise resolving to the approved session
|
|
1071
|
-
*/
|
|
1072
|
-
waitForSessionApproval(): Promise<P2PSession>;
|
|
1073
|
-
/**
|
|
1074
|
-
* Cancel the current pairing offer.
|
|
1075
|
-
*
|
|
1076
|
-
* Cleans up the transport without fully disconnecting.
|
|
1077
|
-
*/
|
|
1078
|
-
cancelPairingOffer(): Promise<void>;
|
|
1079
|
-
/**
|
|
1080
|
-
* @param callback
|
|
1081
|
-
* Register callback for when peer connects
|
|
1082
|
-
*/
|
|
1083
|
-
onConnected(callback: (session: P2PSession) => void): void;
|
|
1084
|
-
/**
|
|
1085
|
-
* @param callback
|
|
1086
|
-
* Register callback for disconnection
|
|
1087
|
-
*/
|
|
1088
|
-
onDisconnected(callback: () => void): void;
|
|
1089
|
-
/**
|
|
1090
|
-
* @param callback
|
|
1091
|
-
* Register callback for errors
|
|
1092
|
-
*/
|
|
1093
|
-
onError(callback: (error: Error) => void): void;
|
|
1094
|
-
/**
|
|
1095
|
-
* @param callback
|
|
1096
|
-
* Register callback for accounts changes
|
|
1097
|
-
*/
|
|
1098
|
-
onAccountsChanged(callback: (accounts: UnifiedAccount[]) => void): void;
|
|
1099
|
-
/**
|
|
1100
|
-
* @param options
|
|
1101
|
-
* Sign a transaction via RPC
|
|
1102
|
-
*/
|
|
1103
|
-
signTransaction(options: TransactionOptions): Promise<{
|
|
1104
|
-
signedPayload: string;
|
|
1105
|
-
signature?: string;
|
|
1106
|
-
metadata?: Record<string, unknown>;
|
|
1107
|
-
}>;
|
|
1108
|
-
/**
|
|
1109
|
-
* @param options
|
|
1110
|
-
* Submit a transaction via RPC
|
|
1111
|
-
*/
|
|
1112
|
-
submitTransaction(options: TransactionOptions): Promise<{
|
|
1113
|
-
transactionId: string;
|
|
1114
|
-
transactionHash?: string;
|
|
1115
|
-
metadata?: Record<string, unknown>;
|
|
1116
|
-
}>;
|
|
1117
|
-
/**
|
|
1118
|
-
* @param options
|
|
1119
|
-
* Sign an arbitrary message via RPC
|
|
1120
|
-
*/
|
|
1121
|
-
signMessage(options: MessageSigningOptions): Promise<{
|
|
1122
|
-
signature: string;
|
|
1123
|
-
publicKey?: string;
|
|
1124
|
-
algorithm?: 'ed25519' | 'ecdsa_secp256k1' | 'secp256k1';
|
|
1125
|
-
encoding?: 'utf-8' | 'base64';
|
|
1126
|
-
caipChainId?: string;
|
|
1127
|
-
messageLength?: number;
|
|
1128
|
-
metadata?: Record<string, unknown>;
|
|
1129
|
-
}>;
|
|
1130
|
-
/**
|
|
1131
|
-
* Terminate the current session
|
|
1132
|
-
*/
|
|
1133
|
-
terminateSession(): Promise<void>;
|
|
1134
|
-
/**
|
|
1135
|
-
* Run function in NgZone if available
|
|
1136
|
-
* @param fn
|
|
1137
|
-
*/
|
|
1138
|
-
private runInZone;
|
|
1139
|
-
/**
|
|
1140
|
-
* Start polling for state changes from the channel client
|
|
1141
|
-
*/
|
|
1142
|
-
private startStateSync;
|
|
1143
|
-
/**
|
|
1144
|
-
* Handle channel state changes
|
|
1145
|
-
* @param state
|
|
1146
|
-
* @param accounts
|
|
1147
|
-
*/
|
|
1148
|
-
private handleStateChange;
|
|
1149
|
-
/**
|
|
1150
|
-
* Create a P2PSession from channel accounts
|
|
1151
|
-
* @param accounts
|
|
1152
|
-
*/
|
|
1153
|
-
private createSession;
|
|
1154
|
-
/**
|
|
1155
|
-
* Handle disconnection
|
|
1156
|
-
* @param reason
|
|
1157
|
-
*/
|
|
1158
|
-
private handleDisconnection;
|
|
1159
|
-
/**
|
|
1160
|
-
* Require active session or throw
|
|
1161
|
-
*/
|
|
1162
|
-
private requireSession;
|
|
1163
|
-
/**
|
|
1164
|
-
* Clean up resources.
|
|
1165
|
-
*
|
|
1166
|
-
* @param rejectPending - If true, reject pending promises with error.
|
|
1167
|
-
* If false, clear them silently (for new session creation).
|
|
1168
|
-
*/
|
|
1169
|
-
private cleanup;
|
|
1170
|
-
/**
|
|
1171
|
-
* Notify connected callbacks
|
|
1172
|
-
* @param session
|
|
1173
|
-
*/
|
|
1174
|
-
private notifyConnected;
|
|
1175
|
-
/**
|
|
1176
|
-
* Notify disconnected callbacks
|
|
1177
|
-
*/
|
|
1178
|
-
private notifyDisconnected;
|
|
1179
|
-
/**
|
|
1180
|
-
* Notify error callbacks
|
|
1181
|
-
* @param error
|
|
1182
|
-
*/
|
|
1183
|
-
private notifyError;
|
|
1184
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<P2PSessionManager, never>;
|
|
1185
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<P2PSessionManager>;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Connection state for the mobile native provider.
|
|
1190
|
-
*
|
|
1191
|
-
* States:
|
|
1192
|
-
* - disconnected: No connection
|
|
1193
|
-
* - generating_offer: Creating WebRTC offer for QR display
|
|
1194
|
-
* - awaiting_scan: QR displayed, waiting for wallet to scan
|
|
1195
|
-
* - connecting: WebRTC handshake in progress
|
|
1196
|
-
* - pending_approval: WebRTC connected, waiting for wallet user to approve
|
|
1197
|
-
* - connected: Session approved and fully connected
|
|
1198
|
-
* - error: An error occurred
|
|
1199
|
-
*/
|
|
1200
|
-
type P2PNativeConnectionState = 'disconnected' | 'generating_offer' | 'awaiting_scan' | 'connecting' | 'pending_approval' | 'connected' | 'error';
|
|
1201
|
-
/**
|
|
1202
|
-
* Pairing offer result containing QR data
|
|
1203
|
-
*/
|
|
1204
|
-
interface PairingOfferResult {
|
|
1205
|
-
/** Encoded channel invite for QR code display (hsc:connect?i=...) */
|
|
1206
|
-
qrData: string;
|
|
1207
|
-
/** Session ID for this connection */
|
|
1208
|
-
sessionId?: string;
|
|
1209
|
-
/** Expiry timestamp */
|
|
1210
|
-
expiresAt: number;
|
|
1211
|
-
}
|
|
1212
|
-
/**
|
|
1213
|
-
* P2P Native Provider for cross-device wallet connections.
|
|
1214
|
-
*
|
|
1215
|
-
* @description
|
|
1216
|
-
* Enables secure P2P wallet connections via WebRTC for mobile and cross-device
|
|
1217
|
-
* scenarios. The dApp generates a QR code containing a channel invite, which
|
|
1218
|
-
* the mobile wallet scans to establish a direct encrypted connection.
|
|
1219
|
-
*
|
|
1220
|
-
* Key Features:
|
|
1221
|
-
* - **Single QR Code Flow**: No answer QR needed - just scan and connect
|
|
1222
|
-
* - **Nostr-First**: Uses Nostr relays for signaling and fallback
|
|
1223
|
-
* - **Automatic P2P Upgrade**: Upgrades to WebRTC for lower latency
|
|
1224
|
-
* - **End-to-End Encrypted**: AES-GCM over Nostr, DTLS over WebRTC
|
|
1225
|
-
* - **Session Persistence**: Supports reconnection after page reload
|
|
1226
|
-
*
|
|
1227
|
-
* Transport States (via `transportState` signal):
|
|
1228
|
-
* - `'nostr-only'` - Connected via Nostr relay only
|
|
1229
|
-
* - `'upgrading'` - P2P upgrade in progress
|
|
1230
|
-
* - `'p2p-connected'` - Direct P2P connection established
|
|
1231
|
-
* - `'p2p-failed'` - P2P upgrade failed, using Nostr fallback
|
|
1232
|
-
*
|
|
1233
|
-
* @publicApi
|
|
1234
|
-
*/
|
|
1235
|
-
declare class P2PNativeProvider extends BaseWalletProvider {
|
|
1236
|
-
private readonly sessionManager;
|
|
1237
|
-
private readonly ngZone;
|
|
1238
|
-
readonly id = "mobile-native";
|
|
1239
|
-
readonly metadata: ProviderMetadata;
|
|
1240
|
-
private readonly _status;
|
|
1241
|
-
private readonly _accounts;
|
|
1242
|
-
private readonly _error;
|
|
1243
|
-
private readonly _connectionState;
|
|
1244
|
-
private readonly _pairingOffer;
|
|
1245
|
-
/** Session persistence for page reload recovery */
|
|
1246
|
-
private readonly sessionPersistence;
|
|
1247
|
-
readonly status: Signal<ConnectionStatus>;
|
|
1248
|
-
readonly accounts: Signal<UnifiedAccount[]>;
|
|
1249
|
-
readonly error: Signal<string | null>;
|
|
1250
|
-
/**
|
|
1251
|
-
* Current detailed connection state
|
|
1252
|
-
*/
|
|
1253
|
-
readonly connectionState: Signal<P2PNativeConnectionState>;
|
|
1254
|
-
/**
|
|
1255
|
-
* Current pairing offer (if awaiting scan)
|
|
1256
|
-
*/
|
|
1257
|
-
readonly pairingOffer: Signal<PairingOfferResult | null>;
|
|
1258
|
-
/**
|
|
1259
|
-
* Whether currently awaiting wallet to scan QR
|
|
1260
|
-
*/
|
|
1261
|
-
readonly isAwaitingScan: Signal<boolean>;
|
|
1262
|
-
/**
|
|
1263
|
-
* Whether a pairing offer is available
|
|
1264
|
-
*/
|
|
1265
|
-
readonly hasPairingOffer: Signal<boolean>;
|
|
1266
|
-
/**
|
|
1267
|
-
* Whether a persisted session exists
|
|
1268
|
-
*/
|
|
1269
|
-
readonly hasPersistedSession: Signal<boolean>;
|
|
1270
|
-
/**
|
|
1271
|
-
* Transport state for the P2P connection.
|
|
1272
|
-
* Values: 'nostr-only' | 'upgrading' | 'p2p-connected' | 'p2p-failed'
|
|
1273
|
-
*
|
|
1274
|
-
* This allows the UI to show the current transport layer being used.
|
|
1275
|
-
*/
|
|
1276
|
-
readonly transportState: Signal<_hsuite_native_connect_sdk.TransportState>;
|
|
1277
|
-
/**
|
|
1278
|
-
* @param sessionManager
|
|
1279
|
-
* @param ngZone
|
|
1280
|
-
*/
|
|
1281
|
-
constructor(sessionManager: P2PSessionManager, ngZone: NgZone);
|
|
1282
|
-
/**
|
|
1283
|
-
* Restore session from localStorage on page load.
|
|
1284
|
-
* Sets accounts and status from persisted data.
|
|
1285
|
-
* Note: This only restores metadata - the actual WebRTC connection
|
|
1286
|
-
* will need to be re-established via QR pairing.
|
|
1287
|
-
*/
|
|
1288
|
-
private restorePersistedSession;
|
|
1289
|
-
/**
|
|
1290
|
-
* Creates a pairing offer for QR code display.
|
|
1291
|
-
*
|
|
1292
|
-
* @description
|
|
1293
|
-
* Generates a channel invite encoded for QR display. The mobile wallet
|
|
1294
|
-
* scans this QR code to establish a connection via Nostr relays with
|
|
1295
|
-
* automatic P2P upgrade.
|
|
1296
|
-
*
|
|
1297
|
-
* The returned `qrData` is a compact `hsc:connect?i=...` URL that contains:
|
|
1298
|
-
* - Channel ID and encryption keys
|
|
1299
|
-
* - App metadata (name, ID)
|
|
1300
|
-
* - Relay endpoints for communication
|
|
1301
|
-
*
|
|
1302
|
-
* @param config - Connection configuration specifying ledger and network
|
|
1303
|
-
*
|
|
1304
|
-
* @returns Promise resolving to pairing offer containing QR data and expiry
|
|
1305
|
-
*
|
|
1306
|
-
* @throws {Error} If offer generation fails
|
|
1307
|
-
*/
|
|
1308
|
-
createPairingOffer(config: ConnectionConfig$1): Promise<PairingOfferResult>;
|
|
1309
|
-
/**
|
|
1310
|
-
* Refresh the pairing offer (e.g., when expired).
|
|
1311
|
-
*
|
|
1312
|
-
* @param config - Connection configuration
|
|
1313
|
-
* @returns Promise resolving to new pairing offer
|
|
1314
|
-
*/
|
|
1315
|
-
refreshPairingOffer(config: ConnectionConfig$1): Promise<PairingOfferResult>;
|
|
1316
|
-
/**
|
|
1317
|
-
* Register callback for when peer connects.
|
|
1318
|
-
*
|
|
1319
|
-
* @param callback - Function to call when connection is established
|
|
1320
|
-
*/
|
|
1321
|
-
onPeerConnected(callback: () => void): void;
|
|
1322
|
-
/**
|
|
1323
|
-
* Waits for the wallet to connect and approve the session.
|
|
1324
|
-
*
|
|
1325
|
-
* @description
|
|
1326
|
-
* Call this after {@link createPairingOffer} to block until the wallet user
|
|
1327
|
-
* completes the connection flow. This is the single-QR flow - no answer
|
|
1328
|
-
* scanning is required.
|
|
1329
|
-
*
|
|
1330
|
-
* The method resolves when all of the following occur:
|
|
1331
|
-
* 1. Wallet scans the QR code
|
|
1332
|
-
* 2. Wallet connects via Nostr relay
|
|
1333
|
-
* 3. User approves the session in the wallet
|
|
1334
|
-
*
|
|
1335
|
-
* Upon success, the session is automatically persisted for reconnection.
|
|
1336
|
-
*
|
|
1337
|
-
* @returns Promise resolving to the approved session with account information
|
|
1338
|
-
*
|
|
1339
|
-
* @throws {Error} If connection fails or is rejected
|
|
1340
|
-
* @throws {Error} If no pairing offer was created
|
|
1341
|
-
*/
|
|
1342
|
-
waitForSessionApproval(): Promise<P2PSession>;
|
|
1343
|
-
/**
|
|
1344
|
-
* Connects to a wallet via the P2P pairing flow.
|
|
1345
|
-
*
|
|
1346
|
-
* @description
|
|
1347
|
-
* Initiates the pairing offer flow and waits for connection. For more
|
|
1348
|
-
* control over QR display timing, use {@link createPairingOffer} and
|
|
1349
|
-
* {@link waitForSessionApproval} separately.
|
|
1350
|
-
*
|
|
1351
|
-
* This method:
|
|
1352
|
-
* 1. Creates a pairing offer
|
|
1353
|
-
* 2. Updates `pairingOffer` signal with QR data
|
|
1354
|
-
* 3. Waits up to 2 minutes for wallet to connect
|
|
1355
|
-
*
|
|
1356
|
-
* @param config - Connection configuration
|
|
1357
|
-
*
|
|
1358
|
-
* @throws {Error} If already connected (no-op)
|
|
1359
|
-
* @throws {Error} If connection times out (2 minutes)
|
|
1360
|
-
*/
|
|
1361
|
-
connect(config: ConnectionConfig$1): Promise<void>;
|
|
1362
|
-
/**
|
|
1363
|
-
* Disconnects from the wallet and clears session.
|
|
1364
|
-
*
|
|
1365
|
-
* @description
|
|
1366
|
-
* Terminates the P2P session, clears all state signals, and removes
|
|
1367
|
-
* persisted session data. The wallet is notified of the disconnection.
|
|
1368
|
-
*/
|
|
1369
|
-
disconnect(): Promise<void>;
|
|
1370
|
-
/**
|
|
1371
|
-
* Signs a transaction without submitting it.
|
|
1051
|
+
* Snapshot of every live native session.
|
|
1372
1052
|
*
|
|
1373
1053
|
* @description
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
* @param options - Transaction signing options
|
|
1378
|
-
*
|
|
1379
|
-
* @returns Promise resolving to signed payload and signature
|
|
1380
|
-
*
|
|
1381
|
-
* @throws {Error} If not connected to wallet
|
|
1382
|
-
* @throws {Error} If user rejects signing
|
|
1383
|
-
*/
|
|
1384
|
-
signTransaction(options: SignTransactionOptions): Promise<SignResult>;
|
|
1385
|
-
/**
|
|
1386
|
-
* Signs and submits a transaction to the blockchain.
|
|
1387
|
-
*
|
|
1388
|
-
* @description
|
|
1389
|
-
* Performs atomic sign and submit in a single operation. Supports batch
|
|
1390
|
-
* transactions when isBatch is true.
|
|
1391
|
-
*
|
|
1392
|
-
* @param options - Transaction submission options
|
|
1054
|
+
* Duck-typed by UnifiedWalletService.getActiveSessions via the
|
|
1055
|
+
* `SessionManagingProvider` capability — same surface WalletConnect
|
|
1056
|
+
* exposes, so session-management UIs treat both protocols uniformly.
|
|
1393
1057
|
*
|
|
1394
|
-
* @returns
|
|
1395
|
-
*
|
|
1396
|
-
* @throws {Error} If not connected to wallet
|
|
1397
|
-
* @throws {Error} If user rejects or transaction fails
|
|
1058
|
+
* @returns One entry per live channel session
|
|
1398
1059
|
*/
|
|
1399
|
-
|
|
1060
|
+
getActiveSessions(): NativeActiveSession[];
|
|
1400
1061
|
/**
|
|
1401
|
-
*
|
|
1062
|
+
* Disconnects a single native session, leaving others untouched.
|
|
1402
1063
|
*
|
|
1403
|
-
* @
|
|
1404
|
-
*
|
|
1405
|
-
* {@link UnifiedWalletService.signAndExecuteTransaction} can detect native
|
|
1406
|
-
* atomic sign+submit support on the provider (via duck-typing) and avoid
|
|
1407
|
-
* its fallback path that chains separate signTransaction + submitTransaction
|
|
1408
|
-
* calls. Mirrors the pattern used by HsuiteNativeProvider and the
|
|
1409
|
-
* WalletConnect signers.
|
|
1410
|
-
*
|
|
1411
|
-
* @param options - Transaction submission options
|
|
1064
|
+
* @param sessionKey - Session key from {@link getActiveSessions} /
|
|
1065
|
+
* account metadata (format `native-<channelId>`)
|
|
1412
1066
|
*
|
|
1413
|
-
* @
|
|
1067
|
+
* @throws {Error} If the key is not a native session key
|
|
1414
1068
|
*/
|
|
1415
|
-
|
|
1416
|
-
/**
|
|
1417
|
-
* Signs an arbitrary message for authentication or verification.
|
|
1418
|
-
*
|
|
1419
|
-
* @description
|
|
1420
|
-
* Requests the wallet to sign a non-transaction message. Used for
|
|
1421
|
-
* authentication challenges, DAO voting, or off-chain signatures.
|
|
1422
|
-
*
|
|
1423
|
-
* @param options - Message signing options
|
|
1424
|
-
*
|
|
1425
|
-
* @returns Promise resolving to signature and public key
|
|
1426
|
-
*
|
|
1427
|
-
* @throws {Error} If not connected to wallet
|
|
1428
|
-
* @throws {Error} If user rejects signing
|
|
1429
|
-
*/
|
|
1430
|
-
signMessage(options: SignMessageOptions): Promise<SignMessageResult>;
|
|
1069
|
+
disconnectSession(sessionKey: string): Promise<void>;
|
|
1431
1070
|
/**
|
|
1432
|
-
*
|
|
1071
|
+
* Resume one persisted session by key (no-op if already live).
|
|
1433
1072
|
*
|
|
1434
|
-
* @
|
|
1435
|
-
*
|
|
1436
|
-
* in all modern browsers and most mobile WebViews.
|
|
1437
|
-
*
|
|
1438
|
-
* @returns Promise resolving to true if WebRTC is available
|
|
1439
|
-
*/
|
|
1440
|
-
isAvailable(): Promise<boolean>;
|
|
1441
|
-
/**
|
|
1442
|
-
* Set up listeners for session manager events
|
|
1073
|
+
* @param sessionKey - Session key (format `native-<channelId>`)
|
|
1074
|
+
* @returns True if the session is live after the call
|
|
1443
1075
|
*/
|
|
1444
|
-
|
|
1076
|
+
resumeSession(sessionKey: string): Promise<boolean>;
|
|
1445
1077
|
/**
|
|
1446
|
-
*
|
|
1447
|
-
* @param
|
|
1078
|
+
* Type guard for HSuite Native config
|
|
1079
|
+
* @param config
|
|
1448
1080
|
*/
|
|
1449
|
-
private
|
|
1450
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<
|
|
1451
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<
|
|
1081
|
+
private isHsuiteNativeConfig;
|
|
1082
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HsuiteNativeProvider, never>;
|
|
1083
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<HsuiteNativeProvider>;
|
|
1452
1084
|
}
|
|
1453
1085
|
|
|
1454
1086
|
/**
|
|
@@ -1640,7 +1272,7 @@ interface ProviderSummary {
|
|
|
1640
1272
|
* regardless of the underlying connection protocol. It manages multiple provider instances,
|
|
1641
1273
|
* aggregates accounts, and provides transaction signing/submission capabilities.
|
|
1642
1274
|
*
|
|
1643
|
-
* The service automatically registers built-in providers (HSuite Native, WalletConnect
|
|
1275
|
+
* The service automatically registers built-in providers (HSuite Native, WalletConnect)
|
|
1644
1276
|
* and supports session restoration across page reloads.
|
|
1645
1277
|
*
|
|
1646
1278
|
* @Component({
|
|
@@ -1689,9 +1321,8 @@ declare class UnifiedWalletService {
|
|
|
1689
1321
|
*
|
|
1690
1322
|
* @param hsuiteProvider
|
|
1691
1323
|
* @param walletConnectProvider
|
|
1692
|
-
* @param p2pNativeProvider
|
|
1693
1324
|
*/
|
|
1694
|
-
constructor(hsuiteProvider: HsuiteNativeProvider, walletConnectProvider: WalletConnectV2Provider
|
|
1325
|
+
constructor(hsuiteProvider: HsuiteNativeProvider, walletConnectProvider: WalletConnectV2Provider);
|
|
1695
1326
|
/**
|
|
1696
1327
|
* Gets summaries of all registered providers including status and accounts.
|
|
1697
1328
|
*
|
|
@@ -1728,10 +1359,9 @@ declare class UnifiedWalletService {
|
|
|
1728
1359
|
*/
|
|
1729
1360
|
readonly connectedProviders: i0.Signal<BaseWalletProvider[]>;
|
|
1730
1361
|
/**
|
|
1731
|
-
* Transport state for HSuite Native
|
|
1362
|
+
* Transport state for HSuite Native connections.
|
|
1732
1363
|
* Values: 'idle' | 'nostr-only' | 'upgrading' | 'p2p-connected' | 'p2p-failed'
|
|
1733
1364
|
*
|
|
1734
|
-
* Checks both HSuite Native and P2P Native providers.
|
|
1735
1365
|
* Returns 'idle' for non-HSuite connections (WalletConnect, etc.)
|
|
1736
1366
|
*/
|
|
1737
1367
|
readonly transportState: i0.Signal<string>;
|
|
@@ -1743,7 +1373,7 @@ declare class UnifiedWalletService {
|
|
|
1743
1373
|
* the provider's accounts will be included in {@link allAccounts} and
|
|
1744
1374
|
* can be used for wallet operations.
|
|
1745
1375
|
*
|
|
1746
|
-
* Built-in providers (HSuite Native, WalletConnect
|
|
1376
|
+
* Built-in providers (HSuite Native, WalletConnect) are auto-registered.
|
|
1747
1377
|
* Use this method only for custom provider implementations.
|
|
1748
1378
|
*
|
|
1749
1379
|
* @param provider - The provider instance to register
|
|
@@ -1790,9 +1420,10 @@ declare class UnifiedWalletService {
|
|
|
1790
1420
|
* @description
|
|
1791
1421
|
* Initiates a wallet connection through the specified provider. The connection
|
|
1792
1422
|
* flow varies by provider type:
|
|
1793
|
-
* - **HSuite Native**: Opens wallet window/tab
|
|
1423
|
+
* - **HSuite Native**: Opens wallet window/tab, uses Nostr discovery, or hands
|
|
1424
|
+
* the invite to `onInviteReady` for manual delivery (e.g. rendered as a QR
|
|
1425
|
+
* code for a cross-device wallet)
|
|
1794
1426
|
* - **WalletConnect**: Displays QR code for mobile wallet scanning
|
|
1795
|
-
* - **P2P Native**: Displays QR code for direct P2P connection
|
|
1796
1427
|
*
|
|
1797
1428
|
* Upon successful connection, emits 'connected' and 'accountsUpdated' events
|
|
1798
1429
|
* via WalletEventBus.
|
|
@@ -1928,9 +1559,10 @@ declare class UnifiedWalletService {
|
|
|
1928
1559
|
* Gets all active sessions across all providers.
|
|
1929
1560
|
*
|
|
1930
1561
|
* @description
|
|
1931
|
-
* Returns detailed session information for all connected providers.
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1562
|
+
* Returns detailed session information for all connected providers.
|
|
1563
|
+
* Providers that support per-session management (WalletConnect, HSuite
|
|
1564
|
+
* Native) report one entry per live session; other providers report a
|
|
1565
|
+
* single entry representing the whole connection.
|
|
1934
1566
|
*
|
|
1935
1567
|
* @returns Array of session objects with provider and account information
|
|
1936
1568
|
*/
|
|
@@ -1945,12 +1577,14 @@ declare class UnifiedWalletService {
|
|
|
1945
1577
|
* Disconnects a specific session from a provider.
|
|
1946
1578
|
*
|
|
1947
1579
|
* @description
|
|
1948
|
-
* For
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1580
|
+
* For providers that support per-session management (WalletConnect, HSuite
|
|
1581
|
+
* Native), disconnects the single session identified by `sessionKey` without
|
|
1582
|
+
* affecting the provider's other sessions. For other providers, or when no
|
|
1583
|
+
* session key is given, this is equivalent to calling {@link disconnect}.
|
|
1951
1584
|
*
|
|
1952
1585
|
* @param providerId - The provider ID
|
|
1953
|
-
* @param sessionKey -
|
|
1586
|
+
* @param sessionKey - Session key from {@link getActiveSessions} identifying
|
|
1587
|
+
* the session to disconnect; omit to disconnect the whole provider
|
|
1954
1588
|
*
|
|
1955
1589
|
* @throws {Error} If provider is not found
|
|
1956
1590
|
*/
|
|
@@ -2169,6 +1803,9 @@ declare class WalletSessionDisplayComponent {
|
|
|
2169
1803
|
* Transport state for the connection (nostr-only, upgrading, p2p-connected, etc.)
|
|
2170
1804
|
*/
|
|
2171
1805
|
readonly transportState: i0.Signal<string>;
|
|
1806
|
+
/**
|
|
1807
|
+
*
|
|
1808
|
+
*/
|
|
2172
1809
|
constructor();
|
|
2173
1810
|
/**
|
|
2174
1811
|
* Get transport state display info (icon, color, label)
|
|
@@ -2180,10 +1817,12 @@ declare class WalletSessionDisplayComponent {
|
|
|
2180
1817
|
};
|
|
2181
1818
|
/**
|
|
2182
1819
|
* Truncate address for display
|
|
1820
|
+
* @param address
|
|
2183
1821
|
*/
|
|
2184
1822
|
formatAddress(address: string): string;
|
|
2185
1823
|
/**
|
|
2186
1824
|
* Format timestamp
|
|
1825
|
+
* @param timestamp
|
|
2187
1826
|
*/
|
|
2188
1827
|
formatTimestamp(timestamp: number): string;
|
|
2189
1828
|
/**
|
|
@@ -3326,7 +2965,7 @@ interface StepConfig {
|
|
|
3326
2965
|
* Main wallet connection modal component.
|
|
3327
2966
|
* Orchestrates the multi-step connection flow.
|
|
3328
2967
|
*/
|
|
3329
|
-
declare class WalletConnectionModalComponent implements OnInit {
|
|
2968
|
+
declare class WalletConnectionModalComponent implements OnInit, OnDestroy {
|
|
3330
2969
|
private modalController;
|
|
3331
2970
|
private unifiedWalletService;
|
|
3332
2971
|
/**
|
|
@@ -3359,7 +2998,7 @@ declare class WalletConnectionModalComponent implements OnInit {
|
|
|
3359
2998
|
*/
|
|
3360
2999
|
connected: EventEmitter<unknown>;
|
|
3361
3000
|
private readonly platform;
|
|
3362
|
-
private readonly
|
|
3001
|
+
private readonly hsuiteNativeProvider;
|
|
3363
3002
|
readonly currentStep: i0.WritableSignal<ConnectionStep>;
|
|
3364
3003
|
readonly ConnectionStep: typeof ConnectionStep;
|
|
3365
3004
|
readonly selectedNetwork: i0.WritableSignal<string>;
|
|
@@ -3379,6 +3018,16 @@ declare class WalletConnectionModalComponent implements OnInit {
|
|
|
3379
3018
|
* Nostr connection is established, but session approval is pending.
|
|
3380
3019
|
*/
|
|
3381
3020
|
readonly isWaitingForApproval: i0.WritableSignal<boolean>;
|
|
3021
|
+
/**
|
|
3022
|
+
* Session key of the pending QR-delivered invite, used to dispose it when the
|
|
3023
|
+
* user backs out (so a half-open session never squats a cap slot until the
|
|
3024
|
+
* approval timeout).
|
|
3025
|
+
*/
|
|
3026
|
+
private qrSessionKey;
|
|
3027
|
+
/** In-flight QR connect promise — identity guard against stale settlements. */
|
|
3028
|
+
private qrConnectPromise;
|
|
3029
|
+
/** Set while cancelling so the connect rejection is not surfaced as an error. */
|
|
3030
|
+
private qrCancelRequested;
|
|
3382
3031
|
readonly isMobile: i0.WritableSignal<boolean>;
|
|
3383
3032
|
readonly isExtensionAvailable: i0.WritableSignal<boolean>;
|
|
3384
3033
|
readonly networkOptions: NetworkOption[];
|
|
@@ -3422,6 +3071,11 @@ declare class WalletConnectionModalComponent implements OnInit {
|
|
|
3422
3071
|
* @param unifiedWalletService
|
|
3423
3072
|
*/
|
|
3424
3073
|
constructor(modalController: ModalController$1, unifiedWalletService: UnifiedWalletService);
|
|
3074
|
+
/**
|
|
3075
|
+
* Modal dismissed mid-pairing: dispose the pending invite so it does not
|
|
3076
|
+
* hold a native session slot the wallet could never join.
|
|
3077
|
+
*/
|
|
3078
|
+
ngOnDestroy(): void;
|
|
3425
3079
|
/**
|
|
3426
3080
|
* Apply the pinned network (if any) before the first render.
|
|
3427
3081
|
*
|
|
@@ -3492,26 +3146,32 @@ declare class WalletConnectionModalComponent implements OnInit {
|
|
|
3492
3146
|
*/
|
|
3493
3147
|
dismiss(): Promise<void>;
|
|
3494
3148
|
/**
|
|
3495
|
-
* Initiate QR pairing flow for
|
|
3149
|
+
* Initiate QR pairing flow for a cross-device wallet.
|
|
3496
3150
|
*
|
|
3497
|
-
*
|
|
3498
|
-
*
|
|
3499
|
-
*
|
|
3500
|
-
*
|
|
3501
|
-
*
|
|
3151
|
+
* Same additive multi-session connect as the Desktop method — only the invite
|
|
3152
|
+
* delivery differs: the provider hands us the encoded `hsc:` invite via
|
|
3153
|
+
* `onInviteReady` and we render it as a QR code for the wallet to scan,
|
|
3154
|
+
* instead of the provider opening a wallet window. The connect promise
|
|
3155
|
+
* resolves when the wallet user approves the session, with the same cap-5 /
|
|
3156
|
+
* subsumption / timeout semantics as every other native session.
|
|
3502
3157
|
*/
|
|
3503
3158
|
private initiateQrPairing;
|
|
3504
3159
|
/**
|
|
3505
|
-
*
|
|
3506
|
-
*
|
|
3160
|
+
* Cancel the in-flight QR pairing, if any: dispose the pending native
|
|
3161
|
+
* session (releasing its cap slot and invalidating the rendered invite) and
|
|
3162
|
+
* neutralize the pending connect promise. Resolves once the cancelled
|
|
3163
|
+
* connect has settled — required before starting a fresh offer, because the
|
|
3164
|
+
* provider ignores connect attempts while one is already in flight.
|
|
3507
3165
|
*/
|
|
3508
|
-
private
|
|
3166
|
+
private cancelPendingQrPairing;
|
|
3509
3167
|
/**
|
|
3510
|
-
* Handle QR code expiry
|
|
3168
|
+
* Handle QR code expiry: the rendered invite is stale, so dispose its
|
|
3169
|
+
* pending session along with clearing the display.
|
|
3511
3170
|
*/
|
|
3512
3171
|
onQrExpired(): void;
|
|
3513
3172
|
/**
|
|
3514
|
-
* Refresh the QR pairing offer
|
|
3173
|
+
* Refresh the QR pairing offer: dispose the previous pending session, then
|
|
3174
|
+
* request a fresh invite.
|
|
3515
3175
|
*/
|
|
3516
3176
|
onQrRefresh(): Promise<void>;
|
|
3517
3177
|
/**
|
|
@@ -6980,44 +6640,32 @@ declare function provideWalletErrorHandler(config?: WalletErrorHandlerConfig): P
|
|
|
6980
6640
|
*/
|
|
6981
6641
|
/**
|
|
6982
6642
|
* @file channel-client.service.ts
|
|
6983
|
-
* @description Angular
|
|
6643
|
+
* @description Angular service for HSuite Native channel connections.
|
|
6984
6644
|
*
|
|
6985
6645
|
* ChannelClientService
|
|
6986
6646
|
*
|
|
6987
|
-
*
|
|
6988
|
-
*
|
|
6989
|
-
*
|
|
6990
|
-
*
|
|
6991
|
-
*
|
|
6992
|
-
*
|
|
6993
|
-
* -
|
|
6994
|
-
*
|
|
6995
|
-
*
|
|
6996
|
-
*
|
|
6997
|
-
*
|
|
6998
|
-
*
|
|
6999
|
-
*
|
|
7000
|
-
*
|
|
7001
|
-
*
|
|
7002
|
-
*
|
|
7003
|
-
*
|
|
7004
|
-
*
|
|
7005
|
-
*
|
|
7006
|
-
*
|
|
7007
|
-
*
|
|
7008
|
-
*
|
|
7009
|
-
* const invite = await this.channelService.connect({
|
|
7010
|
-
* type: 'session',
|
|
7011
|
-
* appId: 'my-dapp',
|
|
7012
|
-
* appName: 'My dApp',
|
|
7013
|
-
* ledgerId: 'hedera',
|
|
7014
|
-
* networkId: 'mainnet',
|
|
7015
|
-
* });
|
|
7016
|
-
* // Open wallet with invite URL
|
|
7017
|
-
* window.open(this.channelService.getWalletInviteUrl(invite, walletUrl));
|
|
7018
|
-
* }
|
|
7019
|
-
* }
|
|
7020
|
-
* ```
|
|
6647
|
+
* Multi-session orchestrator for dApp↔wallet channels. Each connection is a
|
|
6648
|
+
* ManagedChannelSession (one SDK ChannelClient) tracked in a
|
|
6649
|
+
* NativeSessionStore; `connect()` is ADDITIVE — a second connection creates a
|
|
6650
|
+
* second session instead of replacing the first, up to MAX_NATIVE_SESSIONS.
|
|
6651
|
+
*
|
|
6652
|
+
* Key behaviors:
|
|
6653
|
+
* - Aggregate back-compat signals: `accounts`/`unifiedAccounts` are the union
|
|
6654
|
+
* across sessions; `state`/`currentInvite`/`transportState` reflect the
|
|
6655
|
+
* in-flight connection when one exists, else the most recent live session.
|
|
6656
|
+
* - Per-account RPC routing: requests carrying `accountAddress` go to the
|
|
6657
|
+
* session that owns that account.
|
|
6658
|
+
* - Subsumption dedup: when the SAME wallet (TOFU peer fingerprint)
|
|
6659
|
+
* re-approves a superset of an older session's accounts, the older session
|
|
6660
|
+
* is dropped — so re-approving with one more account doesn't stack
|
|
6661
|
+
* duplicates, while different wallets always coexist.
|
|
6662
|
+
* - Multi-record persistence via the SDK ChannelPersistence (one record per
|
|
6663
|
+
* channel, 24h expiry per SOC2 CC6.6) with one-time migration from the
|
|
6664
|
+
* legacy single slot.
|
|
6665
|
+
* - Restore with per-record failure isolation (Promise.allSettled).
|
|
6666
|
+
*
|
|
6667
|
+
* Session lifecycle (connect/disconnect/restore) is driven by
|
|
6668
|
+
* HsuiteNativeProvider, which remains this service's single runtime consumer.
|
|
7021
6669
|
*/
|
|
7022
6670
|
|
|
7023
6671
|
/**
|
|
@@ -7035,7 +6683,7 @@ interface ChannelConnectConfig {
|
|
|
7035
6683
|
/** dApp icon URL (optional) */
|
|
7036
6684
|
appIcon?: string;
|
|
7037
6685
|
/**
|
|
7038
|
-
* dApp origin URL (optional). When omitted,
|
|
6686
|
+
* dApp origin URL (optional). When omitted, falls back to
|
|
7039
6687
|
* `window.location.origin` so the wallet can always show the user where the
|
|
7040
6688
|
* connection request is coming from. Override this only if your dApp serves
|
|
7041
6689
|
* the wallet integration from a different origin than the page hosting it.
|
|
@@ -7057,44 +6705,75 @@ interface ChannelConnectConfig {
|
|
|
7057
6705
|
*
|
|
7058
6706
|
* Angular service for unified channel-based dApp-wallet communication.
|
|
7059
6707
|
*/
|
|
7060
|
-
declare class ChannelClientService {
|
|
7061
|
-
private readonly
|
|
7062
|
-
private
|
|
7063
|
-
/**
|
|
7064
|
-
private readonly
|
|
6708
|
+
declare class ChannelClientService implements OnDestroy {
|
|
6709
|
+
private readonly store;
|
|
6710
|
+
private readonly persistence;
|
|
6711
|
+
/** True while connect() is between invocation and invite creation. */
|
|
6712
|
+
private readonly _pendingConnect;
|
|
6713
|
+
/** Aggregate state to report when no sessions exist. */
|
|
6714
|
+
private readonly _noSessionState;
|
|
6715
|
+
private readonly _lastError;
|
|
6716
|
+
private readonly removalListeners;
|
|
6717
|
+
private reconcileTimer;
|
|
6718
|
+
/** Flag to prevent auto-restore from interfering with new connections */
|
|
6719
|
+
private connectingNewSession;
|
|
6720
|
+
/**
|
|
6721
|
+
* Aggregate channel state. With one session this behaves exactly like the
|
|
6722
|
+
* single-session era; with several it reports the in-flight connection
|
|
6723
|
+
* first, then the strongest live state.
|
|
6724
|
+
*/
|
|
7065
6725
|
readonly state: Signal<ChannelState>;
|
|
7066
|
-
/**
|
|
7067
|
-
private readonly _transportState;
|
|
6726
|
+
/** Transport state of the focused session (see `focusedSession`). */
|
|
7068
6727
|
readonly transportState: Signal<TransportState>;
|
|
7069
|
-
/**
|
|
7070
|
-
private readonly _accounts;
|
|
6728
|
+
/** Union of approved accounts across all sessions (raw channel shape). */
|
|
7071
6729
|
readonly accounts: Signal<ChannelAccount[]>;
|
|
7072
|
-
/**
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
/** Error message (if any) */
|
|
7076
|
-
private readonly _error;
|
|
6730
|
+
/** Invite of the focused session (the connecting one, else the latest live one). */
|
|
6731
|
+
readonly currentInvite: Signal<ChannelInvite>;
|
|
6732
|
+
/** Last error message (if any). */
|
|
7077
6733
|
readonly error: Signal<string | null>;
|
|
7078
|
-
/**
|
|
7079
|
-
private connectingNewSession;
|
|
7080
|
-
/** Whether the channel is currently connected and active */
|
|
6734
|
+
/** Whether at least one channel is connected and active. */
|
|
7081
6735
|
readonly isConnected: Signal<boolean>;
|
|
7082
|
-
/** Whether
|
|
6736
|
+
/** Whether a connection is currently being established. */
|
|
7083
6737
|
readonly isConnecting: Signal<boolean>;
|
|
7084
|
-
/**
|
|
6738
|
+
/** Union of accounts formatted as UnifiedAccount (tagged with sessionKey). */
|
|
7085
6739
|
readonly unifiedAccounts: Signal<UnifiedAccount[]>;
|
|
6740
|
+
/** Number of live native sessions. */
|
|
6741
|
+
readonly sessionCount: Signal<number>;
|
|
7086
6742
|
/**
|
|
7087
|
-
*
|
|
6743
|
+
* The session aggregate single-value signals refer to: the in-flight
|
|
6744
|
+
* (connecting/pending) session when one exists, else the most recently
|
|
6745
|
+
* connected live session.
|
|
6746
|
+
*/
|
|
6747
|
+
private readonly focusedSession;
|
|
6748
|
+
/**
|
|
6749
|
+
* No-op constructor: session lifecycle is driven externally.
|
|
7088
6750
|
*/
|
|
7089
6751
|
constructor();
|
|
7090
6752
|
/**
|
|
7091
|
-
*
|
|
6753
|
+
* Injector teardown: stop the reconcile sweep so a destroyed injector
|
|
6754
|
+
* (e.g. TestBed per spec) doesn't leak the interval. Sessions are NOT torn
|
|
6755
|
+
* down here — this root-provided service normally lives for the app's
|
|
6756
|
+
* lifetime, and teardown of live channels stays an explicit user action.
|
|
6757
|
+
*/
|
|
6758
|
+
ngOnDestroy(): void;
|
|
6759
|
+
/**
|
|
6760
|
+
* Establish a new channel connection IN ADDITION to any existing sessions.
|
|
7092
6761
|
* Returns the invite to share with the wallet (via QR code or deep link).
|
|
7093
6762
|
*
|
|
7094
6763
|
* @param config - Channel configuration
|
|
7095
6764
|
* @returns The channel invite for wallet scanning
|
|
6765
|
+
* @throws {NativeSessionLimitError} When MAX_NATIVE_SESSIONS is reached
|
|
7096
6766
|
*/
|
|
7097
6767
|
connect(config: ChannelConnectConfig): Promise<ChannelInvite>;
|
|
6768
|
+
/**
|
|
6769
|
+
* Wait for a specific session to become active (wallet approval).
|
|
6770
|
+
* Rejects when the session errors, is rejected, or disappears from the
|
|
6771
|
+
* store (wallet declined and the terminal handler removed it).
|
|
6772
|
+
*
|
|
6773
|
+
* @param sessionKey - The session to watch
|
|
6774
|
+
* @param timeoutMs - Overall timeout (default: 120s, the wallet approval window)
|
|
6775
|
+
*/
|
|
6776
|
+
waitForSessionActive(sessionKey: NativeSessionKey, timeoutMs?: number): Promise<void>;
|
|
7098
6777
|
/**
|
|
7099
6778
|
* Generate a wallet invite URL for the current channel.
|
|
7100
6779
|
*
|
|
@@ -7106,6 +6785,10 @@ declare class ChannelClientService {
|
|
|
7106
6785
|
/**
|
|
7107
6786
|
* Send an RPC request to the wallet.
|
|
7108
6787
|
*
|
|
6788
|
+
* Routing: requests carrying a string `accountAddress` param go to the
|
|
6789
|
+
* session owning that account; all other requests go to the focused
|
|
6790
|
+
* session (single-session behavior unchanged).
|
|
6791
|
+
*
|
|
7109
6792
|
* @param method - RPC method name
|
|
7110
6793
|
* @param params - Method parameters
|
|
7111
6794
|
* @param timeoutMs - Request timeout (default: 60s)
|
|
@@ -7113,17 +6796,13 @@ declare class ChannelClientService {
|
|
|
7113
6796
|
*/
|
|
7114
6797
|
request<T = unknown>(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<T>;
|
|
7115
6798
|
/**
|
|
7116
|
-
* Sign a transaction via the wallet.
|
|
6799
|
+
* Sign a transaction via the wallet that owns the signing account.
|
|
7117
6800
|
*
|
|
7118
|
-
* @param options
|
|
7119
|
-
* @param accountAddress - Signer account address
|
|
7120
|
-
* @param options.
|
|
7121
|
-
* @param options.
|
|
7122
|
-
* @param options.
|
|
7123
|
-
* @param options.networkId
|
|
7124
|
-
* @param payload - Transaction payload (base64 or hex)
|
|
7125
|
-
* @param ledgerId - Optional ledger override
|
|
7126
|
-
* @param networkId - Optional network override
|
|
6801
|
+
* @param options - Signing options
|
|
6802
|
+
* @param options.accountAddress - Signer account address
|
|
6803
|
+
* @param options.payload - Transaction payload (base64 or hex)
|
|
6804
|
+
* @param options.ledgerId - Optional ledger override
|
|
6805
|
+
* @param options.networkId - Optional network override
|
|
7127
6806
|
* @returns Sign result with signature
|
|
7128
6807
|
*/
|
|
7129
6808
|
signTransaction(options: {
|
|
@@ -7137,20 +6816,17 @@ declare class ChannelClientService {
|
|
|
7137
6816
|
metadata?: Record<string, unknown>;
|
|
7138
6817
|
}>;
|
|
7139
6818
|
/**
|
|
7140
|
-
* Sign and submit a transaction in one call (single prompt)
|
|
6819
|
+
* Sign and submit a transaction in one call (single prompt), routed to the
|
|
6820
|
+
* wallet that owns the signing account.
|
|
7141
6821
|
*
|
|
7142
|
-
* @param options
|
|
7143
|
-
* @param accountAddress - Signer account address
|
|
7144
|
-
* @param options.
|
|
7145
|
-
* @param options.
|
|
7146
|
-
* @param options.
|
|
7147
|
-
* @param options.
|
|
7148
|
-
* @param options.
|
|
7149
|
-
* @param options.
|
|
7150
|
-
* @param options.innerTransactions
|
|
7151
|
-
* @param payload - Transaction payload
|
|
7152
|
-
* @param ledgerId - Optional ledger override
|
|
7153
|
-
* @param networkId - Optional network override
|
|
6822
|
+
* @param options - Submission options
|
|
6823
|
+
* @param options.accountAddress - Signer account address
|
|
6824
|
+
* @param options.payload - Transaction payload
|
|
6825
|
+
* @param options.ledgerId - Optional ledger override
|
|
6826
|
+
* @param options.networkId - Optional network override
|
|
6827
|
+
* @param options.isBatch - Whether this is a batch transaction
|
|
6828
|
+
* @param options.batchKey - Batch signing key
|
|
6829
|
+
* @param options.innerTransactions - Inner transactions of the batch
|
|
7154
6830
|
* @returns Submit result with transaction ID
|
|
7155
6831
|
*/
|
|
7156
6832
|
signAndSubmitTransaction(options: {
|
|
@@ -7170,54 +6846,86 @@ declare class ChannelClientService {
|
|
|
7170
6846
|
metadata?: Record<string, unknown>;
|
|
7171
6847
|
}>;
|
|
7172
6848
|
/**
|
|
7173
|
-
* Disconnect from
|
|
6849
|
+
* Disconnect ALL sessions from all wallets and clear persisted records.
|
|
6850
|
+
* For a single session use {@link disconnectSession}.
|
|
7174
6851
|
*/
|
|
7175
6852
|
disconnect(): Promise<void>;
|
|
7176
6853
|
/**
|
|
7177
|
-
*
|
|
7178
|
-
*
|
|
7179
|
-
* Note: This method is called by HsuiteNativeProvider as the single point
|
|
7180
|
-
* of session lifecycle control. Do not call from multiple places.
|
|
6854
|
+
* Disconnect one session, leaving the others untouched.
|
|
7181
6855
|
*
|
|
7182
|
-
* @
|
|
6856
|
+
* @param sessionKey - The session to terminate
|
|
6857
|
+
* @param options - Internal removal context
|
|
6858
|
+
* @param options.reason - Set to 'subsumed' by the dedup path
|
|
6859
|
+
* @returns True if the session existed and was disconnected
|
|
7183
6860
|
*/
|
|
7184
|
-
|
|
6861
|
+
disconnectSession(sessionKey: NativeSessionKey, options?: {
|
|
6862
|
+
reason?: 'subsumed';
|
|
6863
|
+
}): Promise<boolean>;
|
|
7185
6864
|
/**
|
|
7186
|
-
*
|
|
7187
|
-
*
|
|
6865
|
+
* Attempt to restore ALL previously persisted sessions.
|
|
6866
|
+
*
|
|
6867
|
+
* Migrates the legacy single-slot record first, applies the §21.1
|
|
6868
|
+
* localContext guard per record, then reconnects every eligible record
|
|
6869
|
+
* with per-record failure isolation.
|
|
6870
|
+
*
|
|
6871
|
+
* Note: called by HsuiteNativeProvider as the single point of session
|
|
6872
|
+
* lifecycle control. Do not call from multiple places.
|
|
6873
|
+
*
|
|
6874
|
+
* @returns True if at least one session was restored
|
|
7188
6875
|
*/
|
|
7189
|
-
|
|
7190
|
-
/** Current polling timeout ID for cleanup */
|
|
7191
|
-
private pollingTimeoutId?;
|
|
6876
|
+
attemptRestore(): Promise<boolean>;
|
|
7192
6877
|
/**
|
|
7193
|
-
*
|
|
7194
|
-
*
|
|
7195
|
-
*
|
|
6878
|
+
* Resume one persisted session by key (no-op if already live).
|
|
6879
|
+
*
|
|
6880
|
+
* @param sessionKey - The session to resume
|
|
6881
|
+
* @returns True if the session is live after the call
|
|
6882
|
+
* @throws {NativeSessionLimitError} When the session is not already live and
|
|
6883
|
+
* MAX_NATIVE_SESSIONS is reached (unlike attemptRestore, which silently
|
|
6884
|
+
* skips extras, this single-session entry point must not add a session
|
|
6885
|
+
* past the cap)
|
|
7196
6886
|
*/
|
|
7197
|
-
|
|
6887
|
+
resumeSession(sessionKey: NativeSessionKey): Promise<boolean>;
|
|
7198
6888
|
/**
|
|
7199
|
-
*
|
|
6889
|
+
* Snapshot of every live session, for session-management UIs and the
|
|
6890
|
+
* provider's duck-typed `getActiveSessions()` surface.
|
|
7200
6891
|
*/
|
|
7201
|
-
|
|
7202
|
-
private static readonly STORAGE_KEY;
|
|
6892
|
+
getActiveSessions(): NativeActiveSession[];
|
|
7203
6893
|
/**
|
|
7204
|
-
*
|
|
6894
|
+
* Register a listener for non-user-initiated session removals (wallet
|
|
6895
|
+
* terminate, rejection, subsumption). User-initiated disconnects are NOT
|
|
6896
|
+
* reported here — UnifiedWalletService emits those itself.
|
|
6897
|
+
*
|
|
6898
|
+
* @param listener - Removal callback
|
|
6899
|
+
* @returns Unsubscribe function
|
|
7205
6900
|
*/
|
|
7206
|
-
|
|
6901
|
+
onSessionRemoved(listener: (event: NativeSessionRemovalEvent) => void): () => void;
|
|
6902
|
+
private createSession;
|
|
6903
|
+
private handleSessionTerminal;
|
|
7207
6904
|
/**
|
|
7208
|
-
*
|
|
7209
|
-
*
|
|
7210
|
-
*
|
|
6905
|
+
* Drop older sessions the newly activated one fully subsumes (same wallet
|
|
6906
|
+
* identity AND account superset). See NativeSessionStore.findSubsumedBy.
|
|
6907
|
+
*
|
|
6908
|
+
* @param candidate - The newly activated/updated session
|
|
7211
6909
|
*/
|
|
7212
|
-
private
|
|
6910
|
+
private applySubsumption;
|
|
6911
|
+
private resolveSessionForRequest;
|
|
6912
|
+
private restoreOne;
|
|
7213
6913
|
/**
|
|
7214
|
-
*
|
|
6914
|
+
* One-time migration of the legacy single-slot record into the
|
|
6915
|
+
* multi-record store. The §21.1 localContext guard applies: legacy records
|
|
6916
|
+
* without it are discarded (they could never restore safely anyway).
|
|
7215
6917
|
*/
|
|
7216
|
-
private
|
|
6918
|
+
private migrateLegacySlot;
|
|
7217
6919
|
/**
|
|
7218
|
-
*
|
|
6920
|
+
* Persist a session's exportable state (fire-and-forget).
|
|
6921
|
+
*
|
|
6922
|
+
* @param session - Session to persist
|
|
7219
6923
|
*/
|
|
7220
|
-
private
|
|
6924
|
+
private persistSession;
|
|
6925
|
+
private deleteRecord;
|
|
6926
|
+
private ensureReconcileLoop;
|
|
6927
|
+
private stopReconcileLoopIfIdle;
|
|
6928
|
+
private notifyRemoval;
|
|
7221
6929
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChannelClientService, never>;
|
|
7222
6930
|
static ɵprov: i0.ɵɵInjectableDeclaration<ChannelClientService>;
|
|
7223
6931
|
}
|
|
@@ -7423,5 +7131,5 @@ declare function getLedgerName(ledgerId: string): string;
|
|
|
7423
7131
|
*/
|
|
7424
7132
|
declare function getTokenIcon(tokenIconUrl: string | undefined, ledgerId: string): string;
|
|
7425
7133
|
|
|
7426
|
-
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL, HSUITE_AUTH_HEADER, HSUITE_LEDGER_HEADER, HederaSigner, HederaTransactionBuilderService, HsuiteAuthInterceptor, HsuiteNativeProvider, HsuiteWalletModule, LEDGER_COLORS, LEDGER_ICON_NAMES, LEDGER_NAMES, LedgerUIRegistry, LoggerService,
|
|
7427
|
-
export type { AccountChangeEvent, AccountCreateOptions, AccountGroupingMode, AccountItem, AccountSelectorConfig, AccountSelectorPresentationMode, AccountWithBalance, AccountsUpdateEvent, ActiveAccountData, ActiveAccountSource, BatchInnerTransaction, BatchInnerTransactionType, ChannelConnectConfig, ChromeExtensionTransportOptions, CompactHeaderFormat, CompactHeaderSize, ConnectionConfig, ConnectionEvent, ConnectionStatus,
|
|
7134
|
+
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL, HSUITE_AUTH_HEADER, HSUITE_LEDGER_HEADER, HederaSigner, HederaTransactionBuilderService, HsuiteAuthInterceptor, HsuiteNativeProvider, HsuiteWalletModule, LEDGER_COLORS, LEDGER_ICON_NAMES, LEDGER_NAMES, LedgerUIRegistry, LoggerService, MAX_NATIVE_SESSIONS, NATIVE_SESSION_KEY_PREFIX, NativeSessionLimitError, SMART_SESSION_CONFIG, SignerFactory, SmartSessionService, TransactionService, UnifiedWalletService, WalletAccountDisplayComponent, WalletConnectButtonComponent, WalletConnectClientManager, WalletConnectPromptComponent, WalletConnectSessionStore, WalletConnectSigningOrchestrator, WalletConnectV2Provider, WalletConnectedDirective, WalletConnectedGuardComponent, WalletConnectionModalComponent, WalletContextDirective, WalletContextService, WalletErrorHandler, WalletEventBus, WalletEventsDirective, WalletSessionDisplayComponent, WalletTransactionStatusComponent, XrplSigner, XrplTransactionBuilderService, channelIdFromSessionKey, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, hsuiteAuthInterceptor, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, nativeSessionKeyFor, parseNativeSessionKey, provideWalletErrorHandler, registerLedgerIcons, scaleHederaAmountToBaseUnits, supportsSessionManagement };
|
|
7135
|
+
export type { AccountChangeEvent, AccountCreateOptions, AccountGroupingMode, AccountItem, AccountSelectorConfig, AccountSelectorPresentationMode, AccountWithBalance, AccountsUpdateEvent, ActiveAccountData, ActiveAccountSource, BatchInnerTransaction, BatchInnerTransactionType, ChannelConnectConfig, ChromeExtensionTransportOptions, CompactHeaderFormat, CompactHeaderSize, ConnectionConfig, ConnectionEvent, ConnectionStatus, DisconnectionEvent, HederaKeyConfig, HsuiteNativeConfig, HsuiteNativeInviteReady, IWalletConnectSigner, LedgerGroup$1 as LedgerGroup, LedgerUiDescriptor, NativeActiveSession, NativeSessionKey, NativeSessionRemovalEvent, NetworkGroup, ProtocolGroup, ProviderErrorEvent, ProviderMetadata, ProviderSessionInfo, ProviderStatusEvent, ProviderType, SelectedAccountData, SessionEvent, SessionManagingProvider, SessionMetadata, SignMessageOptions, SignMessageResult, SignResult, SignTransactionOptions, SignerContext, SignerOperationParams, SigningOrchestratorConfig, SmartHostChallenge, SmartHostHealth, SmartHostVerifyRequest, SmartHostVerifyResponse, SmartSessionConfig, StoredSessionData, SubmitResult, SubmitTransactionOptions, TokenCreateOptions, TopicCreateOptions, UnifiedAccount, WCAppMetadata, WalletConnectSession, WalletConnectSignerConfig, WalletConnectV2Config, WalletContext, WalletErrorHandlerConfig, WalletSession };
|