@pollar/core 0.9.0 → 0.10.0-rc.0

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
@@ -1,7 +1,7 @@
1
1
  import { S as Storage, O as OnStorageDegrade } from './types-DqgJIJBl.js';
2
2
  export { a as StorageDegradeReason } from './types-DqgJIJBl.js';
3
- import { V as VisibilityProvider } from './types-Dyky8g0p.js';
4
3
  import * as openapi_fetch from 'openapi-fetch';
4
+ import { V as VisibilityProvider } from './types-Dyky8g0p.js';
5
5
 
6
6
  /**
7
7
  * Log levels in increasing verbosity. Setting a level emits that level and
@@ -53,1373 +53,89 @@ declare class StellarClient {
53
53
  }
54
54
 
55
55
  /**
56
- * Public JWK shape for an EC P-256 key. Only the four required members for
57
- * RFC 7638 thumbprint computation; never includes private fields or extras
58
- * like `alg` / `use` / `kid`.
59
- */
60
- interface PublicEcJwk {
61
- kty: 'EC';
62
- crv: 'P-256';
63
- /** Base64url-encoded big-endian X coordinate (32 bytes). */
64
- x: string;
65
- /** Base64url-encoded big-endian Y coordinate (32 bytes). */
66
- y: string;
67
- }
68
- /**
69
- * Manages the per-session ECDSA P-256 keypair used to sign DPoP proofs.
70
- *
71
- * Implementations:
72
- * - `WebCryptoKeyManager` (web): non-extractable `CryptoKey` persisted in
73
- * IndexedDB. Private key bytes never leave the browser's crypto context.
74
- * - `NobleKeyManager` (React Native): private scalar bytes stored through an
75
- * injected `Storage` adapter (Keychain / SecureStore). Pure-JS ECDSA via
76
- * `@noble/curves`.
77
- */
78
- interface KeyManager {
79
- /**
80
- * Load an existing key for this session or generate a new one. Idempotent.
81
- * Must be called before `getPublicJwk`, `getThumbprint`, or `sign`.
82
- */
83
- init(): Promise<void>;
84
- /**
85
- * Destroy the key. Removes it from persistent storage and clears any
86
- * cached state. Used on logout.
87
- */
88
- reset(): Promise<void>;
89
- /**
90
- * The public JWK that goes into the DPoP proof header. Returns a fresh
91
- * object every call (callers may mutate without affecting the manager).
92
- */
93
- getPublicJwk(): Promise<PublicEcJwk>;
94
- /**
95
- * RFC 7638 JWK thumbprint, base64url(SHA-256(canonical JWK)). The server
96
- * compares this to the access token's `cnf.jkt` claim.
97
- */
98
- getThumbprint(): Promise<string>;
99
- /**
100
- * Sign the given bytes with ECDSA-P256-SHA256. Returns 64-byte raw r||s
101
- * (IEEE P1363 / JOSE format), NOT DER. Suitable for direct base64url
102
- * encoding into the JWS signature segment.
103
- */
104
- sign(payload: Uint8Array): Promise<Uint8Array>;
105
- }
106
-
107
- declare enum WalletType {
108
- FREIGHTER = "freighter",
109
- ALBEDO = "albedo"
110
- }
111
- /**
112
- * A wallet identifier. Accepts the internal `WalletType` enum values
113
- * (`'freighter'`, `'albedo'`) plus any opaque string id used by external
114
- * adapter packages (e.g. Stellar Wallets Kit ids like `'xbull'`, `'lobstr'`).
115
- * The `(string & {})` keeps autocomplete on the enum values without rejecting
116
- * arbitrary strings.
117
- */
118
- type WalletId = WalletType | (string & {});
119
- interface ConnectWalletResponse {
120
- address: string;
121
- }
122
- interface SignTransactionOptions {
123
- network?: string;
124
- networkPassphrase?: string;
125
- accountToSign?: string;
126
- }
127
- interface SignAuthEntryOptions {
128
- accountToSign?: string;
129
- }
130
- interface SignTransactionResponse {
131
- signedTxXdr: string;
132
- }
133
- interface SignAuthEntryResponse {
134
- signedAuthEntry: string;
135
- }
136
- interface WalletAdapter {
137
- type: WalletId;
138
- isAvailable(): Promise<boolean>;
139
- connect(): Promise<ConnectWalletResponse>;
140
- disconnect(): Promise<void>;
141
- getPublicKey(): Promise<string | null>;
142
- signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
143
- signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
144
- }
145
- /**
146
- * Resolves a {@link WalletAdapter} for a given wallet id. Injected through
147
- * `PollarClientConfig.walletAdapter` so wallet implementations (Stellar
148
- * Wallets Kit, custom modules, etc.) can live outside `@pollar/core`.
56
+ * This file was auto-generated by openapi-typescript.
57
+ * Do not make direct changes to the file.
149
58
  */
150
- type WalletAdapterResolver = (id: WalletId) => WalletAdapter | Promise<WalletAdapter>;
151
-
152
- declare class FreighterAdapter implements WalletAdapter {
153
- readonly type = WalletType.FREIGHTER;
154
- isAvailable(): Promise<boolean>;
155
- connect(): Promise<ConnectWalletResponse>;
156
- disconnect(): Promise<void>;
157
- getPublicKey(): Promise<string | null>;
158
- getNetwork(): Promise<string>;
159
- signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
160
- signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
161
- }
162
-
163
- /** Albedo's own network vocabulary (it only understands these two values). */
164
- type AlbedoNetwork = 'public' | 'testnet';
165
- declare class AlbedoAdapter implements WalletAdapter {
166
- private readonly network;
167
- readonly type = WalletType.ALBEDO;
168
- /**
169
- * Network used for `connect` and `signAuthEntry` (which carry no per-call
170
- * network) and as the fallback for `signTransaction`. Defaults to `'testnet'`
171
- * to preserve the previous behavior when constructed with no argument.
172
- */
173
- constructor(network?: AlbedoNetwork);
174
- isAvailable(): Promise<boolean>;
175
- connect(): Promise<ConnectWalletResponse>;
176
- disconnect(): Promise<void>;
177
- getPublicKey(): Promise<string | null>;
178
- getNetwork(): Promise<string>;
179
- signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
180
- signAuthEntry(entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
181
- }
182
59
 
183
- type PollarApplicationConfigResponse = paths['/auth/login']['post']['responses'][200]['content']['application/json'];
184
- /** Full `/auth/login` response shape — used in transit but NOT persisted. */
185
- type PollarApplicationConfigContent = PollarApplicationConfigResponse['content'];
186
- /**
187
- * What we actually write to `Storage`. Drops the PII subtree (`data.*`)
188
- * which is held in memory only on `PollarClient._profile` after auth.
189
- */
190
- interface PollarPersistedSession {
191
- clientSessionId: string;
192
- userId: string | null;
193
- status: string;
194
- token: {
195
- accessToken: string;
196
- refreshToken: string;
197
- expiresAt: number;
60
+ interface paths {
61
+ "/health": {
62
+ parameters: {
63
+ query?: never;
64
+ header?: never;
65
+ path?: never;
66
+ cookie?: never;
67
+ };
68
+ /** Health check */
69
+ get: operations["getHealth"];
70
+ put?: never;
71
+ post?: never;
72
+ delete?: never;
73
+ options?: never;
74
+ head?: never;
75
+ patch?: never;
76
+ trace?: never;
198
77
  };
199
- user: {
200
- id?: string;
201
- ready: boolean;
78
+ "/auth/session": {
79
+ parameters: {
80
+ query?: never;
81
+ header?: never;
82
+ path?: never;
83
+ cookie?: never;
84
+ };
85
+ get?: never;
86
+ put?: never;
87
+ /**
88
+ * Create a client session
89
+ * @description Creates a pending client session that will be linked to a user after authentication.
90
+ */
91
+ post: operations["postAuthSession"];
92
+ delete?: never;
93
+ options?: never;
94
+ head?: never;
95
+ patch?: never;
96
+ trace?: never;
202
97
  };
203
- wallet: {
204
- type: 'internal' | 'smart' | 'external';
205
- address: string | null;
206
- existsOnStellar?: boolean;
207
- createdAt?: number;
208
- linkedAt?: number;
209
- network?: string;
210
- deployTxHash?: string | null;
98
+ "/auth/session/status/{clientSessionId}": {
99
+ parameters: {
100
+ query?: never;
101
+ header?: never;
102
+ path?: never;
103
+ cookie?: never;
104
+ };
105
+ /**
106
+ * Stream client session status
107
+ * @description Server-Sent Events stream that emits session state every 500 ms. Closes when the session is consumed or expires.
108
+ */
109
+ get: operations["getAuthSessionStatusByClientSessionId"];
110
+ put?: never;
111
+ post?: never;
112
+ delete?: never;
113
+ options?: never;
114
+ head?: never;
115
+ patch?: never;
116
+ trace?: never;
211
117
  };
212
- }
213
- /** In-memory user profile (kept on `PollarClient`, never persisted). */
214
- interface PollarUserProfile {
215
- mail: string;
216
- first_name: string;
217
- last_name: string;
218
- avatar: string;
219
- providers: {
220
- email: {
221
- address: string;
222
- } | null;
223
- google: {
224
- id: string;
225
- } | null;
226
- github: {
227
- id: string;
228
- } | null;
229
- wallet: {
230
- address: string;
231
- } | null;
118
+ "/auth/session/status/{clientSessionId}/poll": {
119
+ parameters: {
120
+ query?: never;
121
+ header?: never;
122
+ path?: never;
123
+ cookie?: never;
124
+ };
125
+ /**
126
+ * Poll client session status (non-streaming)
127
+ * @description One-shot JSON variant of the SSE status stream, for clients without fetch response-body streaming (React Native). Returns the current `{status, user.ready}` immediately. Poll until `status` reaches a ready/consumed state.
128
+ */
129
+ get: operations["getAuthSessionStatusByClientSessionIdPoll"];
130
+ put?: never;
131
+ post?: never;
132
+ delete?: never;
133
+ options?: never;
134
+ head?: never;
135
+ patch?: never;
136
+ trace?: never;
232
137
  };
233
- }
234
- interface PollarClientConfig {
235
- stellarNetwork?: StellarNetwork;
236
- baseUrl?: string;
237
- apiKey: string;
238
- /**
239
- * Pluggable storage. Defaults to `defaultStorage()` on web (localStorage
240
- * with memory fallback). On RN you must inject one of the adapters from
241
- * `@pollar/core/adapters/expo` or `@pollar/core/adapters/react-native-keychain`.
242
- */
243
- storage?: Storage;
244
- /**
245
- * Pluggable DPoP key manager. Defaults to `defaultKeyManager(storage,
246
- * apiKey)`: WebCrypto in browsers, `@noble/curves` in RN.
247
- */
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;
262
- /**
263
- * Notified when persistent storage silently degrades to in-memory mode
264
- * (Safari private browsing quota errors, sandboxed iframes, etc.). Useful
265
- * for telemetry — the SDK keeps working but sessions won't survive reload.
266
- */
267
- onStorageDegrade?: OnStorageDegrade;
268
- /**
269
- * Resolves a {@link WalletAdapter} for a given wallet id. If omitted, the
270
- * SDK falls back to its built-in `FreighterAdapter` / `AlbedoAdapter`,
271
- * which only know `WalletType.FREIGHTER` and `WalletType.ALBEDO`. Inject
272
- * `@pollar/stellar-wallets-kit-adapter` (or your own resolver) to support
273
- * additional wallets without bundling those dependencies into `@pollar/core`.
274
- */
275
- walletAdapter?: WalletAdapterResolver;
276
- /**
277
- * Maximum time (ms) the SDK waits for a `walletAdapter` resolver to return.
278
- * Guards against a broken extension bridge (e.g. Freighter content-script
279
- * down) hanging the login flow forever. The resolver only constructs the
280
- * adapter object — it does NOT include the user-facing approval step — so
281
- * a few seconds is plenty. Defaults to 5000.
282
- */
283
- walletResolverTimeoutMs?: number;
284
- /**
285
- * Optional human-friendly label sent at /auth/login time and recorded on
286
- * the server-side refresh-token row so the user can identify it in the
287
- * "active sessions" UI (e.g. "iPhone — Safari", "Mac — Chrome 126").
288
- * If unset, the server-recorded `user_agent` header is the fallback.
289
- */
290
- deviceLabel?: string;
291
- /**
292
- * Foreground-detection signal for the silent-refresh scheduler. When the
293
- * app is hidden / backgrounded, scheduled refreshes are skipped (saves
294
- * network + sidesteps browser/RN background timer throttling); they run
295
- * the moment visibility comes back. Defaults to a web provider in the
296
- * browser (`visibilitychange` + BFCache + focus) and a noop elsewhere.
297
- * React Native consumers should inject an `AppState`-backed provider —
298
- * use `createAppStateVisibilityProvider` from
299
- * `@pollar/core/adapters/react-native-appstate`.
300
- */
301
- visibilityProvider?: VisibilityProvider;
302
- /**
303
- * If set, the silent-refresh scheduler stops issuing proactive refreshes
304
- * after this many milliseconds of no client-side HTTP activity. The
305
- * session is not cleared — the next user action triggers a request that
306
- * either reuses a still-valid access token or hits 401 → reactive
307
- * refresh (transparent if the RT is still valid). Defaults to
308
- * `undefined` = refresh forever as long as the app is visible.
309
- */
310
- maxIdleMs?: number;
311
- /**
312
- * Strategy for opening the hosted OAuth URL during
313
- * `login({ provider: 'google' | 'github' })`. Defaults to a browser popup
314
- * on web. React Native consumers MUST provide one (typically wrapping
315
- * `expo-web-browser`'s `openAuthSessionAsync`), since `window.open` does
316
- * not exist there. The SDK still drives the rest of the flow by polling the
317
- * auth-session status, so the opener only needs to surface the URL — it does
318
- * NOT need to capture the redirect payload.
319
- */
320
- openAuthUrl?: AuthUrlOpener;
321
- /**
322
- * Value sent to the backend as `redirect_uri` for hosted OAuth (where the
323
- * provider returns the user afterwards). Defaults to `window.location.origin`
324
- * on web. On React Native set this to your app's deep link / scheme — the
325
- * same URL you pass to `WebBrowser.openAuthSessionAsync`.
326
- */
327
- oauthRedirectUri?: string;
328
- /**
329
- * The passkey (WebAuthn) ceremony for "Smart Wallet" login, injected by the
330
- * runtime layer (`@pollar/react` implements it with `@simplewebauthn/browser`).
331
- * `@pollar/core` stays runtime-agnostic and never touches `navigator.credentials`
332
- * directly. Required to use `loginSmartWallet()`. Browser-only for now;
333
- * React Native needs a native passkey provider.
334
- */
335
- passkey?: PasskeyCeremony;
336
- /**
337
- * Signs smart-account (C-address) transactions with the user's passkey.
338
- * Required to send from a smart wallet. Injected by `@pollar/react`;
339
- * browser-only for now.
340
- */
341
- passkeySign?: PasskeySigner;
342
- }
343
- /**
344
- * Runs the device WebAuthn ceremony for a server-issued challenge and returns
345
- * the result to forward to the backend: a registration response for a new user
346
- * (`create()`) or an authentication assertion for a returning one (`get()`).
347
- * `mode` tells the ceremony which to run: `'login'` runs `get()` only (returning
348
- * user) and `'register'` runs `create()` only (new wallet) — the caller picks via
349
- * the "Log in" / "Create wallet" buttons, so there's no ambiguous autodetect that
350
- * could create a wallet when the user merely cancelled a login prompt. `response`
351
- * is the browser's PublicKeyCredential serialized to JSON — forwarded verbatim to
352
- * `/auth/passkey/{register,login}`.
353
- */
354
- type PasskeyMode = 'login' | 'register';
355
- type PasskeyCeremony = (ctx: {
356
- challenge: string;
357
- mode: PasskeyMode;
358
- }) => Promise<{
359
- kind: 'login';
360
- response: unknown;
361
- } | {
362
- kind: 'register';
363
- response: unknown;
364
- }>;
365
- /**
366
- * Signs a smart-account transaction's auth digest with the user's passkey
367
- * (a WebAuthn `get()` whose challenge is the raw digest). Returns the PUBLIC
368
- * assertion fields (base64url) for the server to assemble into the Soroban auth
369
- * entry — no secret leaves the device. Injected by the runtime layer
370
- * (`@pollar/react`); `@pollar/core` never touches `navigator.credentials`.
371
- */
372
- type PasskeySigner = (ctx: {
373
- /** base64url WebAuthn credential id to sign with. */
374
- credentialId: string;
375
- /** hex-encoded auth digest to use as the WebAuthn challenge. */
376
- challenge: string;
377
- }) => Promise<{
378
- authenticatorData: string;
379
- clientDataJSON: string;
380
- signature: string;
381
- }>;
382
- /**
383
- * Strategy for opening the hosted OAuth URL. The SDK mints the per-login auth
384
- * session lazily inside `getUrl()` (call it once; the first call creates the
385
- * `clientSessionId` and returns the full URL, or `null` if session creation
386
- * failed). Open the resolved URL however the platform allows — a popup on web,
387
- * `WebBrowser.openAuthSessionAsync(url, redirectUri)` on React Native — and
388
- * resolve once the user-facing browser step is done or dismissed. You do NOT
389
- * need to capture the redirect payload: the SDK polls the auth-session status
390
- * until the backend marks it READY.
391
- */
392
- type AuthUrlOpener = (ctx: AuthOpenContext) => void | Promise<void>;
393
- interface AuthOpenContext {
394
- provider: 'google' | 'github';
395
- /**
396
- * Mints the auth session (once) and returns the full hosted-OAuth URL, or
397
- * `null` if session creation failed. On web, call it AFTER reserving the
398
- * popup window so popup blockers (which only honor `window.open` inside the
399
- * original user-gesture tick) don't swallow it.
400
- */
401
- getUrl: () => Promise<string | null>;
402
- /** The redirect target passed to the backend as `redirect_uri`. */
403
- redirectUri: string;
404
- signal: AbortSignal;
405
- }
406
- /**
407
- * One row in the active-sessions list (returned by `PollarClient.listSessions()`).
408
- * Mirrors the sdk-api `SessionsListContent` schema.
409
- */
410
- interface SessionInfo {
411
- familyId: string;
412
- createdAt: string;
413
- lastUsedAt: string | null;
414
- userAgent: string | null;
415
- ipHash: string | null;
416
- deviceLabel: string | null;
417
- current: boolean;
418
- expiresAt: string;
419
- }
420
- /**
421
- * Observable state for the active-sessions list. Lives on the client (like
422
- * {@link TxHistoryState} / {@link WalletBalanceState}) so UI layers can
423
- * subscribe via `onSessionsStateChange` and stay pure readers instead of
424
- * holding the loading state locally.
425
- */
426
- type SessionsState = {
427
- step: 'idle';
428
- } | {
429
- step: 'loading';
430
- } | {
431
- step: 'loaded';
432
- sessions: SessionInfo[];
433
- } | {
434
- step: 'error';
435
- message: string;
436
- };
437
- type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
438
- type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
439
- type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
440
- type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
441
- type TxSignBody = NonNullable<paths['/tx/sign']['post']['requestBody']>['content']['application/json'];
442
- type TxSignResponse = paths['/tx/sign']['post']['responses'][200]['content']['application/json'];
443
- type TxSignContent = TxSignResponse['content'];
444
- type TxSubmitSignedBody = NonNullable<paths['/tx/submit']['post']['requestBody']>['content']['application/json'];
445
- type TxBuildSignSubmitBody = NonNullable<paths['/tx/build-sign-submit']['post']['requestBody']>['content']['application/json'];
446
- type TxBuildSignSubmitResponse = paths['/tx/build-sign-submit']['post']['responses'][200]['content']['application/json'];
447
- type TxBuildSignSubmitContent = TxBuildSignSubmitResponse['content'];
448
- type PollarLoginOptions = {
449
- provider: 'google';
450
- } | {
451
- provider: 'github';
452
- } | {
453
- provider: 'email';
454
- email: string;
455
- } | {
456
- provider: 'wallet';
457
- type: WalletId;
458
- };
459
- type TxBuildContent = TxBuildResponse['content'];
460
- /**
461
- * Phases the SDK can be in across the build → sign → submit lifecycle.
462
- *
463
- * **Granular** steps (`building`, `signing`, `submitting`) are emitted when
464
- * the SDK can directly observe that phase — i.e. when each is a separate
465
- * client-driven call (`buildTx`, `signTx`, `submitTx`, external-wallet
466
- * `signAndSubmitTx`).
467
- *
468
- * **Compound** steps (`signing-submitting`, `building-signing-submitting`)
469
- * are emitted when multiple phases collapse into a single opaque backend
470
- * round-trip (`signAndSubmitTx` custodial → `/tx/sign-and-send`, and `runTx`
471
- * / `buildAndSignAndSubmitTx` custodial → `/tx/build-sign-submit`). The SDK
472
- * can't see when one phase ends and the next begins inside that request, so
473
- * it honestly reports a single fused state instead of fabricating
474
- * transitions.
475
- *
476
- * **Terminal states** (`success`, `error`) and the post-Horizon-ack pending
477
- * state (`submitted`) are shared across all paths.
478
- *
479
- * On `error`, the `phase` discriminator tells the consumer *where* the
480
- * failure happened so modal UIs can offer "retry from this step" buttons.
481
- */
482
- type TransactionState = {
483
- step: 'idle';
484
- } | {
485
- step: 'building';
486
- } | {
487
- step: 'built';
488
- buildData: TxBuildContent;
489
- } | {
490
- step: 'signing';
491
- buildData?: TxBuildContent;
492
- } | {
493
- step: 'signed';
494
- buildData?: TxBuildContent;
495
- signedXdr: string;
496
- submissionToken?: string;
497
- } | {
498
- step: 'submitting';
499
- buildData?: TxBuildContent;
500
- signedXdr?: string;
501
- } | {
502
- step: 'signing-submitting';
503
- buildData?: TxBuildContent;
504
- } | {
505
- step: 'building-signing-submitting';
506
- } | {
507
- step: 'submitted';
508
- buildData?: TxBuildContent;
509
- hash: string;
510
- } | {
511
- step: 'success';
512
- buildData?: TxBuildContent;
513
- hash: string;
514
- } | {
515
- step: 'error';
516
- phase: TxErrorPhase;
517
- details?: string;
518
- buildData?: TxBuildContent;
519
- signedXdr?: string;
520
- };
521
- /**
522
- * Identifies which phase failed when `TransactionState.step === 'error'`.
523
- * Compound phase names (`signing-submitting`, `building-signing-submitting`)
524
- * appear here when the failure happened inside an atomic backend call where
525
- * the SDK can't isolate the failing sub-phase.
526
- */
527
- type TxErrorPhase = 'building' | 'signing' | 'submitting' | 'signing-submitting' | 'building-signing-submitting';
528
- /**
529
- * Per-call outcomes returned by `buildTx`, `signTx`, `submitTx`,
530
- * `signAndSubmitTx`, and `buildAndSignAndSubmitTx`. These are additive to
531
- * `TransactionState` — the same operations still drive the state machine for
532
- * modal-style UIs, but headless callers can `await` the method and inspect
533
- * the returned outcome directly instead of subscribing to state changes.
534
- */
535
- type BuildOutcome = {
536
- status: 'built';
537
- buildData: TxBuildContent;
538
- } | {
539
- status: 'error';
540
- details?: string;
541
- };
542
- type SignOutcome = {
543
- status: 'signed';
544
- signedXdr: string;
545
- submissionToken?: string;
546
- expiresAt?: number;
547
- } | {
548
- status: 'error';
549
- details?: string;
550
- };
551
- type SubmitOutcome = {
552
- status: 'success';
553
- hash: string;
554
- buildData?: TxBuildContent;
555
- } | {
556
- status: 'pending';
557
- hash: string;
558
- buildData?: TxBuildContent;
559
- } | {
560
- status: 'error';
561
- hash?: string;
562
- details?: string;
563
- resultCode?: string;
564
- buildData?: TxBuildContent;
565
- };
566
- /**
567
- * Result of {@link PollarClient.setTrustline}. Like {@link SubmitOutcome} but the
568
- * `hash` is optional: the sponsored, server-orchestrated path completes without
569
- * surfacing a transaction hash to the client, whereas the self-paid path returns
570
- * the underlying submit outcome (hash included).
571
- */
572
- type TrustlineOutcome = {
573
- status: 'success';
574
- hash?: string;
575
- } | {
576
- status: 'pending';
577
- hash?: string;
578
- } | {
579
- status: 'error';
580
- details?: string;
581
- };
582
- declare const AUTH_ERROR_CODES: {
583
- readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
584
- readonly SESSION_EXPIRED: "SESSION_EXPIRED";
585
- readonly SESSION_INVALID: "SESSION_INVALID";
586
- readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
587
- readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
588
- readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
589
- readonly EMAIL_CODE_INVALID: "EMAIL_CODE_INVALID";
590
- readonly AUTH_FAILED: "AUTH_FAILED";
591
- readonly WALLET_CONNECT_FAILED: "WALLET_CONNECT_FAILED";
592
- readonly WALLET_AUTH_FAILED: "WALLET_AUTH_FAILED";
593
- readonly WALLET_RESOLVER_TIMEOUT: "WALLET_RESOLVER_TIMEOUT";
594
- readonly PASSKEY_FAILED: "PASSKEY_FAILED";
595
- readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
596
- };
597
- type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
598
- type AuthState = {
599
- step: 'idle';
600
- } | {
601
- step: 'creating_session';
602
- } | {
603
- step: 'entering_email';
604
- clientSessionId: string;
605
- } | {
606
- step: 'sending_email';
607
- email: string;
608
- } | {
609
- step: 'entering_code';
610
- clientSessionId: string;
611
- email: string;
612
- } | {
613
- step: 'verifying_email_code';
614
- clientSessionId: string;
615
- email: string;
616
- } | {
617
- step: 'opening_oauth';
618
- provider: 'google' | 'github';
619
- } | {
620
- step: 'connecting_wallet';
621
- walletType: WalletId;
622
- } | {
623
- step: 'wallet_not_installed';
624
- walletType: WalletId;
625
- } | {
626
- step: 'authenticating_wallet';
627
- } | {
628
- step: 'creating_passkey';
629
- } | {
630
- step: 'deploying_smart_account';
631
- } | {
632
- step: 'authenticating';
633
- } | {
634
- step: 'authenticated';
635
- session: PollarPersistedSession;
636
- /**
637
- * `false` while the session is restored optimistically from storage and
638
- * not yet revalidated with the server; `true` after a fresh login/refresh
639
- * or a successful `/auth/session/resume`. Gate sensitive actions on this.
640
- */
641
- verified: boolean;
642
- } | {
643
- step: 'error';
644
- previousStep: string;
645
- message: string;
646
- errorCode: AuthErrorCode;
647
- clientSessionId?: string;
648
- email?: string;
649
- };
650
- type NetworkState = {
651
- step: 'idle';
652
- } | {
653
- step: 'connected';
654
- network: StellarNetwork;
655
- };
656
- declare class PollarFlowError extends Error {
657
- readonly code: "INVALID_FLOW";
658
- constructor(message: string);
659
- }
660
- type WalletBalanceContent = paths['/wallet/balance']['get']['responses'][200]['content']['application/json']['content'];
661
- type WalletBalanceRecord = WalletBalanceContent['balances'][number];
662
- type WalletBalanceState = {
663
- step: 'idle';
664
- } | {
665
- step: 'loading';
666
- } | {
667
- step: 'loaded';
668
- data: WalletBalanceContent;
669
- } | {
670
- step: 'error';
671
- message: string;
672
- };
673
- type WalletAssetsContent = paths['/wallet/assets']['get']['responses'][200]['content']['application/json']['content'];
674
- type EnabledAssetRecord = WalletAssetsContent['assets'][number];
675
- type EnabledAssetsState = {
676
- step: 'idle';
677
- } | {
678
- step: 'loading';
679
- } | {
680
- step: 'loaded';
681
- data: WalletAssetsContent;
682
- } | {
683
- step: 'error';
684
- message: string;
685
- };
686
- type TxHistoryRecord = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content']['records'][number];
687
- type TxHistoryParams = NonNullable<paths['/tx/history']['get']['parameters']['query']>;
688
- type TxHistoryContent = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content'];
689
- type TxHistoryState = {
690
- step: 'idle';
691
- } | {
692
- step: 'loading';
693
- params: TxHistoryParams;
694
- } | {
695
- step: 'loaded';
696
- params: TxHistoryParams;
697
- data: TxHistoryContent;
698
- } | {
699
- step: 'error';
700
- params: TxHistoryParams;
701
- message: string;
702
- };
703
- type KycLevel = 'basic' | 'intermediate' | 'enhanced';
704
- type KycStatus = 'none' | 'pending' | 'approved' | 'rejected';
705
- type KycFlow = 'iframe' | 'form' | 'redirect';
706
- type KycProvider = paths['/kyc/providers']['get']['responses'][200]['content']['application/json']['content']['providers'][number];
707
- type KycStartBody = NonNullable<paths['/kyc/start']['post']['requestBody']>['content']['application/json'];
708
- type KycStartResponse = paths['/kyc/start']['post']['responses'][200]['content']['application/json']['content'];
709
- type RampsQuoteQuery = NonNullable<paths['/ramps/quote']['get']['parameters']['query']>;
710
- type RampQuote = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content']['quotes'][number];
711
- type RampsQuoteResponse = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content'];
712
- type RampsOnrampBody = NonNullable<paths['/ramps/onramp']['post']['requestBody']>['content']['application/json'];
713
- type RampsOnrampResponse = paths['/ramps/onramp']['post']['responses'][200]['content']['application/json']['content'];
714
- type RampsOfframpBody = NonNullable<paths['/ramps/offramp']['post']['requestBody']>['content']['application/json'];
715
- type RampsOfframpResponse = paths['/ramps/offramp']['post']['responses'][200]['content']['application/json']['content'];
716
- type RampsTransactionResponse = paths['/ramps/transaction/{txId}']['get']['responses'][200]['content']['application/json']['content'];
717
- type RampTxStatus = RampsTransactionResponse['status'];
718
- type RampDirection = RampsTransactionResponse['direction'];
719
- type PaymentInstructions = RampsOnrampResponse['paymentInstructions'];
720
- type DistributionRule = paths['/distribution/rules']['get']['responses'][200]['content']['application/json']['content']['rules'][number];
721
- type RulePeriod = DistributionRule['period'];
722
- type DistributionClaimBody = NonNullable<paths['/distribution/claim']['post']['requestBody']>['content']['application/json'];
723
- type DistributionClaimContent = paths['/distribution/claim']['post']['responses'][200]['content']['application/json']['content'];
724
- type DistributionRulesState = {
725
- step: 'idle';
726
- } | {
727
- step: 'loading';
728
- } | {
729
- step: 'loaded';
730
- rules: DistributionRule[];
731
- } | {
732
- step: 'error';
733
- message: string;
734
- };
735
- type AdapterFn<TParams = unknown> = (params: TParams) => Promise<{
736
- unsignedTransaction: string;
737
- }>;
738
- type PollarAdapter = Record<string, AdapterFn<any>>;
739
- interface PollarAdapters {
740
- [key: string]: PollarAdapter;
741
- }
742
-
743
- declare class PollarClient {
744
- readonly apiKey: string;
745
- readonly id: string;
746
- readonly basePath: string;
747
- private readonly _api;
748
- private readonly _log;
749
- private readonly _storage;
750
- private readonly _keyManager;
751
- /** Resolves once `keyManager.init()` and the initial session restore complete. */
752
- private readonly _initialized;
753
- /**
754
- * Per-API-key storage namespace. Computed asynchronously inside
755
- * `_initialize()` because SHA-256 lives behind `crypto.subtle.digest`.
756
- * Accessing `apiKeyHash` before `await client.ready()` throws.
757
- */
758
- private _apiKeyHash;
759
- /**
760
- * Short SHA-256-derived namespace for this client's persisted state.
761
- * Available after `await client.ready()` (or any awaited method); throws
762
- * if read before initialization completes.
763
- */
764
- get apiKeyHash(): string;
765
- private _session;
766
- private _profile;
767
- /** Last `DPoP-Nonce` we saw from a server response. Carried into the next proof. */
768
- private _dpopNonce;
769
- /**
770
- * Snapshot of each in-flight request's body, taken in `onRequest` before
771
- * `fetch()` consumes the stream. Needed because `Request.clone()` throws
772
- * once the body is disturbed, so the auto-retry path (DPoP nonce challenge
773
- * / 401 refresh) must rebuild the request from scratch instead of cloning.
774
- */
775
- private _requestBodyCache;
776
- /** Singleton in-flight refresh — concurrent 401s coalesce into one /auth/refresh call. */
777
- private _refreshPromise;
778
- private _storageEventHandler;
779
- /** Optional UI label sent to the server at /auth/login so the sessions UI
780
- * can show a recognizable device name. Set via PollarClientConfig.deviceLabel. */
781
- private readonly _deviceLabel;
782
- private readonly _visibilityProvider;
783
- private readonly _maxIdleMs;
784
- /** Updated by the request middleware. Read by the silent-refresh scheduler
785
- * to skip proactive refreshes after `maxIdleMs` of no HTTP activity. */
786
- private _lastRequestAt;
787
- private _refreshTimer;
788
- private _visibilityUnsubscribe;
789
- private _transactionState;
790
- private _transactionStateListeners;
791
- private _txHistoryState;
792
- private _txHistoryStateListeners;
793
- private _sessionsState;
794
- private _sessionsStateListeners;
795
- private _walletBalanceState;
796
- private _walletBalanceStateListeners;
797
- private _enabledAssetsState;
798
- private _enabledAssetsStateListeners;
799
- private _authState;
800
- private _authStateListeners;
801
- private _networkState;
802
- private _networkStateListeners;
803
- /**
804
- * Latched once the storage adapter degrades. We dedupe (the adapter only
805
- * fires once anyway) and use it to replay state to late-subscribers — same
806
- * pattern as `onAuthStateChange` replaying `_authState` on subscribe.
807
- * Only populated when the SDK constructed the default storage adapter; if
808
- * the consumer passes `config.storage`, they own degradation notifications.
809
- */
810
- private _storageDegraded;
811
- private _storageDegradeListeners;
812
- private _walletAdapter;
813
- private readonly _walletAdapterResolver;
814
- private readonly _walletResolverTimeoutMs;
815
- private readonly _passkey;
816
- private readonly _passkeySign;
817
- private _loginController;
818
- /** Aborts an in-flight `/auth/session/resume` on destroy() or re-trigger. */
819
- private _resumeController;
820
- /** Platform strategy for opening the hosted-OAuth URL (popup on web; injected on RN). */
821
- private readonly _openAuthUrl;
822
- /** `redirect_uri` sent to the backend for hosted OAuth. */
823
- private readonly _oauthRedirectUri;
824
- constructor(config: PollarClientConfig);
825
- /** Awaitable handle for the initial keypair + session restore. */
826
- ready(): Promise<void>;
827
- private _initialize;
828
- /** Detach the cross-tab storage listener and abort any in-flight login. */
829
- destroy(): void;
830
- private _wireMiddlewares;
831
- private _buildProofForRequest;
832
- private _retryRequest;
833
- /**
834
- * Coalesce concurrent refresh attempts. The first caller does the work;
835
- * everyone else awaits the same promise and sees the new tokens.
836
- */
837
- refresh(): Promise<void>;
838
- private _doRefresh;
839
- /**
840
- * Arm a single setTimeout to fire shortly before the current access token
841
- * expires. Idempotent — clearing any previous timer first. Safe to call
842
- * from any session-write site (initial login, restore-from-storage, after
843
- * a successful rotation). No-op if there's no session in memory.
844
- *
845
- * Browser/RN background-tab throttling makes long-running setTimeouts
846
- * unreliable on their own; the `visibilitychange` listener compensates by
847
- * re-invoking `_maybeProactiveRefresh` whenever the app comes back to the
848
- * foreground, catching any timer that fired late or never fired at all.
849
- */
850
- private _scheduleNextRefresh;
851
- /**
852
- * Decide whether to actually run a refresh right now. Called both from the
853
- * scheduler timer and from the visibility-change listener.
854
- *
855
- * Skip if:
856
- * - no session / no RT (nothing to refresh)
857
- * - app is hidden — wait for the visibility listener to re-trigger us
858
- * - `maxIdleMs` configured and no client request since that window — let
859
- * the next reactive 401-refresh handle it whenever the user comes back
860
- * - the AT still has more than `REFRESH_SKEW_SECONDS` of life — reschedule
861
- *
862
- * Otherwise call `refresh()`, which uses the existing in-flight singleton
863
- * so we never collide with a reactive 401-triggered refresh. On failure,
864
- * `_doRefresh` already calls `_clearSession`, so auth-state listeners see
865
- * `step:'idle'` — no extra event dispatch needed here.
866
- */
867
- private _maybeProactiveRefresh;
868
- private _clearRefreshTimer;
869
- getAuthState(): AuthState;
870
- onAuthStateChange(cb: (state: AuthState) => void): () => void;
871
- /**
872
- * Subscribe to persistent-storage degradation (Safari private mode,
873
- * sandboxed iframes, quota errors, etc.). The SDK keeps running off
874
- * in-memory storage after degrade, but sessions won't survive reload — a
875
- * host UI typically wants to show "your session won't be saved" so the
876
- * user isn't blindsided after a refresh.
877
- *
878
- * Fires at most once per client lifetime (the underlying adapter dedupes).
879
- * Late subscribers receive the latched state synchronously on subscribe.
880
- *
881
- * Only fires when the SDK constructs the default storage adapter. If you
882
- * pass a custom `config.storage`, wire your own notification path through
883
- * that adapter's API — the SDK has no hook into it.
884
- */
885
- onStorageDegrade(cb: OnStorageDegrade): () => void;
886
- private _dispatchStorageDegrade;
887
- /** PII (email, names, avatar, providers). Held in memory only — never persisted. */
888
- getUserProfile(): PollarUserProfile | null;
889
- login(options: PollarLoginOptions): void;
890
- beginEmailLogin(): void;
891
- sendEmailCode(email: string): void;
892
- verifyEmailCode(code: string): void;
893
- loginWallet(type: WalletId): void;
894
- /**
895
- * "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
896
- * returning user and signs them in. Use {@link createSmartWallet} for a new
897
- * user. Requires the `passkey` ceremony to be configured (e.g. via
898
- * `@pollar/react`).
899
- */
900
- loginSmartWallet(): void;
901
- /**
902
- * "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
903
- * for a new user and deploys a sponsored smart-account C-address. Use
904
- * {@link loginSmartWallet} for a returning user. Requires the `passkey`
905
- * ceremony to be configured (e.g. via `@pollar/react`).
906
- */
907
- createSmartWallet(): void;
908
- cancelLogin(): void;
909
- /**
910
- * Revoke the current session server-side, then clear local storage.
911
- *
912
- * Server revocation is best-effort: if the POST fails (offline, server
913
- * down), local state is wiped regardless. The orphan refresh token then
914
- * remains unused until its natural expiry. The in-flight access token
915
- * stays valid until its own TTL elapses (≤10 min for DPoP-bound tokens).
916
- *
917
- * Pass `everywhere: true` to revoke every active session for this user
918
- * across all devices.
919
- */
920
- logout(options?: {
921
- everywhere?: boolean;
922
- }): Promise<void>;
923
- /** Convenience: revoke every active session for this user (all devices). */
924
- logoutEverywhere(): Promise<void>;
925
- /**
926
- * List active sessions for the authenticated user. Returns one entry per
927
- * refresh-token family with the metadata captured at issuance time. The
928
- * `current` flag identifies which entry corresponds to this client.
929
- */
930
- listSessions(): Promise<SessionInfo[]>;
931
- getSessionsState(): SessionsState;
932
- onSessionsStateChange(cb: (state: SessionsState) => void): () => void;
933
- /**
934
- * Fire-and-forget variant of {@link listSessions} that drives the observable
935
- * `SessionsState` store instead of returning the array. UI layers subscribe
936
- * via `onSessionsStateChange` and stay pure readers — mirrors `fetchTxHistory`.
937
- */
938
- fetchSessions(): Promise<void>;
939
- /**
940
- * Revoke a specific refresh-token family (a single device session). Use
941
- * `listSessions` to enumerate the familyIds. Revoking the current session
942
- * does NOT clear local state — call `logout()` for that case.
943
- */
944
- revokeSession(familyId: string): Promise<void>;
945
- getNetwork(): StellarNetwork;
946
- getNetworkState(): NetworkState;
947
- /**
948
- * The client's level-gated logger (built from `logLevel` / `logger`). Exposed
949
- * so the runtime layer (`@pollar/react`) can route its own logs through the
950
- * same level and sink instead of calling `console` directly.
951
- */
952
- getLogger(): PollarLogger;
953
- setNetwork(network: StellarNetwork): void;
954
- onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
955
- getTransactionState(): TransactionState | null;
956
- onTransactionStateChange(cb: (state: TransactionState) => void): () => void;
957
- getTxHistoryState(): TxHistoryState;
958
- onTxHistoryStateChange(cb: (state: TxHistoryState) => void): () => void;
959
- fetchTxHistory(params?: TxHistoryParams): Promise<void>;
960
- getWalletBalanceState(): WalletBalanceState;
961
- onWalletBalanceStateChange(cb: (state: WalletBalanceState) => void): () => void;
962
- /**
963
- * Refreshes the balances of the authenticated user's OWN wallet. The wallet
964
- * and network are resolved server-side from the session — no arguments. Drives
965
- * `walletBalanceState`. For an arbitrary wallet, use {@link getWalletBalance}.
966
- */
967
- refreshBalance(): Promise<void>;
968
- /**
969
- * General-purpose balance lookup for ANY wallet on ANY network — not scoped
970
- * to this application. Enumerates the account's real on-chain holdings via
971
- * Horizon (server-side) and returns the data directly (no reactive state).
972
- * `network` defaults to the client's current network.
973
- */
974
- getWalletBalance(publicKey: string, network?: StellarNetwork): Promise<WalletBalanceContent>;
975
- getEnabledAssetsState(): EnabledAssetsState;
976
- onEnabledAssetsStateChange(cb: (state: EnabledAssetsState) => void): () => void;
977
- /**
978
- * Loads the application's enabled assets paired with the authenticated
979
- * wallet's on-chain trustline state — so the SDK knows which trustlines still
980
- * need to be added. Wallet and network are resolved server-side from the
981
- * session. Drives `enabledAssetsState`; mirrors {@link refreshBalance}.
982
- */
983
- refreshAssets(): Promise<void>;
984
- /**
985
- * Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
986
- *
987
- * Routing mirrors how the platform pays for the reserve:
988
- * - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
989
- * server orchestrates a sponsored `changeTrust`: the app's wallets cover the
990
- * 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
991
- * `sponsored` flag (from {@link refreshAssets}) straight through.
992
- * - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
993
- * asset not configured in the app) → a plain `change_trust` transaction the
994
- * user's own wallet signs and pays for, via {@link runTx}.
995
- *
996
- * Does not refresh on its own — callers should `refreshAssets()` afterwards.
997
- */
998
- setTrustline(asset: {
999
- code: string;
1000
- issuer: string;
1001
- }, opts?: {
1002
- limit?: string;
1003
- sponsored?: boolean;
1004
- }): Promise<TrustlineOutcome>;
1005
- /**
1006
- * Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
1007
- * AND returns a {@link BuildOutcome} so headless callers can `await` and
1008
- * inspect the result without subscribing to state changes.
1009
- */
1010
- buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<BuildOutcome>;
1011
- getWalletType(): WalletId | null;
1012
- /**
1013
- * Signs the given unsigned XDR and returns the signed XDR.
1014
- *
1015
- * - External wallets: signs locally via the wallet adapter.
1016
- * - Custodial wallets: posts to `/tx/sign`. The backend signs (through
1017
- * wallet-service or the app's customer-managed adapter) and returns the
1018
- * signed XDR plus an `idempotencyKey` the caller should echo back to
1019
- * `submitTx`.
1020
- *
1021
- * Drives `_setTransactionState`: emits `signing` while in flight and
1022
- * `signed` on success (or `error[phase: 'signing']` on failure). `buildData`
1023
- * is threaded through if the consumer previously called `buildTx`.
1024
- */
1025
- signTx(unsignedXdr: string): Promise<SignOutcome>;
1026
- /**
1027
- * Submits a signed XDR via `/tx/submit` regardless of wallet type
1028
- * (custodial or external). Routing through sdk-api gives us:
1029
- * - End-to-end tx_records persistence with full phase lifecycle so the
1030
- * developer dashboard can show every tx (both custodial and external
1031
- * wallet flows) at `/apps/:id/monitor/transactions`.
1032
- * - Idempotency tracking via `submissionToken` (returned by `signTx`).
1033
- * - A single response shape (SUCCESS / PENDING / FAILED) shared by both
1034
- * flows — previously external wallets could only return SUCCESS or
1035
- * error since the direct-to-Horizon path was synchronous.
1036
- *
1037
- * The extra hop adds ~50–150 ms vs. the legacy direct-Horizon path; the
1038
- * persistence + observability win is worth it.
1039
- *
1040
- * Drives `_setTransactionState`: emits `submitting` while in flight,
1041
- * `submitted` on Horizon ack (pending), `success` on ledger confirmation,
1042
- * or `error[phase: 'submitting']` on failure.
1043
- */
1044
- submitTx(signedXdr: string, opts?: {
1045
- submissionToken?: string;
1046
- }): Promise<SubmitOutcome>;
1047
- /**
1048
- * Signs and submits in one logical step. Returns a {@link SubmitOutcome}.
1049
- *
1050
- * - **External wallets**: composes `signTx` + `submitTx` client-side. State
1051
- * machine sees the full granular sequence `signing → signed → submitting
1052
- * → success` because the underlying methods each emit.
1053
- * - **Custodial wallets**: atomic `/tx/sign-and-send` round-trip. State
1054
- * machine emits the compound `signing-submitting` step (the SDK can't
1055
- * observe when one phase ends and the next begins inside that single
1056
- * backend call) and then transitions to `submitted` (Horizon ack only) or
1057
- * `success` (ledger-confirmed), or `error[phase: 'signing-submitting']`.
1058
- */
1059
- signAndSubmitTx(unsignedXdr?: string): Promise<SubmitOutcome>;
1060
- /**
1061
- * One-shot: build → sign → submit, returning the final {@link SubmitOutcome}.
1062
- *
1063
- * - **External wallets**: composes `buildTx` + `signAndSubmitTx` client-side.
1064
- * State machine sees the full granular sequence (`building → built →
1065
- * signing → signed → submitting → success`) because each composed call
1066
- * emits its own transitions.
1067
- * - **Custodial wallets**: single round-trip to `/tx/build-sign-submit`. The
1068
- * signed XDR never leaves the backend. State machine emits the compound
1069
- * `building-signing-submitting` step (the SDK can't observe individual
1070
- * phase boundaries inside one atomic call) and then transitions to
1071
- * `submitted` / `success` / `error[phase: 'building-signing-submitting']`.
1072
- *
1073
- * If you need granular UI feedback for custodial flows (separate
1074
- * "Building…", "Signing…", "Submitting…" indicators), call `buildTx`,
1075
- * `signTx`, and `submitTx` separately instead.
1076
- */
1077
- buildAndSignAndSubmitTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<SubmitOutcome>;
1078
- /** Alias for {@link buildAndSignAndSubmitTx} — shorter "just do the thing" name. */
1079
- runTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<SubmitOutcome>;
1080
- /**
1081
- * Smart-wallet (passkey / C-address) transaction: build (server prepares the
1082
- * SAC transfer + returns the auth digest) → sign the digest with the passkey
1083
- * → submit (server assembles the signed auth entry and broadcasts; the
1084
- * sponsor pays the fee). State machine: building → built → signing →
1085
- * submitting → success.
1086
- */
1087
- private _runSmartTx;
1088
- /**
1089
- * Steps 2–3 of the smart-wallet flow: sign the prepared auth digest with the
1090
- * passkey, then submit. Shared by `_runSmartTx` (atomic) and `signAndSubmitTx`
1091
- * (split flow, when a smart build is already on the state machine).
1092
- */
1093
- private _signSubmitSmart;
1094
- getAppConfig(): Promise<unknown>;
1095
- getKycStatus(providerId?: string): Promise<{
1096
- status: KycStatus;
1097
- level?: KycLevel | undefined;
1098
- providerId: string;
1099
- expiresAt?: string;
1100
- }>;
1101
- getKycProviders(country: string): Promise<{
1102
- providers: KycProvider[];
1103
- }>;
1104
- startKyc(body: KycStartBody): Promise<KycStartResponse>;
1105
- resolveKyc(providerId: string, level?: KycLevel): Promise<{
1106
- alreadyApproved: boolean;
1107
- } & Partial<{
1108
- sessionId: string;
1109
- kycUrl?: string;
1110
- fields?: {
1111
- name: string;
1112
- type: string;
1113
- required: boolean;
1114
- }[];
1115
- }>>;
1116
- pollKycStatus(providerId: string, opts?: {
1117
- intervalMs?: number;
1118
- timeoutMs?: number;
1119
- }): Promise<KycStatus>;
1120
- getRampsQuote(query: RampsQuoteQuery): Promise<RampsQuoteResponse>;
1121
- createOnRamp(body: RampsOnrampBody): Promise<RampsOnrampResponse>;
1122
- createOffRamp(body: RampsOfframpBody): Promise<RampsOfframpResponse>;
1123
- getRampTransaction(txId: string): Promise<RampsTransactionResponse>;
1124
- pollRampTransaction(txId: string, opts?: {
1125
- intervalMs?: number;
1126
- timeoutMs?: number;
1127
- }): Promise<RampTxStatus>;
1128
- listDistributionRules(): Promise<DistributionRule[]>;
1129
- claimDistributionRule(body: DistributionClaimBody): Promise<DistributionClaimContent>;
1130
- private _setTxHistoryState;
1131
- private _setSessionsState;
1132
- private _setWalletBalanceState;
1133
- private _setEnabledAssetsState;
1134
- private _newController;
1135
- private _flowDeps;
1136
- /**
1137
- * Resolves a wallet adapter for the requested id. Uses the consumer's
1138
- * injected `walletAdapter` resolver when present; otherwise falls back to
1139
- * the built-in `FreighterAdapter` / `AlbedoAdapter`. Throws if the id is
1140
- * unknown and no resolver is configured.
1141
- */
1142
- private _resolveWalletAdapter;
1143
- private _handleFlowError;
1144
- private _restoreSession;
1145
- /**
1146
- * Validate the restored session against the server and repopulate the
1147
- * in-memory profile (PII is never persisted, so it's null after a cold
1148
- * reload). Goes through the normal authed client, so it coalesces with any
1149
- * in-flight refresh (onRequest awaits `_refreshPromise`) and, being a GET,
1150
- * is auto-retried after a 401-triggered refresh.
1151
- *
1152
- * - 200 → store profile, mark the session `verified`.
1153
- * - 401 → the refresh-on-401 path already ran; if the family was
1154
- * revoked, refresh failed and `_clearSession()` took us to
1155
- * idle. Nothing to do here — don't double-handle.
1156
- * - network error → stay optimistic (do NOT log out); revalidated later on
1157
- * `visibilitychange` or first use.
1158
- */
1159
- private _resume;
1160
- private _storeSession;
1161
- private _clearSession;
1162
- private _networkPassphrase;
1163
- private _setNetworkState;
1164
- private _setAuthState;
1165
- private _setTransactionState;
1166
- /**
1167
- * Threads `buildData` through state transitions. When the user has already
1168
- * called `buildTx`, every subsequent state (signing, signed, submitting,
1169
- * submitted, success, error) should carry the build summary so modal UIs
1170
- * can keep showing "Send 5 USDC to G..." through the whole flow.
1171
- */
1172
- private _currentBuildData;
1173
- }
1174
-
1175
- /**
1176
- * Version of this `@pollar/core` build (e.g. `'0.8.2'`). Falls back to `'dev'`
1177
- * when running unbundled.
1178
- *
1179
- * Named per-package on purpose: importing it alongside `@pollar/react`'s
1180
- * `POLLAR_REACT_VERSION` never collides, so an app can report both versions in
1181
- * a single bug-report / diagnostics line.
1182
- */
1183
- declare const POLLAR_CORE_VERSION: string;
1184
-
1185
- /**
1186
- * In-memory storage backed by a `Map`. Always available, never throws.
1187
- * Used as the default fallback for SSR, private browsing, sandboxed iframes
1188
- * without `allow-same-origin`, or any environment where `localStorage` is
1189
- * unusable.
1190
- */
1191
- declare function createMemoryAdapter(): Storage;
1192
- interface LocalStorageAdapterOptions {
1193
- /**
1194
- * Optional callback invoked the first time the adapter degrades to its
1195
- * in-memory fallback (e.g. quota exceeded, throwing `localStorage`).
1196
- */
1197
- onDegrade?: OnStorageDegrade;
1198
- /**
1199
- * Logger for the one-shot degrade warning. Defaults to the global `console`;
1200
- * `PollarClient` passes its level-gated logger so `logLevel` applies here too.
1201
- */
1202
- logger?: PollarLogger;
1203
- }
1204
- /**
1205
- * `localStorage`-backed adapter that wraps every operation in try/catch and
1206
- * silently degrades to an in-memory fallback for the rest of the process
1207
- * lifetime on any throw. A single warning is logged when the degrade happens.
1208
- *
1209
- * Why every op (not just the probe): Safari private mode and sandboxed iframes
1210
- * may expose `localStorage` but throw `QuotaExceededError` / `SecurityError`
1211
- * on the first write — a successful probe at construction time isn't enough.
1212
- *
1213
- * Tokens persisted here are DPoP-bound to a non-extractable WebCrypto
1214
- * keypair, so XSS exposure is limited to a signing-oracle attack (the key
1215
- * itself never leaves the browser's crypto subsystem). Consumers who need
1216
- * stricter isolation can inject a custom `Storage` adapter — e.g. one that
1217
- * proxies to an httpOnly cookie on a host origin.
1218
- */
1219
- declare function createLocalStorageAdapter(options?: LocalStorageAdapterOptions): Storage;
1220
-
1221
- /**
1222
- * Returns `localStorage`-backed storage when it works, otherwise an in-memory
1223
- * fallback. The probe writes-reads-removes a sentinel; any throw, value
1224
- * mismatch, or missing `localStorage` (SSR / disabled storage) falls back.
1225
- *
1226
- * Run-time degrade still happens inside `createLocalStorageAdapter` — see its
1227
- * docstring for the rationale.
1228
- */
1229
- declare function defaultStorage(options?: LocalStorageAdapterOptions): Storage;
1230
-
1231
- /**
1232
- * Construct the default `KeyManager` for the current runtime. Throws if no
1233
- * factory has been registered — that only happens if `@pollar/core` was
1234
- * imported in a way that bypassed the entry-point module (a bundler or
1235
- * test setup bug).
1236
- */
1237
- declare function defaultKeyManager(storage: Storage, apiKey: string): KeyManager;
1238
-
1239
- declare class WebCryptoKeyManager implements KeyManager {
1240
- private readonly apiKey;
1241
- private apiKeyHash;
1242
- private keyPair;
1243
- private publicJwk;
1244
- private thumbprint;
1245
- /**
1246
- * Cached in-flight init. Lets `init()` be called concurrently (or implicitly
1247
- * from `getPublicJwk` / `sign`) without doing the work twice. Cleared on
1248
- * failure so callers can retry, and cleared on `reset()`.
1249
- */
1250
- private _initPromise;
1251
- constructor(apiKey: string);
1252
- /**
1253
- * Idempotent and safe under concurrency. The first call kicks off the real
1254
- * init; subsequent (and concurrent) calls return the same in-flight promise.
1255
- * Other methods (`getPublicJwk`, `getThumbprint`, `sign`) auto-await this so
1256
- * the manager is self-healing if `init()` was never explicitly invoked.
1257
- */
1258
- init(): Promise<void>;
1259
- private _doInit;
1260
- /**
1261
- * Derive the public JWK from a `CryptoKey`. Prefers the `'raw'` export (the
1262
- * 65-byte uncompressed point `0x04 || X(32) || Y(32)`) and base64url-encodes
1263
- * the coordinates ourselves — that sidesteps polyfills whose `exportKey('jwk')`
1264
- * emits non-base64url `x`/`y` (standard base64, `=` padding, or — as seen with
1265
- * `react-native-quick-crypto` — a stray `.`). Real browsers and most polyfills
1266
- * support `'raw'` for public EC keys.
1267
- *
1268
- * Falls back to the `'jwk'` export (normalized via `canonicalEcJwk`) if `'raw'`
1269
- * is unsupported or returns an unexpected shape, so this can't regress on a
1270
- * runtime that only implements the JWK path. Both routes yield identical
1271
- * coordinate bytes, so the `cnf.jkt` thumbprint is unchanged either way.
1272
- */
1273
- private _exportPublicJwk;
1274
- reset(): Promise<void>;
1275
- getPublicJwk(): Promise<PublicEcJwk>;
1276
- getThumbprint(): Promise<string>;
1277
- sign(payload: Uint8Array): Promise<Uint8Array>;
1278
- }
1279
-
1280
- /**
1281
- * Compute the RFC 7638 JWK thumbprint for an EC P-256 public JWK.
1282
- *
1283
- * Algorithm (RFC 7638 §3):
1284
- * 1. Build a JSON object containing ONLY the required members of the JWK,
1285
- * ordered lexicographically by member name (Unicode code point).
1286
- * For EC keys, that's exactly {crv, kty, x, y}.
1287
- * 2. Serialize to UTF-8 with no whitespace and no line breaks.
1288
- * 3. Hash with SHA-256.
1289
- * 4. Base64url-encode the hash (no padding).
1290
- *
1291
- * Common bugs guarded against:
1292
- * - Including extra fields (`alg`, `use`, `kid`, `ext`, `key_ops`).
1293
- * - Wrong member ordering (must be lex by Unicode code point).
1294
- * - Padded base64 instead of base64url unpadded.
1295
- * - Using `JSON.stringify(jwk)` of an arbitrary-key-order object — we build
1296
- * a fresh literal in canonical order to make the order explicit and not
1297
- * rely on V8's insertion-order semantics.
1298
- */
1299
- declare function computeJwkThumbprint(jwk: PublicEcJwk): Promise<string>;
1300
- /**
1301
- * Strip a JWK to only the four required EC public members and normalize the
1302
- * coordinates to unpadded base64url. Useful when the input came from
1303
- * `crypto.subtle.exportKey('jwk', publicKey)` which adds `ext` / `key_ops`
1304
- * (and, under some RN polyfills, non-base64url coordinates). Returns a fresh
1305
- * object — never mutates input.
1306
- */
1307
- declare function canonicalEcJwk(jwk: {
1308
- kty?: string;
1309
- crv?: string;
1310
- x?: string;
1311
- y?: string;
1312
- }): PublicEcJwk;
1313
-
1314
- /**
1315
- * RFC 9449 DPoP proof builder.
1316
- *
1317
- * Produces a compact JWS that the consumer attaches as the `DPoP` HTTP
1318
- * header. The header `jwk` is the public part of the SDK's per-session
1319
- * keypair; the server verifies the signature, validates the `htm` / `htu` /
1320
- * `iat` / `jti` / optional `nonce` / optional `ath` claims, and matches the
1321
- * proof's JWK thumbprint against the access token's `cnf.jkt` claim.
1322
- *
1323
- * Server-issued nonce flow (RFC 9449 §8/§9): the server may respond with
1324
- * `WWW-Authenticate: DPoP ... error="use_dpop_nonce"` plus a `DPoP-Nonce`
1325
- * header. The client should re-build the proof with the new nonce and retry.
1326
- * `buildProof` accepts an optional nonce; the SDK client tracks it across
1327
- * requests and feeds it back here.
1328
- *
1329
- * The last seen `DPoP-Nonce` is stored verbatim and embedded in the next
1330
- * proof. The server validates it as an HMAC token, so an attacker who
1331
- * injects an arbitrary nonce cannot escalate — verification fails and the
1332
- * server replies with a fresh nonce on the next request.
1333
- */
1334
- interface BuildProofArgs {
1335
- /** HTTP method, e.g. `"GET"`. Will be uppercased before signing. */
1336
- htm: string;
1337
- /**
1338
- * HTTP target URI. Will be normalized per RFC 3986 §6.2 (lowercase scheme
1339
- * + host, default port elided, query+fragment+userinfo stripped, path
1340
- * dot-segments resolved, trailing slash preserved exactly as provided).
1341
- */
1342
- htu: string;
1343
- /**
1344
- * Access token to bind the proof to (its base64url(SHA-256) goes in the
1345
- * `ath` claim). Omit for proofs sent to the token endpoint per RFC 9449
1346
- * §5 / §6.1 (those proofs MUST NOT include `ath`).
1347
- */
1348
- accessToken?: string;
1349
- /**
1350
- * Server-issued DPoP nonce, if the server has previously challenged this
1351
- * client with `WWW-Authenticate: DPoP ... error="use_dpop_nonce"`. RFC
1352
- * 9449 §8.
1353
- */
1354
- nonce?: string;
1355
- }
1356
- /**
1357
- * Build a DPoP proof JWS for the given request. Returns the compact-form
1358
- * JWS string (`<header>.<payload>.<signature>`).
1359
- */
1360
- declare function buildProof(args: BuildProofArgs, keyManager: KeyManager): Promise<string>;
1361
- /**
1362
- * Normalize an HTTP URI for use as the `htu` claim.
1363
- *
1364
- * RFC 9449 §4.3 + RFC 3986 §6.2:
1365
- * - lowercase scheme + host
1366
- * - elide default port (`:443` for https, `:80` for http)
1367
- * - strip userinfo (never appears in `htu`)
1368
- * - strip query + fragment
1369
- * - apply path dot-segment removal (handled by the URL constructor)
1370
- * - **preserve trailing slash exactly** — `/foo` and `/foo/` are distinct
1371
- * paths per RFC 3986 §6 and must round-trip identically.
1372
- * - preserve IPv6 brackets in host
1373
- *
1374
- * Both client and server must apply the same normalization so the `htu`
1375
- * claim matches deterministically.
1376
- */
1377
- declare function normalizeHtu(rawUrl: string): string;
1378
-
1379
- /**
1380
- * This file was auto-generated by openapi-typescript.
1381
- * Do not make direct changes to the file.
1382
- */
1383
-
1384
- interface paths {
1385
- "/health": {
1386
- parameters: {
1387
- query?: never;
1388
- header?: never;
1389
- path?: never;
1390
- cookie?: never;
1391
- };
1392
- /** Health check */
1393
- get: operations["getHealth"];
1394
- put?: never;
1395
- post?: never;
1396
- delete?: never;
1397
- options?: never;
1398
- head?: never;
1399
- patch?: never;
1400
- trace?: never;
1401
- };
1402
- "/auth/session": {
1403
- parameters: {
1404
- query?: never;
1405
- header?: never;
1406
- path?: never;
1407
- cookie?: never;
1408
- };
1409
- get?: never;
1410
- put?: never;
1411
- /**
1412
- * Create a client session
1413
- * @description Creates a pending client session that will be linked to a user after authentication.
1414
- */
1415
- post: operations["postAuthSession"];
1416
- delete?: never;
1417
- options?: never;
1418
- head?: never;
1419
- patch?: never;
1420
- trace?: never;
1421
- };
1422
- "/auth/session/status/{clientSessionId}": {
138
+ "/auth/google": {
1423
139
  parameters: {
1424
140
  query?: never;
1425
141
  header?: never;
@@ -1427,10 +143,10 @@ interface paths {
1427
143
  cookie?: never;
1428
144
  };
1429
145
  /**
1430
- * Stream client session status
1431
- * @description Server-Sent Events stream that emits session state every 500 ms. Closes when the session is consumed or expires.
146
+ * Redirect to Google OAuth
147
+ * @description Redirects the user to the Google OAuth consent screen.
1432
148
  */
1433
- get: operations["getAuthSessionStatusByClientSessionId"];
149
+ get: operations["getAuthGoogle"];
1434
150
  put?: never;
1435
151
  post?: never;
1436
152
  delete?: never;
@@ -1439,7 +155,7 @@ interface paths {
1439
155
  patch?: never;
1440
156
  trace?: never;
1441
157
  };
1442
- "/auth/session/status/{clientSessionId}/poll": {
158
+ "/auth/github": {
1443
159
  parameters: {
1444
160
  query?: never;
1445
161
  header?: never;
@@ -1447,10 +163,10 @@ interface paths {
1447
163
  cookie?: never;
1448
164
  };
1449
165
  /**
1450
- * Poll client session status (non-streaming)
1451
- * @description One-shot JSON variant of the SSE status stream, for clients without fetch response-body streaming (React Native). Returns the current `{status, user.ready}` immediately. Poll until `status` reaches a ready/consumed state.
166
+ * Redirect to GitHub OAuth
167
+ * @description Redirects the user to the GitHub OAuth consent screen.
1452
168
  */
1453
- get: operations["getAuthSessionStatusByClientSessionIdPoll"];
169
+ get: operations["getAuthGithub"];
1454
170
  put?: never;
1455
171
  post?: never;
1456
172
  delete?: never;
@@ -1459,7 +175,7 @@ interface paths {
1459
175
  patch?: never;
1460
176
  trace?: never;
1461
177
  };
1462
- "/auth/google": {
178
+ "/auth/oidc": {
1463
179
  parameters: {
1464
180
  query?: never;
1465
181
  header?: never;
@@ -1467,10 +183,10 @@ interface paths {
1467
183
  cookie?: never;
1468
184
  };
1469
185
  /**
1470
- * Redirect to Google OAuth
1471
- * @description Redirects the user to the Google OAuth consent screen.
186
+ * Redirect to Authentik OIDC
187
+ * @description Redirects the user to the Authentik authorization endpoint (PKCE, per-app).
1472
188
  */
1473
- get: operations["getAuthGoogle"];
189
+ get: operations["getAuthOidc"];
1474
190
  put?: never;
1475
191
  post?: never;
1476
192
  delete?: never;
@@ -1479,47 +195,41 @@ interface paths {
1479
195
  patch?: never;
1480
196
  trace?: never;
1481
197
  };
1482
- "/auth/github": {
198
+ "/auth/email": {
1483
199
  parameters: {
1484
200
  query?: never;
1485
201
  header?: never;
1486
202
  path?: never;
1487
203
  cookie?: never;
1488
204
  };
1489
- /**
1490
- * Redirect to GitHub OAuth
1491
- * @description Redirects the user to the GitHub OAuth consent screen.
1492
- */
1493
- get: operations["getAuthGithub"];
205
+ get?: never;
1494
206
  put?: never;
1495
- post?: never;
207
+ /** Send email verification code */
208
+ post: operations["postAuthEmail"];
1496
209
  delete?: never;
1497
210
  options?: never;
1498
211
  head?: never;
1499
212
  patch?: never;
1500
213
  trace?: never;
1501
214
  };
1502
- "/auth/oidc": {
215
+ "/auth/email/verify-code": {
1503
216
  parameters: {
1504
217
  query?: never;
1505
218
  header?: never;
1506
219
  path?: never;
1507
220
  cookie?: never;
1508
221
  };
1509
- /**
1510
- * Redirect to Authentik OIDC
1511
- * @description Redirects the user to the Authentik authorization endpoint (PKCE, per-app).
1512
- */
1513
- get: operations["getAuthOidc"];
222
+ get?: never;
1514
223
  put?: never;
1515
- post?: never;
224
+ /** Verify email code */
225
+ post: operations["postAuthEmailVerifyCode"];
1516
226
  delete?: never;
1517
227
  options?: never;
1518
228
  head?: never;
1519
229
  patch?: never;
1520
230
  trace?: never;
1521
231
  };
1522
- "/auth/email": {
232
+ "/auth/wallet/challenge": {
1523
233
  parameters: {
1524
234
  query?: never;
1525
235
  header?: never;
@@ -1528,15 +238,18 @@ interface paths {
1528
238
  };
1529
239
  get?: never;
1530
240
  put?: never;
1531
- /** Send email verification code */
1532
- post: operations["postAuthEmail"];
241
+ /**
242
+ * Issue a SEP-10 wallet challenge
243
+ * @description Returns a server-signed SEP-10 challenge transaction (XDR) bound to the client session. The wallet counter-signs it to prove key control, then posts it to /auth/wallet (or /auth/external).
244
+ */
245
+ post: operations["postAuthWalletChallenge"];
1533
246
  delete?: never;
1534
247
  options?: never;
1535
248
  head?: never;
1536
249
  patch?: never;
1537
250
  trace?: never;
1538
251
  };
1539
- "/auth/email/verify-code": {
252
+ "/auth/wallet": {
1540
253
  parameters: {
1541
254
  query?: never;
1542
255
  header?: never;
@@ -1545,15 +258,18 @@ interface paths {
1545
258
  };
1546
259
  get?: never;
1547
260
  put?: never;
1548
- /** Verify email code */
1549
- post: operations["postAuthEmailVerifyCode"];
261
+ /**
262
+ * Authenticate with a Stellar wallet
263
+ * @description Verifies the SEP-10 counter-signed challenge (from /auth/wallet/challenge) and sets the session ready. During rollout an unsigned legacy request is still accepted unless SDK_WALLET_REQUIRE_SIGNATURE is enabled.
264
+ */
265
+ post: operations["postAuthWallet"];
1550
266
  delete?: never;
1551
267
  options?: never;
1552
268
  head?: never;
1553
269
  patch?: never;
1554
270
  trace?: never;
1555
271
  };
1556
- "/auth/wallet": {
272
+ "/auth/external": {
1557
273
  parameters: {
1558
274
  query?: never;
1559
275
  header?: never;
@@ -1562,8 +278,11 @@ interface paths {
1562
278
  };
1563
279
  get?: never;
1564
280
  put?: never;
1565
- /** Authenticate with a Stellar wallet */
1566
- post: operations["postAuthWallet"];
281
+ /**
282
+ * Authenticate via a custom external provider
283
+ * @description For custom login providers (Privy, Magic, …) that authenticate the user client-side and surface a Stellar wallet. Control is proven with the same SEP-10 counter-signed challenge (from /auth/wallet/challenge); Pollar needs nothing of the provider itself.
284
+ */
285
+ post: operations["postAuthExternal"];
1567
286
  delete?: never;
1568
287
  options?: never;
1569
288
  head?: never;
@@ -1847,6 +566,26 @@ interface paths {
1847
566
  patch?: never;
1848
567
  trace?: never;
1849
568
  };
569
+ "/tx/sign-auth-entry": {
570
+ parameters: {
571
+ query?: never;
572
+ header?: never;
573
+ path?: never;
574
+ cookie?: never;
575
+ };
576
+ get?: never;
577
+ put?: never;
578
+ /**
579
+ * Sign a Soroban authorization entry (custodial)
580
+ * @description Signs a single SorobanAuthorizationEntry with the user's custodial key. Use when a developer's own contract is the transaction source (it sponsors the gas) and only needs the user's address-credentials authorization, not a full signed envelope. sdk-api enforces the app's per-contract/function allowlist and a short validity-ledger window BEFORE signing — an entry touching any contract or function not allowlisted, or with too long an expiration, is rejected. External (user-controlled) wallets sign auth entries client-side and do not call this endpoint.
581
+ */
582
+ post: operations["postTxSignAuthEntry"];
583
+ delete?: never;
584
+ options?: never;
585
+ head?: never;
586
+ patch?: never;
587
+ trace?: never;
588
+ };
1850
589
  "/tx/submit": {
1851
590
  parameters: {
1852
591
  query?: never;
@@ -1995,8 +734,8 @@ interface paths {
1995
734
  cookie?: never;
1996
735
  };
1997
736
  /**
1998
- * Get my enabled assets
1999
- * @description Returns the application's dashboard-enabled assets paired with the authenticated wallet's on-chain trustline state (code, type, issuer, name, trustlineEstablished, limit). No balances. Native XLM is always included with trustlineEstablished=true. Lets the SDK know which trustlines the wallet still needs to add. The wallet and network are derived from the session — no parameters required.
737
+ * Get my trustlines
738
+ * @description Returns every trustline the authenticated wallet holds on-chain — the application's configured assets AND any the user added on their own — plus the app-enabled assets the wallet has not established a trustline for yet. Each asset carries enabledInApp (tag which belong to the app), trustlineEstablished, limit, and sponsored (app assets only). No balances. Native XLM is always included first. Trustlines are enumerated via Horizon. The wallet and network are derived from the session — no parameters required.
2000
739
  */
2001
740
  get: operations["getWalletAssets"];
2002
741
  put?: never;
@@ -2018,7 +757,7 @@ interface paths {
2018
757
  put?: never;
2019
758
  /**
2020
759
  * Enable or remove a trustline for an enabled asset
2021
- * @description Establishes (no limit) or removes (limit '0') a trustline on the authenticated user's custodial wallet for an asset configured in the application, sponsored by the app. Returns the refreshed enabled-asset list. Only valid for the sponsored custodial path; custom assets, adapter-managed wallets, and apps with trustline sponsoring disabled must sign a change_trust transaction client-side instead.
760
+ * @description Establishes (no limit) or removes (limit '0') a trustline on the authenticated user's custodial wallet for an asset configured in the application, sponsored by the app (the reserve and fee are paid by the app wallets). Returns the refreshed enabled-asset list. Only valid for the sponsored custodial path custom assets, adapter-managed wallets, and apps with trustline sponsoring disabled must sign a change_trust transaction client-side instead and will get a 400 here. The wallet and network are derived from the session.
2022
761
  */
2023
762
  post: operations["postWalletAssetsTrustline"];
2024
763
  delete?: never;
@@ -2295,6 +1034,8 @@ interface operations {
2295
1034
  /** @constant */
2296
1035
  success: false;
2297
1036
  code: string;
1037
+ message?: string;
1038
+ resultCode?: string;
2298
1039
  };
2299
1040
  };
2300
1041
  };
@@ -2308,6 +1049,8 @@ interface operations {
2308
1049
  /** @constant */
2309
1050
  success: false;
2310
1051
  code: string;
1052
+ message?: string;
1053
+ resultCode?: string;
2311
1054
  };
2312
1055
  };
2313
1056
  };
@@ -2321,6 +1064,8 @@ interface operations {
2321
1064
  /** @constant */
2322
1065
  success: false;
2323
1066
  code: string;
1067
+ message?: string;
1068
+ resultCode?: string;
2324
1069
  };
2325
1070
  };
2326
1071
  };
@@ -2394,6 +1139,8 @@ interface operations {
2394
1139
  /** @constant */
2395
1140
  success: false;
2396
1141
  code: string;
1142
+ message?: string;
1143
+ resultCode?: string;
2397
1144
  };
2398
1145
  };
2399
1146
  };
@@ -2407,6 +1154,8 @@ interface operations {
2407
1154
  /** @constant */
2408
1155
  success: false;
2409
1156
  code: string;
1157
+ message?: string;
1158
+ resultCode?: string;
2410
1159
  };
2411
1160
  };
2412
1161
  };
@@ -2442,6 +1191,8 @@ interface operations {
2442
1191
  /** @constant */
2443
1192
  success: false;
2444
1193
  code: string;
1194
+ message?: string;
1195
+ resultCode?: string;
2445
1196
  };
2446
1197
  };
2447
1198
  };
@@ -2455,6 +1206,8 @@ interface operations {
2455
1206
  /** @constant */
2456
1207
  success: false;
2457
1208
  code: string;
1209
+ message?: string;
1210
+ resultCode?: string;
2458
1211
  };
2459
1212
  };
2460
1213
  };
@@ -2468,6 +1221,8 @@ interface operations {
2468
1221
  /** @constant */
2469
1222
  success: false;
2470
1223
  code: string;
1224
+ message?: string;
1225
+ resultCode?: string;
2471
1226
  };
2472
1227
  };
2473
1228
  };
@@ -2481,6 +1236,8 @@ interface operations {
2481
1236
  /** @constant */
2482
1237
  success: false;
2483
1238
  code: string;
1239
+ message?: string;
1240
+ resultCode?: string;
2484
1241
  };
2485
1242
  };
2486
1243
  };
@@ -2516,6 +1273,171 @@ interface operations {
2516
1273
  /** @constant */
2517
1274
  success: false;
2518
1275
  code: string;
1276
+ message?: string;
1277
+ resultCode?: string;
1278
+ };
1279
+ };
1280
+ };
1281
+ /** @description Unauthorized */
1282
+ 401: {
1283
+ headers: {
1284
+ [name: string]: unknown;
1285
+ };
1286
+ content: {
1287
+ "application/json": {
1288
+ /** @constant */
1289
+ success: false;
1290
+ code: string;
1291
+ message?: string;
1292
+ resultCode?: string;
1293
+ };
1294
+ };
1295
+ };
1296
+ /** @description Forbidden */
1297
+ 403: {
1298
+ headers: {
1299
+ [name: string]: unknown;
1300
+ };
1301
+ content: {
1302
+ "application/json": {
1303
+ /** @constant */
1304
+ success: false;
1305
+ code: string;
1306
+ message?: string;
1307
+ resultCode?: string;
1308
+ };
1309
+ };
1310
+ };
1311
+ /** @description Not found */
1312
+ 404: {
1313
+ headers: {
1314
+ [name: string]: unknown;
1315
+ };
1316
+ content: {
1317
+ "application/json": {
1318
+ /** @constant */
1319
+ success: false;
1320
+ code: string;
1321
+ message?: string;
1322
+ resultCode?: string;
1323
+ };
1324
+ };
1325
+ };
1326
+ };
1327
+ };
1328
+ getAuthOidc: {
1329
+ parameters: {
1330
+ query: {
1331
+ api_key: string;
1332
+ client_session_id: string;
1333
+ };
1334
+ header?: never;
1335
+ path?: never;
1336
+ cookie?: never;
1337
+ };
1338
+ requestBody?: never;
1339
+ responses: {
1340
+ /** @description Redirect to Authentik */
1341
+ 302: {
1342
+ headers: {
1343
+ [name: string]: unknown;
1344
+ };
1345
+ content?: never;
1346
+ };
1347
+ /** @description Validation error */
1348
+ 400: {
1349
+ headers: {
1350
+ [name: string]: unknown;
1351
+ };
1352
+ content: {
1353
+ "application/json": {
1354
+ /** @constant */
1355
+ success: false;
1356
+ code: string;
1357
+ message?: string;
1358
+ resultCode?: string;
1359
+ };
1360
+ };
1361
+ };
1362
+ /** @description Unauthorized */
1363
+ 401: {
1364
+ headers: {
1365
+ [name: string]: unknown;
1366
+ };
1367
+ content: {
1368
+ "application/json": {
1369
+ /** @constant */
1370
+ success: false;
1371
+ code: string;
1372
+ message?: string;
1373
+ resultCode?: string;
1374
+ };
1375
+ };
1376
+ };
1377
+ /** @description Not found */
1378
+ 404: {
1379
+ headers: {
1380
+ [name: string]: unknown;
1381
+ };
1382
+ content: {
1383
+ "application/json": {
1384
+ /** @constant */
1385
+ success: false;
1386
+ code: string;
1387
+ message?: string;
1388
+ resultCode?: string;
1389
+ };
1390
+ };
1391
+ };
1392
+ };
1393
+ };
1394
+ postAuthEmail: {
1395
+ parameters: {
1396
+ query?: never;
1397
+ header?: never;
1398
+ path?: never;
1399
+ cookie?: never;
1400
+ };
1401
+ requestBody: {
1402
+ content: {
1403
+ "application/json": {
1404
+ clientSessionId: string;
1405
+ /** Format: email */
1406
+ email: string;
1407
+ };
1408
+ };
1409
+ };
1410
+ responses: {
1411
+ /** @description Code sent */
1412
+ 200: {
1413
+ headers: {
1414
+ [name: string]: unknown;
1415
+ };
1416
+ content: {
1417
+ "application/json": {
1418
+ /** @constant */
1419
+ code: "SDK_EMAIL_CODE_SENT";
1420
+ /** @constant */
1421
+ success: true;
1422
+ content: {
1423
+ clientSessionId: string;
1424
+ email: string;
1425
+ };
1426
+ };
1427
+ };
1428
+ };
1429
+ /** @description Validation error */
1430
+ 400: {
1431
+ headers: {
1432
+ [name: string]: unknown;
1433
+ };
1434
+ content: {
1435
+ "application/json": {
1436
+ /** @constant */
1437
+ success: false;
1438
+ code: string;
1439
+ message?: string;
1440
+ resultCode?: string;
2519
1441
  };
2520
1442
  };
2521
1443
  };
@@ -2529,11 +1451,93 @@ interface operations {
2529
1451
  /** @constant */
2530
1452
  success: false;
2531
1453
  code: string;
1454
+ message?: string;
1455
+ resultCode?: string;
1456
+ };
1457
+ };
1458
+ };
1459
+ /** @description Forbidden */
1460
+ 403: {
1461
+ headers: {
1462
+ [name: string]: unknown;
1463
+ };
1464
+ content: {
1465
+ "application/json": {
1466
+ /** @constant */
1467
+ success: false;
1468
+ code: string;
1469
+ message?: string;
1470
+ resultCode?: string;
1471
+ };
1472
+ };
1473
+ };
1474
+ /** @description Not found */
1475
+ 404: {
1476
+ headers: {
1477
+ [name: string]: unknown;
1478
+ };
1479
+ content: {
1480
+ "application/json": {
1481
+ /** @constant */
1482
+ success: false;
1483
+ code: string;
1484
+ message?: string;
1485
+ resultCode?: string;
1486
+ };
1487
+ };
1488
+ };
1489
+ /** @description Gone (expired) */
1490
+ 410: {
1491
+ headers: {
1492
+ [name: string]: unknown;
1493
+ };
1494
+ content: {
1495
+ "application/json": {
1496
+ /** @constant */
1497
+ success: false;
1498
+ code: string;
1499
+ message?: string;
1500
+ resultCode?: string;
1501
+ };
1502
+ };
1503
+ };
1504
+ };
1505
+ };
1506
+ postAuthEmailVerifyCode: {
1507
+ parameters: {
1508
+ query?: never;
1509
+ header?: never;
1510
+ path?: never;
1511
+ cookie?: never;
1512
+ };
1513
+ requestBody: {
1514
+ content: {
1515
+ "application/json": {
1516
+ clientSessionId: string;
1517
+ code: string;
1518
+ };
1519
+ };
1520
+ };
1521
+ responses: {
1522
+ /** @description Code verified */
1523
+ 200: {
1524
+ headers: {
1525
+ [name: string]: unknown;
1526
+ };
1527
+ content: {
1528
+ "application/json": {
1529
+ /** @constant */
1530
+ code: "SDK_EMAIL_CODE_VERIFIED";
1531
+ /** @constant */
1532
+ success: true;
1533
+ content: {
1534
+ clientSessionId: string;
1535
+ };
2532
1536
  };
2533
1537
  };
2534
1538
  };
2535
- /** @description Forbidden */
2536
- 403: {
1539
+ /** @description Validation error */
1540
+ 400: {
2537
1541
  headers: {
2538
1542
  [name: string]: unknown;
2539
1543
  };
@@ -2542,11 +1546,13 @@ interface operations {
2542
1546
  /** @constant */
2543
1547
  success: false;
2544
1548
  code: string;
1549
+ message?: string;
1550
+ resultCode?: string;
2545
1551
  };
2546
1552
  };
2547
1553
  };
2548
- /** @description Not found */
2549
- 404: {
1554
+ /** @description Unauthorized */
1555
+ 401: {
2550
1556
  headers: {
2551
1557
  [name: string]: unknown;
2552
1558
  };
@@ -2555,32 +1561,13 @@ interface operations {
2555
1561
  /** @constant */
2556
1562
  success: false;
2557
1563
  code: string;
1564
+ message?: string;
1565
+ resultCode?: string;
2558
1566
  };
2559
1567
  };
2560
1568
  };
2561
- };
2562
- };
2563
- getAuthOidc: {
2564
- parameters: {
2565
- query: {
2566
- api_key: string;
2567
- client_session_id: string;
2568
- };
2569
- header?: never;
2570
- path?: never;
2571
- cookie?: never;
2572
- };
2573
- requestBody?: never;
2574
- responses: {
2575
- /** @description Redirect to Authentik */
2576
- 302: {
2577
- headers: {
2578
- [name: string]: unknown;
2579
- };
2580
- content?: never;
2581
- };
2582
- /** @description Validation error */
2583
- 400: {
1569
+ /** @description Forbidden */
1570
+ 403: {
2584
1571
  headers: {
2585
1572
  [name: string]: unknown;
2586
1573
  };
@@ -2589,11 +1576,13 @@ interface operations {
2589
1576
  /** @constant */
2590
1577
  success: false;
2591
1578
  code: string;
1579
+ message?: string;
1580
+ resultCode?: string;
2592
1581
  };
2593
1582
  };
2594
1583
  };
2595
- /** @description Unauthorized */
2596
- 401: {
1584
+ /** @description Not found */
1585
+ 404: {
2597
1586
  headers: {
2598
1587
  [name: string]: unknown;
2599
1588
  };
@@ -2602,11 +1591,13 @@ interface operations {
2602
1591
  /** @constant */
2603
1592
  success: false;
2604
1593
  code: string;
1594
+ message?: string;
1595
+ resultCode?: string;
2605
1596
  };
2606
1597
  };
2607
1598
  };
2608
- /** @description Not found */
2609
- 404: {
1599
+ /** @description Gone (expired) */
1600
+ 410: {
2610
1601
  headers: {
2611
1602
  [name: string]: unknown;
2612
1603
  };
@@ -2615,12 +1606,14 @@ interface operations {
2615
1606
  /** @constant */
2616
1607
  success: false;
2617
1608
  code: string;
1609
+ message?: string;
1610
+ resultCode?: string;
2618
1611
  };
2619
1612
  };
2620
1613
  };
2621
1614
  };
2622
1615
  };
2623
- postAuthEmail: {
1616
+ postAuthWalletChallenge: {
2624
1617
  parameters: {
2625
1618
  query?: never;
2626
1619
  header?: never;
@@ -2631,13 +1624,12 @@ interface operations {
2631
1624
  content: {
2632
1625
  "application/json": {
2633
1626
  clientSessionId: string;
2634
- /** Format: email */
2635
- email: string;
1627
+ walletAddress: string;
2636
1628
  };
2637
1629
  };
2638
1630
  };
2639
1631
  responses: {
2640
- /** @description Code sent */
1632
+ /** @description Challenge issued */
2641
1633
  200: {
2642
1634
  headers: {
2643
1635
  [name: string]: unknown;
@@ -2645,12 +1637,12 @@ interface operations {
2645
1637
  content: {
2646
1638
  "application/json": {
2647
1639
  /** @constant */
2648
- code: "SDK_EMAIL_CODE_SENT";
1640
+ code: "SDK_WALLET_CHALLENGE_CREATED";
2649
1641
  /** @constant */
2650
1642
  success: true;
2651
1643
  content: {
2652
1644
  clientSessionId: string;
2653
- email: string;
1645
+ challengeXdr: string;
2654
1646
  };
2655
1647
  };
2656
1648
  };
@@ -2665,6 +1657,8 @@ interface operations {
2665
1657
  /** @constant */
2666
1658
  success: false;
2667
1659
  code: string;
1660
+ message?: string;
1661
+ resultCode?: string;
2668
1662
  };
2669
1663
  };
2670
1664
  };
@@ -2678,6 +1672,8 @@ interface operations {
2678
1672
  /** @constant */
2679
1673
  success: false;
2680
1674
  code: string;
1675
+ message?: string;
1676
+ resultCode?: string;
2681
1677
  };
2682
1678
  };
2683
1679
  };
@@ -2691,6 +1687,8 @@ interface operations {
2691
1687
  /** @constant */
2692
1688
  success: false;
2693
1689
  code: string;
1690
+ message?: string;
1691
+ resultCode?: string;
2694
1692
  };
2695
1693
  };
2696
1694
  };
@@ -2704,6 +1702,8 @@ interface operations {
2704
1702
  /** @constant */
2705
1703
  success: false;
2706
1704
  code: string;
1705
+ message?: string;
1706
+ resultCode?: string;
2707
1707
  };
2708
1708
  };
2709
1709
  };
@@ -2717,12 +1717,14 @@ interface operations {
2717
1717
  /** @constant */
2718
1718
  success: false;
2719
1719
  code: string;
1720
+ message?: string;
1721
+ resultCode?: string;
2720
1722
  };
2721
1723
  };
2722
1724
  };
2723
1725
  };
2724
1726
  };
2725
- postAuthEmailVerifyCode: {
1727
+ postAuthWallet: {
2726
1728
  parameters: {
2727
1729
  query?: never;
2728
1730
  header?: never;
@@ -2733,12 +1735,13 @@ interface operations {
2733
1735
  content: {
2734
1736
  "application/json": {
2735
1737
  clientSessionId: string;
2736
- code: string;
1738
+ walletAddress: string;
1739
+ signedChallengeXdr?: string;
2737
1740
  };
2738
1741
  };
2739
1742
  };
2740
1743
  responses: {
2741
- /** @description Code verified */
1744
+ /** @description Wallet authenticated */
2742
1745
  200: {
2743
1746
  headers: {
2744
1747
  [name: string]: unknown;
@@ -2746,11 +1749,12 @@ interface operations {
2746
1749
  content: {
2747
1750
  "application/json": {
2748
1751
  /** @constant */
2749
- code: "SDK_EMAIL_CODE_VERIFIED";
1752
+ code: "SDK_WALLET_AUTHENTICATED";
2750
1753
  /** @constant */
2751
1754
  success: true;
2752
1755
  content: {
2753
1756
  clientSessionId: string;
1757
+ walletAddress: string;
2754
1758
  };
2755
1759
  };
2756
1760
  };
@@ -2765,6 +1769,8 @@ interface operations {
2765
1769
  /** @constant */
2766
1770
  success: false;
2767
1771
  code: string;
1772
+ message?: string;
1773
+ resultCode?: string;
2768
1774
  };
2769
1775
  };
2770
1776
  };
@@ -2778,6 +1784,8 @@ interface operations {
2778
1784
  /** @constant */
2779
1785
  success: false;
2780
1786
  code: string;
1787
+ message?: string;
1788
+ resultCode?: string;
2781
1789
  };
2782
1790
  };
2783
1791
  };
@@ -2791,6 +1799,8 @@ interface operations {
2791
1799
  /** @constant */
2792
1800
  success: false;
2793
1801
  code: string;
1802
+ message?: string;
1803
+ resultCode?: string;
2794
1804
  };
2795
1805
  };
2796
1806
  };
@@ -2804,6 +1814,8 @@ interface operations {
2804
1814
  /** @constant */
2805
1815
  success: false;
2806
1816
  code: string;
1817
+ message?: string;
1818
+ resultCode?: string;
2807
1819
  };
2808
1820
  };
2809
1821
  };
@@ -2817,12 +1829,14 @@ interface operations {
2817
1829
  /** @constant */
2818
1830
  success: false;
2819
1831
  code: string;
1832
+ message?: string;
1833
+ resultCode?: string;
2820
1834
  };
2821
1835
  };
2822
1836
  };
2823
1837
  };
2824
1838
  };
2825
- postAuthWallet: {
1839
+ postAuthExternal: {
2826
1840
  parameters: {
2827
1841
  query?: never;
2828
1842
  header?: never;
@@ -2833,12 +1847,14 @@ interface operations {
2833
1847
  content: {
2834
1848
  "application/json": {
2835
1849
  clientSessionId: string;
1850
+ provider: string;
2836
1851
  walletAddress: string;
1852
+ signedChallengeXdr: string;
2837
1853
  };
2838
1854
  };
2839
1855
  };
2840
1856
  responses: {
2841
- /** @description Wallet authenticated */
1857
+ /** @description External provider authenticated */
2842
1858
  200: {
2843
1859
  headers: {
2844
1860
  [name: string]: unknown;
@@ -2846,12 +1862,13 @@ interface operations {
2846
1862
  content: {
2847
1863
  "application/json": {
2848
1864
  /** @constant */
2849
- code: "SDK_WALLET_AUTHENTICATED";
1865
+ code: "SDK_EXTERNAL_AUTHENTICATED";
2850
1866
  /** @constant */
2851
1867
  success: true;
2852
1868
  content: {
2853
1869
  clientSessionId: string;
2854
1870
  walletAddress: string;
1871
+ provider: string;
2855
1872
  };
2856
1873
  };
2857
1874
  };
@@ -2866,6 +1883,8 @@ interface operations {
2866
1883
  /** @constant */
2867
1884
  success: false;
2868
1885
  code: string;
1886
+ message?: string;
1887
+ resultCode?: string;
2869
1888
  };
2870
1889
  };
2871
1890
  };
@@ -2879,6 +1898,8 @@ interface operations {
2879
1898
  /** @constant */
2880
1899
  success: false;
2881
1900
  code: string;
1901
+ message?: string;
1902
+ resultCode?: string;
2882
1903
  };
2883
1904
  };
2884
1905
  };
@@ -2892,6 +1913,8 @@ interface operations {
2892
1913
  /** @constant */
2893
1914
  success: false;
2894
1915
  code: string;
1916
+ message?: string;
1917
+ resultCode?: string;
2895
1918
  };
2896
1919
  };
2897
1920
  };
@@ -2905,6 +1928,8 @@ interface operations {
2905
1928
  /** @constant */
2906
1929
  success: false;
2907
1930
  code: string;
1931
+ message?: string;
1932
+ resultCode?: string;
2908
1933
  };
2909
1934
  };
2910
1935
  };
@@ -2918,6 +1943,8 @@ interface operations {
2918
1943
  /** @constant */
2919
1944
  success: false;
2920
1945
  code: string;
1946
+ message?: string;
1947
+ resultCode?: string;
2921
1948
  };
2922
1949
  };
2923
1950
  };
@@ -2966,6 +1993,8 @@ interface operations {
2966
1993
  /** @constant */
2967
1994
  success: false;
2968
1995
  code: string;
1996
+ message?: string;
1997
+ resultCode?: string;
2969
1998
  };
2970
1999
  };
2971
2000
  };
@@ -2979,6 +2008,8 @@ interface operations {
2979
2008
  /** @constant */
2980
2009
  success: false;
2981
2010
  code: string;
2011
+ message?: string;
2012
+ resultCode?: string;
2982
2013
  };
2983
2014
  };
2984
2015
  };
@@ -2992,6 +2023,8 @@ interface operations {
2992
2023
  /** @constant */
2993
2024
  success: false;
2994
2025
  code: string;
2026
+ message?: string;
2027
+ resultCode?: string;
2995
2028
  };
2996
2029
  };
2997
2030
  };
@@ -3005,6 +2038,8 @@ interface operations {
3005
2038
  /** @constant */
3006
2039
  success: false;
3007
2040
  code: string;
2041
+ message?: string;
2042
+ resultCode?: string;
3008
2043
  };
3009
2044
  };
3010
2045
  };
@@ -3018,6 +2053,8 @@ interface operations {
3018
2053
  /** @constant */
3019
2054
  success: false;
3020
2055
  code: string;
2056
+ message?: string;
2057
+ resultCode?: string;
3021
2058
  };
3022
2059
  };
3023
2060
  };
@@ -3069,6 +2106,8 @@ interface operations {
3069
2106
  /** @constant */
3070
2107
  success: false;
3071
2108
  code: string;
2109
+ message?: string;
2110
+ resultCode?: string;
3072
2111
  };
3073
2112
  };
3074
2113
  };
@@ -3082,6 +2121,8 @@ interface operations {
3082
2121
  /** @constant */
3083
2122
  success: false;
3084
2123
  code: string;
2124
+ message?: string;
2125
+ resultCode?: string;
3085
2126
  };
3086
2127
  };
3087
2128
  };
@@ -3095,6 +2136,8 @@ interface operations {
3095
2136
  /** @constant */
3096
2137
  success: false;
3097
2138
  code: string;
2139
+ message?: string;
2140
+ resultCode?: string;
3098
2141
  };
3099
2142
  };
3100
2143
  };
@@ -3108,6 +2151,8 @@ interface operations {
3108
2151
  /** @constant */
3109
2152
  success: false;
3110
2153
  code: string;
2154
+ message?: string;
2155
+ resultCode?: string;
3111
2156
  };
3112
2157
  };
3113
2158
  };
@@ -3121,6 +2166,8 @@ interface operations {
3121
2166
  /** @constant */
3122
2167
  success: false;
3123
2168
  code: string;
2169
+ message?: string;
2170
+ resultCode?: string;
3124
2171
  };
3125
2172
  };
3126
2173
  };
@@ -3172,6 +2219,8 @@ interface operations {
3172
2219
  /** @constant */
3173
2220
  success: false;
3174
2221
  code: string;
2222
+ message?: string;
2223
+ resultCode?: string;
3175
2224
  };
3176
2225
  };
3177
2226
  };
@@ -3185,6 +2234,8 @@ interface operations {
3185
2234
  /** @constant */
3186
2235
  success: false;
3187
2236
  code: string;
2237
+ message?: string;
2238
+ resultCode?: string;
3188
2239
  };
3189
2240
  };
3190
2241
  };
@@ -3198,6 +2249,8 @@ interface operations {
3198
2249
  /** @constant */
3199
2250
  success: false;
3200
2251
  code: string;
2252
+ message?: string;
2253
+ resultCode?: string;
3201
2254
  };
3202
2255
  };
3203
2256
  };
@@ -3211,6 +2264,8 @@ interface operations {
3211
2264
  /** @constant */
3212
2265
  success: false;
3213
2266
  code: string;
2267
+ message?: string;
2268
+ resultCode?: string;
3214
2269
  };
3215
2270
  };
3216
2271
  };
@@ -3224,6 +2279,8 @@ interface operations {
3224
2279
  /** @constant */
3225
2280
  success: false;
3226
2281
  code: string;
2282
+ message?: string;
2283
+ resultCode?: string;
3227
2284
  };
3228
2285
  };
3229
2286
  };
@@ -3280,6 +2337,7 @@ interface operations {
3280
2337
  wallet: {
3281
2338
  /** @enum {string} */
3282
2339
  type: "custodial" | "smart" | "external";
2340
+ provider?: string;
3283
2341
  publicKey: string | null;
3284
2342
  address: string | null;
3285
2343
  existsOnStellar?: boolean;
@@ -3322,6 +2380,8 @@ interface operations {
3322
2380
  /** @constant */
3323
2381
  success: false;
3324
2382
  code: string;
2383
+ message?: string;
2384
+ resultCode?: string;
3325
2385
  };
3326
2386
  };
3327
2387
  };
@@ -3335,6 +2395,8 @@ interface operations {
3335
2395
  /** @constant */
3336
2396
  success: false;
3337
2397
  code: string;
2398
+ message?: string;
2399
+ resultCode?: string;
3338
2400
  };
3339
2401
  };
3340
2402
  };
@@ -3348,6 +2410,8 @@ interface operations {
3348
2410
  /** @constant */
3349
2411
  success: false;
3350
2412
  code: string;
2413
+ message?: string;
2414
+ resultCode?: string;
3351
2415
  };
3352
2416
  };
3353
2417
  };
@@ -3361,6 +2425,8 @@ interface operations {
3361
2425
  /** @constant */
3362
2426
  success: false;
3363
2427
  code: string;
2428
+ message?: string;
2429
+ resultCode?: string;
3364
2430
  };
3365
2431
  };
3366
2432
  };
@@ -3374,6 +2440,8 @@ interface operations {
3374
2440
  /** @constant */
3375
2441
  success: false;
3376
2442
  code: string;
2443
+ message?: string;
2444
+ resultCode?: string;
3377
2445
  };
3378
2446
  };
3379
2447
  };
@@ -3425,6 +2493,8 @@ interface operations {
3425
2493
  /** @constant */
3426
2494
  success: false;
3427
2495
  code: string;
2496
+ message?: string;
2497
+ resultCode?: string;
3428
2498
  };
3429
2499
  };
3430
2500
  };
@@ -3438,6 +2508,8 @@ interface operations {
3438
2508
  /** @constant */
3439
2509
  success: false;
3440
2510
  code: string;
2511
+ message?: string;
2512
+ resultCode?: string;
3441
2513
  };
3442
2514
  };
3443
2515
  };
@@ -3451,6 +2523,8 @@ interface operations {
3451
2523
  /** @constant */
3452
2524
  success: false;
3453
2525
  code: string;
2526
+ message?: string;
2527
+ resultCode?: string;
3454
2528
  };
3455
2529
  };
3456
2530
  };
@@ -3464,6 +2538,8 @@ interface operations {
3464
2538
  /** @constant */
3465
2539
  success: false;
3466
2540
  code: string;
2541
+ message?: string;
2542
+ resultCode?: string;
3467
2543
  };
3468
2544
  };
3469
2545
  };
@@ -3477,6 +2553,8 @@ interface operations {
3477
2553
  /** @constant */
3478
2554
  success: false;
3479
2555
  code: string;
2556
+ message?: string;
2557
+ resultCode?: string;
3480
2558
  };
3481
2559
  };
3482
2560
  };
@@ -3524,6 +2602,8 @@ interface operations {
3524
2602
  /** @constant */
3525
2603
  success: false;
3526
2604
  code: string;
2605
+ message?: string;
2606
+ resultCode?: string;
3527
2607
  };
3528
2608
  };
3529
2609
  };
@@ -3574,6 +2654,8 @@ interface operations {
3574
2654
  /** @constant */
3575
2655
  success: false;
3576
2656
  code: string;
2657
+ message?: string;
2658
+ resultCode?: string;
3577
2659
  };
3578
2660
  };
3579
2661
  };
@@ -3632,6 +2714,8 @@ interface operations {
3632
2714
  /** @constant */
3633
2715
  success: false;
3634
2716
  code: string;
2717
+ message?: string;
2718
+ resultCode?: string;
3635
2719
  };
3636
2720
  };
3637
2721
  };
@@ -3675,6 +2759,8 @@ interface operations {
3675
2759
  /** @constant */
3676
2760
  success: false;
3677
2761
  code: string;
2762
+ message?: string;
2763
+ resultCode?: string;
3678
2764
  };
3679
2765
  };
3680
2766
  };
@@ -3688,6 +2774,8 @@ interface operations {
3688
2774
  /** @constant */
3689
2775
  success: false;
3690
2776
  code: string;
2777
+ message?: string;
2778
+ resultCode?: string;
3691
2779
  };
3692
2780
  };
3693
2781
  };
@@ -3746,6 +2834,8 @@ interface operations {
3746
2834
  /** @constant */
3747
2835
  success: false;
3748
2836
  code: string;
2837
+ message?: string;
2838
+ resultCode?: string;
3749
2839
  };
3750
2840
  };
3751
2841
  };
@@ -3759,6 +2849,8 @@ interface operations {
3759
2849
  /** @constant */
3760
2850
  success: false;
3761
2851
  code: string;
2852
+ message?: string;
2853
+ resultCode?: string;
3762
2854
  };
3763
2855
  };
3764
2856
  };
@@ -3772,6 +2864,8 @@ interface operations {
3772
2864
  /** @constant */
3773
2865
  success: false;
3774
2866
  code: string;
2867
+ message?: string;
2868
+ resultCode?: string;
3775
2869
  };
3776
2870
  };
3777
2871
  };
@@ -3807,6 +2901,8 @@ interface operations {
3807
2901
  /** @constant */
3808
2902
  success: false;
3809
2903
  code: string;
2904
+ message?: string;
2905
+ resultCode?: string;
3810
2906
  };
3811
2907
  };
3812
2908
  };
@@ -4065,6 +3161,8 @@ interface operations {
4065
3161
  /** @constant */
4066
3162
  success: false;
4067
3163
  code: string;
3164
+ message?: string;
3165
+ resultCode?: string;
4068
3166
  };
4069
3167
  };
4070
3168
  };
@@ -4078,6 +3176,8 @@ interface operations {
4078
3176
  /** @constant */
4079
3177
  success: false;
4080
3178
  code: string;
3179
+ message?: string;
3180
+ resultCode?: string;
4081
3181
  };
4082
3182
  };
4083
3183
  };
@@ -4091,6 +3191,8 @@ interface operations {
4091
3191
  /** @constant */
4092
3192
  success: false;
4093
3193
  code: string;
3194
+ message?: string;
3195
+ resultCode?: string;
4094
3196
  };
4095
3197
  };
4096
3198
  };
@@ -4146,6 +3248,8 @@ interface operations {
4146
3248
  /** @constant */
4147
3249
  success: false;
4148
3250
  code: string;
3251
+ message?: string;
3252
+ resultCode?: string;
4149
3253
  };
4150
3254
  };
4151
3255
  };
@@ -4159,6 +3263,8 @@ interface operations {
4159
3263
  /** @constant */
4160
3264
  success: false;
4161
3265
  code: string;
3266
+ message?: string;
3267
+ resultCode?: string;
4162
3268
  };
4163
3269
  };
4164
3270
  };
@@ -4172,6 +3278,8 @@ interface operations {
4172
3278
  /** @constant */
4173
3279
  success: false;
4174
3280
  code: string;
3281
+ message?: string;
3282
+ resultCode?: string;
4175
3283
  };
4176
3284
  };
4177
3285
  };
@@ -4185,6 +3293,8 @@ interface operations {
4185
3293
  /** @constant */
4186
3294
  success: false;
4187
3295
  code: string;
3296
+ message?: string;
3297
+ resultCode?: string;
4188
3298
  };
4189
3299
  };
4190
3300
  };
@@ -4238,6 +3348,8 @@ interface operations {
4238
3348
  /** @constant */
4239
3349
  success: false;
4240
3350
  code: string;
3351
+ message?: string;
3352
+ resultCode?: string;
4241
3353
  };
4242
3354
  };
4243
3355
  };
@@ -4251,6 +3363,8 @@ interface operations {
4251
3363
  /** @constant */
4252
3364
  success: false;
4253
3365
  code: string;
3366
+ message?: string;
3367
+ resultCode?: string;
4254
3368
  };
4255
3369
  };
4256
3370
  };
@@ -4264,6 +3378,107 @@ interface operations {
4264
3378
  /** @constant */
4265
3379
  success: false;
4266
3380
  code: string;
3381
+ message?: string;
3382
+ resultCode?: string;
3383
+ };
3384
+ };
3385
+ };
3386
+ /** @description Signing error */
3387
+ 502: {
3388
+ headers: {
3389
+ [name: string]: unknown;
3390
+ };
3391
+ content: {
3392
+ "application/json": {
3393
+ /** @constant */
3394
+ success: false;
3395
+ code: string;
3396
+ message?: string;
3397
+ resultCode?: string;
3398
+ };
3399
+ };
3400
+ };
3401
+ };
3402
+ };
3403
+ postTxSignAuthEntry: {
3404
+ parameters: {
3405
+ query?: never;
3406
+ header?: never;
3407
+ path?: never;
3408
+ cookie?: never;
3409
+ };
3410
+ requestBody: {
3411
+ content: {
3412
+ "application/json": {
3413
+ /** @enum {string} */
3414
+ network: "testnet" | "mainnet";
3415
+ publicKey?: string;
3416
+ address?: string;
3417
+ entryXdr: string;
3418
+ validUntilLedger: number;
3419
+ };
3420
+ };
3421
+ };
3422
+ responses: {
3423
+ /** @description Base64 XDR of the signed auth entry */
3424
+ 200: {
3425
+ headers: {
3426
+ [name: string]: unknown;
3427
+ };
3428
+ content: {
3429
+ "application/json": {
3430
+ /** @constant */
3431
+ code: "SDK_TX_AUTH_ENTRY_SIGNED";
3432
+ /** @constant */
3433
+ success: true;
3434
+ content: {
3435
+ signedAuthEntry: string;
3436
+ };
3437
+ };
3438
+ };
3439
+ };
3440
+ /** @description Validation error */
3441
+ 400: {
3442
+ headers: {
3443
+ [name: string]: unknown;
3444
+ };
3445
+ content: {
3446
+ "application/json": {
3447
+ /** @constant */
3448
+ success: false;
3449
+ code: string;
3450
+ message?: string;
3451
+ resultCode?: string;
3452
+ };
3453
+ };
3454
+ };
3455
+ /** @description Unauthorized */
3456
+ 401: {
3457
+ headers: {
3458
+ [name: string]: unknown;
3459
+ };
3460
+ content: {
3461
+ "application/json": {
3462
+ /** @constant */
3463
+ success: false;
3464
+ code: string;
3465
+ message?: string;
3466
+ resultCode?: string;
3467
+ };
3468
+ };
3469
+ };
3470
+ /** @description Policy denial (contract/function not allowlisted, expiration too long) */
3471
+ 403: {
3472
+ headers: {
3473
+ [name: string]: unknown;
3474
+ };
3475
+ content: {
3476
+ "application/json": {
3477
+ /** @constant */
3478
+ success: false;
3479
+ code: string;
3480
+ message?: string;
3481
+ resultCode?: string;
4267
3482
  };
4268
3483
  };
4269
3484
  };
@@ -4277,6 +3492,8 @@ interface operations {
4277
3492
  /** @constant */
4278
3493
  success: false;
4279
3494
  code: string;
3495
+ message?: string;
3496
+ resultCode?: string;
4280
3497
  };
4281
3498
  };
4282
3499
  };
@@ -4342,6 +3559,8 @@ interface operations {
4342
3559
  /** @constant */
4343
3560
  success: false;
4344
3561
  code: string;
3562
+ message?: string;
3563
+ resultCode?: string;
4345
3564
  };
4346
3565
  };
4347
3566
  };
@@ -4355,6 +3574,8 @@ interface operations {
4355
3574
  /** @constant */
4356
3575
  success: false;
4357
3576
  code: string;
3577
+ message?: string;
3578
+ resultCode?: string;
4358
3579
  };
4359
3580
  };
4360
3581
  };
@@ -4368,6 +3589,8 @@ interface operations {
4368
3589
  /** @constant */
4369
3590
  success: false;
4370
3591
  code: string;
3592
+ message?: string;
3593
+ resultCode?: string;
4371
3594
  };
4372
3595
  };
4373
3596
  };
@@ -4625,6 +3848,8 @@ interface operations {
4625
3848
  /** @constant */
4626
3849
  success: false;
4627
3850
  code: string;
3851
+ message?: string;
3852
+ resultCode?: string;
4628
3853
  };
4629
3854
  };
4630
3855
  };
@@ -4638,6 +3863,8 @@ interface operations {
4638
3863
  /** @constant */
4639
3864
  success: false;
4640
3865
  code: string;
3866
+ message?: string;
3867
+ resultCode?: string;
4641
3868
  };
4642
3869
  };
4643
3870
  };
@@ -4651,6 +3878,8 @@ interface operations {
4651
3878
  /** @constant */
4652
3879
  success: false;
4653
3880
  code: string;
3881
+ message?: string;
3882
+ resultCode?: string;
4654
3883
  };
4655
3884
  };
4656
3885
  };
@@ -4700,6 +3929,8 @@ interface operations {
4700
3929
  /** @constant */
4701
3930
  success: false;
4702
3931
  code: string;
3932
+ message?: string;
3933
+ resultCode?: string;
4703
3934
  };
4704
3935
  };
4705
3936
  };
@@ -4713,6 +3944,8 @@ interface operations {
4713
3944
  /** @constant */
4714
3945
  success: false;
4715
3946
  code: string;
3947
+ message?: string;
3948
+ resultCode?: string;
4716
3949
  };
4717
3950
  };
4718
3951
  };
@@ -4776,6 +4009,8 @@ interface operations {
4776
4009
  /** @constant */
4777
4010
  success: false;
4778
4011
  code: string;
4012
+ message?: string;
4013
+ resultCode?: string;
4779
4014
  };
4780
4015
  };
4781
4016
  };
@@ -4789,6 +4024,8 @@ interface operations {
4789
4024
  /** @constant */
4790
4025
  success: false;
4791
4026
  code: string;
4027
+ message?: string;
4028
+ resultCode?: string;
4792
4029
  };
4793
4030
  };
4794
4031
  };
@@ -4837,6 +4074,8 @@ interface operations {
4837
4074
  /** @constant */
4838
4075
  success: false;
4839
4076
  code: string;
4077
+ message?: string;
4078
+ resultCode?: string;
4840
4079
  };
4841
4080
  };
4842
4081
  };
@@ -4850,6 +4089,8 @@ interface operations {
4850
4089
  /** @constant */
4851
4090
  success: false;
4852
4091
  code: string;
4092
+ message?: string;
4093
+ resultCode?: string;
4853
4094
  };
4854
4095
  };
4855
4096
  };
@@ -4863,6 +4104,8 @@ interface operations {
4863
4104
  /** @constant */
4864
4105
  success: false;
4865
4106
  code: string;
4107
+ message?: string;
4108
+ resultCode?: string;
4866
4109
  };
4867
4110
  };
4868
4111
  };
@@ -4876,6 +4119,8 @@ interface operations {
4876
4119
  /** @constant */
4877
4120
  success: false;
4878
4121
  code: string;
4122
+ message?: string;
4123
+ resultCode?: string;
4879
4124
  };
4880
4125
  };
4881
4126
  };
@@ -4953,6 +4198,8 @@ interface operations {
4953
4198
  /** @constant */
4954
4199
  success: false;
4955
4200
  code: string;
4201
+ message?: string;
4202
+ resultCode?: string;
4956
4203
  };
4957
4204
  };
4958
4205
  };
@@ -4966,6 +4213,8 @@ interface operations {
4966
4213
  /** @constant */
4967
4214
  success: false;
4968
4215
  code: string;
4216
+ message?: string;
4217
+ resultCode?: string;
4969
4218
  };
4970
4219
  };
4971
4220
  };
@@ -4979,6 +4228,8 @@ interface operations {
4979
4228
  /** @constant */
4980
4229
  success: false;
4981
4230
  code: string;
4231
+ message?: string;
4232
+ resultCode?: string;
4982
4233
  };
4983
4234
  };
4984
4235
  };
@@ -5034,6 +4285,8 @@ interface operations {
5034
4285
  /** @constant */
5035
4286
  success: false;
5036
4287
  code: string;
4288
+ message?: string;
4289
+ resultCode?: string;
5037
4290
  };
5038
4291
  };
5039
4292
  };
@@ -5047,6 +4300,8 @@ interface operations {
5047
4300
  /** @constant */
5048
4301
  success: false;
5049
4302
  code: string;
4303
+ message?: string;
4304
+ resultCode?: string;
5050
4305
  };
5051
4306
  };
5052
4307
  };
@@ -5102,6 +4357,8 @@ interface operations {
5102
4357
  /** @constant */
5103
4358
  success: false;
5104
4359
  code: string;
4360
+ message?: string;
4361
+ resultCode?: string;
5105
4362
  };
5106
4363
  };
5107
4364
  };
@@ -5115,6 +4372,8 @@ interface operations {
5115
4372
  /** @constant */
5116
4373
  success: false;
5117
4374
  code: string;
4375
+ message?: string;
4376
+ resultCode?: string;
5118
4377
  };
5119
4378
  };
5120
4379
  };
@@ -5178,6 +4437,8 @@ interface operations {
5178
4437
  /** @constant */
5179
4438
  success: false;
5180
4439
  code: string;
4440
+ message?: string;
4441
+ resultCode?: string;
5181
4442
  };
5182
4443
  };
5183
4444
  };
@@ -5191,6 +4452,8 @@ interface operations {
5191
4452
  /** @constant */
5192
4453
  success: false;
5193
4454
  code: string;
4455
+ message?: string;
4456
+ resultCode?: string;
5194
4457
  };
5195
4458
  };
5196
4459
  };
@@ -5204,6 +4467,8 @@ interface operations {
5204
4467
  /** @constant */
5205
4468
  success: false;
5206
4469
  code: string;
4470
+ message?: string;
4471
+ resultCode?: string;
5207
4472
  };
5208
4473
  };
5209
4474
  };
@@ -5263,6 +4528,8 @@ interface operations {
5263
4528
  /** @constant */
5264
4529
  success: false;
5265
4530
  code: string;
4531
+ message?: string;
4532
+ resultCode?: string;
5266
4533
  };
5267
4534
  };
5268
4535
  };
@@ -5276,6 +4543,8 @@ interface operations {
5276
4543
  /** @constant */
5277
4544
  success: false;
5278
4545
  code: string;
4546
+ message?: string;
4547
+ resultCode?: string;
5279
4548
  };
5280
4549
  };
5281
4550
  };
@@ -5324,6 +4593,8 @@ interface operations {
5324
4593
  /** @constant */
5325
4594
  success: false;
5326
4595
  code: string;
4596
+ message?: string;
4597
+ resultCode?: string;
5327
4598
  };
5328
4599
  };
5329
4600
  };
@@ -5337,6 +4608,8 @@ interface operations {
5337
4608
  /** @constant */
5338
4609
  success: false;
5339
4610
  code: string;
4611
+ message?: string;
4612
+ resultCode?: string;
5340
4613
  };
5341
4614
  };
5342
4615
  };
@@ -5350,6 +4623,8 @@ interface operations {
5350
4623
  /** @constant */
5351
4624
  success: false;
5352
4625
  code: string;
4626
+ message?: string;
4627
+ resultCode?: string;
5353
4628
  };
5354
4629
  };
5355
4630
  };
@@ -5399,6 +4674,8 @@ interface operations {
5399
4674
  /** @constant */
5400
4675
  success: false;
5401
4676
  code: string;
4677
+ message?: string;
4678
+ resultCode?: string;
5402
4679
  };
5403
4680
  };
5404
4681
  };
@@ -5412,6 +4689,8 @@ interface operations {
5412
4689
  /** @constant */
5413
4690
  success: false;
5414
4691
  code: string;
4692
+ message?: string;
4693
+ resultCode?: string;
5415
4694
  };
5416
4695
  };
5417
4696
  };
@@ -5467,6 +4746,8 @@ interface operations {
5467
4746
  /** @constant */
5468
4747
  success: false;
5469
4748
  code: string;
4749
+ message?: string;
4750
+ resultCode?: string;
5470
4751
  };
5471
4752
  };
5472
4753
  };
@@ -5480,6 +4761,8 @@ interface operations {
5480
4761
  /** @constant */
5481
4762
  success: false;
5482
4763
  code: string;
4764
+ message?: string;
4765
+ resultCode?: string;
5483
4766
  };
5484
4767
  };
5485
4768
  };
@@ -5493,6 +4776,8 @@ interface operations {
5493
4776
  /** @constant */
5494
4777
  success: false;
5495
4778
  code: string;
4779
+ message?: string;
4780
+ resultCode?: string;
5496
4781
  };
5497
4782
  };
5498
4783
  };
@@ -5551,6 +4836,8 @@ interface operations {
5551
4836
  /** @constant */
5552
4837
  success: false;
5553
4838
  code: string;
4839
+ message?: string;
4840
+ resultCode?: string;
5554
4841
  };
5555
4842
  };
5556
4843
  };
@@ -5564,6 +4851,8 @@ interface operations {
5564
4851
  /** @constant */
5565
4852
  success: false;
5566
4853
  code: string;
4854
+ message?: string;
4855
+ resultCode?: string;
5567
4856
  };
5568
4857
  };
5569
4858
  };
@@ -5626,6 +4915,8 @@ interface operations {
5626
4915
  /** @constant */
5627
4916
  success: false;
5628
4917
  code: string;
4918
+ message?: string;
4919
+ resultCode?: string;
5629
4920
  };
5630
4921
  };
5631
4922
  };
@@ -5639,6 +4930,8 @@ interface operations {
5639
4930
  /** @constant */
5640
4931
  success: false;
5641
4932
  code: string;
4933
+ message?: string;
4934
+ resultCode?: string;
5642
4935
  };
5643
4936
  };
5644
4937
  };
@@ -5652,6 +4945,8 @@ interface operations {
5652
4945
  /** @constant */
5653
4946
  success: false;
5654
4947
  code: string;
4948
+ message?: string;
4949
+ resultCode?: string;
5655
4950
  };
5656
4951
  };
5657
4952
  };
@@ -5711,6 +5006,8 @@ interface operations {
5711
5006
  /** @constant */
5712
5007
  success: false;
5713
5008
  code: string;
5009
+ message?: string;
5010
+ resultCode?: string;
5714
5011
  };
5715
5012
  };
5716
5013
  };
@@ -5724,6 +5021,8 @@ interface operations {
5724
5021
  /** @constant */
5725
5022
  success: false;
5726
5023
  code: string;
5024
+ message?: string;
5025
+ resultCode?: string;
5727
5026
  };
5728
5027
  };
5729
5028
  };
@@ -5737,6 +5036,8 @@ interface operations {
5737
5036
  /** @constant */
5738
5037
  success: false;
5739
5038
  code: string;
5039
+ message?: string;
5040
+ resultCode?: string;
5740
5041
  };
5741
5042
  };
5742
5043
  };
@@ -5789,6 +5090,8 @@ interface operations {
5789
5090
  /** @constant */
5790
5091
  success: false;
5791
5092
  code: string;
5093
+ message?: string;
5094
+ resultCode?: string;
5792
5095
  };
5793
5096
  };
5794
5097
  };
@@ -5802,6 +5105,8 @@ interface operations {
5802
5105
  /** @constant */
5803
5106
  success: false;
5804
5107
  code: string;
5108
+ message?: string;
5109
+ resultCode?: string;
5805
5110
  };
5806
5111
  };
5807
5112
  };
@@ -5815,6 +5120,8 @@ interface operations {
5815
5120
  /** @constant */
5816
5121
  success: false;
5817
5122
  code: string;
5123
+ message?: string;
5124
+ resultCode?: string;
5818
5125
  };
5819
5126
  };
5820
5127
  };
@@ -5867,6 +5174,8 @@ interface operations {
5867
5174
  /** @constant */
5868
5175
  success: false;
5869
5176
  code: string;
5177
+ message?: string;
5178
+ resultCode?: string;
5870
5179
  };
5871
5180
  };
5872
5181
  };
@@ -5917,6 +5226,8 @@ interface operations {
5917
5226
  /** @constant */
5918
5227
  success: false;
5919
5228
  code: string;
5229
+ message?: string;
5230
+ resultCode?: string;
5920
5231
  };
5921
5232
  };
5922
5233
  };
@@ -5930,6 +5241,8 @@ interface operations {
5930
5241
  /** @constant */
5931
5242
  success: false;
5932
5243
  code: string;
5244
+ message?: string;
5245
+ resultCode?: string;
5933
5246
  };
5934
5247
  };
5935
5248
  };
@@ -5943,6 +5256,8 @@ interface operations {
5943
5256
  /** @constant */
5944
5257
  success: false;
5945
5258
  code: string;
5259
+ message?: string;
5260
+ resultCode?: string;
5946
5261
  };
5947
5262
  };
5948
5263
  };
@@ -5956,6 +5271,8 @@ interface operations {
5956
5271
  /** @constant */
5957
5272
  success: false;
5958
5273
  code: string;
5274
+ message?: string;
5275
+ resultCode?: string;
5959
5276
  };
5960
5277
  };
5961
5278
  };
@@ -5963,8 +5280,1553 @@ interface operations {
5963
5280
  };
5964
5281
  }
5965
5282
 
5966
- type PollarApiClient = ReturnType<typeof createApiClient>;
5967
- declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
5283
+ type PollarApiClient = ReturnType<typeof createApiClient>;
5284
+ declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
5285
+
5286
+ /**
5287
+ * Public JWK shape for an EC P-256 key. Only the four required members for
5288
+ * RFC 7638 thumbprint computation; never includes private fields or extras
5289
+ * like `alg` / `use` / `kid`.
5290
+ */
5291
+ interface PublicEcJwk {
5292
+ kty: 'EC';
5293
+ crv: 'P-256';
5294
+ /** Base64url-encoded big-endian X coordinate (32 bytes). */
5295
+ x: string;
5296
+ /** Base64url-encoded big-endian Y coordinate (32 bytes). */
5297
+ y: string;
5298
+ }
5299
+ /**
5300
+ * Manages the per-session ECDSA P-256 keypair used to sign DPoP proofs.
5301
+ *
5302
+ * Implementations:
5303
+ * - `WebCryptoKeyManager` (web): non-extractable `CryptoKey` persisted in
5304
+ * IndexedDB. Private key bytes never leave the browser's crypto context.
5305
+ * - `NobleKeyManager` (React Native): private scalar bytes stored through an
5306
+ * injected `Storage` adapter (Keychain / SecureStore). Pure-JS ECDSA via
5307
+ * `@noble/curves`.
5308
+ */
5309
+ interface KeyManager {
5310
+ /**
5311
+ * Load an existing key for this session or generate a new one. Idempotent.
5312
+ * Must be called before `getPublicJwk`, `getThumbprint`, or `sign`.
5313
+ */
5314
+ init(): Promise<void>;
5315
+ /**
5316
+ * Destroy the key. Removes it from persistent storage and clears any
5317
+ * cached state. Used on logout.
5318
+ */
5319
+ reset(): Promise<void>;
5320
+ /**
5321
+ * The public JWK that goes into the DPoP proof header. Returns a fresh
5322
+ * object every call (callers may mutate without affecting the manager).
5323
+ */
5324
+ getPublicJwk(): Promise<PublicEcJwk>;
5325
+ /**
5326
+ * RFC 7638 JWK thumbprint, base64url(SHA-256(canonical JWK)). The server
5327
+ * compares this to the access token's `cnf.jkt` claim.
5328
+ */
5329
+ getThumbprint(): Promise<string>;
5330
+ /**
5331
+ * Sign the given bytes with ECDSA-P256-SHA256. Returns 64-byte raw r||s
5332
+ * (IEEE P1363 / JOSE format), NOT DER. Suitable for direct base64url
5333
+ * encoding into the JWS signature segment.
5334
+ */
5335
+ sign(payload: Uint8Array): Promise<Uint8Array>;
5336
+ }
5337
+
5338
+ declare enum WalletType {
5339
+ FREIGHTER = "freighter",
5340
+ ALBEDO = "albedo"
5341
+ }
5342
+ /**
5343
+ * A wallet identifier. Accepts the internal `WalletType` enum values
5344
+ * (`'freighter'`, `'albedo'`) plus any opaque string id used by external
5345
+ * adapter packages (e.g. Stellar Wallets Kit ids like `'xbull'`, `'lobstr'`).
5346
+ * The `(string & {})` keeps autocomplete on the enum values without rejecting
5347
+ * arbitrary strings.
5348
+ */
5349
+ type WalletId = WalletType | (string & {});
5350
+ interface ConnectWalletResponse {
5351
+ address: string;
5352
+ }
5353
+ interface SignTransactionOptions {
5354
+ network?: string;
5355
+ networkPassphrase?: string;
5356
+ accountToSign?: string;
5357
+ }
5358
+ interface SignAuthEntryOptions {
5359
+ accountToSign?: string;
5360
+ }
5361
+ interface SignTransactionResponse {
5362
+ signedTxXdr: string;
5363
+ }
5364
+ interface SignAuthEntryResponse {
5365
+ signedAuthEntry: string;
5366
+ }
5367
+ interface WalletAdapter {
5368
+ type: WalletId;
5369
+ isAvailable(): Promise<boolean>;
5370
+ connect(): Promise<ConnectWalletResponse>;
5371
+ disconnect(): Promise<void>;
5372
+ getPublicKey(): Promise<string | null>;
5373
+ signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
5374
+ signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
5375
+ }
5376
+ /**
5377
+ * Resolves a {@link WalletAdapter} for a given wallet id. Injected through
5378
+ * `PollarClientConfig.walletAdapter` so wallet implementations (Stellar
5379
+ * Wallets Kit, custom modules, etc.) can live outside `@pollar/core`.
5380
+ */
5381
+ type WalletAdapterResolver = (id: WalletId) => WalletAdapter | Promise<WalletAdapter>;
5382
+
5383
+ declare class FreighterAdapter implements WalletAdapter {
5384
+ readonly type = WalletType.FREIGHTER;
5385
+ isAvailable(): Promise<boolean>;
5386
+ connect(): Promise<ConnectWalletResponse>;
5387
+ disconnect(): Promise<void>;
5388
+ getPublicKey(): Promise<string | null>;
5389
+ getNetwork(): Promise<string>;
5390
+ signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
5391
+ signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
5392
+ }
5393
+
5394
+ /** Albedo's own network vocabulary (it only understands these two values). */
5395
+ type AlbedoNetwork = 'public' | 'testnet';
5396
+ declare class AlbedoAdapter implements WalletAdapter {
5397
+ private readonly network;
5398
+ readonly type = WalletType.ALBEDO;
5399
+ /**
5400
+ * Network used for `connect` and `signAuthEntry` (which carry no per-call
5401
+ * network) and as the fallback for `signTransaction`. Defaults to `'testnet'`
5402
+ * to preserve the previous behavior when constructed with no argument.
5403
+ */
5404
+ constructor(network?: AlbedoNetwork);
5405
+ isAvailable(): Promise<boolean>;
5406
+ connect(): Promise<ConnectWalletResponse>;
5407
+ disconnect(): Promise<void>;
5408
+ getPublicKey(): Promise<string | null>;
5409
+ getNetwork(): Promise<string>;
5410
+ signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
5411
+ signAuthEntry(entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
5412
+ }
5413
+
5414
+ type PollarApplicationConfigResponse = paths['/auth/login']['post']['responses'][200]['content']['application/json'];
5415
+ /** Full `/auth/login` response shape — used in transit but NOT persisted. */
5416
+ type PollarApplicationConfigContent = PollarApplicationConfigResponse['content'];
5417
+ /**
5418
+ * What we actually write to `Storage`. Drops the PII subtree (`data.*`)
5419
+ * which is held in memory only on `PollarClient._profile` after auth.
5420
+ */
5421
+ interface PollarPersistedSession {
5422
+ clientSessionId: string;
5423
+ userId: string | null;
5424
+ status: string;
5425
+ token: {
5426
+ accessToken: string;
5427
+ refreshToken: string;
5428
+ expiresAt: number;
5429
+ };
5430
+ user: {
5431
+ id?: string;
5432
+ ready: boolean;
5433
+ };
5434
+ wallet: {
5435
+ type: 'internal' | 'smart' | 'external';
5436
+ provider?: string;
5437
+ address: string | null;
5438
+ existsOnStellar?: boolean;
5439
+ createdAt?: number;
5440
+ linkedAt?: number;
5441
+ network?: string;
5442
+ deployTxHash?: string | null;
5443
+ };
5444
+ }
5445
+ /**
5446
+ * Custodial login methods — the providers that map to an `internal` wallet.
5447
+ * Mirrors the backend `AuthProvider` enum minus passkey (→ smart) and
5448
+ * wallet/external (→ external).
5449
+ */
5450
+ type PollarAuthMethod = 'email' | 'google' | 'github' | 'oidc';
5451
+ /**
5452
+ * The authenticated user's wallet, as a discriminated union over `custody`.
5453
+ * Every authenticated session has exactly one wallet whose custody is fixed at
5454
+ * account creation, so `custody` strictly determines the shape of `provider`:
5455
+ *
5456
+ * - `internal` (platform-custodied G-address) → `provider` is the login
5457
+ * method, or `null` if the session predates provider tracking server-side.
5458
+ * - `smart` (passkey Soroban C-address) → `provider` is always `'passkey'`.
5459
+ * - `external` (user-connected wallet) → `provider` is the on-chain adapter
5460
+ * id (`'freighter'`, `'albedo'`, …), or `null` when no adapter is resolved
5461
+ * (e.g. a restored session whose adapter could not be re-attached).
5462
+ *
5463
+ * Obtained via {@link PollarClient.getWallet}.
5464
+ */
5465
+ type WalletInfo = {
5466
+ custody: 'internal';
5467
+ address: string;
5468
+ provider: PollarAuthMethod | null;
5469
+ } | {
5470
+ custody: 'smart';
5471
+ address: string;
5472
+ provider: 'passkey';
5473
+ } | {
5474
+ custody: 'external';
5475
+ address: string;
5476
+ provider: WalletId | null;
5477
+ };
5478
+ /** In-memory user profile (kept on `PollarClient`, never persisted). */
5479
+ interface PollarUserProfile {
5480
+ mail: string;
5481
+ first_name: string;
5482
+ last_name: string;
5483
+ avatar: string;
5484
+ providers: {
5485
+ email: {
5486
+ address: string;
5487
+ } | null;
5488
+ google: {
5489
+ id: string;
5490
+ } | null;
5491
+ github: {
5492
+ id: string;
5493
+ } | null;
5494
+ wallet: {
5495
+ address: string;
5496
+ } | null;
5497
+ };
5498
+ }
5499
+ interface PollarClientConfig {
5500
+ stellarNetwork?: StellarNetwork;
5501
+ baseUrl?: string;
5502
+ apiKey: string;
5503
+ /**
5504
+ * Pluggable storage. Defaults to `defaultStorage()` on web (localStorage
5505
+ * with memory fallback). On RN you must inject one of the adapters from
5506
+ * `@pollar/core/adapters/expo` or `@pollar/core/adapters/react-native-keychain`.
5507
+ */
5508
+ storage?: Storage;
5509
+ /**
5510
+ * Pluggable DPoP key manager. Defaults to `defaultKeyManager(storage,
5511
+ * apiKey)`: WebCrypto in browsers, `@noble/curves` in RN.
5512
+ */
5513
+ keyManager?: KeyManager;
5514
+ /**
5515
+ * Minimum severity the SDK logs. `silent` disables all SDK logging; the rest
5516
+ * emit that level and everything more important (`error` < `warn` < `info` <
5517
+ * `debug`). State-transition chatter (auth/tx/network) is at `debug`.
5518
+ * Defaults to `'info'`.
5519
+ */
5520
+ logLevel?: LogLevel;
5521
+ /**
5522
+ * Sink the SDK writes logs to. Defaults to the global `console`. Inject your
5523
+ * own (pino, Sentry breadcrumbs, a test spy…) to route SDK logs anywhere.
5524
+ * Filtering by `logLevel` still applies on top of whatever you pass.
5525
+ */
5526
+ logger?: PollarLogger;
5527
+ /**
5528
+ * Notified when persistent storage silently degrades to in-memory mode
5529
+ * (Safari private browsing quota errors, sandboxed iframes, etc.). Useful
5530
+ * for telemetry — the SDK keeps working but sessions won't survive reload.
5531
+ */
5532
+ onStorageDegrade?: OnStorageDegrade;
5533
+ /**
5534
+ * Resolves a {@link WalletAdapter} for a given wallet id. If omitted, the
5535
+ * SDK falls back to its built-in `FreighterAdapter` / `AlbedoAdapter`,
5536
+ * which only know `WalletType.FREIGHTER` and `WalletType.ALBEDO`. Inject
5537
+ * `@pollar/stellar-wallets-kit-adapter` (or your own resolver) to support
5538
+ * additional wallets without bundling those dependencies into `@pollar/core`.
5539
+ */
5540
+ walletAdapter?: WalletAdapterResolver;
5541
+ /**
5542
+ * Maximum time (ms) the SDK waits for a `walletAdapter` resolver to return.
5543
+ * Guards against a broken extension bridge (e.g. Freighter content-script
5544
+ * down) hanging the login flow forever. The resolver only constructs the
5545
+ * adapter object — it does NOT include the user-facing approval step — so
5546
+ * a few seconds is plenty. Defaults to 5000.
5547
+ */
5548
+ walletResolverTimeoutMs?: number;
5549
+ /**
5550
+ * Optional human-friendly label sent at /auth/login time and recorded on
5551
+ * the server-side refresh-token row so the user can identify it in the
5552
+ * "active sessions" UI (e.g. "iPhone — Safari", "Mac — Chrome 126").
5553
+ * If unset, the server-recorded `user_agent` header is the fallback.
5554
+ */
5555
+ deviceLabel?: string;
5556
+ /**
5557
+ * Foreground-detection signal for the silent-refresh scheduler. When the
5558
+ * app is hidden / backgrounded, scheduled refreshes are skipped (saves
5559
+ * network + sidesteps browser/RN background timer throttling); they run
5560
+ * the moment visibility comes back. Defaults to a web provider in the
5561
+ * browser (`visibilitychange` + BFCache + focus) and a noop elsewhere.
5562
+ * React Native consumers should inject an `AppState`-backed provider —
5563
+ * use `createAppStateVisibilityProvider` from
5564
+ * `@pollar/core/adapters/react-native-appstate`.
5565
+ */
5566
+ visibilityProvider?: VisibilityProvider;
5567
+ /**
5568
+ * If set, the silent-refresh scheduler stops issuing proactive refreshes
5569
+ * after this many milliseconds of no client-side HTTP activity. The
5570
+ * session is not cleared — the next user action triggers a request that
5571
+ * either reuses a still-valid access token or hits 401 → reactive
5572
+ * refresh (transparent if the RT is still valid). Defaults to
5573
+ * `undefined` = refresh forever as long as the app is visible.
5574
+ */
5575
+ maxIdleMs?: number;
5576
+ /**
5577
+ * Strategy for opening the hosted OAuth URL during
5578
+ * `login({ provider: 'google' | 'github' })`. Defaults to a browser popup
5579
+ * on web. React Native consumers MUST provide one (typically wrapping
5580
+ * `expo-web-browser`'s `openAuthSessionAsync`), since `window.open` does
5581
+ * not exist there. The SDK still drives the rest of the flow by polling the
5582
+ * auth-session status, so the opener only needs to surface the URL — it does
5583
+ * NOT need to capture the redirect payload.
5584
+ */
5585
+ openAuthUrl?: AuthUrlOpener;
5586
+ /**
5587
+ * Value sent to the backend as `redirect_uri` for hosted OAuth (where the
5588
+ * provider returns the user afterwards). Defaults to `window.location.origin`
5589
+ * on web. On React Native set this to your app's deep link / scheme — the
5590
+ * same URL you pass to `WebBrowser.openAuthSessionAsync`.
5591
+ */
5592
+ oauthRedirectUri?: string;
5593
+ /**
5594
+ * Custom auth providers (e.g. Privy, Magic). Each is a {@link PollarAuthProvider}
5595
+ * registered by its `id`; `login({ provider: id })` then dispatches to it.
5596
+ * Registered AFTER the built-ins, so an entry whose `id` matches a built-in
5597
+ * (`'google'`, `'github'`, `'email'`) overrides it. Does NOT affect `wallet`,
5598
+ * which keeps its own dedicated flow. Custom providers typically authenticate
5599
+ * with their own SDK and then call `ctx.exchangeExternalToken(...)`, which the
5600
+ * backend validates via `POST /auth/external`.
5601
+ */
5602
+ providers?: PollarAuthProvider[];
5603
+ /**
5604
+ * The passkey (WebAuthn) ceremony for "Smart Wallet" login, injected by the
5605
+ * runtime layer (`@pollar/react` implements it with `@simplewebauthn/browser`).
5606
+ * `@pollar/core` stays runtime-agnostic and never touches `navigator.credentials`
5607
+ * directly. Required to use `loginSmartWallet()`. Browser-only for now;
5608
+ * React Native needs a native passkey provider.
5609
+ */
5610
+ passkey?: PasskeyCeremony;
5611
+ /**
5612
+ * Signs smart-account (C-address) transactions with the user's passkey.
5613
+ * Required to send from a smart wallet. Injected by `@pollar/react`;
5614
+ * browser-only for now.
5615
+ */
5616
+ passkeySign?: PasskeySigner;
5617
+ }
5618
+ /**
5619
+ * Runs the device WebAuthn ceremony for a server-issued challenge and returns
5620
+ * the result to forward to the backend: a registration response for a new user
5621
+ * (`create()`) or an authentication assertion for a returning one (`get()`).
5622
+ * `mode` tells the ceremony which to run: `'login'` runs `get()` only (returning
5623
+ * user) and `'register'` runs `create()` only (new wallet) — the caller picks via
5624
+ * the "Log in" / "Create wallet" buttons, so there's no ambiguous autodetect that
5625
+ * could create a wallet when the user merely cancelled a login prompt. `response`
5626
+ * is the browser's PublicKeyCredential serialized to JSON — forwarded verbatim to
5627
+ * `/auth/passkey/{register,login}`.
5628
+ */
5629
+ type PasskeyMode = 'login' | 'register';
5630
+ type PasskeyCeremony = (ctx: {
5631
+ challenge: string;
5632
+ mode: PasskeyMode;
5633
+ }) => Promise<{
5634
+ kind: 'login';
5635
+ response: unknown;
5636
+ } | {
5637
+ kind: 'register';
5638
+ response: unknown;
5639
+ }>;
5640
+ /**
5641
+ * Signs a smart-account transaction's auth digest with the user's passkey
5642
+ * (a WebAuthn `get()` whose challenge is the raw digest). Returns the PUBLIC
5643
+ * assertion fields (base64url) for the server to assemble into the Soroban auth
5644
+ * entry — no secret leaves the device. Injected by the runtime layer
5645
+ * (`@pollar/react`); `@pollar/core` never touches `navigator.credentials`.
5646
+ */
5647
+ type PasskeySigner = (ctx: {
5648
+ /** base64url WebAuthn credential id to sign with. */
5649
+ credentialId: string;
5650
+ /** hex-encoded auth digest to use as the WebAuthn challenge. */
5651
+ challenge: string;
5652
+ }) => Promise<{
5653
+ authenticatorData: string;
5654
+ clientDataJSON: string;
5655
+ signature: string;
5656
+ }>;
5657
+ /**
5658
+ * Strategy for opening the hosted OAuth URL. The SDK mints the per-login auth
5659
+ * session lazily inside `getUrl()` (call it once; the first call creates the
5660
+ * `clientSessionId` and returns the full URL, or `null` if session creation
5661
+ * failed). Open the resolved URL however the platform allows — a popup on web,
5662
+ * `WebBrowser.openAuthSessionAsync(url, redirectUri)` on React Native — and
5663
+ * resolve once the user-facing browser step is done or dismissed. You do NOT
5664
+ * need to capture the redirect payload: the SDK polls the auth-session status
5665
+ * until the backend marks it READY.
5666
+ */
5667
+ type AuthUrlOpener = (ctx: AuthOpenContext) => void | Promise<void>;
5668
+ interface AuthOpenContext {
5669
+ provider: 'google' | 'github';
5670
+ /**
5671
+ * Mints the auth session (once) and returns the full hosted-OAuth URL, or
5672
+ * `null` if session creation failed. On web, call it AFTER reserving the
5673
+ * popup window so popup blockers (which only honor `window.open` inside the
5674
+ * original user-gesture tick) don't swallow it.
5675
+ */
5676
+ getUrl: () => Promise<string | null>;
5677
+ /** The redirect target passed to the backend as `redirect_uri`. */
5678
+ redirectUri: string;
5679
+ signal: AbortSignal;
5680
+ }
5681
+ /**
5682
+ * One row in the active-sessions list (returned by `PollarClient.listSessions()`).
5683
+ * Mirrors the sdk-api `SessionsListContent` schema.
5684
+ */
5685
+ interface SessionInfo {
5686
+ familyId: string;
5687
+ createdAt: string;
5688
+ lastUsedAt: string | null;
5689
+ userAgent: string | null;
5690
+ ipHash: string | null;
5691
+ deviceLabel: string | null;
5692
+ current: boolean;
5693
+ expiresAt: string;
5694
+ }
5695
+ /**
5696
+ * Observable state for the active-sessions list. Lives on the client (like
5697
+ * {@link TxHistoryState} / {@link WalletBalanceState}) so UI layers can
5698
+ * subscribe via `onSessionsStateChange` and stay pure readers instead of
5699
+ * holding the loading state locally.
5700
+ */
5701
+ type SessionsState = {
5702
+ step: 'idle';
5703
+ } | {
5704
+ step: 'loading';
5705
+ } | {
5706
+ step: 'loaded';
5707
+ sessions: SessionInfo[];
5708
+ } | {
5709
+ step: 'error';
5710
+ message: string;
5711
+ };
5712
+ type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
5713
+ type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
5714
+ type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
5715
+ type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
5716
+ type TxSignBody = NonNullable<paths['/tx/sign']['post']['requestBody']>['content']['application/json'];
5717
+ type TxSignResponse = paths['/tx/sign']['post']['responses'][200]['content']['application/json'];
5718
+ type TxSignContent = TxSignResponse['content'];
5719
+ type TxSubmitSignedBody = NonNullable<paths['/tx/submit']['post']['requestBody']>['content']['application/json'];
5720
+ type TxBuildSignSubmitBody = NonNullable<paths['/tx/build-sign-submit']['post']['requestBody']>['content']['application/json'];
5721
+ type TxBuildSignSubmitResponse = paths['/tx/build-sign-submit']['post']['responses'][200]['content']['application/json'];
5722
+ type TxBuildSignSubmitContent = TxBuildSignSubmitResponse['content'];
5723
+ /**
5724
+ * Discriminated union of every login the SDK understands. Intentionally
5725
+ * **closed**: each custom provider you add (and wire up server-side via
5726
+ * `POST /auth/external`) gets its own member here so `login()` stays fully
5727
+ * typed and `switch (options.provider)` stays exhaustive. To add one, append a
5728
+ * line — e.g. `| { provider: 'privy'; loginMethod?: 'email' | 'sms' }` — and
5729
+ * register a matching {@link PollarAuthProvider} via `PollarClientConfig.providers`.
5730
+ */
5731
+ type PollarLoginOptions = {
5732
+ provider: 'google';
5733
+ } | {
5734
+ provider: 'github';
5735
+ } | {
5736
+ provider: 'email';
5737
+ email: string;
5738
+ } | {
5739
+ provider: 'wallet';
5740
+ type: WalletId;
5741
+ };
5742
+ /**
5743
+ * Curated, stable facade handed to every {@link PollarAuthProvider}. It exposes
5744
+ * only the primitives a login strategy needs — the shared backbone
5745
+ * (`createSession` → drive the session READY → `authenticate`) plus a couple of
5746
+ * ready-made legs — and deliberately keeps `PollarClient` internals (storage,
5747
+ * wallet-adapter resolution, DPoP key manager) private. This is the public
5748
+ * contract a third-party provider (e.g. Privy) builds against.
5749
+ */
5750
+ interface AuthProviderContext {
5751
+ /** Aborts when the host calls `cancelLogin()` (or a new login supersedes this one). */
5752
+ readonly signal: AbortSignal;
5753
+ /** Typed `openapi-fetch` client, already wired with DPoP + refresh middleware. */
5754
+ readonly api: PollarApiClient;
5755
+ /** API origin + version prefix (e.g. `https://sdk.api.pollar.xyz/v1`). */
5756
+ readonly basePath: string;
5757
+ readonly apiKey: string;
5758
+ readonly logger: PollarLogger;
5759
+ /** Drive the SDK's auth state machine (the host's `onAuthStateChange` mirrors it). */
5760
+ setAuthState(state: AuthState): void;
5761
+ /** `POST /auth/session` → `clientSessionId` (null on failure; error state already set). */
5762
+ createSession(): Promise<string | null>;
5763
+ /** Poll the session to READY, then `POST /auth/login` and persist the session. The shared backbone. */
5764
+ authenticate(clientSessionId: string): Promise<void>;
5765
+ /**
5766
+ * `POST /auth/wallet/challenge` → the server-signed SEP-10 challenge transaction
5767
+ * (XDR) the wallet must counter-sign to prove key control. Sign it with your
5768
+ * provider's Stellar signer (e.g. Privy), then pass the result to
5769
+ * {@link exchangeExternalToken} as `signedChallengeXdr`. Returns `null` on
5770
+ * failure. Bind the network you sign on to the app's network.
5771
+ */
5772
+ requestChallenge(clientSessionId: string, walletAddress: string): Promise<string | null>;
5773
+ /**
5774
+ * External-provider leg: `POST /auth/external` with `{ clientSessionId, ...body }`.
5775
+ * The backend proves wallet control via SEP-10, so `body` must carry
5776
+ * `{ provider, walletAddress, signedChallengeXdr }` (the challenge from
5777
+ * {@link requestChallenge}, counter-signed by the wallet). Returns `false` and
5778
+ * sets an error state on failure.
5779
+ */
5780
+ exchangeExternalToken(clientSessionId: string, body: Record<string, unknown>): Promise<boolean>;
5781
+ /** Built-in hosted-OAuth dance (popup on web, in-app browser on RN). Backs the google/github providers. */
5782
+ startHostedOAuth(provider: 'google' | 'github'): Promise<void>;
5783
+ }
5784
+ /**
5785
+ * A pluggable login strategy. Built-ins (`google`, `github`, `email`) ship as
5786
+ * these; custom ones (Privy, Magic, …) are injected via
5787
+ * `PollarClientConfig.providers`. Note: `wallet` is intentionally NOT a provider
5788
+ * — it yields a persistent `WalletAdapter` reused for signing, a concern
5789
+ * orthogonal to login, so it keeps its own dedicated `loginWallet()` flow.
5790
+ *
5791
+ * - `login` handles the one-shot entry point (`client.login({ provider: id })`).
5792
+ * - `actions` exposes extra named steps for multi-step flows (e.g. email's
5793
+ * send-code / verify-code), invoked via `client.providerAction(id, action, payload)`.
5794
+ */
5795
+ interface PollarAuthProvider {
5796
+ /** Matches `PollarLoginOptions.provider` and the key in `providerAction`. */
5797
+ readonly id: string;
5798
+ login?(ctx: AuthProviderContext, options: PollarLoginOptions): Promise<void>;
5799
+ actions?: Record<string, (ctx: AuthProviderContext, payload?: unknown) => Promise<void>>;
5800
+ }
5801
+ type TxBuildContent = TxBuildResponse['content'];
5802
+ /**
5803
+ * Phases the SDK can be in across the build → sign → submit lifecycle.
5804
+ *
5805
+ * **Granular** steps (`building`, `signing`, `submitting`) are emitted when
5806
+ * the SDK can directly observe that phase — i.e. when each is a separate
5807
+ * client-driven call (`buildTx`, `signTx`, `submitTx`, external-wallet
5808
+ * `signAndSubmitTx`).
5809
+ *
5810
+ * **Compound** steps (`signing-submitting`, `building-signing-submitting`)
5811
+ * are emitted when multiple phases collapse into a single opaque backend
5812
+ * round-trip (`signAndSubmitTx` custodial → `/tx/sign-and-send`, and `runTx`
5813
+ * / `buildAndSignAndSubmitTx` custodial → `/tx/build-sign-submit`). The SDK
5814
+ * can't see when one phase ends and the next begins inside that request, so
5815
+ * it honestly reports a single fused state instead of fabricating
5816
+ * transitions.
5817
+ *
5818
+ * **Terminal states** (`success`, `error`) and the post-Horizon-ack pending
5819
+ * state (`submitted`) are shared across all paths.
5820
+ *
5821
+ * On `error`, the `phase` discriminator tells the consumer *where* the
5822
+ * failure happened so modal UIs can offer "retry from this step" buttons.
5823
+ */
5824
+ type TransactionState = {
5825
+ step: 'idle';
5826
+ } | {
5827
+ step: 'building';
5828
+ } | {
5829
+ step: 'built';
5830
+ buildData: TxBuildContent;
5831
+ } | {
5832
+ step: 'signing';
5833
+ buildData?: TxBuildContent;
5834
+ } | {
5835
+ step: 'signed';
5836
+ buildData?: TxBuildContent;
5837
+ signedXdr: string;
5838
+ submissionToken?: string;
5839
+ } | {
5840
+ step: 'submitting';
5841
+ buildData?: TxBuildContent;
5842
+ signedXdr?: string;
5843
+ } | {
5844
+ step: 'signing-submitting';
5845
+ buildData?: TxBuildContent;
5846
+ } | {
5847
+ step: 'building-signing-submitting';
5848
+ } | {
5849
+ step: 'submitted';
5850
+ buildData?: TxBuildContent;
5851
+ hash: string;
5852
+ } | {
5853
+ step: 'success';
5854
+ buildData?: TxBuildContent;
5855
+ hash: string;
5856
+ } | {
5857
+ step: 'error';
5858
+ phase: TxErrorPhase;
5859
+ details?: string;
5860
+ code?: string;
5861
+ message?: string;
5862
+ buildData?: TxBuildContent;
5863
+ signedXdr?: string;
5864
+ };
5865
+ /**
5866
+ * Identifies which phase failed when `TransactionState.step === 'error'`.
5867
+ * Compound phase names (`signing-submitting`, `building-signing-submitting`)
5868
+ * appear here when the failure happened inside an atomic backend call where
5869
+ * the SDK can't isolate the failing sub-phase.
5870
+ */
5871
+ type TxErrorPhase = 'building' | 'signing' | 'submitting' | 'signing-submitting' | 'building-signing-submitting';
5872
+ /**
5873
+ * Per-call outcomes returned by `buildTx`, `signTx`, `submitTx`,
5874
+ * `signAndSubmitTx`, and `buildAndSignAndSubmitTx`. These are additive to
5875
+ * `TransactionState` — the same operations still drive the state machine for
5876
+ * modal-style UIs, but headless callers can `await` the method and inspect
5877
+ * the returned outcome directly instead of subscribing to state changes.
5878
+ */
5879
+ type BuildOutcome = {
5880
+ status: 'built';
5881
+ buildData: TxBuildContent;
5882
+ } | {
5883
+ status: 'error';
5884
+ details?: string;
5885
+ };
5886
+ type SignOutcome = {
5887
+ status: 'signed';
5888
+ signedXdr: string;
5889
+ submissionToken?: string;
5890
+ expiresAt?: number;
5891
+ } | {
5892
+ status: 'error';
5893
+ details?: string;
5894
+ code?: string;
5895
+ message?: string;
5896
+ };
5897
+ /**
5898
+ * Result of {@link PollarClient.signAuthEntry}. `signedAuthEntry` is the base64
5899
+ * XDR of the signed `SorobanAuthorizationEntry`, ready to be composed into the
5900
+ * caller's transaction envelope (e.g. by a contract that sponsors the gas).
5901
+ */
5902
+ type SignAuthEntryOutcome = {
5903
+ status: 'signed';
5904
+ signedAuthEntry: string;
5905
+ } | {
5906
+ status: 'error';
5907
+ details?: string;
5908
+ };
5909
+ type SubmitOutcome = {
5910
+ status: 'success';
5911
+ hash: string;
5912
+ buildData?: TxBuildContent;
5913
+ } | {
5914
+ status: 'pending';
5915
+ hash: string;
5916
+ buildData?: TxBuildContent;
5917
+ } | {
5918
+ status: 'error';
5919
+ hash?: string;
5920
+ details?: string;
5921
+ resultCode?: string;
5922
+ code?: string;
5923
+ message?: string;
5924
+ buildData?: TxBuildContent;
5925
+ };
5926
+ /**
5927
+ * Result of {@link PollarClient.setTrustline}. Like {@link SubmitOutcome} but the
5928
+ * `hash` is optional: the sponsored, server-orchestrated path completes without
5929
+ * surfacing a transaction hash to the client, whereas the self-paid path returns
5930
+ * the underlying submit outcome (hash included).
5931
+ */
5932
+ type TrustlineOutcome = {
5933
+ status: 'success';
5934
+ hash?: string;
5935
+ } | {
5936
+ status: 'pending';
5937
+ hash?: string;
5938
+ } | {
5939
+ status: 'error';
5940
+ details?: string;
5941
+ };
5942
+ declare const AUTH_ERROR_CODES: {
5943
+ readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
5944
+ readonly SESSION_EXPIRED: "SESSION_EXPIRED";
5945
+ readonly SESSION_INVALID: "SESSION_INVALID";
5946
+ readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
5947
+ readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
5948
+ readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
5949
+ readonly EMAIL_CODE_INVALID: "EMAIL_CODE_INVALID";
5950
+ readonly AUTH_FAILED: "AUTH_FAILED";
5951
+ readonly WALLET_CONNECT_FAILED: "WALLET_CONNECT_FAILED";
5952
+ readonly WALLET_AUTH_FAILED: "WALLET_AUTH_FAILED";
5953
+ readonly WALLET_RESOLVER_TIMEOUT: "WALLET_RESOLVER_TIMEOUT";
5954
+ readonly EXTERNAL_AUTH_FAILED: "EXTERNAL_AUTH_FAILED";
5955
+ readonly PASSKEY_FAILED: "PASSKEY_FAILED";
5956
+ readonly TX_FAILED: "TX_FAILED";
5957
+ readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
5958
+ };
5959
+ type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
5960
+ type AuthState = {
5961
+ step: 'idle';
5962
+ } | {
5963
+ step: 'creating_session';
5964
+ } | {
5965
+ step: 'entering_email';
5966
+ clientSessionId: string;
5967
+ } | {
5968
+ step: 'sending_email';
5969
+ email: string;
5970
+ } | {
5971
+ step: 'entering_code';
5972
+ clientSessionId: string;
5973
+ email: string;
5974
+ } | {
5975
+ step: 'verifying_email_code';
5976
+ clientSessionId: string;
5977
+ email: string;
5978
+ } | {
5979
+ step: 'opening_oauth';
5980
+ provider: 'google' | 'github';
5981
+ } | {
5982
+ step: 'connecting_wallet';
5983
+ walletType: WalletId;
5984
+ } | {
5985
+ step: 'signing_wallet_challenge';
5986
+ walletType: WalletId;
5987
+ } | {
5988
+ step: 'wallet_not_installed';
5989
+ walletType: WalletId;
5990
+ } | {
5991
+ step: 'authenticating_wallet';
5992
+ } | {
5993
+ step: 'creating_passkey';
5994
+ } | {
5995
+ step: 'deploying_smart_account';
5996
+ } | {
5997
+ step: 'authenticating';
5998
+ } | {
5999
+ step: 'authenticated';
6000
+ session: PollarPersistedSession;
6001
+ /**
6002
+ * `false` while the session is restored optimistically from storage and
6003
+ * not yet revalidated with the server; `true` after a fresh login/refresh
6004
+ * or a successful `/auth/session/resume`. Gate sensitive actions on this.
6005
+ */
6006
+ verified: boolean;
6007
+ } | {
6008
+ step: 'error';
6009
+ previousStep: string;
6010
+ message: string;
6011
+ errorCode: AuthErrorCode;
6012
+ clientSessionId?: string;
6013
+ email?: string;
6014
+ };
6015
+ type NetworkState = {
6016
+ step: 'idle';
6017
+ } | {
6018
+ step: 'connected';
6019
+ network: StellarNetwork;
6020
+ };
6021
+ declare class PollarFlowError extends Error {
6022
+ readonly code: "INVALID_FLOW";
6023
+ constructor(message: string);
6024
+ }
6025
+ type WalletBalanceContent = paths['/wallet/balance']['get']['responses'][200]['content']['application/json']['content'];
6026
+ type WalletBalanceRecord = WalletBalanceContent['balances'][number];
6027
+ type WalletBalanceState = {
6028
+ step: 'idle';
6029
+ } | {
6030
+ step: 'loading';
6031
+ } | {
6032
+ step: 'loaded';
6033
+ data: WalletBalanceContent;
6034
+ } | {
6035
+ step: 'error';
6036
+ message: string;
6037
+ };
6038
+ type WalletAssetsContent = paths['/wallet/assets']['get']['responses'][200]['content']['application/json']['content'];
6039
+ type EnabledAssetRecord = WalletAssetsContent['assets'][number];
6040
+ type EnabledAssetsState = {
6041
+ step: 'idle';
6042
+ } | {
6043
+ step: 'loading';
6044
+ } | {
6045
+ step: 'loaded';
6046
+ data: WalletAssetsContent;
6047
+ } | {
6048
+ step: 'error';
6049
+ message: string;
6050
+ };
6051
+ type TxHistoryRecord = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content']['records'][number];
6052
+ type TxHistoryParams = NonNullable<paths['/tx/history']['get']['parameters']['query']>;
6053
+ type TxHistoryContent = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content'];
6054
+ type TxHistoryState = {
6055
+ step: 'idle';
6056
+ } | {
6057
+ step: 'loading';
6058
+ params: TxHistoryParams;
6059
+ } | {
6060
+ step: 'loaded';
6061
+ params: TxHistoryParams;
6062
+ data: TxHistoryContent;
6063
+ } | {
6064
+ step: 'error';
6065
+ params: TxHistoryParams;
6066
+ message: string;
6067
+ };
6068
+ type KycLevel = 'basic' | 'intermediate' | 'enhanced';
6069
+ type KycStatus = 'none' | 'pending' | 'approved' | 'rejected';
6070
+ type KycFlow = 'iframe' | 'form' | 'redirect';
6071
+ type KycProvider = paths['/kyc/providers']['get']['responses'][200]['content']['application/json']['content']['providers'][number];
6072
+ type KycStartBody = NonNullable<paths['/kyc/start']['post']['requestBody']>['content']['application/json'];
6073
+ type KycStartResponse = paths['/kyc/start']['post']['responses'][200]['content']['application/json']['content'];
6074
+ type RampsQuoteQuery = NonNullable<paths['/ramps/quote']['get']['parameters']['query']>;
6075
+ type RampQuote = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content']['quotes'][number];
6076
+ type RampsQuoteResponse = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content'];
6077
+ type RampsOnrampBody = NonNullable<paths['/ramps/onramp']['post']['requestBody']>['content']['application/json'];
6078
+ type RampsOnrampResponse = paths['/ramps/onramp']['post']['responses'][200]['content']['application/json']['content'];
6079
+ type RampsOfframpBody = NonNullable<paths['/ramps/offramp']['post']['requestBody']>['content']['application/json'];
6080
+ type RampsOfframpResponse = paths['/ramps/offramp']['post']['responses'][200]['content']['application/json']['content'];
6081
+ type RampsTransactionResponse = paths['/ramps/transaction/{txId}']['get']['responses'][200]['content']['application/json']['content'];
6082
+ type RampTxStatus = RampsTransactionResponse['status'];
6083
+ type RampDirection = RampsTransactionResponse['direction'];
6084
+ type PaymentInstructions = RampsOnrampResponse['paymentInstructions'];
6085
+ type DistributionRule = paths['/distribution/rules']['get']['responses'][200]['content']['application/json']['content']['rules'][number];
6086
+ type RulePeriod = DistributionRule['period'];
6087
+ type DistributionClaimBody = NonNullable<paths['/distribution/claim']['post']['requestBody']>['content']['application/json'];
6088
+ type DistributionClaimContent = paths['/distribution/claim']['post']['responses'][200]['content']['application/json']['content'];
6089
+ type DistributionRulesState = {
6090
+ step: 'idle';
6091
+ } | {
6092
+ step: 'loading';
6093
+ } | {
6094
+ step: 'loaded';
6095
+ rules: DistributionRule[];
6096
+ } | {
6097
+ step: 'error';
6098
+ message: string;
6099
+ };
6100
+ type AdapterFn<TParams = unknown> = (params: TParams) => Promise<{
6101
+ unsignedTransaction: string;
6102
+ }>;
6103
+ type PollarAdapter = Record<string, AdapterFn<any>>;
6104
+ interface PollarAdapters {
6105
+ [key: string]: PollarAdapter;
6106
+ }
6107
+
6108
+ declare class PollarClient {
6109
+ readonly apiKey: string;
6110
+ readonly id: string;
6111
+ readonly basePath: string;
6112
+ private readonly _api;
6113
+ private readonly _log;
6114
+ private readonly _storage;
6115
+ private readonly _keyManager;
6116
+ /** Resolves once `keyManager.init()` and the initial session restore complete. */
6117
+ private readonly _initialized;
6118
+ /**
6119
+ * Per-API-key storage namespace. Computed asynchronously inside
6120
+ * `_initialize()` because SHA-256 lives behind `crypto.subtle.digest`.
6121
+ * Accessing `apiKeyHash` before `await client.ready()` throws.
6122
+ */
6123
+ private _apiKeyHash;
6124
+ /**
6125
+ * Short SHA-256-derived namespace for this client's persisted state.
6126
+ * Available after `await client.ready()` (or any awaited method); throws
6127
+ * if read before initialization completes.
6128
+ */
6129
+ get apiKeyHash(): string;
6130
+ private _session;
6131
+ private _profile;
6132
+ /** Last `DPoP-Nonce` we saw from a server response. Carried into the next proof. */
6133
+ private _dpopNonce;
6134
+ /**
6135
+ * Snapshot of each in-flight request's body, taken in `onRequest` before
6136
+ * `fetch()` consumes the stream. Needed because `Request.clone()` throws
6137
+ * once the body is disturbed, so the auto-retry path (DPoP nonce challenge
6138
+ * / 401 refresh) must rebuild the request from scratch instead of cloning.
6139
+ */
6140
+ private _requestBodyCache;
6141
+ /** Singleton in-flight refresh — concurrent 401s coalesce into one /auth/refresh call. */
6142
+ private _refreshPromise;
6143
+ private _storageEventHandler;
6144
+ /** Optional UI label sent to the server at /auth/login so the sessions UI
6145
+ * can show a recognizable device name. Set via PollarClientConfig.deviceLabel. */
6146
+ private readonly _deviceLabel;
6147
+ private readonly _visibilityProvider;
6148
+ private readonly _maxIdleMs;
6149
+ /** Updated by the request middleware. Read by the silent-refresh scheduler
6150
+ * to skip proactive refreshes after `maxIdleMs` of no HTTP activity. */
6151
+ private _lastRequestAt;
6152
+ private _refreshTimer;
6153
+ private _visibilityUnsubscribe;
6154
+ private _transactionState;
6155
+ private _transactionStateListeners;
6156
+ private _txHistoryState;
6157
+ private _txHistoryStateListeners;
6158
+ private _sessionsState;
6159
+ private _sessionsStateListeners;
6160
+ private _walletBalanceState;
6161
+ private _walletBalanceStateListeners;
6162
+ private _enabledAssetsState;
6163
+ private _enabledAssetsStateListeners;
6164
+ private _authState;
6165
+ private _authStateListeners;
6166
+ private _networkState;
6167
+ private _networkStateListeners;
6168
+ /**
6169
+ * Latched once the storage adapter degrades. We dedupe (the adapter only
6170
+ * fires once anyway) and use it to replay state to late-subscribers — same
6171
+ * pattern as `onAuthStateChange` replaying `_authState` on subscribe.
6172
+ * Only populated when the SDK constructed the default storage adapter; if
6173
+ * the consumer passes `config.storage`, they own degradation notifications.
6174
+ */
6175
+ private _storageDegraded;
6176
+ private _storageDegradeListeners;
6177
+ private _walletAdapter;
6178
+ private readonly _walletAdapterResolver;
6179
+ private readonly _walletResolverTimeoutMs;
6180
+ private readonly _passkey;
6181
+ private readonly _passkeySign;
6182
+ private _loginController;
6183
+ /** Aborts an in-flight `/auth/session/resume` on destroy() or re-trigger. */
6184
+ private _resumeController;
6185
+ /** Platform strategy for opening the hosted-OAuth URL (popup on web; injected on RN). */
6186
+ private readonly _openAuthUrl;
6187
+ /** `redirect_uri` sent to the backend for hosted OAuth. */
6188
+ private readonly _oauthRedirectUri;
6189
+ /**
6190
+ * Registry of pluggable login strategies, keyed by provider id. Seeded with
6191
+ * the built-ins (`google`, `github`, `email`) and then any `config.providers`
6192
+ * (which can override a built-in by reusing its id). `wallet` is deliberately
6193
+ * absent — it keeps its own dedicated flow. See {@link PollarAuthProvider}.
6194
+ */
6195
+ private readonly _providers;
6196
+ constructor(config: PollarClientConfig);
6197
+ /** Awaitable handle for the initial keypair + session restore. */
6198
+ ready(): Promise<void>;
6199
+ private _initialize;
6200
+ /** Detach the cross-tab storage listener and abort any in-flight login. */
6201
+ destroy(): void;
6202
+ private _wireMiddlewares;
6203
+ /**
6204
+ * Logs the final outcome of an SDK API call exactly once: successes (`2xx`) at
6205
+ * `debug` (method + path + status, no body), failures (`4xx`/`5xx`) at `error`
6206
+ * with the redacted request body and the response error body. Returns the
6207
+ * response so it can be chained at the middleware's return points. The error
6208
+ * body is read off a synchronous `clone()` so it never disturbs the body the
6209
+ * caller consumes.
6210
+ */
6211
+ private _logHttp;
6212
+ /** Reads the redacted request body + JSON response body and logs at `error`. */
6213
+ private _logHttpError;
6214
+ /** Strips origin + `/v1` version prefix from a request URL for compact logs. */
6215
+ private _httpPath;
6216
+ private _buildProofForRequest;
6217
+ private _retryRequest;
6218
+ /**
6219
+ * Coalesce concurrent refresh attempts. The first caller does the work;
6220
+ * everyone else awaits the same promise and sees the new tokens.
6221
+ */
6222
+ refresh(): Promise<void>;
6223
+ private _doRefresh;
6224
+ /**
6225
+ * Arm a single setTimeout to fire shortly before the current access token
6226
+ * expires. Idempotent — clearing any previous timer first. Safe to call
6227
+ * from any session-write site (initial login, restore-from-storage, after
6228
+ * a successful rotation). No-op if there's no session in memory.
6229
+ *
6230
+ * Browser/RN background-tab throttling makes long-running setTimeouts
6231
+ * unreliable on their own; the `visibilitychange` listener compensates by
6232
+ * re-invoking `_maybeProactiveRefresh` whenever the app comes back to the
6233
+ * foreground, catching any timer that fired late or never fired at all.
6234
+ */
6235
+ private _scheduleNextRefresh;
6236
+ /**
6237
+ * Decide whether to actually run a refresh right now. Called both from the
6238
+ * scheduler timer and from the visibility-change listener.
6239
+ *
6240
+ * Skip if:
6241
+ * - no session / no RT (nothing to refresh)
6242
+ * - app is hidden — wait for the visibility listener to re-trigger us
6243
+ * - `maxIdleMs` configured and no client request since that window — let
6244
+ * the next reactive 401-refresh handle it whenever the user comes back
6245
+ * - the AT still has more than `REFRESH_SKEW_SECONDS` of life — reschedule
6246
+ *
6247
+ * Otherwise call `refresh()`, which uses the existing in-flight singleton
6248
+ * so we never collide with a reactive 401-triggered refresh. On failure,
6249
+ * `_doRefresh` already calls `_clearSession`, so auth-state listeners see
6250
+ * `step:'idle'` — no extra event dispatch needed here.
6251
+ */
6252
+ private _maybeProactiveRefresh;
6253
+ private _clearRefreshTimer;
6254
+ getAuthState(): AuthState;
6255
+ onAuthStateChange(cb: (state: AuthState) => void): () => void;
6256
+ /**
6257
+ * Subscribe to persistent-storage degradation (Safari private mode,
6258
+ * sandboxed iframes, quota errors, etc.). The SDK keeps running off
6259
+ * in-memory storage after degrade, but sessions won't survive reload — a
6260
+ * host UI typically wants to show "your session won't be saved" so the
6261
+ * user isn't blindsided after a refresh.
6262
+ *
6263
+ * Fires at most once per client lifetime (the underlying adapter dedupes).
6264
+ * Late subscribers receive the latched state synchronously on subscribe.
6265
+ *
6266
+ * Only fires when the SDK constructs the default storage adapter. If you
6267
+ * pass a custom `config.storage`, wire your own notification path through
6268
+ * that adapter's API — the SDK has no hook into it.
6269
+ */
6270
+ onStorageDegrade(cb: OnStorageDegrade): () => void;
6271
+ private _dispatchStorageDegrade;
6272
+ /** PII (email, names, avatar, providers). Held in memory only — never persisted. */
6273
+ getUserProfile(): PollarUserProfile | null;
6274
+ login(options: PollarLoginOptions): void;
6275
+ /**
6276
+ * Invoke a named secondary step on a registered provider (e.g. email's
6277
+ * `sendCode` / `verifyCode`, or a custom provider's multi-step continuation).
6278
+ * Reuses the in-flight login `AbortController` when one exists so the step
6279
+ * stays cancellable via `cancelLogin()`; otherwise starts a fresh one. The
6280
+ * built-in email steps also have dedicated typed methods
6281
+ * ({@link sendEmailCode} / {@link verifyEmailCode}) — prefer those for email.
6282
+ */
6283
+ providerAction(provider: string, action: string, payload?: unknown): void;
6284
+ beginEmailLogin(): void;
6285
+ sendEmailCode(email: string): void;
6286
+ verifyEmailCode(code: string): void;
6287
+ loginWallet(type: WalletId): void;
6288
+ /**
6289
+ * "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
6290
+ * returning user and signs them in. Use {@link createSmartWallet} for a new
6291
+ * user. Requires the `passkey` ceremony to be configured (e.g. via
6292
+ * `@pollar/react`).
6293
+ */
6294
+ loginSmartWallet(): void;
6295
+ /**
6296
+ * "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
6297
+ * for a new user and deploys a sponsored smart-account C-address. Use
6298
+ * {@link loginSmartWallet} for a returning user. Requires the `passkey`
6299
+ * ceremony to be configured (e.g. via `@pollar/react`).
6300
+ */
6301
+ createSmartWallet(): void;
6302
+ cancelLogin(): void;
6303
+ /**
6304
+ * Revoke the current session server-side, then clear local storage.
6305
+ *
6306
+ * Server revocation is best-effort: if the POST fails (offline, server
6307
+ * down), local state is wiped regardless. The orphan refresh token then
6308
+ * remains unused until its natural expiry. The in-flight access token
6309
+ * stays valid until its own TTL elapses (≤10 min for DPoP-bound tokens).
6310
+ *
6311
+ * Pass `everywhere: true` to revoke every active session for this user
6312
+ * across all devices.
6313
+ */
6314
+ logout(options?: {
6315
+ everywhere?: boolean;
6316
+ }): Promise<void>;
6317
+ /** Convenience: revoke every active session for this user (all devices). */
6318
+ logoutEverywhere(): Promise<void>;
6319
+ /**
6320
+ * List active sessions for the authenticated user. Returns one entry per
6321
+ * refresh-token family with the metadata captured at issuance time. The
6322
+ * `current` flag identifies which entry corresponds to this client.
6323
+ */
6324
+ listSessions(): Promise<SessionInfo[]>;
6325
+ getSessionsState(): SessionsState;
6326
+ onSessionsStateChange(cb: (state: SessionsState) => void): () => void;
6327
+ /**
6328
+ * Fire-and-forget variant of {@link listSessions} that drives the observable
6329
+ * `SessionsState` store instead of returning the array. UI layers subscribe
6330
+ * via `onSessionsStateChange` and stay pure readers — mirrors `fetchTxHistory`.
6331
+ */
6332
+ fetchSessions(): Promise<void>;
6333
+ /**
6334
+ * Revoke a specific refresh-token family (a single device session). Use
6335
+ * `listSessions` to enumerate the familyIds. Revoking the current session
6336
+ * does NOT clear local state — call `logout()` for that case.
6337
+ */
6338
+ revokeSession(familyId: string): Promise<void>;
6339
+ getNetwork(): StellarNetwork;
6340
+ getNetworkState(): NetworkState;
6341
+ /**
6342
+ * The client's level-gated logger (built from `logLevel` / `logger`). Exposed
6343
+ * so the runtime layer (`@pollar/react`) can route its own logs through the
6344
+ * same level and sink instead of calling `console` directly.
6345
+ */
6346
+ getLogger(): PollarLogger;
6347
+ setNetwork(network: StellarNetwork): void;
6348
+ onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
6349
+ getTransactionState(): TransactionState | null;
6350
+ onTransactionStateChange(cb: (state: TransactionState) => void): () => void;
6351
+ getTxHistoryState(): TxHistoryState;
6352
+ onTxHistoryStateChange(cb: (state: TxHistoryState) => void): () => void;
6353
+ fetchTxHistory(params?: TxHistoryParams): Promise<void>;
6354
+ getWalletBalanceState(): WalletBalanceState;
6355
+ onWalletBalanceStateChange(cb: (state: WalletBalanceState) => void): () => void;
6356
+ /**
6357
+ * Refreshes the balances of the authenticated user's OWN wallet. The wallet
6358
+ * and network are resolved server-side from the session — no arguments. Drives
6359
+ * `walletBalanceState`. For an arbitrary wallet, use {@link getWalletBalance}.
6360
+ */
6361
+ refreshBalance(): Promise<void>;
6362
+ /**
6363
+ * General-purpose balance lookup for ANY wallet on ANY network — not scoped
6364
+ * to this application. Enumerates the account's real on-chain holdings via
6365
+ * Horizon (server-side) and returns the data directly (no reactive state).
6366
+ * `network` defaults to the client's current network.
6367
+ */
6368
+ getWalletBalance(publicKey: string, network?: StellarNetwork): Promise<WalletBalanceContent>;
6369
+ getEnabledAssetsState(): EnabledAssetsState;
6370
+ onEnabledAssetsStateChange(cb: (state: EnabledAssetsState) => void): () => void;
6371
+ /**
6372
+ * Loads the application's enabled assets paired with the authenticated
6373
+ * wallet's on-chain trustline state — so the SDK knows which trustlines still
6374
+ * need to be added. Wallet and network are resolved server-side from the
6375
+ * session. Drives `enabledAssetsState`; mirrors {@link refreshBalance}.
6376
+ */
6377
+ refreshAssets(): Promise<void>;
6378
+ /**
6379
+ * Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
6380
+ *
6381
+ * Routing mirrors how the platform pays for the reserve:
6382
+ * - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
6383
+ * server orchestrates a sponsored `changeTrust`: the app's wallets cover the
6384
+ * 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
6385
+ * `sponsored` flag (from {@link refreshAssets}) straight through.
6386
+ * - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
6387
+ * asset not configured in the app) → a plain `change_trust` transaction the
6388
+ * user's own wallet signs and pays for, via {@link runTx}.
6389
+ *
6390
+ * Does not refresh on its own — callers should `refreshAssets()` afterwards.
6391
+ */
6392
+ setTrustline(asset: {
6393
+ code: string;
6394
+ issuer: string;
6395
+ }, opts?: {
6396
+ limit?: string;
6397
+ sponsored?: boolean;
6398
+ }): Promise<TrustlineOutcome>;
6399
+ /**
6400
+ * Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
6401
+ * AND returns a {@link BuildOutcome} so headless callers can `await` and
6402
+ * inspect the result without subscribing to state changes.
6403
+ */
6404
+ buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<BuildOutcome>;
6405
+ getWalletType(): WalletId | null;
6406
+ /**
6407
+ * The authenticated user's wallet as a {@link WalletInfo} discriminated union,
6408
+ * or `null` when there's no session (or the session carries no address yet).
6409
+ *
6410
+ * `custody` strictly determines `provider` (the mapping is 1:1 and fixed at
6411
+ * account creation server-side): `external` reports the connected adapter id
6412
+ * (`getWalletType()`), `smart` is always `'passkey'`, and `internal` reports
6413
+ * the login method the backend recorded (`null` for pre-provider sessions).
6414
+ */
6415
+ getWallet(): WalletInfo | null;
6416
+ /**
6417
+ * Signs the given unsigned XDR and returns the signed XDR.
6418
+ *
6419
+ * - External wallets: signs locally via the wallet adapter.
6420
+ * - Custodial wallets: posts to `/tx/sign`. The backend signs (through
6421
+ * wallet-service or the app's customer-managed adapter) and returns the
6422
+ * signed XDR plus an `idempotencyKey` the caller should echo back to
6423
+ * `submitTx`.
6424
+ *
6425
+ * Drives `_setTransactionState`: emits `signing` while in flight and
6426
+ * `signed` on success (or `error[phase: 'signing']` on failure). `buildData`
6427
+ * is threaded through if the consumer previously called `buildTx`.
6428
+ */
6429
+ signTx(unsignedXdr: string): Promise<SignOutcome>;
6430
+ /**
6431
+ * Sign a single Soroban authorization entry (`SorobanAuthorizationEntry`).
6432
+ *
6433
+ * Use this when a contract is the transaction source (e.g. it sponsors the
6434
+ * gas and swaps the fee out of the user's token) and only needs the user's
6435
+ * address-credentials authorization, not a full signed envelope. The signed
6436
+ * entry is returned as base64 XDR for the caller to compose into its tx.
6437
+ *
6438
+ * - External wallets (Freighter/Albedo) sign the entry via the provider.
6439
+ * - Custodial wallets are signed by the backend, which FIRST validates the
6440
+ * entry's invocation tree against the app's contract/function allowlist and
6441
+ * caps the validity window — entries touching a non-allowlisted contract or
6442
+ * function, or expiring too far ahead, are rejected.
6443
+ *
6444
+ * @param entryXdr base64 XDR of the unsigned `SorobanAuthorizationEntry`.
6445
+ * @param options.validUntilLedger absolute ledger the signature expires at
6446
+ * (computed from the network's latest ledger). Ignored on the external-wallet
6447
+ * path, where the provider sets its own expiration.
6448
+ */
6449
+ signAuthEntry(entryXdr: string, options: {
6450
+ validUntilLedger: number;
6451
+ }): Promise<SignAuthEntryOutcome>;
6452
+ /**
6453
+ * Submits a signed XDR via `/tx/submit` regardless of wallet type
6454
+ * (custodial or external). Routing through sdk-api gives us:
6455
+ * - End-to-end tx_records persistence with full phase lifecycle so the
6456
+ * developer dashboard can show every tx (both custodial and external
6457
+ * wallet flows) at `/apps/:id/monitor/transactions`.
6458
+ * - Idempotency tracking via `submissionToken` (returned by `signTx`).
6459
+ * - A single response shape (SUCCESS / PENDING / FAILED) shared by both
6460
+ * flows — previously external wallets could only return SUCCESS or
6461
+ * error since the direct-to-Horizon path was synchronous.
6462
+ *
6463
+ * The extra hop adds ~50–150 ms vs. the legacy direct-Horizon path; the
6464
+ * persistence + observability win is worth it.
6465
+ *
6466
+ * Drives `_setTransactionState`: emits `submitting` while in flight,
6467
+ * `submitted` on Horizon ack (pending), `success` on ledger confirmation,
6468
+ * or `error[phase: 'submitting']` on failure.
6469
+ */
6470
+ /**
6471
+ * Normalize a backend API error into { details, code, message }. `code` is the
6472
+ * precise backend ErrorCode (e.g. `TX_FEE_LIMIT_EXCEEDED`) for programmatic
6473
+ * handling; `message` is a friendly string from the error catalog; `details`
6474
+ * is the raw diagnostic. Lets tx flows surface a typed reason instead of an
6475
+ * opaque details string.
6476
+ */
6477
+ private _resolveTxApiError;
6478
+ submitTx(signedXdr: string, opts?: {
6479
+ submissionToken?: string;
6480
+ }): Promise<SubmitOutcome>;
6481
+ /**
6482
+ * Signs and submits in one logical step. Returns a {@link SubmitOutcome}.
6483
+ *
6484
+ * - **External wallets**: composes `signTx` + `submitTx` client-side. State
6485
+ * machine sees the full granular sequence `signing → signed → submitting
6486
+ * → success` because the underlying methods each emit.
6487
+ * - **Custodial wallets**: atomic `/tx/sign-and-send` round-trip. State
6488
+ * machine emits the compound `signing-submitting` step (the SDK can't
6489
+ * observe when one phase ends and the next begins inside that single
6490
+ * backend call) and then transitions to `submitted` (Horizon ack only) or
6491
+ * `success` (ledger-confirmed), or `error[phase: 'signing-submitting']`.
6492
+ */
6493
+ signAndSubmitTx(unsignedXdr?: string): Promise<SubmitOutcome>;
6494
+ /**
6495
+ * One-shot: build → sign → submit, returning the final {@link SubmitOutcome}.
6496
+ *
6497
+ * - **External wallets**: composes `buildTx` + `signAndSubmitTx` client-side.
6498
+ * State machine sees the full granular sequence (`building → built →
6499
+ * signing → signed → submitting → success`) because each composed call
6500
+ * emits its own transitions.
6501
+ * - **Custodial wallets**: single round-trip to `/tx/build-sign-submit`. The
6502
+ * signed XDR never leaves the backend. State machine emits the compound
6503
+ * `building-signing-submitting` step (the SDK can't observe individual
6504
+ * phase boundaries inside one atomic call) and then transitions to
6505
+ * `submitted` / `success` / `error[phase: 'building-signing-submitting']`.
6506
+ *
6507
+ * If you need granular UI feedback for custodial flows (separate
6508
+ * "Building…", "Signing…", "Submitting…" indicators), call `buildTx`,
6509
+ * `signTx`, and `submitTx` separately instead.
6510
+ */
6511
+ buildAndSignAndSubmitTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<SubmitOutcome>;
6512
+ /** Alias for {@link buildAndSignAndSubmitTx} — shorter "just do the thing" name. */
6513
+ runTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<SubmitOutcome>;
6514
+ /**
6515
+ * Smart-wallet (passkey / C-address) transaction: build (server prepares the
6516
+ * SAC transfer + returns the auth digest) → sign the digest with the passkey
6517
+ * → submit (server assembles the signed auth entry and broadcasts; the
6518
+ * sponsor pays the fee). State machine: building → built → signing →
6519
+ * submitting → success.
6520
+ */
6521
+ private _runSmartTx;
6522
+ /**
6523
+ * Steps 2–3 of the smart-wallet flow: sign the prepared auth digest with the
6524
+ * passkey, then submit. Shared by `_runSmartTx` (atomic) and `signAndSubmitTx`
6525
+ * (split flow, when a smart build is already on the state machine).
6526
+ */
6527
+ private _signSubmitSmart;
6528
+ getAppConfig(): Promise<unknown>;
6529
+ getKycStatus(providerId?: string): Promise<{
6530
+ status: KycStatus;
6531
+ level?: KycLevel | undefined;
6532
+ providerId: string;
6533
+ expiresAt?: string;
6534
+ }>;
6535
+ getKycProviders(country: string): Promise<{
6536
+ providers: KycProvider[];
6537
+ }>;
6538
+ startKyc(body: KycStartBody): Promise<KycStartResponse>;
6539
+ resolveKyc(providerId: string, level?: KycLevel): Promise<{
6540
+ alreadyApproved: boolean;
6541
+ } & Partial<{
6542
+ sessionId: string;
6543
+ kycUrl?: string;
6544
+ fields?: {
6545
+ name: string;
6546
+ type: string;
6547
+ required: boolean;
6548
+ }[];
6549
+ }>>;
6550
+ pollKycStatus(providerId: string, opts?: {
6551
+ intervalMs?: number;
6552
+ timeoutMs?: number;
6553
+ }): Promise<KycStatus>;
6554
+ getRampsQuote(query: RampsQuoteQuery): Promise<RampsQuoteResponse>;
6555
+ createOnRamp(body: RampsOnrampBody): Promise<RampsOnrampResponse>;
6556
+ createOffRamp(body: RampsOfframpBody): Promise<RampsOfframpResponse>;
6557
+ getRampTransaction(txId: string): Promise<RampsTransactionResponse>;
6558
+ pollRampTransaction(txId: string, opts?: {
6559
+ intervalMs?: number;
6560
+ timeoutMs?: number;
6561
+ }): Promise<RampTxStatus>;
6562
+ listDistributionRules(): Promise<DistributionRule[]>;
6563
+ claimDistributionRule(body: DistributionClaimBody): Promise<DistributionClaimContent>;
6564
+ private _setTxHistoryState;
6565
+ private _setSessionsState;
6566
+ private _setWalletBalanceState;
6567
+ private _setEnabledAssetsState;
6568
+ private _newController;
6569
+ /**
6570
+ * Build the {@link AuthProviderContext} facade for one login attempt. Wraps
6571
+ * the internal `FlowDeps` so providers get only the curated primitives —
6572
+ * `createSession`, `authenticate`, `exchangeExternalToken`, `startHostedOAuth`
6573
+ * — while storage / wallet-adapter / key-manager internals stay private. All
6574
+ * legs share the same `signal`, so `cancelLogin()` aborts the whole chain.
6575
+ */
6576
+ private _providerContext;
6577
+ /**
6578
+ * Generic external-provider exchange leg (`POST /auth/external`). Custom
6579
+ * providers call this (via the context) after their own SDK has authenticated
6580
+ * the user and the wallet has counter-signed the SEP-10 challenge
6581
+ * (`{ provider, walletAddress, signedChallengeXdr }`). On success the session
6582
+ * is marked READY server-side and the provider should then call
6583
+ * `ctx.authenticate(clientSessionId)`. Returns `false` (and sets an error
6584
+ * state) on failure.
6585
+ */
6586
+ private _exchangeExternalToken;
6587
+ private _flowDeps;
6588
+ /**
6589
+ * Resolves a wallet adapter for the requested id. Uses the consumer's
6590
+ * injected `walletAdapter` resolver when present; otherwise falls back to
6591
+ * the built-in `FreighterAdapter` / `AlbedoAdapter`. Throws if the id is
6592
+ * unknown and no resolver is configured.
6593
+ */
6594
+ private _resolveWalletAdapter;
6595
+ private _handleFlowError;
6596
+ private _restoreSession;
6597
+ /**
6598
+ * Validate the restored session against the server and repopulate the
6599
+ * in-memory profile (PII is never persisted, so it's null after a cold
6600
+ * reload). Goes through the normal authed client, so it coalesces with any
6601
+ * in-flight refresh (onRequest awaits `_refreshPromise`) and, being a GET,
6602
+ * is auto-retried after a 401-triggered refresh.
6603
+ *
6604
+ * - 200 → store profile, mark the session `verified`.
6605
+ * - 401 → the refresh-on-401 path already ran; if the family was
6606
+ * revoked, refresh failed and `_clearSession()` took us to
6607
+ * idle. Nothing to do here — don't double-handle.
6608
+ * - network error → stay optimistic (do NOT log out); revalidated later on
6609
+ * `visibilitychange` or first use.
6610
+ */
6611
+ private _resume;
6612
+ private _storeSession;
6613
+ private _clearSession;
6614
+ private _networkPassphrase;
6615
+ private _setNetworkState;
6616
+ private _setAuthState;
6617
+ private _setTransactionState;
6618
+ /**
6619
+ * Threads `buildData` through state transitions. When the user has already
6620
+ * called `buildTx`, every subsequent state (signing, signed, submitting,
6621
+ * submitted, success, error) should carry the build summary so modal UIs
6622
+ * can keep showing "Send 5 USDC to G..." through the whole flow.
6623
+ */
6624
+ private _currentBuildData;
6625
+ }
6626
+
6627
+ /**
6628
+ * Version of this `@pollar/core` build (e.g. `'0.8.2'`). Falls back to `'dev'`
6629
+ * when running unbundled.
6630
+ *
6631
+ * Named per-package on purpose: importing it alongside `@pollar/react`'s
6632
+ * `POLLAR_REACT_VERSION` never collides, so an app can report both versions in
6633
+ * a single bug-report / diagnostics line.
6634
+ */
6635
+ declare const POLLAR_CORE_VERSION: string;
6636
+
6637
+ /**
6638
+ * In-memory storage backed by a `Map`. Always available, never throws.
6639
+ * Used as the default fallback for SSR, private browsing, sandboxed iframes
6640
+ * without `allow-same-origin`, or any environment where `localStorage` is
6641
+ * unusable.
6642
+ */
6643
+ declare function createMemoryAdapter(): Storage;
6644
+ interface LocalStorageAdapterOptions {
6645
+ /**
6646
+ * Optional callback invoked the first time the adapter degrades to its
6647
+ * in-memory fallback (e.g. quota exceeded, throwing `localStorage`).
6648
+ */
6649
+ onDegrade?: OnStorageDegrade;
6650
+ /**
6651
+ * Logger for the one-shot degrade warning. Defaults to the global `console`;
6652
+ * `PollarClient` passes its level-gated logger so `logLevel` applies here too.
6653
+ */
6654
+ logger?: PollarLogger;
6655
+ }
6656
+ /**
6657
+ * `localStorage`-backed adapter that wraps every operation in try/catch and
6658
+ * silently degrades to an in-memory fallback for the rest of the process
6659
+ * lifetime on any throw. A single warning is logged when the degrade happens.
6660
+ *
6661
+ * Why every op (not just the probe): Safari private mode and sandboxed iframes
6662
+ * may expose `localStorage` but throw `QuotaExceededError` / `SecurityError`
6663
+ * on the first write — a successful probe at construction time isn't enough.
6664
+ *
6665
+ * Tokens persisted here are DPoP-bound to a non-extractable WebCrypto
6666
+ * keypair, so XSS exposure is limited to a signing-oracle attack (the key
6667
+ * itself never leaves the browser's crypto subsystem). Consumers who need
6668
+ * stricter isolation can inject a custom `Storage` adapter — e.g. one that
6669
+ * proxies to an httpOnly cookie on a host origin.
6670
+ */
6671
+ declare function createLocalStorageAdapter(options?: LocalStorageAdapterOptions): Storage;
6672
+
6673
+ /**
6674
+ * Returns `localStorage`-backed storage when it works, otherwise an in-memory
6675
+ * fallback. The probe writes-reads-removes a sentinel; any throw, value
6676
+ * mismatch, or missing `localStorage` (SSR / disabled storage) falls back.
6677
+ *
6678
+ * Run-time degrade still happens inside `createLocalStorageAdapter` — see its
6679
+ * docstring for the rationale.
6680
+ */
6681
+ declare function defaultStorage(options?: LocalStorageAdapterOptions): Storage;
6682
+
6683
+ /**
6684
+ * Construct the default `KeyManager` for the current runtime. Throws if no
6685
+ * factory has been registered — that only happens if `@pollar/core` was
6686
+ * imported in a way that bypassed the entry-point module (a bundler or
6687
+ * test setup bug).
6688
+ */
6689
+ declare function defaultKeyManager(storage: Storage, apiKey: string): KeyManager;
6690
+
6691
+ declare class WebCryptoKeyManager implements KeyManager {
6692
+ private readonly apiKey;
6693
+ private apiKeyHash;
6694
+ private keyPair;
6695
+ private publicJwk;
6696
+ private thumbprint;
6697
+ /**
6698
+ * Cached in-flight init. Lets `init()` be called concurrently (or implicitly
6699
+ * from `getPublicJwk` / `sign`) without doing the work twice. Cleared on
6700
+ * failure so callers can retry, and cleared on `reset()`.
6701
+ */
6702
+ private _initPromise;
6703
+ constructor(apiKey: string);
6704
+ /**
6705
+ * Idempotent and safe under concurrency. The first call kicks off the real
6706
+ * init; subsequent (and concurrent) calls return the same in-flight promise.
6707
+ * Other methods (`getPublicJwk`, `getThumbprint`, `sign`) auto-await this so
6708
+ * the manager is self-healing if `init()` was never explicitly invoked.
6709
+ */
6710
+ init(): Promise<void>;
6711
+ private _doInit;
6712
+ /**
6713
+ * Derive the public JWK from a `CryptoKey`. Prefers the `'raw'` export (the
6714
+ * 65-byte uncompressed point `0x04 || X(32) || Y(32)`) and base64url-encodes
6715
+ * the coordinates ourselves — that sidesteps polyfills whose `exportKey('jwk')`
6716
+ * emits non-base64url `x`/`y` (standard base64, `=` padding, or — as seen with
6717
+ * `react-native-quick-crypto` — a stray `.`). Real browsers and most polyfills
6718
+ * support `'raw'` for public EC keys.
6719
+ *
6720
+ * Falls back to the `'jwk'` export (normalized via `canonicalEcJwk`) if `'raw'`
6721
+ * is unsupported or returns an unexpected shape, so this can't regress on a
6722
+ * runtime that only implements the JWK path. Both routes yield identical
6723
+ * coordinate bytes, so the `cnf.jkt` thumbprint is unchanged either way.
6724
+ */
6725
+ private _exportPublicJwk;
6726
+ reset(): Promise<void>;
6727
+ getPublicJwk(): Promise<PublicEcJwk>;
6728
+ getThumbprint(): Promise<string>;
6729
+ sign(payload: Uint8Array): Promise<Uint8Array>;
6730
+ }
6731
+
6732
+ /**
6733
+ * Compute the RFC 7638 JWK thumbprint for an EC P-256 public JWK.
6734
+ *
6735
+ * Algorithm (RFC 7638 §3):
6736
+ * 1. Build a JSON object containing ONLY the required members of the JWK,
6737
+ * ordered lexicographically by member name (Unicode code point).
6738
+ * For EC keys, that's exactly {crv, kty, x, y}.
6739
+ * 2. Serialize to UTF-8 with no whitespace and no line breaks.
6740
+ * 3. Hash with SHA-256.
6741
+ * 4. Base64url-encode the hash (no padding).
6742
+ *
6743
+ * Common bugs guarded against:
6744
+ * - Including extra fields (`alg`, `use`, `kid`, `ext`, `key_ops`).
6745
+ * - Wrong member ordering (must be lex by Unicode code point).
6746
+ * - Padded base64 instead of base64url unpadded.
6747
+ * - Using `JSON.stringify(jwk)` of an arbitrary-key-order object — we build
6748
+ * a fresh literal in canonical order to make the order explicit and not
6749
+ * rely on V8's insertion-order semantics.
6750
+ */
6751
+ declare function computeJwkThumbprint(jwk: PublicEcJwk): Promise<string>;
6752
+ /**
6753
+ * Strip a JWK to only the four required EC public members and normalize the
6754
+ * coordinates to unpadded base64url. Useful when the input came from
6755
+ * `crypto.subtle.exportKey('jwk', publicKey)` which adds `ext` / `key_ops`
6756
+ * (and, under some RN polyfills, non-base64url coordinates). Returns a fresh
6757
+ * object — never mutates input.
6758
+ */
6759
+ declare function canonicalEcJwk(jwk: {
6760
+ kty?: string;
6761
+ crv?: string;
6762
+ x?: string;
6763
+ y?: string;
6764
+ }): PublicEcJwk;
6765
+
6766
+ /**
6767
+ * RFC 9449 DPoP proof builder.
6768
+ *
6769
+ * Produces a compact JWS that the consumer attaches as the `DPoP` HTTP
6770
+ * header. The header `jwk` is the public part of the SDK's per-session
6771
+ * keypair; the server verifies the signature, validates the `htm` / `htu` /
6772
+ * `iat` / `jti` / optional `nonce` / optional `ath` claims, and matches the
6773
+ * proof's JWK thumbprint against the access token's `cnf.jkt` claim.
6774
+ *
6775
+ * Server-issued nonce flow (RFC 9449 §8/§9): the server may respond with
6776
+ * `WWW-Authenticate: DPoP ... error="use_dpop_nonce"` plus a `DPoP-Nonce`
6777
+ * header. The client should re-build the proof with the new nonce and retry.
6778
+ * `buildProof` accepts an optional nonce; the SDK client tracks it across
6779
+ * requests and feeds it back here.
6780
+ *
6781
+ * The last seen `DPoP-Nonce` is stored verbatim and embedded in the next
6782
+ * proof. The server validates it as an HMAC token, so an attacker who
6783
+ * injects an arbitrary nonce cannot escalate — verification fails and the
6784
+ * server replies with a fresh nonce on the next request.
6785
+ */
6786
+ interface BuildProofArgs {
6787
+ /** HTTP method, e.g. `"GET"`. Will be uppercased before signing. */
6788
+ htm: string;
6789
+ /**
6790
+ * HTTP target URI. Will be normalized per RFC 3986 §6.2 (lowercase scheme
6791
+ * + host, default port elided, query+fragment+userinfo stripped, path
6792
+ * dot-segments resolved, trailing slash preserved exactly as provided).
6793
+ */
6794
+ htu: string;
6795
+ /**
6796
+ * Access token to bind the proof to (its base64url(SHA-256) goes in the
6797
+ * `ath` claim). Omit for proofs sent to the token endpoint per RFC 9449
6798
+ * §5 / §6.1 (those proofs MUST NOT include `ath`).
6799
+ */
6800
+ accessToken?: string;
6801
+ /**
6802
+ * Server-issued DPoP nonce, if the server has previously challenged this
6803
+ * client with `WWW-Authenticate: DPoP ... error="use_dpop_nonce"`. RFC
6804
+ * 9449 §8.
6805
+ */
6806
+ nonce?: string;
6807
+ }
6808
+ /**
6809
+ * Build a DPoP proof JWS for the given request. Returns the compact-form
6810
+ * JWS string (`<header>.<payload>.<signature>`).
6811
+ */
6812
+ declare function buildProof(args: BuildProofArgs, keyManager: KeyManager): Promise<string>;
6813
+ /**
6814
+ * Normalize an HTTP URI for use as the `htu` claim.
6815
+ *
6816
+ * RFC 9449 §4.3 + RFC 3986 §6.2:
6817
+ * - lowercase scheme + host
6818
+ * - elide default port (`:443` for https, `:80` for http)
6819
+ * - strip userinfo (never appears in `htu`)
6820
+ * - strip query + fragment
6821
+ * - apply path dot-segment removal (handled by the URL constructor)
6822
+ * - **preserve trailing slash exactly** — `/foo` and `/foo/` are distinct
6823
+ * paths per RFC 3986 §6 and must round-trip identically.
6824
+ * - preserve IPv6 brackets in host
6825
+ *
6826
+ * Both client and server must apply the same normalization so the `htu`
6827
+ * claim matches deterministically.
6828
+ */
6829
+ declare function normalizeHtu(rawUrl: string): string;
5968
6830
 
5969
6831
  declare function isValidSession(value: unknown, logger?: PollarLogger): value is PollarPersistedSession;
5970
6832
 
@@ -6059,4 +6921,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
6059
6921
  */
6060
6922
  declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
6061
6923
 
6062
- 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 PasskeyMode, 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 TrustlineOutcome, 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 };
6924
+ export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthProviderContext, 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 PasskeyMode, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, type PollarAuthMethod, type PollarAuthProvider, 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 SignAuthEntryOutcome, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TrustlineOutcome, 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, type WalletInfo, 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 };