@hsuite/native-connect-angular 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ import { SupportedLedger, TransportState, Logger, TransportProvider, ChannelStat
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';
12
+ import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpInterceptorFn } from '@angular/common/http';
12
13
  import { MessageEnvelope, LedgerId } from '@hsuite/native-connect-types';
13
14
  export { LedgerId, RpcEnvelope, RpcRequest, RpcResponse, SessionApproval } from '@hsuite/native-connect-types';
14
15
  import SignClient from '@walletconnect/sign-client';
@@ -177,7 +178,7 @@ type ConnectionConfig$1 = HsuiteNativeConfig | WalletConnectV2Config | MobileNat
177
178
  * visit https://hsuite.finance/licensing
178
179
  */
179
180
  /**
180
- * @fileoverview Unified account model that works across all wallet providers.
181
+ * @file Unified account model that works across all wallet providers.
181
182
  *
182
183
  * @module models/unified-account
183
184
  *
@@ -209,6 +210,8 @@ interface UnifiedAccount {
209
210
  id: string;
210
211
  /** Account address/public key */
211
212
  address: string;
213
+ /** Public key associated with the account, when available from the provider. */
214
+ publicKey?: string;
212
215
  /** Human-readable label */
213
216
  label?: string;
214
217
  /** Ledger ID (e.g., 'hedera', 'xrpl') */
@@ -1884,7 +1887,7 @@ declare class UnifiedWalletService {
1884
1887
  * @throws {Error} If provider is not found
1885
1888
  * @throws {Error} If user rejects the signing request
1886
1889
  */
1887
- signMessage(message: string, encoding?: 'utf-8' | 'base64'): Promise<unknown>;
1890
+ signMessage(message: string, encoding?: 'utf-8' | 'base64'): Promise<SignMessageResult>;
1888
1891
  /**
1889
1892
  * Signs and executes a transaction in a single prompt.
1890
1893
  *
@@ -4598,7 +4601,7 @@ declare class TransactionService {
4598
4601
  * @param message - Message to sign
4599
4602
  * @returns Sign result with signature
4600
4603
  */
4601
- signMessage(message: string): Promise<SignResult>;
4604
+ signMessage(message: string): Promise<SignMessageResult>;
4602
4605
  /**
4603
4606
  * Show a success toast notification
4604
4607
  * Uses cssClass-only styling (no Ionic color property) for theme compatibility.
@@ -4728,6 +4731,233 @@ declare class LoggerService {
4728
4731
  static ɵprov: i0.ɵɵInjectableDeclaration<LoggerService>;
4729
4732
  }
4730
4733
 
4734
+ /**
4735
+ * Configuration token for {@link SmartSessionService}.
4736
+ */
4737
+ declare const SMART_SESSION_CONFIG: InjectionToken<SmartSessionConfig>;
4738
+ /**
4739
+ * Configuration for the smart-host session handshake.
4740
+ */
4741
+ interface SmartSessionConfig {
4742
+ /**
4743
+ * Base URL for the smart-host API.
4744
+ * @default '' (relative to the current origin)
4745
+ */
4746
+ baseUrl?: string;
4747
+ /**
4748
+ * Health endpoint used to discover the host `appId`.
4749
+ * @default '/api/health'
4750
+ */
4751
+ healthEndpoint?: string;
4752
+ /**
4753
+ * Challenge endpoint used to obtain a message to sign.
4754
+ * @default '/api/auth/challenge'
4755
+ */
4756
+ challengeEndpoint?: string;
4757
+ /**
4758
+ * Verify endpoint used to exchange the signed challenge for a bearer token.
4759
+ * @default '/api/auth/verify'
4760
+ */
4761
+ verifyEndpoint?: string;
4762
+ /**
4763
+ * sessionStorage key used to persist the session token and expiry.
4764
+ * @default 'hsuite.smart-session'
4765
+ */
4766
+ storageKey?: string;
4767
+ }
4768
+ /**
4769
+ * Health response shape expected from the smart host.
4770
+ */
4771
+ interface SmartHostHealth {
4772
+ appId: string;
4773
+ [key: string]: unknown;
4774
+ }
4775
+ /**
4776
+ * Challenge response shape expected from the smart host.
4777
+ */
4778
+ interface SmartHostChallenge {
4779
+ challenge: string;
4780
+ [key: string]: unknown;
4781
+ }
4782
+ /**
4783
+ * Verify request payload sent to the smart host.
4784
+ */
4785
+ interface SmartHostVerifyRequest {
4786
+ appId: string;
4787
+ accountAddress: string;
4788
+ publicKey?: string;
4789
+ signature: string;
4790
+ algorithm?: string;
4791
+ message: string;
4792
+ caipChainId?: string;
4793
+ ledgerId?: string;
4794
+ networkId?: string;
4795
+ }
4796
+ /**
4797
+ * Verify response shape expected from the smart host.
4798
+ */
4799
+ interface SmartHostVerifyResponse {
4800
+ bearer: string;
4801
+ expiresAt?: number;
4802
+ expiresIn?: number;
4803
+ [key: string]: unknown;
4804
+ }
4805
+ /**
4806
+ * Smart-host customer session helper.
4807
+ *
4808
+ * @service SmartSessionService
4809
+ *
4810
+ * @description
4811
+ * Encapsulates the full challenge → sign → verify → store JWT flow required by
4812
+ * HSuite smart hosts. The service is intentionally thin: it delegates signing to
4813
+ * {@link TransactionService} and relies on standard Angular `HttpClient` for the
4814
+ * host HTTP calls.
4815
+ *
4816
+ * @providedIn root
4817
+ */
4818
+ declare class SmartSessionService {
4819
+ private readonly http;
4820
+ private readonly walletService;
4821
+ private readonly transactionService;
4822
+ private readonly config;
4823
+ private get baseUrl();
4824
+ private get healthEndpoint();
4825
+ private get challengeEndpoint();
4826
+ private get verifyEndpoint();
4827
+ private get storageKey();
4828
+ /**
4829
+ * Returns the currently stored bearer token, or `null` if there is no session.
4830
+ *
4831
+ * @returns Bearer token string or null
4832
+ */
4833
+ getBearer(): string | null;
4834
+ /**
4835
+ * Checks whether a non-expired session is available.
4836
+ *
4837
+ * @returns true if logged in and the bearer has not expired
4838
+ */
4839
+ isLoggedIn(): boolean;
4840
+ /**
4841
+ * Performs the full smart-host login handshake.
4842
+ *
4843
+ * @description
4844
+ * 1. Discovers `appId` from the health endpoint.
4845
+ * 2. Fetches a challenge from the challenge endpoint.
4846
+ * 3. Signs the challenge with the active wallet account.
4847
+ * 4. Exchanges the signed challenge for a bearer token.
4848
+ * 5. Stores the bearer and expiry in `sessionStorage`.
4849
+ *
4850
+ * @returns The verify response from the host
4851
+ *
4852
+ * @throws {Error} If no active account is available
4853
+ * @throws {Error} If the health endpoint does not return an `appId`
4854
+ * @throws {Error} If the challenge endpoint does not return a `challenge`
4855
+ * @throws {Error} If the verify call fails
4856
+ */
4857
+ login(): Promise<SmartHostVerifyResponse>;
4858
+ /**
4859
+ * Clears the stored session.
4860
+ */
4861
+ logout(): void;
4862
+ /**
4863
+ * Runs an HTTP operation with automatic 401 recovery.
4864
+ *
4865
+ * @description
4866
+ * Executes the provided operation. If it rejects with an HTTP 401 error,
4867
+ * the service clears the current bearer, performs a fresh login, and retries
4868
+ * the operation once. Any other error is propagated immediately.
4869
+ *
4870
+ * @param operation - Async operation that needs a valid session
4871
+ * @returns The result of the operation
4872
+ *
4873
+ * @throws {Error} The original error if retry is not possible or fails
4874
+ */
4875
+ withSession<T>(operation: () => Promise<T>): Promise<T>;
4876
+ private fetchHealth;
4877
+ private fetchChallenge;
4878
+ private verifyChallenge;
4879
+ private resolveExpiry;
4880
+ private readStoredSession;
4881
+ private storeSession;
4882
+ private clearStoredSession;
4883
+ private isUnauthorizedError;
4884
+ static ɵfac: i0.ɵɵFactoryDeclaration<SmartSessionService, never>;
4885
+ static ɵprov: i0.ɵɵInjectableDeclaration<SmartSessionService>;
4886
+ }
4887
+
4888
+ /**
4889
+ * HSuite Native Connect
4890
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4891
+ *
4892
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
4893
+ *
4894
+ * This file is part of HSuite Native Connect. For commercial licensing,
4895
+ * visit https://hsuite.finance/licensing
4896
+ */
4897
+ /**
4898
+ * @file HTTP interceptor that attaches wallet-attributed auth headers.
4899
+ *
4900
+ * @module services/hsuite-auth-interceptor
4901
+ *
4902
+ * @description
4903
+ * `HsuiteAuthInterceptor` automatically adds the active smart-host bearer token
4904
+ * and wallet ledger identifier to outgoing HTTP requests. When a request fails
4905
+ * with HTTP 401, it delegates recovery to {@link SmartSessionService} for a
4906
+ * single re-login and retry.
4907
+ *
4908
+ * **Registration (standalone apps):**
4909
+ * ```typescript
4910
+ * provideHttpClient(withInterceptors([provideHsuiteAuthInterceptor()]))
4911
+ * ```
4912
+ *
4913
+ * **Registration (module-based apps):**
4914
+ * ```typescript
4915
+ * { provide: HTTP_INTERCEPTORS, useClass: HsuiteAuthInterceptor, multi: true }
4916
+ * ```
4917
+ */
4918
+
4919
+ /**
4920
+ * Headers injected by the interceptor.
4921
+ */
4922
+ declare const HSUITE_AUTH_HEADER = "Authorization";
4923
+ declare const HSUITE_LEDGER_HEADER = "X-Ledger-Id";
4924
+ /**
4925
+ * Functional HTTP interceptor that attaches wallet-attributed auth headers.
4926
+ *
4927
+ * @description
4928
+ * Adds:
4929
+ * - `Authorization: Bearer <token>` when {@link SmartSessionService.getBearer} returns a token
4930
+ * - `X-Ledger-Id: <ledgerId>` when a wallet account is active
4931
+ *
4932
+ * On 401 responses, clears the stale bearer and retries once after re-login.
4933
+ *
4934
+ * @param req - The outgoing HTTP request
4935
+ * @param next - The downstream request handler
4936
+ * @returns Observable of HTTP events
4937
+ */
4938
+ declare const hsuiteAuthInterceptor: HttpInterceptorFn;
4939
+ /**
4940
+ * Class-based HTTP interceptor for module-based Angular apps.
4941
+ *
4942
+ * @description
4943
+ * Provides the same behavior as {@link hsuiteAuthInterceptor} in a class form
4944
+ * suitable for registration via `HTTP_INTERCEPTORS`.
4945
+ */
4946
+ declare class HsuiteAuthInterceptor implements HttpInterceptor {
4947
+ private readonly session;
4948
+ private readonly wallet;
4949
+ /**
4950
+ * Intercepts outgoing HTTP requests to attach wallet-attributed auth headers.
4951
+ *
4952
+ * @param req - The outgoing HTTP request
4953
+ * @param next - The downstream request handler
4954
+ * @returns Observable of HTTP events
4955
+ */
4956
+ intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
4957
+ static ɵfac: i0.ɵɵFactoryDeclaration<HsuiteAuthInterceptor, never>;
4958
+ static ɵprov: i0.ɵɵInjectableDeclaration<HsuiteAuthInterceptor>;
4959
+ }
4960
+
4731
4961
  /**
4732
4962
  * Supported inner transaction types for batch transactions.
4733
4963
  * Excludes 'batch-transaction' since batches cannot be nested.
@@ -7171,5 +7401,5 @@ declare function getLedgerName(ledgerId: string): string;
7171
7401
  */
7172
7402
  declare function getTokenIcon(tokenIconUrl: string | undefined, ledgerId: string): string;
7173
7403
 
7174
- export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL, HederaSigner, HederaTransactionBuilderService, HsuiteNativeProvider, HsuiteWalletModule, LEDGER_COLORS, LEDGER_ICON_NAMES, LEDGER_NAMES, LedgerUIRegistry, LoggerService, P2PNativeProvider, P2PSessionManager, SignerFactory, TransactionService, UnifiedWalletService, WalletAccountDisplayComponent, WalletConnectButtonComponent, WalletConnectClientManager, WalletConnectPromptComponent, WalletConnectSessionStore, WalletConnectSigningOrchestrator, WalletConnectV2Provider, WalletConnectedDirective, WalletConnectedGuardComponent, WalletConnectionModalComponent, WalletContextDirective, WalletContextService, WalletErrorHandler, WalletEventBus, WalletEventsDirective, WalletSessionDisplayComponent, WalletTransactionStatusComponent, XrplSigner, XrplTransactionBuilderService, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, provideWalletErrorHandler, registerLedgerIcons, scaleHederaAmountToBaseUnits };
7175
- export type { AccountChangeEvent, AccountCreateOptions, AccountGroupingMode, AccountItem, AccountSelectorConfig, AccountSelectorPresentationMode, AccountWithBalance, AccountsUpdateEvent, ActiveAccountData, ActiveAccountSource, BatchInnerTransaction, BatchInnerTransactionType, ChannelConnectConfig, ChromeExtensionTransportOptions, CompactHeaderFormat, CompactHeaderSize, ConnectionConfig, ConnectionEvent, ConnectionStatus, CreateOfferOptions, CreateOfferResult, DisconnectionEvent, HederaKeyConfig, HsuiteNativeConfig, IWalletConnectSigner, LedgerGroup$1 as LedgerGroup, LedgerUiDescriptor, MobileNativeConfig, NetworkGroup, P2PConnectionState, P2PNativeConnectionState, P2PSession, PairingOfferResult, ProtocolGroup, ProviderErrorEvent, ProviderMetadata, ProviderStatusEvent, ProviderType, SelectedAccountData, SessionEvent, SessionMetadata, SignMessageOptions, SignMessageResult, SignResult, SignTransactionOptions, SignerContext, SignerOperationParams, SigningOrchestratorConfig, StoredSessionData, SubmitResult, SubmitTransactionOptions, TokenCreateOptions, TopicCreateOptions, UnifiedAccount, WCAppMetadata, WalletConnectSession, WalletConnectSignerConfig, WalletConnectV2Config, WalletContext, WalletErrorHandlerConfig, WalletSession };
7404
+ 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, P2PNativeProvider, P2PSessionManager, 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, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, hsuiteAuthInterceptor, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, provideWalletErrorHandler, registerLedgerIcons, scaleHederaAmountToBaseUnits };
7405
+ export type { AccountChangeEvent, AccountCreateOptions, AccountGroupingMode, AccountItem, AccountSelectorConfig, AccountSelectorPresentationMode, AccountWithBalance, AccountsUpdateEvent, ActiveAccountData, ActiveAccountSource, BatchInnerTransaction, BatchInnerTransactionType, ChannelConnectConfig, ChromeExtensionTransportOptions, CompactHeaderFormat, CompactHeaderSize, ConnectionConfig, ConnectionEvent, ConnectionStatus, CreateOfferOptions, CreateOfferResult, DisconnectionEvent, HederaKeyConfig, HsuiteNativeConfig, IWalletConnectSigner, LedgerGroup$1 as LedgerGroup, LedgerUiDescriptor, MobileNativeConfig, NetworkGroup, P2PConnectionState, P2PNativeConnectionState, P2PSession, PairingOfferResult, ProtocolGroup, ProviderErrorEvent, ProviderMetadata, ProviderStatusEvent, ProviderType, SelectedAccountData, SessionEvent, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsuite/native-connect-angular",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "description": "Angular integration SDK for HSuite Wallet - provides direct SDK integration without wrappers",
6
6
  "type": "module",
@@ -20,6 +20,7 @@
20
20
  "dependencies": {
21
21
  "@hashgraph/proto": "^2.25.0",
22
22
  "@hashgraph/sdk": "^2.76.0",
23
+ "@hsuite/native-connect-sdk": "^2.1.1",
23
24
  "@walletconnect/modal": "^2.7.0",
24
25
  "@walletconnect/sign-client": "^2.23.0",
25
26
  "@walletconnect/types": "^2.23.0",
@@ -27,8 +28,7 @@
27
28
  "qrcode": "^1.5.4",
28
29
  "tslib": "^2.6.0",
29
30
  "xrpl": "^3.0.0",
30
- "@hsuite/native-connect-types": "2.1.2",
31
- "@hsuite/native-connect-sdk": "2.1.0"
31
+ "@hsuite/native-connect-types": "^2.1.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@angular-devkit/build-angular": "^20.3.14",