@hsuite/native-connect-angular 1.0.0 → 2.1.1
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/coverage/coverage-summary.json +53 -49
- package/coverage/index.html +100 -100
- package/coverage/lcov-report/index.html +100 -100
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +13 -19
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/index.html +5 -5
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +21 -21
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +475 -451
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +148 -148
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +17 -17
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +21 -21
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +17 -17
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +838 -838
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +1230 -987
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/index.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +1 -1
- package/coverage/lcov-report/lib/index.html +1 -1
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +1 -1
- package/coverage/lcov-report/lib/models/index.html +7 -7
- package/coverage/lcov-report/lib/models/provider-types.ts.html +11 -5
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +9 -6
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +10 -10
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/index.html +1 -1
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +7 -7
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +10 -10
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +10 -7
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +49 -49
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1 -1
- package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +568 -0
- package/coverage/lcov-report/lib/services/index.html +50 -20
- package/coverage/lcov-report/lib/services/logger.service.ts.html +4 -4
- package/coverage/lcov-report/lib/services/smart-session.service.ts.html +1264 -0
- package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +250 -0
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +1 -1
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +318 -318
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +24 -9
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +7 -10
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +9 -12
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +4 -7
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +1 -1
- package/coverage/lcov-report/lib/transports/index.html +1 -1
- package/coverage/lcov-report/lib/utils/index.html +36 -21
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +254 -161
- package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +676 -0
- package/coverage/lcov.info +3236 -2122
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-actions/index.html +1 -1
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-filter/index.html +1 -1
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +13 -19
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-list/index.html +1 -1
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +1 -1
- package/coverage/lib/components/account-selector/index.html +5 -5
- package/coverage/lib/components/wallet-account-display/index.html +1 -1
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
- package/coverage/lib/components/wallet-connect-button/index.html +21 -21
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +475 -451
- package/coverage/lib/components/wallet-connect-prompt/index.html +1 -1
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connected-guard/index.html +1 -1
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +148 -148
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +17 -17
- package/coverage/lib/components/wallet-connection-modal/index.html +21 -21
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +17 -17
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +838 -838
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +1230 -987
- package/coverage/lib/components/wallet-session-display/index.html +1 -1
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
- package/coverage/lib/components/wallet-transaction-status/index.html +1 -1
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
- package/coverage/lib/directives/index.html +1 -1
- package/coverage/lib/directives/wallet-connected.directive.ts.html +1 -1
- package/coverage/lib/directives/wallet-context.directive.ts.html +1 -1
- package/coverage/lib/directives/wallet-events.directive.ts.html +1 -1
- package/coverage/lib/hsuite-wallet.module.ts.html +1 -1
- package/coverage/lib/index.html +1 -1
- package/coverage/lib/models/connection-config.model.ts.html +1 -1
- package/coverage/lib/models/index.html +7 -7
- package/coverage/lib/models/provider-types.ts.html +11 -5
- package/coverage/lib/providers/base-wallet-provider.ts.html +1 -1
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +9 -6
- package/coverage/lib/providers/hsuite-native/index.html +10 -10
- package/coverage/lib/providers/hsuite-native-provider.ts.html +1 -1
- package/coverage/lib/providers/index.html +1 -1
- package/coverage/lib/providers/p2p-native/index.html +7 -7
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +1 -1
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
- package/coverage/lib/providers/wallet-error-handler.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/core/index.html +10 -10
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +10 -7
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/signers/index.html +1 -1
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +49 -49
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1 -1
- package/coverage/lib/services/hsuite-auth.interceptor.ts.html +568 -0
- package/coverage/lib/services/index.html +50 -20
- package/coverage/lib/services/logger.service.ts.html +4 -4
- package/coverage/lib/services/smart-session.service.ts.html +1264 -0
- package/coverage/lib/services/transaction-builders/active-account-source.ts.html +250 -0
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +1 -1
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +318 -318
- package/coverage/lib/services/transaction-builders/index.html +24 -9
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1 -1
- package/coverage/lib/services/transaction.service.ts.html +7 -10
- package/coverage/lib/services/unified-wallet.service.ts.html +9 -12
- package/coverage/lib/services/wallet-context.service.ts.html +1 -1
- package/coverage/lib/services/wallet-event-bus.service.ts.html +1 -1
- package/coverage/lib/services/wallet-providers.service.ts.html +4 -7
- package/coverage/lib/transports/chrome-extension-transport.ts.html +1 -1
- package/coverage/lib/transports/index.html +1 -1
- package/coverage/lib/utils/index.html +36 -21
- package/coverage/lib/utils/ledger-icons.util.ts.html +254 -161
- package/coverage/lib/utils/ledger-ui-registry.ts.html +676 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +939 -328
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
- package/dist/index.d.ts +489 -33
- package/package.json +4 -4
- package/src/index.ts +26 -0
- package/src/lib/components/account-selector/account-formatting.service.ts +8 -10
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +9 -9
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +89 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +8 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +1 -6
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +173 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +118 -37
- package/src/lib/models/provider-types.ts +3 -1
- package/src/lib/models/unified-account.model.ts +4 -1
- package/src/lib/providers/hsuite-native/channel-client.service.ts +1 -0
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +1 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +2 -1
- package/src/lib/services/hsuite-auth.interceptor.ts +159 -0
- package/src/lib/services/smart-session.service.ts +378 -0
- package/src/lib/services/transaction-builders/active-account-source.spec.ts +75 -0
- package/src/lib/services/transaction-builders/active-account-source.ts +55 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +4 -4
- package/src/lib/services/transaction-builders/index.ts +1 -0
- package/src/lib/services/transaction.service.ts +7 -4
- package/src/lib/services/unified-wallet.service.spec.ts +1 -1
- package/src/lib/services/unified-wallet.service.ts +2 -3
- package/src/lib/services/wallet-providers.service.ts +0 -1
- package/src/lib/utils/index.ts +1 -0
- package/src/lib/utils/ledger-icons.util.ts +61 -30
- package/src/lib/utils/ledger-ui-registry.ts +197 -0
|
@@ -22,14 +22,26 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { CommonModule } from '@angular/common';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
Component,
|
|
27
|
+
Input,
|
|
28
|
+
Output,
|
|
29
|
+
EventEmitter,
|
|
30
|
+
OnInit,
|
|
31
|
+
signal,
|
|
32
|
+
computed,
|
|
33
|
+
inject,
|
|
34
|
+
} from '@angular/core';
|
|
26
35
|
import { getLogger } from '@hsuite/native-connect-sdk';
|
|
36
|
+
import type { SupportedLedger } from '@hsuite/native-connect-sdk';
|
|
27
37
|
import { IonicModule, ModalController, Platform } from '@ionic/angular';
|
|
28
38
|
|
|
29
39
|
import type { WalletConnectV2Config } from '../../models/provider-types';
|
|
30
40
|
import { DEFAULT_WALLET_URL } from '../../models/provider-types';
|
|
31
41
|
import { P2PNativeProvider } from '../../providers/p2p-native/p2p-native.provider';
|
|
32
42
|
import { UnifiedWalletService } from '../../services/unified-wallet.service';
|
|
43
|
+
import { registerLedgerIcons } from '../../utils/ledger-icons.util';
|
|
44
|
+
import { LedgerUIRegistry } from '../../utils/ledger-ui-registry';
|
|
33
45
|
|
|
34
46
|
import {
|
|
35
47
|
ConnectionMethodStepComponent,
|
|
@@ -84,12 +96,25 @@ interface ProtocolOption {
|
|
|
84
96
|
* Ledger configuration options
|
|
85
97
|
*/
|
|
86
98
|
interface LedgerOption {
|
|
87
|
-
id:
|
|
99
|
+
id: SupportedLedger;
|
|
88
100
|
name: string;
|
|
89
101
|
description: string;
|
|
90
102
|
icon: string;
|
|
91
103
|
}
|
|
92
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Per-ledger copy for the WalletConnect "Choose Blockchain" step.
|
|
107
|
+
*
|
|
108
|
+
* Keyed by {@link SupportedLedger} (the closed set of ledgers the WalletConnect
|
|
109
|
+
* provider brokers) via `satisfies`, so widening that union forces a description
|
|
110
|
+
* here. Display name and icon come from {@link LedgerUIRegistry}; this map holds
|
|
111
|
+
* only the connection-flow copy specific to this surface.
|
|
112
|
+
*/
|
|
113
|
+
const LEDGER_DESCRIPTIONS = {
|
|
114
|
+
hedera: 'Hedera Hashgraph network',
|
|
115
|
+
xrpl: 'XRP Ledger network',
|
|
116
|
+
} satisfies Record<SupportedLedger, string>;
|
|
117
|
+
|
|
93
118
|
/**
|
|
94
119
|
* Step configuration for dynamic step indicator.
|
|
95
120
|
* Defines the total steps and labels based on selected protocol path.
|
|
@@ -112,12 +137,22 @@ interface StepConfig {
|
|
|
112
137
|
templateUrl: './wallet-connection-modal.component.html',
|
|
113
138
|
styleUrls: ['./wallet-connection-modal.component.scss'],
|
|
114
139
|
})
|
|
115
|
-
export class WalletConnectionModalComponent {
|
|
140
|
+
export class WalletConnectionModalComponent implements OnInit {
|
|
116
141
|
/**
|
|
117
142
|
* WalletConnect project ID (required for WalletConnect)
|
|
118
143
|
*/
|
|
119
144
|
@Input() projectId?: string;
|
|
120
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Pins the connection network and hides the network-selection step.
|
|
148
|
+
*
|
|
149
|
+
* When set to `'mainnet'` or `'testnet'`, the host dApp decides the network
|
|
150
|
+
* and the user is never shown the network picker — the modal opens directly
|
|
151
|
+
* on protocol selection. When omitted (default), the user chooses the network
|
|
152
|
+
* as the first step.
|
|
153
|
+
*/
|
|
154
|
+
@Input() network?: 'mainnet' | 'testnet';
|
|
155
|
+
|
|
121
156
|
/**
|
|
122
157
|
* App name for WalletConnect metadata
|
|
123
158
|
*/
|
|
@@ -151,7 +186,7 @@ export class WalletConnectionModalComponent {
|
|
|
151
186
|
readonly selectedNetwork = signal<string>('testnet');
|
|
152
187
|
readonly selectedProtocol = signal<'hsuite-native' | 'walletconnect' | null>(null);
|
|
153
188
|
readonly selectedConnectionMethod = signal<ConnectionMethod | null>(null);
|
|
154
|
-
readonly selectedLedger = signal<
|
|
189
|
+
readonly selectedLedger = signal<SupportedLedger | null>(null);
|
|
155
190
|
|
|
156
191
|
// Loading state
|
|
157
192
|
readonly isConnecting = signal<boolean>(false);
|
|
@@ -228,20 +263,17 @@ export class WalletConnectionModalComponent {
|
|
|
228
263
|
return options;
|
|
229
264
|
});
|
|
230
265
|
|
|
231
|
-
readonly ledgerOptions: LedgerOption[] =
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
icon: 'logo-usd', // Placeholder, use actual XRPL icon
|
|
243
|
-
},
|
|
244
|
-
];
|
|
266
|
+
readonly ledgerOptions: LedgerOption[] = (
|
|
267
|
+
Object.keys(LEDGER_DESCRIPTIONS) as SupportedLedger[]
|
|
268
|
+
).map((id) => {
|
|
269
|
+
const ui = LedgerUIRegistry.get(id);
|
|
270
|
+
return {
|
|
271
|
+
id,
|
|
272
|
+
name: ui?.displayName ?? id,
|
|
273
|
+
description: LEDGER_DESCRIPTIONS[id],
|
|
274
|
+
icon: ui?.iconName ?? '',
|
|
275
|
+
};
|
|
276
|
+
});
|
|
245
277
|
|
|
246
278
|
/**
|
|
247
279
|
* Connection method options for HSuite Native.
|
|
@@ -325,23 +357,30 @@ export class WalletConnectionModalComponent {
|
|
|
325
357
|
const protocol = this.selectedProtocol();
|
|
326
358
|
const method = this.selectedConnectionMethod();
|
|
327
359
|
|
|
360
|
+
let base: StepConfig;
|
|
361
|
+
|
|
328
362
|
// Initial state: show 3 placeholder steps until protocol is selected
|
|
329
363
|
if (!protocol) {
|
|
330
|
-
|
|
364
|
+
base = { total: 3, labels: ['Network', 'Protocol', '...'] };
|
|
365
|
+
} else if (protocol === 'hsuite-native') {
|
|
366
|
+
// HSuite Native path
|
|
367
|
+
base =
|
|
368
|
+
method === 'mobile-qr'
|
|
369
|
+
? // Mobile QR needs 4 steps
|
|
370
|
+
{ total: 4, labels: ['Network', 'Protocol', 'Method', 'Pair'] }
|
|
371
|
+
: // Desktop connects immediately after method selection (3 steps)
|
|
372
|
+
{ total: 3, labels: ['Network', 'Protocol', 'Method'] };
|
|
373
|
+
} else {
|
|
374
|
+
// WalletConnect path: 4 steps
|
|
375
|
+
base = { total: 4, labels: ['Network', 'Protocol', 'Ledger', 'Connect'] };
|
|
331
376
|
}
|
|
332
377
|
|
|
333
|
-
//
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return { total: 4, labels: ['Network', 'Protocol', 'Method', 'Pair'] };
|
|
338
|
-
}
|
|
339
|
-
// Desktop connection is 3 steps (connects immediately after method selection)
|
|
340
|
-
return { total: 3, labels: ['Network', 'Protocol', 'Method'] };
|
|
378
|
+
// When the network is pinned by the host dApp the network step is never
|
|
379
|
+
// shown — drop it from the indicator so the numbering stays accurate.
|
|
380
|
+
if (this.network) {
|
|
381
|
+
return { total: base.total - 1, labels: base.labels.slice(1) };
|
|
341
382
|
}
|
|
342
|
-
|
|
343
|
-
// WalletConnect path: 4 steps
|
|
344
|
-
return { total: 4, labels: ['Network', 'Protocol', 'Ledger', 'Connect'] };
|
|
383
|
+
return base;
|
|
345
384
|
});
|
|
346
385
|
|
|
347
386
|
/**
|
|
@@ -353,20 +392,24 @@ export class WalletConnectionModalComponent {
|
|
|
353
392
|
// Protocol could be used for protocol-specific step mapping in the future
|
|
354
393
|
const _protocol = this.selectedProtocol();
|
|
355
394
|
|
|
395
|
+
// When the network is pinned the network step is removed, so every
|
|
396
|
+
// subsequent step shifts down one position in the indicator.
|
|
397
|
+
const networkOffset = this.network ? 1 : 0;
|
|
398
|
+
|
|
356
399
|
// Map internal step to display position based on protocol path
|
|
357
400
|
switch (step) {
|
|
358
401
|
case ConnectionStep.NetworkSelection:
|
|
359
402
|
return 1;
|
|
360
403
|
case ConnectionStep.ProtocolSelection:
|
|
361
|
-
return 2;
|
|
404
|
+
return 2 - networkOffset;
|
|
362
405
|
case ConnectionStep.ConnectionMethodSelection:
|
|
363
|
-
return 3;
|
|
406
|
+
return 3 - networkOffset;
|
|
364
407
|
case ConnectionStep.LedgerSelection:
|
|
365
408
|
// WalletConnect ledger selection is step 3
|
|
366
|
-
return 3;
|
|
409
|
+
return 3 - networkOffset;
|
|
367
410
|
case ConnectionStep.QrPairing:
|
|
368
411
|
// QR pairing is step 4 for both paths that use it
|
|
369
|
-
return 4;
|
|
412
|
+
return 4 - networkOffset;
|
|
370
413
|
case ConnectionStep.ConnectionProgress:
|
|
371
414
|
// Connection progress is always the last step
|
|
372
415
|
return this.stepConfig().total;
|
|
@@ -375,6 +418,23 @@ export class WalletConnectionModalComponent {
|
|
|
375
418
|
}
|
|
376
419
|
});
|
|
377
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Whether a back affordance should be offered for the current step.
|
|
423
|
+
* The first reachable step has no back target — that is protocol selection
|
|
424
|
+
* when the network is pinned, otherwise network selection. The connection
|
|
425
|
+
* progress step manages its own retry navigation instead.
|
|
426
|
+
*/
|
|
427
|
+
readonly canGoBack = computed<boolean>(() => {
|
|
428
|
+
const step = this.currentStep();
|
|
429
|
+
if (step === ConnectionStep.ConnectionProgress) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
const firstStep = this.network
|
|
433
|
+
? ConnectionStep.ProtocolSelection
|
|
434
|
+
: ConnectionStep.NetworkSelection;
|
|
435
|
+
return step > firstStep;
|
|
436
|
+
});
|
|
437
|
+
|
|
378
438
|
/**
|
|
379
439
|
*
|
|
380
440
|
* @param modalController
|
|
@@ -388,6 +448,23 @@ export class WalletConnectionModalComponent {
|
|
|
388
448
|
this.p2pNativeProvider.onPeerConnected(() => {
|
|
389
449
|
this.onMobileConnected();
|
|
390
450
|
});
|
|
451
|
+
|
|
452
|
+
// Register the shared ledger brand logos so <ion-icon> can resolve them by name.
|
|
453
|
+
registerLedgerIcons();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Apply the pinned network (if any) before the first render.
|
|
458
|
+
*
|
|
459
|
+
* When the host dApp provides a {@link network}, lock the selection to it and
|
|
460
|
+
* skip straight to protocol selection so the user never sees — and cannot
|
|
461
|
+
* change — the network. With no input, the modal opens on network selection.
|
|
462
|
+
*/
|
|
463
|
+
ngOnInit(): void {
|
|
464
|
+
if (this.network) {
|
|
465
|
+
this.selectedNetwork.set(this.network);
|
|
466
|
+
this.currentStep.set(ConnectionStep.ProtocolSelection);
|
|
467
|
+
}
|
|
391
468
|
}
|
|
392
469
|
|
|
393
470
|
/**
|
|
@@ -457,7 +534,7 @@ export class WalletConnectionModalComponent {
|
|
|
457
534
|
* Select a ledger option (internal, use selectLedgerAndConnect for UI)
|
|
458
535
|
* @param ledgerId
|
|
459
536
|
*/
|
|
460
|
-
selectLedger(ledgerId:
|
|
537
|
+
selectLedger(ledgerId: SupportedLedger): void {
|
|
461
538
|
this.selectedLedger.set(ledgerId);
|
|
462
539
|
}
|
|
463
540
|
|
|
@@ -466,7 +543,7 @@ export class WalletConnectionModalComponent {
|
|
|
466
543
|
* This enables direct selection behavior for WalletConnect ledger step.
|
|
467
544
|
* @param ledgerId - The ledger ID to select ('hedera' or 'xrpl')
|
|
468
545
|
*/
|
|
469
|
-
selectLedgerAndConnect(ledgerId:
|
|
546
|
+
selectLedgerAndConnect(ledgerId: SupportedLedger): void {
|
|
470
547
|
this.selectedLedger.set(ledgerId);
|
|
471
548
|
// Auto-connect with the selected ledger
|
|
472
549
|
void this.connect();
|
|
@@ -510,7 +587,11 @@ export class WalletConnectionModalComponent {
|
|
|
510
587
|
back(): void {
|
|
511
588
|
const currentStep = this.currentStep();
|
|
512
589
|
if (currentStep === ConnectionStep.ProtocolSelection) {
|
|
513
|
-
|
|
590
|
+
// When the network is pinned, protocol selection is the first reachable
|
|
591
|
+
// step — there is no network step to return to.
|
|
592
|
+
if (!this.network) {
|
|
593
|
+
this.currentStep.set(ConnectionStep.NetworkSelection);
|
|
594
|
+
}
|
|
514
595
|
} else if (currentStep === ConnectionStep.ConnectionMethodSelection) {
|
|
515
596
|
this.currentStep.set(ConnectionStep.ProtocolSelection);
|
|
516
597
|
} else if (currentStep === ConnectionStep.LedgerSelection) {
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
+
import type { SupportedLedger } from '@hsuite/native-connect-sdk';
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* Supported wallet connection protocol types.
|
|
25
27
|
*
|
|
@@ -129,7 +131,7 @@ export interface HsuiteNativeConfig {
|
|
|
129
131
|
export interface WalletConnectV2Config {
|
|
130
132
|
type: 'walletconnect-v2';
|
|
131
133
|
projectId: string; // WalletConnect Cloud project ID - REQUIRED
|
|
132
|
-
ledgerId:
|
|
134
|
+
ledgerId: SupportedLedger; // Which ledger to connect to
|
|
133
135
|
networkId: string; // e.g., 'hedera:testnet' or 'xrpl:testnet'
|
|
134
136
|
appName?: string;
|
|
135
137
|
appDescription?: string;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @file Unified account model that works across all wallet providers.
|
|
13
13
|
*
|
|
14
14
|
* @module models/unified-account
|
|
15
15
|
*
|
|
@@ -45,6 +45,9 @@ export interface UnifiedAccount {
|
|
|
45
45
|
/** Account address/public key */
|
|
46
46
|
address: string;
|
|
47
47
|
|
|
48
|
+
/** Public key associated with the account, when available from the provider. */
|
|
49
|
+
publicKey?: string;
|
|
50
|
+
|
|
48
51
|
/** Human-readable label */
|
|
49
52
|
label?: string;
|
|
50
53
|
|
|
@@ -170,6 +170,7 @@ export class ChannelClientService {
|
|
|
170
170
|
return {
|
|
171
171
|
id: `channel-${account.address}`,
|
|
172
172
|
address: account.address,
|
|
173
|
+
publicKey: account.publicKey,
|
|
173
174
|
label: account.alias ?? `Account ${index + 1}`,
|
|
174
175
|
ledgerId: account.ledgerId,
|
|
175
176
|
networkId: account.networkId,
|
|
@@ -587,6 +587,7 @@ export class P2PSessionManager {
|
|
|
587
587
|
accounts: accounts.map((acc, index) => ({
|
|
588
588
|
id: `p2p-${acc.address}`,
|
|
589
589
|
address: acc.address,
|
|
590
|
+
publicKey: acc.publicKey,
|
|
590
591
|
label: acc.alias || `Account ${index + 1}`,
|
|
591
592
|
ledgerId: acc.ledgerId,
|
|
592
593
|
networkId: acc.networkId,
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
import { Injectable, signal, inject, NgZone } from '@angular/core';
|
|
31
31
|
import { getLogger } from '@hsuite/native-connect-sdk';
|
|
32
|
+
import type { SupportedLedger } from '@hsuite/native-connect-sdk';
|
|
32
33
|
|
|
33
34
|
import type {
|
|
34
35
|
ConnectionStatus,
|
|
@@ -298,7 +299,7 @@ export class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
298
299
|
id: `${this.id}-${ledgerId}-${acc.address}`,
|
|
299
300
|
address: acc.address,
|
|
300
301
|
label: `Account ${index + 1}`,
|
|
301
|
-
ledgerId: ledgerId as
|
|
302
|
+
ledgerId: ledgerId as SupportedLedger,
|
|
302
303
|
networkId: networkId, // Use user's selected network
|
|
303
304
|
providerId: this.id,
|
|
304
305
|
providerType: 'walletconnect-v2',
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @file HTTP interceptor that attaches wallet-attributed auth headers.
|
|
13
|
+
*
|
|
14
|
+
* @module services/hsuite-auth-interceptor
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* `HsuiteAuthInterceptor` automatically adds the active smart-host bearer token
|
|
18
|
+
* and wallet ledger identifier to outgoing HTTP requests. When a request fails
|
|
19
|
+
* with HTTP 401, it delegates recovery to {@link SmartSessionService} for a
|
|
20
|
+
* single re-login and retry.
|
|
21
|
+
*
|
|
22
|
+
* **Registration (standalone apps):**
|
|
23
|
+
* ```typescript
|
|
24
|
+
* provideHttpClient(withInterceptors([provideHsuiteAuthInterceptor()]))
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* **Registration (module-based apps):**
|
|
28
|
+
* ```typescript
|
|
29
|
+
* { provide: HTTP_INTERCEPTORS, useClass: HsuiteAuthInterceptor, multi: true }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
HttpErrorResponse,
|
|
35
|
+
HttpEvent,
|
|
36
|
+
HttpHandler,
|
|
37
|
+
HttpInterceptor,
|
|
38
|
+
HttpInterceptorFn,
|
|
39
|
+
HttpRequest,
|
|
40
|
+
} from '@angular/common/http';
|
|
41
|
+
import { inject, Injectable } from '@angular/core';
|
|
42
|
+
import { catchError, from, Observable, switchMap, throwError } from 'rxjs';
|
|
43
|
+
|
|
44
|
+
import { SmartSessionService } from './smart-session.service';
|
|
45
|
+
import { UnifiedWalletService } from './unified-wallet.service';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Headers injected by the interceptor.
|
|
49
|
+
*/
|
|
50
|
+
export const HSUITE_AUTH_HEADER = 'Authorization';
|
|
51
|
+
export const HSUITE_LEDGER_HEADER = 'X-Ledger-Id';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Functional HTTP interceptor that attaches wallet-attributed auth headers.
|
|
55
|
+
*
|
|
56
|
+
* @description
|
|
57
|
+
* Adds:
|
|
58
|
+
* - `Authorization: Bearer <token>` when {@link SmartSessionService.getBearer} returns a token
|
|
59
|
+
* - `X-Ledger-Id: <ledgerId>` when a wallet account is active
|
|
60
|
+
*
|
|
61
|
+
* On 401 responses, clears the stale bearer and retries once after re-login.
|
|
62
|
+
*
|
|
63
|
+
* @param req - The outgoing HTTP request
|
|
64
|
+
* @param next - The downstream request handler
|
|
65
|
+
* @returns Observable of HTTP events
|
|
66
|
+
*/
|
|
67
|
+
export const hsuiteAuthInterceptor: HttpInterceptorFn = (req, next) => {
|
|
68
|
+
const session = inject(SmartSessionService);
|
|
69
|
+
const wallet = inject(UnifiedWalletService);
|
|
70
|
+
|
|
71
|
+
const authenticated = appendAuthHeaders(req, session, wallet);
|
|
72
|
+
|
|
73
|
+
return next(authenticated).pipe(
|
|
74
|
+
catchError((error) => {
|
|
75
|
+
if (error instanceof HttpErrorResponse && error.status === 401) {
|
|
76
|
+
session.logout();
|
|
77
|
+
return from(session.login()).pipe(
|
|
78
|
+
switchMap(() => next(appendAuthHeaders(req, session, wallet))),
|
|
79
|
+
catchError((loginError) => throwError(() => loginError)),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
return throwError(() => error);
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Class-based HTTP interceptor for module-based Angular apps.
|
|
89
|
+
*
|
|
90
|
+
* @description
|
|
91
|
+
* Provides the same behavior as {@link hsuiteAuthInterceptor} in a class form
|
|
92
|
+
* suitable for registration via `HTTP_INTERCEPTORS`.
|
|
93
|
+
*/
|
|
94
|
+
@Injectable({ providedIn: 'root' })
|
|
95
|
+
export class HsuiteAuthInterceptor implements HttpInterceptor {
|
|
96
|
+
private readonly session = inject(SmartSessionService);
|
|
97
|
+
private readonly wallet = inject(UnifiedWalletService);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Intercepts outgoing HTTP requests to attach wallet-attributed auth headers.
|
|
101
|
+
*
|
|
102
|
+
* @param req - The outgoing HTTP request
|
|
103
|
+
* @param next - The downstream request handler
|
|
104
|
+
* @returns Observable of HTTP events
|
|
105
|
+
*/
|
|
106
|
+
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
|
107
|
+
const authenticated = appendAuthHeaders(req, this.session, this.wallet);
|
|
108
|
+
|
|
109
|
+
return next.handle(authenticated).pipe(
|
|
110
|
+
catchError((error) => {
|
|
111
|
+
if (error instanceof HttpErrorResponse && error.status === 401) {
|
|
112
|
+
this.session.logout();
|
|
113
|
+
return from(this.session.login()).pipe(
|
|
114
|
+
switchMap(() => next.handle(appendAuthHeaders(req, this.session, this.wallet))),
|
|
115
|
+
catchError((loginError) => throwError(() => loginError)),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return throwError(() => error);
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Helper that clones a request with the active auth headers attached.
|
|
126
|
+
*
|
|
127
|
+
* @param req - The outgoing HTTP request
|
|
128
|
+
* @param session - Smart session service for bearer lookup
|
|
129
|
+
* @param wallet - Unified wallet service for ledger ID lookup
|
|
130
|
+
* @returns The request cloned with Authorization and/or X-Ledger-Id headers
|
|
131
|
+
*/
|
|
132
|
+
function appendAuthHeaders(
|
|
133
|
+
req: HttpRequest<unknown>,
|
|
134
|
+
session: SmartSessionService,
|
|
135
|
+
wallet: UnifiedWalletService,
|
|
136
|
+
): HttpRequest<unknown> {
|
|
137
|
+
const bearer = session.getBearer();
|
|
138
|
+
const activeAccount = wallet.activeAccount();
|
|
139
|
+
const ledgerId = activeAccount?.ledgerId;
|
|
140
|
+
|
|
141
|
+
// Avoid mutating requests that already carry an Authorization header
|
|
142
|
+
if (!bearer && !ledgerId) {
|
|
143
|
+
return req;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const headers: Record<string, string> = {};
|
|
147
|
+
if (bearer && !req.headers.has(HSUITE_AUTH_HEADER)) {
|
|
148
|
+
headers[HSUITE_AUTH_HEADER] = `Bearer ${bearer}`;
|
|
149
|
+
}
|
|
150
|
+
if (ledgerId && !req.headers.has(HSUITE_LEDGER_HEADER)) {
|
|
151
|
+
headers[HSUITE_LEDGER_HEADER] = ledgerId;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (Object.keys(headers).length === 0) {
|
|
155
|
+
return req;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return req.clone({ setHeaders: headers });
|
|
159
|
+
}
|