@pollar/core 0.9.0-rc.0 → 0.9.0-rc.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.
package/README.md CHANGED
@@ -205,6 +205,41 @@ Same as React (`useSyncExternalStore`), plus the entry-file polyfills and inject
205
205
  React Native sections above. OAuth and external-wallet logins require `openAuthUrl` / `walletAdapter` to be injected
206
206
  (the built-in popup/extension adapters are web-only).
207
207
 
208
+ ## Logging
209
+
210
+ The SDK logs through a level-gated logger. Configure it on `PollarClient`:
211
+
212
+ ```ts
213
+ const client = new PollarClient({
214
+ apiKey: 'pk_...',
215
+ logLevel: 'warn', // 'silent' | 'error' | 'warn' | 'info' | 'debug' (default 'info')
216
+ });
217
+ ```
218
+
219
+ Levels are ordered `silent` < `error` < `warn` < `info` < `debug`; setting one emits that level and every more
220
+ important one. `silent` disables all SDK logging. State-transition chatter (`auth:…`, `transaction:…`, `network:…`)
221
+ and retry warnings live at `debug`, so the default `info` keeps the console quiet while still showing lifecycle events
222
+ (Initialized, Session stored/restored, Tokens refreshed) and all warnings/errors.
223
+
224
+ Route logs to your own sink (pino, Sentry breadcrumbs, a test spy…) with `logger` — filtering by `logLevel` still
225
+ applies on top:
226
+
227
+ ```ts
228
+ import { PollarClient, type PollarLogger } from '@pollar/core';
229
+
230
+ const sink: PollarLogger = {
231
+ error: (...a) => myLogger.error(...a),
232
+ warn: (...a) => myLogger.warn(...a),
233
+ info: (...a) => myLogger.info(...a),
234
+ debug: (...a) => myLogger.debug(...a),
235
+ };
236
+
237
+ const client = new PollarClient({ apiKey: 'pk_...', logLevel: 'debug', logger: sink });
238
+ ```
239
+
240
+ `client.getLogger()` returns the configured logger (used internally by `@pollar/react` so its own logs honor the same
241
+ level + sink). `@pollar/stellar-wallets-kit-adapter` accepts the same `logLevel` / `logger` on its options.
242
+
208
243
  ## Preserved-on-disk storage shape
209
244
 
210
245
  0.7.0 persists exactly:
package/dist/index.d.mts CHANGED
@@ -3,6 +3,34 @@ export { a as StorageDegradeReason } from './types-DqgJIJBl.mjs';
3
3
  import { V as VisibilityProvider } from './types-Dyky8g0p.mjs';
4
4
  import * as openapi_fetch from 'openapi-fetch';
5
5
 
6
+ /**
7
+ * Log levels in increasing verbosity. Setting a level emits that level and
8
+ * every more-important one; `silent` disables all SDK logging.
9
+ *
10
+ * silent < error < warn < info < debug
11
+ */
12
+ type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
13
+ /**
14
+ * Sink the SDK writes logs to. The global `console` already satisfies this
15
+ * shape, so it's the default. Inject your own (pino, Sentry breadcrumbs, a test
16
+ * spy…) via `PollarClientConfig.logger` to route SDK logs wherever you want.
17
+ */
18
+ interface PollarLogger {
19
+ error(...args: unknown[]): void;
20
+ warn(...args: unknown[]): void;
21
+ info(...args: unknown[]): void;
22
+ debug(...args: unknown[]): void;
23
+ }
24
+ /**
25
+ * Build a level-gated logger over a sink. The returned object has the same
26
+ * method surface as {@link PollarLogger}; each call is silently dropped when its
27
+ * level is more verbose than the configured `level`. Messages keep their own
28
+ * `[PollarClient…]` prefixes, so this only adds filtering + sink routing.
29
+ *
30
+ * Defaults: `level = 'info'`, `sink = console`.
31
+ */
32
+ declare function createLogger(level?: LogLevel, sink?: PollarLogger): PollarLogger;
33
+
6
34
  type StellarNetwork = 'mainnet' | 'testnet';
7
35
  type StellarClientConfig = StellarNetwork | {
8
36
  horizonUrl: string;
@@ -218,6 +246,19 @@ interface PollarClientConfig {
218
246
  * apiKey)`: WebCrypto in browsers, `@noble/curves` in RN.
219
247
  */
220
248
  keyManager?: KeyManager;
249
+ /**
250
+ * Minimum severity the SDK logs. `silent` disables all SDK logging; the rest
251
+ * emit that level and everything more important (`error` < `warn` < `info` <
252
+ * `debug`). State-transition chatter (auth/tx/network) is at `debug`.
253
+ * Defaults to `'info'`.
254
+ */
255
+ logLevel?: LogLevel;
256
+ /**
257
+ * Sink the SDK writes logs to. Defaults to the global `console`. Inject your
258
+ * own (pino, Sentry breadcrumbs, a test spy…) to route SDK logs anywhere.
259
+ * Filtering by `logLevel` still applies on top of whatever you pass.
260
+ */
261
+ logger?: PollarLogger;
221
262
  /**
222
263
  * Notified when persistent storage silently degrades to in-memory mode
223
264
  * (Safari private browsing quota errors, sandboxed iframes, etc.). Useful
@@ -683,6 +724,7 @@ declare class PollarClient {
683
724
  readonly id: string;
684
725
  readonly basePath: string;
685
726
  private readonly _api;
727
+ private readonly _log;
686
728
  private readonly _storage;
687
729
  private readonly _keyManager;
688
730
  /** Resolves once `keyManager.init()` and the initial session restore complete. */
@@ -873,6 +915,12 @@ declare class PollarClient {
873
915
  revokeSession(familyId: string): Promise<void>;
874
916
  getNetwork(): StellarNetwork;
875
917
  getNetworkState(): NetworkState;
918
+ /**
919
+ * The client's level-gated logger (built from `logLevel` / `logger`). Exposed
920
+ * so the runtime layer (`@pollar/react`) can route its own logs through the
921
+ * same level and sink instead of calling `console` directly.
922
+ */
923
+ getLogger(): PollarLogger;
876
924
  setNetwork(network: StellarNetwork): void;
877
925
  onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
878
926
  getTransactionState(): TransactionState | null;
@@ -1097,6 +1145,11 @@ interface LocalStorageAdapterOptions {
1097
1145
  * in-memory fallback (e.g. quota exceeded, throwing `localStorage`).
1098
1146
  */
1099
1147
  onDegrade?: OnStorageDegrade;
1148
+ /**
1149
+ * Logger for the one-shot degrade warning. Defaults to the global `console`;
1150
+ * `PollarClient` passes its level-gated logger so `logLevel` applies here too.
1151
+ */
1152
+ logger?: PollarLogger;
1100
1153
  }
1101
1154
  /**
1102
1155
  * `localStorage`-backed adapter that wraps every operation in try/catch and
@@ -5751,7 +5804,7 @@ interface operations {
5751
5804
  type PollarApiClient = ReturnType<typeof createApiClient>;
5752
5805
  declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
5753
5806
 
5754
- declare function isValidSession(value: unknown): value is PollarPersistedSession;
5807
+ declare function isValidSession(value: unknown, logger?: PollarLogger): value is PollarPersistedSession;
5755
5808
 
5756
5809
  /**
5757
5810
  * GET /kyc/status
@@ -5844,4 +5897,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
5844
5897
  */
5845
5898
  declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
5846
5899
 
5847
- export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
5900
+ export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,34 @@ export { a as StorageDegradeReason } from './types-DqgJIJBl.js';
3
3
  import { V as VisibilityProvider } from './types-Dyky8g0p.js';
4
4
  import * as openapi_fetch from 'openapi-fetch';
5
5
 
6
+ /**
7
+ * Log levels in increasing verbosity. Setting a level emits that level and
8
+ * every more-important one; `silent` disables all SDK logging.
9
+ *
10
+ * silent < error < warn < info < debug
11
+ */
12
+ type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
13
+ /**
14
+ * Sink the SDK writes logs to. The global `console` already satisfies this
15
+ * shape, so it's the default. Inject your own (pino, Sentry breadcrumbs, a test
16
+ * spy…) via `PollarClientConfig.logger` to route SDK logs wherever you want.
17
+ */
18
+ interface PollarLogger {
19
+ error(...args: unknown[]): void;
20
+ warn(...args: unknown[]): void;
21
+ info(...args: unknown[]): void;
22
+ debug(...args: unknown[]): void;
23
+ }
24
+ /**
25
+ * Build a level-gated logger over a sink. The returned object has the same
26
+ * method surface as {@link PollarLogger}; each call is silently dropped when its
27
+ * level is more verbose than the configured `level`. Messages keep their own
28
+ * `[PollarClient…]` prefixes, so this only adds filtering + sink routing.
29
+ *
30
+ * Defaults: `level = 'info'`, `sink = console`.
31
+ */
32
+ declare function createLogger(level?: LogLevel, sink?: PollarLogger): PollarLogger;
33
+
6
34
  type StellarNetwork = 'mainnet' | 'testnet';
7
35
  type StellarClientConfig = StellarNetwork | {
8
36
  horizonUrl: string;
@@ -218,6 +246,19 @@ interface PollarClientConfig {
218
246
  * apiKey)`: WebCrypto in browsers, `@noble/curves` in RN.
219
247
  */
220
248
  keyManager?: KeyManager;
249
+ /**
250
+ * Minimum severity the SDK logs. `silent` disables all SDK logging; the rest
251
+ * emit that level and everything more important (`error` < `warn` < `info` <
252
+ * `debug`). State-transition chatter (auth/tx/network) is at `debug`.
253
+ * Defaults to `'info'`.
254
+ */
255
+ logLevel?: LogLevel;
256
+ /**
257
+ * Sink the SDK writes logs to. Defaults to the global `console`. Inject your
258
+ * own (pino, Sentry breadcrumbs, a test spy…) to route SDK logs anywhere.
259
+ * Filtering by `logLevel` still applies on top of whatever you pass.
260
+ */
261
+ logger?: PollarLogger;
221
262
  /**
222
263
  * Notified when persistent storage silently degrades to in-memory mode
223
264
  * (Safari private browsing quota errors, sandboxed iframes, etc.). Useful
@@ -683,6 +724,7 @@ declare class PollarClient {
683
724
  readonly id: string;
684
725
  readonly basePath: string;
685
726
  private readonly _api;
727
+ private readonly _log;
686
728
  private readonly _storage;
687
729
  private readonly _keyManager;
688
730
  /** Resolves once `keyManager.init()` and the initial session restore complete. */
@@ -873,6 +915,12 @@ declare class PollarClient {
873
915
  revokeSession(familyId: string): Promise<void>;
874
916
  getNetwork(): StellarNetwork;
875
917
  getNetworkState(): NetworkState;
918
+ /**
919
+ * The client's level-gated logger (built from `logLevel` / `logger`). Exposed
920
+ * so the runtime layer (`@pollar/react`) can route its own logs through the
921
+ * same level and sink instead of calling `console` directly.
922
+ */
923
+ getLogger(): PollarLogger;
876
924
  setNetwork(network: StellarNetwork): void;
877
925
  onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
878
926
  getTransactionState(): TransactionState | null;
@@ -1097,6 +1145,11 @@ interface LocalStorageAdapterOptions {
1097
1145
  * in-memory fallback (e.g. quota exceeded, throwing `localStorage`).
1098
1146
  */
1099
1147
  onDegrade?: OnStorageDegrade;
1148
+ /**
1149
+ * Logger for the one-shot degrade warning. Defaults to the global `console`;
1150
+ * `PollarClient` passes its level-gated logger so `logLevel` applies here too.
1151
+ */
1152
+ logger?: PollarLogger;
1100
1153
  }
1101
1154
  /**
1102
1155
  * `localStorage`-backed adapter that wraps every operation in try/catch and
@@ -5751,7 +5804,7 @@ interface operations {
5751
5804
  type PollarApiClient = ReturnType<typeof createApiClient>;
5752
5805
  declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
5753
5806
 
5754
- declare function isValidSession(value: unknown): value is PollarPersistedSession;
5807
+ declare function isValidSession(value: unknown, logger?: PollarLogger): value is PollarPersistedSession;
5755
5808
 
5756
5809
  /**
5757
5810
  * GET /kyc/status
@@ -5844,4 +5897,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
5844
5897
  */
5845
5898
  declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
5846
5899
 
5847
- export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
5900
+ export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };