@bluxcc/core 0.2.18 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
  declare const getTransactionDetails: (xdr: string, network: string) => {
2
- action: "accountMerge" | "allowTrust" | "beginSponsoringFutureReserves" | "bumpSequence" | "changeTrust" | "claimClaimableBalance" | "clawbackClaimableBalance" | "clawback" | "createAccount" | "createClaimableBalance" | "createPassiveSellOffer" | "endSponsoringFutureReserves" | "extendFootprintTtl" | "inflation" | "invokeHostFunction" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "manageBuyOffer" | "manageData" | "manageSellOffer" | "pathPaymentStrictReceive" | "pathPaymentStrictSend" | "payment" | "restoreFootprint" | "revokeAccountSponsorship" | "revokeClaimableBalanceSponsorship" | "revokeDataSponsorship" | "revokeLiquidityPoolSponsorship" | "revokeOfferSponsorship" | "revokeSignerSponsorship" | "revokeTrustlineSponsorship" | "setOptions" | "setTrustLineFlags";
2
+ action: "pathPaymentStrictSend" | "pathPaymentStrictReceive" | "payment" | "createAccount" | "createClaimableBalance" | "accountMerge" | "allowTrust" | "beginSponsoringFutureReserves" | "bumpSequence" | "changeTrust" | "claimClaimableBalance" | "clawbackClaimableBalance" | "clawback" | "createPassiveSellOffer" | "endSponsoringFutureReserves" | "extendFootprintTtl" | "inflation" | "invokeHostFunction" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "manageBuyOffer" | "manageData" | "manageSellOffer" | "restoreFootprint" | "revokeAccountSponsorship" | "revokeClaimableBalanceSponsorship" | "revokeDataSponsorship" | "revokeLiquidityPoolSponsorship" | "revokeOfferSponsorship" | "revokeSignerSponsorship" | "revokeTrustlineSponsorship" | "setOptions" | "setTrustLineFlags";
3
3
  operations: number;
4
4
  sender: string;
5
5
  receiver: string;
@@ -1,3 +1,3 @@
1
1
  import { IWallet } from "../types";
2
- declare const handleSignMessage: (wallet: IWallet, message: string, address: string, network: string) => Promise<string>;
2
+ declare const handleSignMessage: (wallet: IWallet, message: string, address: string, network?: string) => Promise<string>;
3
3
  export default handleSignMessage;
@@ -0,0 +1,26 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ import { IAsset } from '../types';
3
+ export type MoneygramMemoType = 'text' | 'id' | 'hash';
4
+ export type MoneygramSession = {
5
+ url: string;
6
+ id: string;
7
+ token: string;
8
+ transferServer: string;
9
+ };
10
+ export type MoneygramWithdrawDetails = {
11
+ amount: string;
12
+ destination: string;
13
+ memo: string;
14
+ memoType: MoneygramMemoType;
15
+ };
16
+ export declare const isMoneygramNetwork: (network: string) => boolean;
17
+ export declare const moneygramUsdc: (network: string) => IAsset;
18
+ export declare const startMoneygramWithdraw: ({ address, network, lang, sign, signal, }: {
19
+ address: string;
20
+ network: string;
21
+ lang?: string;
22
+ sign: (xdr: string) => Promise<string>;
23
+ signal?: AbortSignal;
24
+ }) => Promise<MoneygramSession>;
25
+ export declare const waitForMoneygramTransfer: (session: MoneygramSession, signal?: AbortSignal) => Promise<MoneygramWithdrawDetails>;
26
+ export declare const assertHorizon: (horizon?: Horizon.Server) => Horizon.Server;
@@ -1,4 +1,4 @@
1
- import { Horizon } from "@stellar/stellar-sdk";
2
- import { IAsset } from "../types";
3
- declare const paymentTransaction: (memo: string, amount: string, destinationAddress: string, asset: IAsset, sourceAddress: string, server: Horizon.Server, networkPassphrase: string) => Promise<string>;
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ import { IAsset } from '../types';
3
+ declare const paymentTransaction: (memo: string, amount: string, destinationAddress: string, asset: IAsset, sourceAddress: string, server: Horizon.Server, networkPassphrase: string, memoType?: "text" | "id" | "hash") => Promise<string>;
4
4
  export default paymentTransaction;
@@ -1,3 +1,4 @@
1
1
  export declare const completeLoginProcess: () => void;
2
+ export declare const rejectLoginProcess: (reason?: string) => void;
2
3
  declare const continueLoginProcess: () => void;
3
4
  export default continueLoginProcess;
package/dist/store.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Horizon, rpc } from '@stellar/stellar-sdk';
2
2
  import { SignClient } from '@walletconnect/sign-client/dist/types/client';
3
3
  import { Route } from './enums';
4
- import { UseBalancesResult } from './hooks/useBalances';
5
- import { UseTransactionsResult } from './hooks/useTransactions';
4
+ import type { UseBalancesResult } from './hooks/useBalances';
6
5
  import Emitter, { BluxEventMap } from './utils/events';
7
6
  import { IAsset, IWallet, IAppearance, AssetMetaMap, ICustomToken, ICustomTokens, ISignMessage, IInternalConfig, ISendTransaction, AuthenticateApiResponse, ISignAuthEntry } from './types';
8
7
  export type AlertType = 'error' | 'success' | 'warn' | 'none' | 'copy';
@@ -78,7 +77,7 @@ export interface IStoreProperties {
78
77
  loginError?: string;
79
78
  balances: UseBalancesResult;
80
79
  balanceValues: Record<string, string>;
81
- transactions: UseTransactionsResult;
80
+ accountRefreshNonce: number;
82
81
  selectAsset: ISelectAsset;
83
82
  detailsAsset?: IAsset;
84
83
  customTokens: ICustomTokens;
@@ -93,6 +92,7 @@ export interface IStoreProperties {
93
92
  }
94
93
  export interface IStoreMethods {
95
94
  connectEmail: (email: string) => void;
95
+ connectSms: (phone: string) => void;
96
96
  connectSocial: (provider: string) => void;
97
97
  connectWallet: (walletName: string) => void;
98
98
  connectWalletSuccessful: (publicKey: string, passphrase: string) => void;
@@ -120,7 +120,7 @@ export interface IStoreMethods {
120
120
  setCustomTokenBalances: (network: 'mainnet' | 'testnet', balances: Record<number, string>) => void;
121
121
  setBalancesTab: (tab: 'assets' | 'tokens') => void;
122
122
  setDetailsToken: (token: ICustomToken | undefined) => void;
123
- setTransactions: (transactions: UseTransactionsResult) => void;
123
+ bumpAccountRefresh: () => void;
124
124
  setWalletConnectClient: (client: SignClient, connection: any) => void;
125
125
  cleanUp: (method: 'sendTransaction' | 'signMessage' | 'signAuthEntry') => void;
126
126
  setNetworkSyncDisabled: (isDisabled: boolean) => void;
@@ -0,0 +1,2 @@
1
+ declare const styles: Record<string, string>;
2
+ export default styles;
package/dist/types.d.ts CHANGED
@@ -1,9 +1,12 @@
1
+ import type { ReactNode } from 'react';
1
2
  import { Horizon, rpc } from '@stellar/stellar-sdk';
2
3
  import { SupportedWallet } from './enums';
3
4
  /** Supported UI language codes (ISO 639-1). */
4
- export type LanguageKey = 'en' | 'es' | 'pt' | 'fr' | 'de' | 'ru' | 'zh' | 'ja' | 'ko';
5
+ export type LanguageKey = 'en' | 'es' | 'pt' | 'fr' | 'de' | 'ru' | 'zh' | 'ja' | 'ko' | 'tr';
5
6
  /** Custom RPC endpoints keyed by network passphrase. */
6
7
  export type ITransports = Record<string, IServers>;
8
+ /** A value TypeScript still treats as a string, while keeping literal unions suggestable. */
9
+ type LooseString = string & {};
7
10
  /** Block explorer used to build account/transaction links. */
8
11
  export type IExplorer = 'steexp' | 'stellarchain' | 'stellarexpert' | 'lumenscan';
9
12
  /** Social login providers supported by Blux. */
@@ -13,7 +16,7 @@ export type ILoginMethods = Array<'wallet' | 'sms' | 'email' | 'passkey' | ISoci
13
16
  /** Canonical names of the wallets Blux can integrate with. */
14
17
  export type IWalletNames = Array<'rabet' | 'albedo' | 'freighter' | 'xbull' | 'lobstr' | 'hana' | 'hot' | 'klever' | 'cactuslink' | 'fordefi' | 'trezor'>;
15
18
  /** RPC endpoints for a single network. */
16
- interface IServers {
19
+ export interface IServers {
17
20
  /** Horizon base URL. */
18
21
  horizon: string;
19
22
  /** Soroban RPC base URL. */
@@ -39,7 +42,7 @@ export interface ITrezorMetaData {
39
42
  }
40
43
  /** Configuration passed to {@link createConfig}. */
41
44
  export interface IConfig {
42
- /** Your Blux app id, from the Blux dashboard. Required for email/passkey/social login. */
45
+ /** Your Blux app id, from the Blux dashboard. Required for email/SMS/passkey/social login. */
43
46
  appId: string;
44
47
  /** Display name of your app, shown in wallet prompts and UI. */
45
48
  appName: string;
@@ -53,18 +56,18 @@ export interface IConfig {
53
56
  lang?: LanguageKey;
54
57
  /** Block explorer used for links. Defaults to `'stellarchain'`. */
55
58
  explorer?: IExplorer;
56
- /** Persist the session across reloads. Defaults to `false`. */
59
+ /** Persist the session across page reloads. Defaults to `false` and should remain `false` in most scenarios. */
57
60
  isPersistent?: boolean;
58
61
  /** Show Blux's built-in signing/approval UIs. When `false`, signing happens headlessly. Defaults to `true`. */
59
62
  showWalletUIs?: boolean;
60
- /** Login methods to offer. Defaults to `['wallet']`. */
61
- loginMethods?: ILoginMethods | string[];
63
+ /** Login methods to offer. Defaults to `['wallet']`. `'sms'` is shown only when `/auth/validate` reports a paid plan. */
64
+ loginMethods?: Array<ILoginMethods[number] | LooseString>;
62
65
  /** Custom Horizon/Soroban endpoints per network; required for custom networks. */
63
66
  transports?: ITransports;
64
67
  /** Wallets to hide from the picker. */
65
68
  excludeWallets?: IWalletNames;
66
69
  /** Wallets to surface first in the picker, in the given order. */
67
- orderWallets?: IWalletNames | string[];
70
+ orderWallets?: Array<IWalletNames[number] | LooseString>;
68
71
  /** WalletConnect metadata; required to enable WalletConnect. */
69
72
  walletConnect?: IWalletConnectMetaData;
70
73
  /** Trezor manifest metadata; required to enable Trezor. */
@@ -116,9 +119,19 @@ export interface IAppearance {
116
119
  /** Box shadow style for the modal. */
117
120
  boxShadow: string;
118
121
  }
122
+ /** How a wallet proves it controls an address during login. */
123
+ export type WalletProofType = 'signed_transaction' | 'signed_message';
119
124
  export interface IWallet {
120
125
  name: SupportedWallet;
121
126
  website: string;
127
+ /**
128
+ * When true, login proves ownership with `signMessage` (SEP-53) instead of a
129
+ * SEP-10 challenge transaction. Use this for wallets that treat the
130
+ * unsubmittable challenge as a real payment and block on insufficient XLM
131
+ * (Freighter, Hana, Rabet, OneKey). Hardware wallets that cannot sign arbitrary messages
132
+ * must leave this unset so they keep using the challenge transaction.
133
+ */
134
+ authenticateWithSignedMessage?: boolean;
122
135
  connect: () => Promise<string>;
123
136
  disconnect: () => Promise<void>;
124
137
  getNetwork: () => Promise<{
@@ -132,7 +145,7 @@ export interface IWallet {
132
145
  }) => Promise<string>;
133
146
  signMessage: (message: string, options: {
134
147
  address: string;
135
- network: string;
148
+ network?: string;
136
149
  }) => Promise<string>;
137
150
  signTransaction: (xdr: string, options: {
138
151
  network: string;
@@ -149,7 +162,7 @@ export interface IAccountData {
149
162
  transactions?: Horizon.ServerApi.TransactionRecord[];
150
163
  }
151
164
  export interface IAsset {
152
- logo?: string | React.ReactNode;
165
+ logo?: string | ReactNode;
153
166
  valueInCurrency?: string;
154
167
  assetBalance: string;
155
168
  assetCode: string;
@@ -233,7 +246,6 @@ export interface ISendTransaction {
233
246
  export interface ISignMessage {
234
247
  message: string;
235
248
  result?: string;
236
- options: ISignOptions;
237
249
  rejecter: (reason: any) => void;
238
250
  resolver: (value: string) => void;
239
251
  }
@@ -255,5 +267,9 @@ export interface AuthenticateApiResponse {
255
267
  terms: string;
256
268
  socials: string[];
257
269
  socialsConfig: ISocialConfigEntry[];
270
+ /** Entitled billing plan of the account that owns this app. */
271
+ plan: string;
272
+ /** True when the account is on a paid plan and may offer SMS login. */
273
+ smsEnabled: boolean;
258
274
  }
259
275
  export {};
@@ -1,5 +1,5 @@
1
1
  import { IUser } from '../store';
2
- import { AuthenticateApiResponse } from '../types';
2
+ import { AuthenticateApiResponse, WalletProofType } from '../types';
3
3
  import { PasskeyFlowResult } from '../pages/Onboarding/Passkey';
4
4
  type ApiPasskeyChallenge = {
5
5
  user_id: string;
@@ -9,13 +9,18 @@ type ApiPasskeyChallenge = {
9
9
  export declare const authenticateAppId: (appId: string) => Promise<AuthenticateApiResponse>;
10
10
  export declare const apiPasskeyChallenge: (appId: string, authValue: string) => Promise<ApiPasskeyChallenge>;
11
11
  export declare const apiPasskeyVerify: (appId: string, challenge: ApiPasskeyChallenge, passkeyResult: PasskeyFlowResult) => Promise<string>;
12
- export declare const apiSendOtp: (appId: string, authValue: string) => Promise<boolean>;
12
+ export declare const apiSendOtp: (appId: string, authValue: string, authMethod?: "email" | "sms") => Promise<boolean>;
13
13
  type ApiWalletChallenge = {
14
- challenge_xdr: string;
14
+ challenge_xdr?: string;
15
+ challenge?: string;
15
16
  network_passphrase: string;
17
+ proof_type?: WalletProofType;
16
18
  };
17
- export declare const apiWalletChallenge: (appId: string, walletName: string, walletAddress: string) => Promise<ApiWalletChallenge>;
18
- export declare const apiVerifyWalletChallenge: (appId: string, signedXdr: string) => Promise<string>;
19
+ export declare const apiWalletChallenge: (appId: string, walletName: string, walletAddress: string, proofType?: WalletProofType) => Promise<ApiWalletChallenge>;
20
+ export declare const apiVerifyWalletChallenge: (appId: string, code: string, options?: {
21
+ proofType?: WalletProofType;
22
+ challenge?: string;
23
+ }) => Promise<string>;
19
24
  export declare const apiVerifyOtp: (appId: string, user: IUser, otp: string) => Promise<string>;
20
25
  type ApiGetUserResponse = {
21
26
  auth_method: string;
@@ -15,8 +15,9 @@ export declare const isAppValid: () => boolean;
15
15
  */
16
16
  export declare const assertAppIsValid: () => void;
17
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.
18
+ * Resolves once the SDK has finished initializing AND appId validation has
19
+ * settled, so the caller can then assert validity. Polls because both happen
20
+ * asynchronously after createConfig. For apps that do not offer wallet login,
21
+ * `isReady` does not wait on wallet availability — only appId validation.
21
22
  */
22
23
  export declare const waitForBluxReady: () => Promise<void>;
@@ -1,8 +1,7 @@
1
1
  import { Asset, Horizon } from '@stellar/stellar-sdk';
2
2
  import translations from '../constants/locales';
3
3
  import { Route, SupportedWallet } from '../enums';
4
- import { IAsset, IWallet, IExplorer, LanguageKey, ITransports, IWalletNames } from '../types';
5
- import { INetworkTransports } from '../constants/networkDetails';
4
+ import { IAsset, IWallet, IExplorer, LanguageKey, ITransports, IWalletNames, ILoginMethods } from '../types';
6
5
  export declare const bufferToBase64Url: (buf: ArrayBuffer) => string;
7
6
  export declare const base64UrlToBuffer: (value: string) => ArrayBuffer;
8
7
  export declare const getAssetTitle: (asset: Horizon.HorizonApi.BalanceLineNative | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum4"> | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum12"> | Horizon.HorizonApi.BalanceLineLiquidityPool) => string;
@@ -34,8 +33,9 @@ export declare const getExplorerUrl: (networkPassphrase: string, explorerProvide
34
33
  export declare const getMappedWallets: (walletNames: IWalletNames) => Promise<IWallet[]>;
35
34
  export declare const getRecentConnectionMethod: () => SupportedWallet[];
36
35
  export declare const getNetworkByPassphrase: (passphrase: string) => string;
37
- export declare const getNetworkRpc: (network: string, transports: ITransports) => INetworkTransports;
36
+ export { getNetworkRpc } from './networkRpc';
38
37
  export declare const canonicalWalletName: (name: string) => string;
38
+ export declare const loginMethodsIncludeWallet: (loginMethods: ILoginMethods | string[] | undefined) => boolean;
39
39
  export declare const getSortedCheckedWallets: (wallets: IWallet[], priorityNames?: string[]) => IWallet[];
40
40
  export declare const getWalletNetwork: (wallet: IWallet) => Promise<string>;
41
41
  export declare const handleLoadWallets: (walletNames: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
@@ -54,3 +54,4 @@ export declare const getNetworkNamesFromPassphrase: (userNetworks: string[]) =>
54
54
  export declare const validateOrderWallets: (orderWallets: string[] | undefined) => string[];
55
55
  export declare const validateNetworkOptions: (networks: string[], defaultNetwork: string | undefined, transports: ITransports | undefined) => void;
56
56
  export declare const validateInput: (type: string, value: string) => boolean;
57
+ export declare const isUSCanadaPhone: (raw: string) => boolean;
@@ -0,0 +1,7 @@
1
+ import { ITransports } from '../types';
2
+ import { INetworkTransports } from '../constants/networkDetails';
3
+ /**
4
+ * Resolves Horizon and Soroban URLs for a passphrase, overlaying any custom
5
+ * transports from config.
6
+ */
7
+ export declare const getNetworkRpc: (network: string, transports: ITransports) => INetworkTransports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluxcc/core",
3
- "version": "0.2.18",
3
+ "version": "0.3.1",
4
4
  "homepage": "https://blux.cc",
5
5
  "description": "Blux is a wallet infra for the Stellar network",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "@ledgerhq/hw-app-str": "^7.2.8",
43
43
  "@lobstrco/signer-extension-api": "^1.0.0-beta.0",
44
44
  "@stellar/freighter-api": "^5.0.0",
45
- "@stellar/stellar-sdk": "^16.2.0",
45
+ "@stellar/stellar-sdk": "^17.0.1",
46
46
  "@walletconnect/core": "^2.21.9",
47
47
  "@walletconnect/sign-client": "^2.21.9",
48
48
  "qrcode.react": "^4.2.0",