@hsuite/native-connect-angular 2.1.3 → 2.1.5

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
@@ -5,10 +5,11 @@ 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, TransportState, Logger, TransportProvider, ChannelState, ChannelAccount, ChannelInvite, ChannelType } from '@hsuite/native-connect-sdk';
8
+ import { SupportedLedger, AuthSigningScheme, TransportState, Logger, TransportProvider, ChannelState, 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';
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') */
@@ -449,6 +452,19 @@ interface SignMessageResult {
449
452
  * ambiguity when verifying the signature.
450
453
  */
451
454
  messageLength?: number;
455
+ /**
456
+ * Which byte layout the wallet actually signed, so a verifier reconstructs
457
+ * the correct bytes:
458
+ * - `hsuite-domain` — HSuite domain-separated blob (native `hsc:` path;
459
+ * `buildDomainSeparatedMessage`). This is the default when absent.
460
+ * - `hedera-wc` — Hedera WalletConnect standard
461
+ * (`\x19Hedera Signed Message:\n<len><msg>`), returned by `hedera_signMessage`.
462
+ *
463
+ * A signature is only verifiable against the scheme it was produced under —
464
+ * the two are cryptographically incompatible. Absent = `hsuite-domain` for
465
+ * backwards compatibility with pre-existing native flows.
466
+ */
467
+ signingScheme?: AuthSigningScheme;
452
468
  /** Additional metadata from the wallet. */
453
469
  metadata?: Record<string, unknown>;
454
470
  }
@@ -1884,7 +1900,7 @@ declare class UnifiedWalletService {
1884
1900
  * @throws {Error} If provider is not found
1885
1901
  * @throws {Error} If user rejects the signing request
1886
1902
  */
1887
- signMessage(message: string, encoding?: 'utf-8' | 'base64'): Promise<unknown>;
1903
+ signMessage(message: string, encoding?: 'utf-8' | 'base64'): Promise<SignMessageResult>;
1888
1904
  /**
1889
1905
  * Signs and executes a transaction in a single prompt.
1890
1906
  *
@@ -4598,7 +4614,7 @@ declare class TransactionService {
4598
4614
  * @param message - Message to sign
4599
4615
  * @returns Sign result with signature
4600
4616
  */
4601
- signMessage(message: string): Promise<SignResult>;
4617
+ signMessage(message: string): Promise<SignMessageResult>;
4602
4618
  /**
4603
4619
  * Show a success toast notification
4604
4620
  * Uses cssClass-only styling (no Ionic color property) for theme compatibility.
@@ -4728,6 +4744,242 @@ declare class LoggerService {
4728
4744
  static ɵprov: i0.ɵɵInjectableDeclaration<LoggerService>;
4729
4745
  }
4730
4746
 
4747
+ /**
4748
+ * Configuration token for {@link SmartSessionService}.
4749
+ */
4750
+ declare const SMART_SESSION_CONFIG: InjectionToken<SmartSessionConfig>;
4751
+ /**
4752
+ * Configuration for the smart-host session handshake.
4753
+ */
4754
+ interface SmartSessionConfig {
4755
+ /**
4756
+ * Base URL for the smart-host API.
4757
+ * @default '' (relative to the current origin)
4758
+ */
4759
+ baseUrl?: string;
4760
+ /**
4761
+ * Health endpoint used to discover the host `appId`.
4762
+ * @default '/api/health'
4763
+ */
4764
+ healthEndpoint?: string;
4765
+ /**
4766
+ * Challenge endpoint used to obtain a message to sign.
4767
+ * @default '/api/auth/challenge'
4768
+ */
4769
+ challengeEndpoint?: string;
4770
+ /**
4771
+ * Verify endpoint used to exchange the signed challenge for a bearer token.
4772
+ * @default '/api/auth/verify'
4773
+ */
4774
+ verifyEndpoint?: string;
4775
+ /**
4776
+ * sessionStorage key used to persist the session token and expiry.
4777
+ * @default 'hsuite.smart-session'
4778
+ */
4779
+ storageKey?: string;
4780
+ }
4781
+ /**
4782
+ * Health response shape expected from the smart host.
4783
+ */
4784
+ interface SmartHostHealth {
4785
+ appId: string;
4786
+ [key: string]: unknown;
4787
+ }
4788
+ /**
4789
+ * Challenge response shape expected from the smart host.
4790
+ */
4791
+ interface SmartHostChallenge {
4792
+ challenge: string;
4793
+ [key: string]: unknown;
4794
+ }
4795
+ /**
4796
+ * Verify request payload sent to the smart host.
4797
+ */
4798
+ interface SmartHostVerifyRequest {
4799
+ appId: string;
4800
+ accountAddress: string;
4801
+ publicKey?: string;
4802
+ signature: string;
4803
+ algorithm?: string;
4804
+ message: string;
4805
+ caipChainId?: string;
4806
+ ledgerId?: string;
4807
+ networkId?: string;
4808
+ /**
4809
+ * Byte layout the wallet signed, so the host reconstructs the correct bytes
4810
+ * before verifying. Only sent when it deviates from the legacy default:
4811
+ * absent = native `hsc:` domain-separated signing (`hsuite-domain`), which
4812
+ * every already-deployed host understands; `hedera-wc` = WalletConnect's
4813
+ * `hedera_signMessage`. The host should feed this straight into
4814
+ * `verifyAuthSignature` from `@hsuite/native-connect-sdk`.
4815
+ */
4816
+ signingScheme?: AuthSigningScheme;
4817
+ }
4818
+ /**
4819
+ * Verify response shape expected from the smart host.
4820
+ */
4821
+ interface SmartHostVerifyResponse {
4822
+ bearer: string;
4823
+ expiresAt?: number;
4824
+ expiresIn?: number;
4825
+ [key: string]: unknown;
4826
+ }
4827
+ /**
4828
+ * Smart-host customer session helper.
4829
+ *
4830
+ * @service SmartSessionService
4831
+ *
4832
+ * @description
4833
+ * Encapsulates the full challenge → sign → verify → store JWT flow required by
4834
+ * HSuite smart hosts. The service is intentionally thin: it delegates signing to
4835
+ * {@link TransactionService} and relies on standard Angular `HttpClient` for the
4836
+ * host HTTP calls.
4837
+ *
4838
+ * @providedIn root
4839
+ */
4840
+ declare class SmartSessionService {
4841
+ private readonly http;
4842
+ private readonly walletService;
4843
+ private readonly transactionService;
4844
+ private readonly config;
4845
+ private get baseUrl();
4846
+ private get healthEndpoint();
4847
+ private get challengeEndpoint();
4848
+ private get verifyEndpoint();
4849
+ private get storageKey();
4850
+ /**
4851
+ * Returns the currently stored bearer token, or `null` if there is no session.
4852
+ *
4853
+ * @returns Bearer token string or null
4854
+ */
4855
+ getBearer(): string | null;
4856
+ /**
4857
+ * Checks whether a non-expired session is available.
4858
+ *
4859
+ * @returns true if logged in and the bearer has not expired
4860
+ */
4861
+ isLoggedIn(): boolean;
4862
+ /**
4863
+ * Performs the full smart-host login handshake.
4864
+ *
4865
+ * @description
4866
+ * 1. Discovers `appId` from the health endpoint.
4867
+ * 2. Fetches a challenge from the challenge endpoint.
4868
+ * 3. Signs the challenge with the active wallet account.
4869
+ * 4. Exchanges the signed challenge for a bearer token.
4870
+ * 5. Stores the bearer and expiry in `sessionStorage`.
4871
+ *
4872
+ * @returns The verify response from the host
4873
+ *
4874
+ * @throws {Error} If no active account is available
4875
+ * @throws {Error} If the health endpoint does not return an `appId`
4876
+ * @throws {Error} If the challenge endpoint does not return a `challenge`
4877
+ * @throws {Error} If the verify call fails
4878
+ */
4879
+ login(): Promise<SmartHostVerifyResponse>;
4880
+ /**
4881
+ * Clears the stored session.
4882
+ */
4883
+ logout(): void;
4884
+ /**
4885
+ * Runs an HTTP operation with automatic 401 recovery.
4886
+ *
4887
+ * @description
4888
+ * Executes the provided operation. If it rejects with an HTTP 401 error,
4889
+ * the service clears the current bearer, performs a fresh login, and retries
4890
+ * the operation once. Any other error is propagated immediately.
4891
+ *
4892
+ * @param operation - Async operation that needs a valid session
4893
+ * @returns The result of the operation
4894
+ *
4895
+ * @throws {Error} The original error if retry is not possible or fails
4896
+ */
4897
+ withSession<T>(operation: () => Promise<T>): Promise<T>;
4898
+ private fetchHealth;
4899
+ private fetchChallenge;
4900
+ private verifyChallenge;
4901
+ private resolveExpiry;
4902
+ private readStoredSession;
4903
+ private storeSession;
4904
+ private clearStoredSession;
4905
+ private isUnauthorizedError;
4906
+ static ɵfac: i0.ɵɵFactoryDeclaration<SmartSessionService, never>;
4907
+ static ɵprov: i0.ɵɵInjectableDeclaration<SmartSessionService>;
4908
+ }
4909
+
4910
+ /**
4911
+ * HSuite Native Connect
4912
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4913
+ *
4914
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
4915
+ *
4916
+ * This file is part of HSuite Native Connect. For commercial licensing,
4917
+ * visit https://hsuite.finance/licensing
4918
+ */
4919
+ /**
4920
+ * @file HTTP interceptor that attaches wallet-attributed auth headers.
4921
+ *
4922
+ * @module services/hsuite-auth-interceptor
4923
+ *
4924
+ * @description
4925
+ * `HsuiteAuthInterceptor` automatically adds the active smart-host bearer token
4926
+ * and wallet ledger identifier to outgoing HTTP requests. When a request fails
4927
+ * with HTTP 401, it delegates recovery to {@link SmartSessionService} for a
4928
+ * single re-login and retry.
4929
+ *
4930
+ * **Registration (standalone apps):**
4931
+ * ```typescript
4932
+ * provideHttpClient(withInterceptors([provideHsuiteAuthInterceptor()]))
4933
+ * ```
4934
+ *
4935
+ * **Registration (module-based apps):**
4936
+ * ```typescript
4937
+ * { provide: HTTP_INTERCEPTORS, useClass: HsuiteAuthInterceptor, multi: true }
4938
+ * ```
4939
+ */
4940
+
4941
+ /**
4942
+ * Headers injected by the interceptor.
4943
+ */
4944
+ declare const HSUITE_AUTH_HEADER = "Authorization";
4945
+ declare const HSUITE_LEDGER_HEADER = "X-Ledger-Id";
4946
+ /**
4947
+ * Functional HTTP interceptor that attaches wallet-attributed auth headers.
4948
+ *
4949
+ * @description
4950
+ * Adds:
4951
+ * - `Authorization: Bearer <token>` when {@link SmartSessionService.getBearer} returns a token
4952
+ * - `X-Ledger-Id: <ledgerId>` when a wallet account is active
4953
+ *
4954
+ * On 401 responses, clears the stale bearer and retries once after re-login.
4955
+ *
4956
+ * @param req - The outgoing HTTP request
4957
+ * @param next - The downstream request handler
4958
+ * @returns Observable of HTTP events
4959
+ */
4960
+ declare const hsuiteAuthInterceptor: HttpInterceptorFn;
4961
+ /**
4962
+ * Class-based HTTP interceptor for module-based Angular apps.
4963
+ *
4964
+ * @description
4965
+ * Provides the same behavior as {@link hsuiteAuthInterceptor} in a class form
4966
+ * suitable for registration via `HTTP_INTERCEPTORS`.
4967
+ */
4968
+ declare class HsuiteAuthInterceptor implements HttpInterceptor {
4969
+ private readonly session;
4970
+ private readonly wallet;
4971
+ /**
4972
+ * Intercepts outgoing HTTP requests to attach wallet-attributed auth headers.
4973
+ *
4974
+ * @param req - The outgoing HTTP request
4975
+ * @param next - The downstream request handler
4976
+ * @returns Observable of HTTP events
4977
+ */
4978
+ intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
4979
+ static ɵfac: i0.ɵɵFactoryDeclaration<HsuiteAuthInterceptor, never>;
4980
+ static ɵprov: i0.ɵɵInjectableDeclaration<HsuiteAuthInterceptor>;
4981
+ }
4982
+
4731
4983
  /**
4732
4984
  * Supported inner transaction types for batch transactions.
4733
4985
  * Excludes 'batch-transaction' since batches cannot be nested.
@@ -7171,5 +7423,5 @@ declare function getLedgerName(ledgerId: string): string;
7171
7423
  */
7172
7424
  declare function getTokenIcon(tokenIconUrl: string | undefined, ledgerId: string): string;
7173
7425
 
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 };
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, 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 };
7427
+ 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.5",
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",
@@ -27,8 +27,8 @@
27
27
  "qrcode": "^1.5.4",
28
28
  "tslib": "^2.6.0",
29
29
  "xrpl": "^3.0.0",
30
- "@hsuite/native-connect-types": "2.1.2",
31
- "@hsuite/native-connect-sdk": "2.1.0"
30
+ "@hsuite/native-connect-sdk": "^2.1.2",
31
+ "@hsuite/native-connect-types": "^2.1.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@angular-devkit/build-angular": "^20.3.14",