@hsuite/native-connect-angular 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1829,6 +1829,23 @@ class NoAccountsForNetworkError extends Error {
|
|
|
1829
1829
|
this.name = 'NoAccountsForNetworkError';
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
1832
|
+
/**
|
|
1833
|
+
* A connect was asked for while another one is still waiting for the wallet,
|
|
1834
|
+
* and it cannot share that request: a QR pairing next to a window connect, or
|
|
1835
|
+
* a pending session this call did not start. Nothing was started. The connect
|
|
1836
|
+
* modal shows it as the `'busy'` error.
|
|
1837
|
+
*/
|
|
1838
|
+
class ConnectionInProgressError extends Error {
|
|
1839
|
+
providerType;
|
|
1840
|
+
/**
|
|
1841
|
+
* @param providerType - Provider that already has a connect waiting
|
|
1842
|
+
*/
|
|
1843
|
+
constructor(providerType) {
|
|
1844
|
+
super('Another connection is still waiting for approval in the wallet');
|
|
1845
|
+
this.providerType = providerType;
|
|
1846
|
+
this.name = 'ConnectionInProgressError';
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1832
1849
|
|
|
1833
1850
|
/**
|
|
1834
1851
|
* HSuite Native Connect
|
|
@@ -3302,6 +3319,11 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
3302
3319
|
this.localDiscoveryService = LocalDiscoveryService.getDAppInstance();
|
|
3303
3320
|
this.localDiscoveryService.start();
|
|
3304
3321
|
}
|
|
3322
|
+
/**
|
|
3323
|
+
* The connect waiting for the wallet's answer, if any. A second window
|
|
3324
|
+
* connect returns this promise instead of starting another request.
|
|
3325
|
+
*/
|
|
3326
|
+
pendingConnect = null;
|
|
3305
3327
|
/**
|
|
3306
3328
|
* Maps the internal channel state to the provider connection status.
|
|
3307
3329
|
*
|
|
@@ -3380,17 +3402,46 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
3380
3402
|
* @throws {Error} If configuration is invalid
|
|
3381
3403
|
* @throws {Error} If connection times out (default 120 seconds)
|
|
3382
3404
|
* @throws {Error} If popup is blocked and wallet cannot be opened
|
|
3405
|
+
* @throws {ConnectionInProgressError} If another connect is waiting for the
|
|
3406
|
+
* wallet and this one cannot share its request
|
|
3383
3407
|
*/
|
|
3384
3408
|
async connect(config) {
|
|
3385
3409
|
if (!this.isHsuiteNativeConfig(config)) {
|
|
3386
3410
|
throw new Error('Invalid HSuite Native configuration');
|
|
3387
3411
|
}
|
|
3388
|
-
//
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3412
|
+
// One request at a time, and a connect never resolves before the wallet
|
|
3413
|
+
// answers: callers read a resolved connect as "the wallet approved".
|
|
3414
|
+
const manualDelivery = !!config.onInviteReady;
|
|
3415
|
+
const pending = this.pendingConnect;
|
|
3416
|
+
if (pending) {
|
|
3417
|
+
// A second window connect is, to the user, the request the wallet is
|
|
3418
|
+
// still showing, so it waits for that answer. A QR pairing is not: the
|
|
3419
|
+
// pending request cannot carry its invite.
|
|
3420
|
+
if (!manualDelivery && !pending.manualDelivery) {
|
|
3421
|
+
logger$f.warn('Connection already in progress, waiting for it');
|
|
3422
|
+
return pending.promise;
|
|
3423
|
+
}
|
|
3424
|
+
throw new ConnectionInProgressError('hsuite-native');
|
|
3425
|
+
}
|
|
3426
|
+
if (this.status() === 'connecting') {
|
|
3427
|
+
// A session is pending that this call did not start and cannot wait on.
|
|
3428
|
+
throw new ConnectionInProgressError('hsuite-native');
|
|
3393
3429
|
}
|
|
3430
|
+
const promise = this.startConnect(config);
|
|
3431
|
+
const started = { promise, manualDelivery };
|
|
3432
|
+
this.pendingConnect = started;
|
|
3433
|
+
const clear = () => {
|
|
3434
|
+
if (this.pendingConnect === started)
|
|
3435
|
+
this.pendingConnect = null;
|
|
3436
|
+
};
|
|
3437
|
+
promise.then(clear, clear);
|
|
3438
|
+
return promise;
|
|
3439
|
+
}
|
|
3440
|
+
/**
|
|
3441
|
+
* Create the invite, deliver it and wait for the wallet's answer.
|
|
3442
|
+
* @param config - HSuite Native connection configuration
|
|
3443
|
+
*/
|
|
3444
|
+
async startConnect(config) {
|
|
3394
3445
|
logger$f.info('Connecting to HSuite Wallet via unified channel protocol', { config });
|
|
3395
3446
|
// Tracked so the catch block can clean up a half-open session created
|
|
3396
3447
|
// before the failure (the SDK never expires pending invites itself).
|
|
@@ -10834,13 +10885,18 @@ function isPhoneLayout(platform) {
|
|
|
10834
10885
|
* messages come from `channel-client.service.ts` (rejected / timeout);
|
|
10835
10886
|
* WalletConnect wallets report rejections as "User rejected …" and stale
|
|
10836
10887
|
* pairings as "… expired", which reads as a timeout to the user. A connect
|
|
10837
|
-
* that shared no account on the selected network
|
|
10838
|
-
*
|
|
10888
|
+
* that shared no account on the selected network, and one refused because
|
|
10889
|
+
* another is still waiting for the wallet, are matched by name as well, in
|
|
10890
|
+
* case the error comes from another copy of the package.
|
|
10839
10891
|
* @param err
|
|
10840
10892
|
*/
|
|
10841
10893
|
function classifyConnectError(err) {
|
|
10842
10894
|
if (err instanceof NativeSessionLimitError)
|
|
10843
10895
|
return 'session-limit';
|
|
10896
|
+
if (err instanceof ConnectionInProgressError ||
|
|
10897
|
+
(err instanceof Error && err.name === 'ConnectionInProgressError')) {
|
|
10898
|
+
return 'busy';
|
|
10899
|
+
}
|
|
10844
10900
|
if (err instanceof NoAccountsForNetworkError ||
|
|
10845
10901
|
(err instanceof Error && err.name === 'NoAccountsForNetworkError')) {
|
|
10846
10902
|
return 'wrong-network';
|
|
@@ -13093,9 +13149,10 @@ class WalletConnectionModalComponent {
|
|
|
13093
13149
|
this.onAttemptSucceeded(attempt, ledger ? 'walletconnect-v2' : 'hsuite-native', network, before);
|
|
13094
13150
|
}
|
|
13095
13151
|
/**
|
|
13096
|
-
*
|
|
13097
|
-
*
|
|
13098
|
-
* the request
|
|
13152
|
+
* Re-picking HSuite Wallet after backing out re-attaches to the request the
|
|
13153
|
+
* wallet is still showing instead of starting a new one. The provider does
|
|
13154
|
+
* the same for a request this modal did not start (one left pending by a
|
|
13155
|
+
* modal that was closed): its connect waits for that request's answer.
|
|
13099
13156
|
* @param network
|
|
13100
13157
|
*/
|
|
13101
13158
|
connectHsuiteWallet(network) {
|
|
@@ -13192,8 +13249,8 @@ class WalletConnectionModalComponent {
|
|
|
13192
13249
|
async startQrPairing(attempt) {
|
|
13193
13250
|
this.pairingOffer.set('');
|
|
13194
13251
|
this.pairingInviteUrl.set('');
|
|
13195
|
-
// The provider
|
|
13196
|
-
//
|
|
13252
|
+
// The provider refuses a pairing while a window connect is pending: say
|
|
13253
|
+
// so here without asking it.
|
|
13197
13254
|
if (this.nativeConnect) {
|
|
13198
13255
|
// Waiting for it could take the whole approval timeout; say why instead.
|
|
13199
13256
|
this.onAttemptFailed(attempt, new Error('Another HSuite Wallet connection is still waiting for approval'), 'busy');
|
|
@@ -19310,5 +19367,5 @@ function provideWalletErrorHandler(config) {
|
|
|
19310
19367
|
* Generated bundle index. Do not edit.
|
|
19311
19368
|
*/
|
|
19312
19369
|
|
|
19313
|
-
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountChipComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountMenuComponent, 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$1 as LEDGER_NAMES, LedgerUIRegistry, LoggerService, MAX_NATIVE_SESSIONS, NATIVE_SESSION_KEY_PREFIX, NativeSessionLimitError, NoAccountsForNetworkError, SMART_SESSION_CONFIG, SessionNoticeService, SignerFactory, SmartSessionService, TransactionService, UnifiedWalletService, WALLET_UI_CONFIG, WalletAccountDisplayComponent, WalletButtonComponent, WalletConnectButtonComponent, WalletConnectClientManager, WalletConnectPromptComponent, WalletConnectSessionStore, WalletConnectSigningOrchestrator, WalletConnectV2Provider, WalletConnectedDirective, WalletConnectedGuardComponent, WalletConnectionModalComponent, WalletContextDirective, WalletContextService, WalletErrorHandler, WalletEventBus, WalletEventsDirective, WalletSessionDisplayComponent, WalletTransactionStatusComponent, WalletUiService, XrplSigner, XrplTransactionBuilderService, channelIdFromSessionKey, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, hsuiteAuthInterceptor, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, nativeSessionKeyFor, parseNativeSessionKey, provideWalletErrorHandler, provideWalletUi, registerLedgerIcons, scaleHederaAmountToBaseUnits, supportsSessionManagement };
|
|
19370
|
+
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountChipComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountMenuComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, ConnectionInProgressError, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL, HSUITE_AUTH_HEADER, HSUITE_LEDGER_HEADER, HederaSigner, HederaTransactionBuilderService, HsuiteAuthInterceptor, HsuiteNativeProvider, HsuiteWalletModule, LEDGER_COLORS, LEDGER_ICON_NAMES, LEDGER_NAMES$1 as LEDGER_NAMES, LedgerUIRegistry, LoggerService, MAX_NATIVE_SESSIONS, NATIVE_SESSION_KEY_PREFIX, NativeSessionLimitError, NoAccountsForNetworkError, SMART_SESSION_CONFIG, SessionNoticeService, SignerFactory, SmartSessionService, TransactionService, UnifiedWalletService, WALLET_UI_CONFIG, WalletAccountDisplayComponent, WalletButtonComponent, WalletConnectButtonComponent, WalletConnectClientManager, WalletConnectPromptComponent, WalletConnectSessionStore, WalletConnectSigningOrchestrator, WalletConnectV2Provider, WalletConnectedDirective, WalletConnectedGuardComponent, WalletConnectionModalComponent, WalletContextDirective, WalletContextService, WalletErrorHandler, WalletEventBus, WalletEventsDirective, WalletSessionDisplayComponent, WalletTransactionStatusComponent, WalletUiService, XrplSigner, XrplTransactionBuilderService, channelIdFromSessionKey, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, hsuiteAuthInterceptor, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, nativeSessionKeyFor, parseNativeSessionKey, provideWalletErrorHandler, provideWalletUi, registerLedgerIcons, scaleHederaAmountToBaseUnits, supportsSessionManagement };
|
|
19314
19371
|
//# sourceMappingURL=hsuite-native-connect-angular.mjs.map
|