@bluxcc/core 0.2.8 → 0.2.10

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/store.d.ts CHANGED
@@ -76,6 +76,7 @@ export interface IStoreProperties {
76
76
  login?: ILoginPromise;
77
77
  loginError?: string;
78
78
  balances: UseBalancesResult;
79
+ balanceValues: Record<string, string>;
79
80
  transactions: UseTransactionsResult;
80
81
  selectAsset: ISelectAsset;
81
82
  detailsAsset?: IAsset;
@@ -106,6 +107,7 @@ export interface IStoreMethods {
106
107
  setAlert: (alert: AlertType, message: string) => void;
107
108
  setDynamicTitle: (title: string) => void;
108
109
  setBalances: (balances: UseBalancesResult) => void;
110
+ setBalanceValues: (balanceValues: Record<string, string>) => void;
109
111
  setSelectAsset: (selectAsset: ISelectAsset) => void;
110
112
  setDetailsAsset: (asset: IAsset | undefined) => void;
111
113
  setTransactions: (transactions: UseTransactionsResult) => void;
@@ -7,10 +7,15 @@ type ApiPasskeyChallenge = {
7
7
  challenge_id: number;
8
8
  };
9
9
  export declare const authenticateAppId: (appId: string) => Promise<AuthenticateApiResponse>;
10
- export declare const apiRegisterPasskeyChallenge: (appId: string) => Promise<ApiPasskeyChallenge>;
11
- export declare const apiRegisterPasskey: (appId: string, challenge: ApiPasskeyChallenge, passkeyResult: PasskeyFlowResult) => Promise<string>;
10
+ export declare const apiPasskeyChallenge: (appId: string, authValue: string) => Promise<ApiPasskeyChallenge>;
11
+ export declare const apiPasskeyVerify: (appId: string, challenge: ApiPasskeyChallenge, passkeyResult: PasskeyFlowResult) => Promise<string>;
12
12
  export declare const apiSendOtp: (appId: string, authValue: string) => Promise<boolean>;
13
- export declare const apiStoreWalletConnection: (appId: string, walletName: string, walletAddress: string) => Promise<boolean>;
13
+ type ApiWalletChallenge = {
14
+ challenge_xdr: string;
15
+ network_passphrase: string;
16
+ };
17
+ export declare const apiWalletChallenge: (appId: string, walletName: string, walletAddress: string) => Promise<ApiWalletChallenge>;
18
+ export declare const apiVerifyWalletChallenge: (appId: string, signedXdr: string) => Promise<string>;
14
19
  export declare const apiVerifyOtp: (appId: string, user: IUser, otp: string) => Promise<string>;
15
20
  type ApiGetUserResponse = {
16
21
  auth_method: string;
@@ -0,0 +1,22 @@
1
+ /** Whether appId validation has finished (regardless of the outcome). */
2
+ export declare const isAppValidated: () => boolean;
3
+ /** Whether the configured appId was confirmed valid by the Blux API. */
4
+ export declare const isAppValid: () => boolean;
5
+ /**
6
+ * Throws when the appId is known to be invalid. Every authentication / wallet
7
+ * entry point (login, profile, fundMe, and all signing methods) calls this so
8
+ * Blux refuses to operate with a bad appId. The read-only chain helpers under
9
+ * `exports/core` intentionally do NOT call this — they don't depend on the
10
+ * appId and must keep working.
11
+ *
12
+ * No-op while validation is still pending: callers that need a settled result
13
+ * (e.g. login) await {@link waitForBluxReady} first; the rest are already gated
14
+ * behind an auth check that can't pass before validation completes.
15
+ */
16
+ export declare const assertAppIsValid: () => void;
17
+ /**
18
+ * Resolves once the SDK has finished initializing (wallets loaded) AND appId
19
+ * validation has settled, so the caller can then assert validity. Polls because
20
+ * both happen asynchronously after createConfig.
21
+ */
22
+ export declare const waitForBluxReady: () => Promise<void>;
@@ -41,6 +41,7 @@ export declare const getWalletNetwork: (wallet: IWallet) => Promise<string>;
41
41
  export declare const handleLoadWallets: (walletNames: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
42
42
  export declare const hexToRgba: (hex: string, alpha?: number) => string;
43
43
  export declare const humanizeAmount: (amount: number | string, big?: boolean) => string;
44
+ export declare const formatUsd: (value: number | string) => string;
44
45
  export declare const initializeRabetMobile: () => void;
45
46
  export declare const isBackgroundDark: (bgColor: string) => boolean;
46
47
  export declare const loadWallets: (excludedWallets: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
@@ -0,0 +1,4 @@
1
+ export declare const getStoredPasskeyCredentialId: (appId: string) => string | null;
2
+ export declare const setStoredPasskeyCredentialId: (appId: string, credentialId: string) => void;
3
+ export declare const clearStoredPasskeyCredentialId: (appId: string) => void;
4
+ export declare const createPasskeyRegistrationHandle: () => string;
@@ -0,0 +1,25 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ type BalanceLine = Horizon.HorizonApi.BalanceLine;
3
+ /**
4
+ * Stable key for a balance line used to index its computed USD value. Native is
5
+ * `'native'`, liquidity pools use their pool id, every other asset uses
6
+ * `CODE:ISSUER` — matching {@link assetValueKey} so the UI can look values up.
7
+ */
8
+ export declare const balanceLineKey: (balance: BalanceLine) => string;
9
+ /** Same key as {@link balanceLineKey} but from an {@link IAsset}-style triple. */
10
+ export declare const assetValueKey: (assetType: string, assetCode: string, assetIssuer: string) => string;
11
+ /**
12
+ * Computes the realistic USD value of each balance by selling the full held
13
+ * amount into the live DEX order book (price-impact aware), keyed by
14
+ * {@link balanceLineKey}.
15
+ *
16
+ * Real USD pricing only runs on mainnet, where USDC carries real-world value;
17
+ * on every other network all values resolve to `'0'`. Per-asset failures are
18
+ * isolated, so one unpriceable asset never blanks the rest.
19
+ *
20
+ * @param balances - The account's balance lines.
21
+ * @param network - Active network passphrase.
22
+ * @returns A map of `balanceLineKey` → USD value string (7-dp, never NaN/Infinity).
23
+ */
24
+ export declare const getBalancesUsdValues: (balances: BalanceLine[], network: string) => Promise<Record<string, string>>;
25
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluxcc/core",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "homepage": "https://blux.cc",
5
5
  "description": "Blux is a wallet infra for the Stellar network",
6
6
  "type": "module",
@@ -73,6 +73,7 @@
73
73
  "dependencies": {
74
74
  "@hot-wallet/sdk": "^1.0.11",
75
75
  "@ledgerhq/hw-transport-webusb": "^6.29.12",
76
- "@trezor/connect-web": "^10.0.0-alpha.1"
76
+ "@trezor/connect-web": "^10.0.0-alpha.1",
77
+ "bignumber.js": "^9.3.1"
77
78
  }
78
79
  }