@pollar/core 0.9.0-rc.2 → 0.9.0-rc.3

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
  import { KeyManager, PublicEcJwk } from './index.mjs';
2
- export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthOpenContext, AuthState, AuthUrlOpener, BuildOutcome, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, EnabledAssetRecord, EnabledAssetsState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, LogLevel, NetworkState, POLLAR_CORE_VERSION, PasskeyCeremony, PasskeySigner, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLogger, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SessionsState, SignAuthEntryOptions, SignAuthEntryResponse, SignOutcome, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, SubmitOutcome, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxBuildSignSubmitBody, TxBuildSignSubmitContent, TxBuildSignSubmitResponse, TxErrorPhase, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignBody, TxSignContent, TxSignResponse, TxSignSendResponse, TxSubmitSignedBody, WalletAdapter, WalletAdapterResolver, WalletAssetsContent, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.mjs';
2
+ export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthOpenContext, AuthState, AuthUrlOpener, BuildOutcome, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, EnabledAssetRecord, EnabledAssetsState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, LogLevel, NetworkState, POLLAR_CORE_VERSION, PasskeyCeremony, PasskeyMode, PasskeySigner, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLogger, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SessionsState, SignAuthEntryOptions, SignAuthEntryResponse, SignOutcome, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, SubmitOutcome, TransactionState, TrustlineOutcome, TxBuildBody, TxBuildContent, TxBuildResponse, TxBuildSignSubmitBody, TxBuildSignSubmitContent, TxBuildSignSubmitResponse, TxErrorPhase, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignBody, TxSignContent, TxSignResponse, TxSignSendResponse, TxSubmitSignedBody, WalletAdapter, WalletAdapterResolver, WalletAssetsContent, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.mjs';
3
3
  import { S as Storage } from './types-DqgJIJBl.mjs';
4
4
  export { O as OnStorageDegrade, a as StorageDegradeReason } from './types-DqgJIJBl.mjs';
5
5
  import './types-Dyky8g0p.mjs';
@@ -1,5 +1,5 @@
1
1
  import { KeyManager, PublicEcJwk } from './index.js';
2
- export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthOpenContext, AuthState, AuthUrlOpener, BuildOutcome, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, EnabledAssetRecord, EnabledAssetsState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, LogLevel, NetworkState, POLLAR_CORE_VERSION, PasskeyCeremony, PasskeySigner, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLogger, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SessionsState, SignAuthEntryOptions, SignAuthEntryResponse, SignOutcome, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, SubmitOutcome, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxBuildSignSubmitBody, TxBuildSignSubmitContent, TxBuildSignSubmitResponse, TxErrorPhase, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignBody, TxSignContent, TxSignResponse, TxSignSendResponse, TxSubmitSignedBody, WalletAdapter, WalletAdapterResolver, WalletAssetsContent, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.js';
2
+ export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthOpenContext, AuthState, AuthUrlOpener, BuildOutcome, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, EnabledAssetRecord, EnabledAssetsState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, LogLevel, NetworkState, POLLAR_CORE_VERSION, PasskeyCeremony, PasskeyMode, PasskeySigner, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLogger, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SessionsState, SignAuthEntryOptions, SignAuthEntryResponse, SignOutcome, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, SubmitOutcome, TransactionState, TrustlineOutcome, TxBuildBody, TxBuildContent, TxBuildResponse, TxBuildSignSubmitBody, TxBuildSignSubmitContent, TxBuildSignSubmitResponse, TxErrorPhase, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignBody, TxSignContent, TxSignResponse, TxSignSendResponse, TxSubmitSignedBody, WalletAdapter, WalletAdapterResolver, WalletAssetsContent, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.js';
3
3
  import { S as Storage } from './types-DqgJIJBl.js';
4
4
  export { O as OnStorageDegrade, a as StorageDegradeReason } from './types-DqgJIJBl.js';
5
5
  import './types-Dyky8g0p.js';
package/dist/index.rn.js CHANGED
@@ -1109,7 +1109,7 @@ function defaultStorage(options = {}) {
1109
1109
  }
1110
1110
 
1111
1111
  // src/version.ts
1112
- var POLLAR_CORE_VERSION = "0.9.0-rc.2" ;
1112
+ var POLLAR_CORE_VERSION = "0.9.0-rc.3" ;
1113
1113
 
1114
1114
  // src/visibility/noop.ts
1115
1115
  function createNoopVisibilityProvider() {
@@ -1830,7 +1830,7 @@ async function loginOAuth(provider, deps) {
1830
1830
  }
1831
1831
 
1832
1832
  // src/client/auth/passkeyFlow.ts
1833
- async function loginSmartWallet(deps) {
1833
+ async function smartWalletFlow(deps, mode) {
1834
1834
  const { api, signal, setAuthState, passkey } = deps;
1835
1835
  if (!passkey) {
1836
1836
  setAuthState({
@@ -1853,7 +1853,7 @@ async function loginSmartWallet(deps) {
1853
1853
  return failPasskey(setAuthState, "Failed to start passkey");
1854
1854
  }
1855
1855
  setAuthState({ step: "creating_passkey" });
1856
- const ceremony = await passkey({ challenge });
1856
+ const ceremony = await passkey({ challenge, mode });
1857
1857
  const response = ceremony.response;
1858
1858
  if (ceremony.kind === "register") {
1859
1859
  setAuthState({ step: "deploying_smart_account" });
@@ -2446,9 +2446,10 @@ var PollarClient = class {
2446
2446
  loginWallet(type, this._flowDeps(controller.signal)).catch((err) => this._handleFlowError(err));
2447
2447
  }
2448
2448
  /**
2449
- * "Smart Wallet" login: runs the passkey (WebAuthn) ceremony and, for a new
2450
- * user, creates a sponsored smart-account C-address. Requires the `passkey`
2451
- * ceremony to be configured (e.g. via `@pollar/react`).
2449
+ * "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
2450
+ * returning user and signs them in. Use {@link createSmartWallet} for a new
2451
+ * user. Requires the `passkey` ceremony to be configured (e.g. via
2452
+ * `@pollar/react`).
2452
2453
  */
2453
2454
  loginSmartWallet() {
2454
2455
  if (!isClientRuntime) {
@@ -2456,7 +2457,21 @@ var PollarClient = class {
2456
2457
  return;
2457
2458
  }
2458
2459
  const controller = this._newController();
2459
- loginSmartWallet(this._flowDeps(controller.signal)).catch((err) => this._handleFlowError(err));
2460
+ smartWalletFlow(this._flowDeps(controller.signal), "login").catch((err) => this._handleFlowError(err));
2461
+ }
2462
+ /**
2463
+ * "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
2464
+ * for a new user and deploys a sponsored smart-account C-address. Use
2465
+ * {@link loginSmartWallet} for a returning user. Requires the `passkey`
2466
+ * ceremony to be configured (e.g. via `@pollar/react`).
2467
+ */
2468
+ createSmartWallet() {
2469
+ if (!isClientRuntime) {
2470
+ warnServerSide("createSmartWallet");
2471
+ return;
2472
+ }
2473
+ const controller = this._newController();
2474
+ smartWalletFlow(this._flowDeps(controller.signal), "register").catch((err) => this._handleFlowError(err));
2460
2475
  }
2461
2476
  // ─── Cancel ───────────────────────────────────────────────────────────────
2462
2477
  cancelLogin() {
@@ -2696,6 +2711,54 @@ var PollarClient = class {
2696
2711
  this._setEnabledAssetsState({ step: "error", message: "Failed to load assets" });
2697
2712
  }
2698
2713
  }
2714
+ /**
2715
+ * Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
2716
+ *
2717
+ * Routing mirrors how the platform pays for the reserve:
2718
+ * - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
2719
+ * server orchestrates a sponsored `changeTrust`: the app's wallets cover the
2720
+ * 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
2721
+ * `sponsored` flag (from {@link refreshAssets}) straight through.
2722
+ * - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
2723
+ * asset not configured in the app) → a plain `change_trust` transaction the
2724
+ * user's own wallet signs and pays for, via {@link runTx}.
2725
+ *
2726
+ * Does not refresh on its own — callers should `refreshAssets()` afterwards.
2727
+ */
2728
+ async setTrustline(asset, opts) {
2729
+ const limit = opts?.limit;
2730
+ const walletType = this._session?.wallet?.type;
2731
+ if (!this._session?.wallet?.address) {
2732
+ return { status: "error", details: "No wallet connected" };
2733
+ }
2734
+ if (walletType === "smart") {
2735
+ return { status: "error", details: "Trustlines do not apply to smart wallets" };
2736
+ }
2737
+ if (opts?.sponsored && !this._walletAdapter && walletType === "internal") {
2738
+ try {
2739
+ const { data, error } = await this._api.POST("/wallet/assets/trustline", {
2740
+ body: { code: asset.code, issuer: asset.issuer, ...limit !== void 0 && { limit } }
2741
+ });
2742
+ if (!error && data?.success) {
2743
+ if (data.content) this._setEnabledAssetsState({ step: "loaded", data: data.content });
2744
+ return { status: "success" };
2745
+ }
2746
+ const details = error?.details ?? error?.code;
2747
+ return { status: "error", ...details && { details } };
2748
+ } catch (err) {
2749
+ const details = err instanceof Error ? err.message : void 0;
2750
+ return { status: "error", ...details && { details } };
2751
+ }
2752
+ }
2753
+ return this.runTx("change_trust", {
2754
+ asset: {
2755
+ type: asset.code.length <= 4 ? "credit_alphanum4" : "credit_alphanum12",
2756
+ code: asset.code,
2757
+ issuer: asset.issuer
2758
+ },
2759
+ ...limit !== void 0 && { limit }
2760
+ });
2761
+ }
2699
2762
  // ─── Transactions ─────────────────────────────────────────────────────────
2700
2763
  /**
2701
2764
  * Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs