@pollar/core 0.4.4 → 0.5.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.mts CHANGED
@@ -1,5 +1,310 @@
1
1
  import * as openapi_fetch from 'openapi-fetch';
2
2
 
3
+ type StellarNetwork = 'mainnet' | 'testnet';
4
+ type StellarClientConfig = StellarNetwork | {
5
+ horizonUrl: string;
6
+ };
7
+ interface StellarBalance {
8
+ asset: string;
9
+ balance: string;
10
+ assetIssuer?: string;
11
+ }
12
+ declare class StellarClient {
13
+ private readonly horizonUrl;
14
+ constructor(config: StellarClientConfig);
15
+ submitTransaction(signedXdr: string): Promise<{
16
+ success: true;
17
+ hash: string;
18
+ } | {
19
+ success: false;
20
+ errorCode: string;
21
+ }>;
22
+ }
23
+
24
+ declare enum WalletType {
25
+ FREIGHTER = "freighter",
26
+ ALBEDO = "albedo"
27
+ }
28
+ interface ConnectWalletResponse {
29
+ address: string;
30
+ publicKey: string;
31
+ }
32
+ interface SignTransactionOptions {
33
+ network?: string;
34
+ networkPassphrase?: string;
35
+ accountToSign?: string;
36
+ }
37
+ interface SignAuthEntryOptions {
38
+ accountToSign?: string;
39
+ }
40
+ interface SignTransactionResponse {
41
+ signedTxXdr: string;
42
+ }
43
+ interface SignAuthEntryResponse {
44
+ signedAuthEntry: string;
45
+ }
46
+ interface WalletAdapter {
47
+ type: WalletType;
48
+ isAvailable(): Promise<boolean>;
49
+ connect(): Promise<ConnectWalletResponse>;
50
+ disconnect(): Promise<void>;
51
+ getPublicKey(): Promise<string | null>;
52
+ signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
53
+ signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
54
+ }
55
+
56
+ declare class FreighterAdapter implements WalletAdapter {
57
+ readonly type = WalletType.FREIGHTER;
58
+ isAvailable(): Promise<boolean>;
59
+ connect(): Promise<ConnectWalletResponse>;
60
+ disconnect(): Promise<void>;
61
+ getPublicKey(): Promise<string | null>;
62
+ getNetwork(): Promise<string>;
63
+ signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
64
+ signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
65
+ }
66
+
67
+ declare class AlbedoAdapter implements WalletAdapter {
68
+ readonly type = WalletType.ALBEDO;
69
+ isAvailable(): Promise<boolean>;
70
+ connect(): Promise<ConnectWalletResponse>;
71
+ disconnect(): Promise<void>;
72
+ getPublicKey(): Promise<string | null>;
73
+ getNetwork(): Promise<string>;
74
+ signTransaction(xdr: string, _options?: SignTransactionOptions): Promise<SignTransactionResponse>;
75
+ signAuthEntry(entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
76
+ }
77
+
78
+ type PollarApplicationConfigResponse = paths['/auth/login']['post']['responses'][200]['content']['application/json'];
79
+ type PollarApplicationConfigContent = PollarApplicationConfigResponse['content'];
80
+ interface PollarClientConfig {
81
+ stellarNetwork?: StellarNetwork;
82
+ baseUrl?: string;
83
+ apiKey: string;
84
+ }
85
+ type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
86
+ type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
87
+ type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
88
+ type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
89
+ type PollarLoginOptions = {
90
+ provider: 'google';
91
+ } | {
92
+ provider: 'github';
93
+ } | {
94
+ provider: 'email';
95
+ email: string;
96
+ } | {
97
+ provider: 'wallet';
98
+ type: WalletType;
99
+ };
100
+ type TxBuildContent = TxBuildResponse['content'];
101
+ type TransactionState = {
102
+ step: 'idle';
103
+ } | {
104
+ step: 'building';
105
+ } | {
106
+ step: 'built';
107
+ buildData: TxBuildContent;
108
+ } | {
109
+ step: 'signing';
110
+ buildData: TxBuildContent;
111
+ } | {
112
+ step: 'success';
113
+ buildData: TxBuildContent;
114
+ hash: string;
115
+ } | {
116
+ step: 'error';
117
+ details?: string;
118
+ buildData?: TxBuildContent;
119
+ };
120
+ declare const AUTH_ERROR_CODES: {
121
+ readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
122
+ readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
123
+ readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
124
+ readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
125
+ readonly EMAIL_CODE_INVALID: "EMAIL_CODE_INVALID";
126
+ readonly AUTH_FAILED: "AUTH_FAILED";
127
+ readonly WALLET_CONNECT_FAILED: "WALLET_CONNECT_FAILED";
128
+ readonly WALLET_AUTH_FAILED: "WALLET_AUTH_FAILED";
129
+ readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
130
+ };
131
+ type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
132
+ type AuthState = {
133
+ step: 'idle';
134
+ } | {
135
+ step: 'creating_session';
136
+ } | {
137
+ step: 'entering_email';
138
+ clientSessionId: string;
139
+ } | {
140
+ step: 'sending_email';
141
+ email: string;
142
+ } | {
143
+ step: 'entering_code';
144
+ clientSessionId: string;
145
+ email: string;
146
+ } | {
147
+ step: 'verifying_email_code';
148
+ clientSessionId: string;
149
+ email: string;
150
+ } | {
151
+ step: 'opening_oauth';
152
+ provider: 'google' | 'github';
153
+ } | {
154
+ step: 'connecting_wallet';
155
+ walletType: WalletType;
156
+ } | {
157
+ step: 'wallet_not_installed';
158
+ walletType: WalletType;
159
+ } | {
160
+ step: 'authenticating_wallet';
161
+ } | {
162
+ step: 'authenticating';
163
+ } | {
164
+ step: 'authenticated';
165
+ session: PollarApplicationConfigContent;
166
+ } | {
167
+ step: 'error';
168
+ previousStep: string;
169
+ message: string;
170
+ errorCode: AuthErrorCode;
171
+ clientSessionId?: string;
172
+ email?: string;
173
+ };
174
+ type NetworkState = {
175
+ step: 'idle';
176
+ } | {
177
+ step: 'connected';
178
+ network: StellarNetwork;
179
+ };
180
+ declare class PollarFlowError extends Error {
181
+ readonly code: "INVALID_FLOW";
182
+ constructor(message: string);
183
+ }
184
+ type WalletBalanceContent = paths['/wallet/balance']['get']['responses'][200]['content']['application/json']['content'];
185
+ type WalletBalanceRecord = WalletBalanceContent['balances'][number];
186
+ type TxHistoryRecord = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content']['records'][number];
187
+ type TxHistoryParams = NonNullable<paths['/tx/history']['get']['parameters']['query']>;
188
+ type TxHistoryContent = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content'];
189
+ type TxHistoryState = {
190
+ step: 'idle';
191
+ } | {
192
+ step: 'loading';
193
+ params: TxHistoryParams;
194
+ } | {
195
+ step: 'loaded';
196
+ params: TxHistoryParams;
197
+ data: TxHistoryContent;
198
+ } | {
199
+ step: 'error';
200
+ params: TxHistoryParams;
201
+ message: string;
202
+ };
203
+ type KycLevel = 'basic' | 'intermediate' | 'enhanced';
204
+ type KycStatus = 'none' | 'pending' | 'approved' | 'rejected';
205
+ type KycFlow = 'iframe' | 'form' | 'redirect';
206
+ type KycProvider = paths['/kyc/providers']['get']['responses'][200]['content']['application/json']['content']['providers'][number];
207
+ type KycStartBody = NonNullable<paths['/kyc/start']['post']['requestBody']>['content']['application/json'];
208
+ type KycStartResponse = paths['/kyc/start']['post']['responses'][200]['content']['application/json']['content'];
209
+ type RampsQuoteQuery = NonNullable<paths['/ramps/quote']['get']['parameters']['query']>;
210
+ type RampQuote = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content']['quotes'][number];
211
+ type RampsQuoteResponse = paths['/ramps/quote']['get']['responses'][200]['content']['application/json']['content'];
212
+ type RampsOnrampBody = NonNullable<paths['/ramps/onramp']['post']['requestBody']>['content']['application/json'];
213
+ type RampsOnrampResponse = paths['/ramps/onramp']['post']['responses'][200]['content']['application/json']['content'];
214
+ type RampsOfframpBody = NonNullable<paths['/ramps/offramp']['post']['requestBody']>['content']['application/json'];
215
+ type RampsOfframpResponse = paths['/ramps/offramp']['post']['responses'][200]['content']['application/json']['content'];
216
+ type RampsTransactionResponse = paths['/ramps/transaction/{txId}']['get']['responses'][200]['content']['application/json']['content'];
217
+ type RampTxStatus = RampsTransactionResponse['status'];
218
+ type RampDirection = RampsTransactionResponse['direction'];
219
+ type PaymentInstructions = RampsOnrampResponse['paymentInstructions'];
220
+
221
+ declare class PollarClient {
222
+ readonly apiKey: string;
223
+ readonly id: string;
224
+ readonly basePath: string;
225
+ private readonly _api;
226
+ private _session;
227
+ private _transactionState;
228
+ private _transactionStateListeners;
229
+ private _txHistoryState;
230
+ private _txHistoryStateListeners;
231
+ private _authState;
232
+ private _authStateListeners;
233
+ private _networkState;
234
+ private _networkStateListeners;
235
+ private _walletAdapter;
236
+ private _loginController;
237
+ constructor(config: PollarClientConfig);
238
+ getAuthState(): AuthState;
239
+ onAuthStateChange(cb: (state: AuthState) => void): () => void;
240
+ login(options: PollarLoginOptions): void;
241
+ beginEmailLogin(): void;
242
+ sendEmailCode(email: string): void;
243
+ verifyEmailCode(code: string): void;
244
+ loginWallet(type: WalletType): void;
245
+ cancelLogin(): void;
246
+ logout(): void;
247
+ getNetwork(): StellarNetwork;
248
+ getNetworkState(): NetworkState;
249
+ setNetwork(network: StellarNetwork): void;
250
+ onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
251
+ getTransactionState(): TransactionState | null;
252
+ onTransactionStateChange(cb: (state: TransactionState) => void): () => void;
253
+ private _setTxHistoryState;
254
+ getTxHistoryState(): TxHistoryState;
255
+ onTxHistoryStateChange(cb: (state: TxHistoryState) => void): () => void;
256
+ fetchTxHistory(params?: TxHistoryParams): Promise<void>;
257
+ getWalletBalance(publicKey?: string): Promise<WalletBalanceContent | null>;
258
+ buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
259
+ signAndSubmitTx(unsignedXdr: string): Promise<void>;
260
+ getAppConfig(): Promise<unknown>;
261
+ getKycStatus(providerId?: string): Promise<{
262
+ status: KycStatus;
263
+ level?: KycLevel | undefined;
264
+ providerId: string;
265
+ expiresAt?: string;
266
+ }>;
267
+ getKycProviders(country: string): Promise<{
268
+ providers: KycProvider[];
269
+ }>;
270
+ startKyc(body: KycStartBody): Promise<KycStartResponse>;
271
+ resolveKyc(providerId: string, level?: KycLevel): Promise<{
272
+ alreadyApproved: boolean;
273
+ } & Partial<{
274
+ sessionId: string;
275
+ kycUrl?: string;
276
+ fields?: {
277
+ name: string;
278
+ type: string;
279
+ required: boolean;
280
+ }[];
281
+ }>>;
282
+ pollKycStatus(providerId: string, opts?: {
283
+ intervalMs?: number;
284
+ timeoutMs?: number;
285
+ }): Promise<KycStatus>;
286
+ getRampsQuote(query: RampsQuoteQuery): Promise<RampsQuoteResponse>;
287
+ createOnRamp(body: RampsOnrampBody): Promise<RampsOnrampResponse>;
288
+ createOffRamp(body: RampsOfframpBody): Promise<RampsOfframpResponse>;
289
+ getRampTransaction(txId: string): Promise<RampsTransactionResponse>;
290
+ pollRampTransaction(txId: string, opts?: {
291
+ intervalMs?: number;
292
+ timeoutMs?: number;
293
+ }): Promise<RampTxStatus>;
294
+ /** Creates a new AbortController, cancelling any existing flow first. */
295
+ private _newController;
296
+ /** Builds the deps object passed to flow functions via bind pattern. */
297
+ private _flowDeps;
298
+ private _handleFlowError;
299
+ private _restoreSession;
300
+ private _storeSession;
301
+ private _clearSession;
302
+ private _networkPassphrase;
303
+ private _setNetworkState;
304
+ private _setAuthState;
305
+ private _setTransactionState;
306
+ }
307
+
3
308
  /**
4
309
  * This file was auto-generated by openapi-typescript.
5
310
  * Do not make direct changes to the file.
@@ -244,8 +549,8 @@ interface paths {
244
549
  get?: never;
245
550
  put?: never;
246
551
  /**
247
- * Submit signed transaction
248
- * @description Submits a signed transaction envelope to the Stellar network.
552
+ * Sign and submit transaction
553
+ * @description Sends an unsigned XDR to the wallet service for signing, then submits the signed transaction to the Stellar network.
249
554
  */
250
555
  post: operations["postTxSignAndSend"];
251
556
  delete?: never;
@@ -274,112 +579,292 @@ interface paths {
274
579
  patch?: never;
275
580
  trace?: never;
276
581
  };
277
- }
278
- interface operations {
279
- getHealth: {
582
+ "/tx/history": {
280
583
  parameters: {
281
584
  query?: never;
282
585
  header?: never;
283
586
  path?: never;
284
587
  cookie?: never;
285
588
  };
286
- requestBody?: never;
287
- responses: {
288
- /** @description Service is healthy */
289
- 200: {
290
- headers: {
291
- [name: string]: unknown;
292
- };
293
- content: {
294
- "application/json": {
295
- /** @constant */
296
- code: "SDK_API_HEALTH_OK";
297
- /** @constant */
298
- success: true;
299
- content: {
300
- /** @constant */
301
- status: "ok";
302
- version: string;
303
- };
304
- };
305
- };
306
- };
307
- };
589
+ /**
590
+ * Get transaction history
591
+ * @description Returns paginated transaction history for the authenticated SDK user. Only includes transactions submitted through Pollar. Transactions appear as PENDING immediately after /tx/build and are updated to SUCCESS or FAILED after /tx/sign-and-send.
592
+ */
593
+ get: operations["getTxHistory"];
594
+ put?: never;
595
+ post?: never;
596
+ delete?: never;
597
+ options?: never;
598
+ head?: never;
599
+ patch?: never;
600
+ trace?: never;
308
601
  };
309
- postAuthSession: {
602
+ "/wallet/balance": {
310
603
  parameters: {
311
604
  query?: never;
312
605
  header?: never;
313
606
  path?: never;
314
607
  cookie?: never;
315
608
  };
316
- requestBody?: never;
317
- responses: {
318
- /** @description Session created */
319
- 201: {
320
- headers: {
321
- [name: string]: unknown;
322
- };
323
- content: {
324
- "application/json": {
325
- /** @constant */
326
- code: "SDK_SESSION_CREATED";
327
- /** @constant */
328
- success: true;
329
- content: {
330
- clientSessionId: string;
331
- };
332
- };
333
- };
334
- };
335
- /** @description Unauthorized */
336
- 401: {
337
- headers: {
338
- [name: string]: unknown;
339
- };
340
- content: {
341
- "application/json": {
342
- /** @constant */
343
- success: false;
344
- error: string;
345
- };
346
- };
347
- };
348
- /** @description Forbidden */
349
- 403: {
350
- headers: {
351
- [name: string]: unknown;
352
- };
353
- content: {
354
- "application/json": {
355
- /** @constant */
356
- success: false;
357
- error: string;
358
- };
359
- };
360
- };
361
- /** @description Not found */
362
- 404: {
363
- headers: {
364
- [name: string]: unknown;
365
- };
366
- content: {
367
- "application/json": {
368
- /** @constant */
369
- success: false;
370
- error: string;
371
- };
372
- };
373
- };
609
+ /**
610
+ * Get wallet balances
611
+ * @description Returns XLM and configured asset balances for a Stellar account using Soroban RPC (no Horizon). The asset list is derived from the application's enabled assets. "available" reflects the spendable amount after minimum reserve (XLM) and selling liabilities.
612
+ */
613
+ get: operations["getWalletBalance"];
614
+ put?: never;
615
+ post?: never;
616
+ delete?: never;
617
+ options?: never;
618
+ head?: never;
619
+ patch?: never;
620
+ trace?: never;
621
+ };
622
+ "/kyc/status": {
623
+ parameters: {
624
+ query?: never;
625
+ header?: never;
626
+ path?: never;
627
+ cookie?: never;
374
628
  };
629
+ /**
630
+ * Get KYC status
631
+ * @description Returns the KYC verification status of the authenticated end-user. Optionally filter by a specific provider. If no providerId is given, returns the first active verification found across all providers configured for the application.
632
+ */
633
+ get: operations["getKycStatus"];
634
+ put?: never;
635
+ post?: never;
636
+ delete?: never;
637
+ options?: never;
638
+ head?: never;
639
+ patch?: never;
640
+ trace?: never;
375
641
  };
376
- getAuthSessionStatusByClientSessionId: {
642
+ "/kyc/providers": {
377
643
  parameters: {
378
644
  query?: never;
379
645
  header?: never;
380
- path: {
381
- clientSessionId: string;
382
- };
646
+ path?: never;
647
+ cookie?: never;
648
+ };
649
+ /**
650
+ * List available KYC providers
651
+ * @description Returns the KYC providers enabled for the application, filtered by the given country (ISO 3166-1 alpha-2). Use this to show the user which KYC options are available before calling POST /kyc/start.
652
+ */
653
+ get: operations["getKycProviders"];
654
+ put?: never;
655
+ post?: never;
656
+ delete?: never;
657
+ options?: never;
658
+ head?: never;
659
+ patch?: never;
660
+ trace?: never;
661
+ };
662
+ "/kyc/start": {
663
+ parameters: {
664
+ query?: never;
665
+ header?: never;
666
+ path?: never;
667
+ cookie?: never;
668
+ };
669
+ get?: never;
670
+ put?: never;
671
+ /**
672
+ * Start a KYC session
673
+ * @description Initiates a KYC verification session with the specified provider and level. Returns a sessionId and either a kycUrl (for iframe/redirect flows) or a fields array (for form flows). The session expires in 30 minutes.
674
+ */
675
+ post: operations["postKycStart"];
676
+ delete?: never;
677
+ options?: never;
678
+ head?: never;
679
+ patch?: never;
680
+ trace?: never;
681
+ };
682
+ "/ramps/quote": {
683
+ parameters: {
684
+ query?: never;
685
+ header?: never;
686
+ path?: never;
687
+ cookie?: never;
688
+ };
689
+ /**
690
+ * Get ramp quotes
691
+ * @description Returns available quotes for converting fiat to crypto (onramp) or crypto to fiat (offramp) for a given country, amount, and currency. Each quote includes a quoteId valid for 15 minutes. Pass the quoteId to POST /ramps/onramp or POST /ramps/offramp to execute the transaction.
692
+ */
693
+ get: operations["getRampsQuote"];
694
+ put?: never;
695
+ post?: never;
696
+ delete?: never;
697
+ options?: never;
698
+ head?: never;
699
+ patch?: never;
700
+ trace?: never;
701
+ };
702
+ "/ramps/onramp": {
703
+ parameters: {
704
+ query?: never;
705
+ header?: never;
706
+ path?: never;
707
+ cookie?: never;
708
+ };
709
+ get?: never;
710
+ put?: never;
711
+ /**
712
+ * Create onramp transaction
713
+ * @description Initiates a fiat-to-crypto onramp transaction using a previously obtained quoteId. Returns payment instructions (CLABE, PIX key, etc.) the user must use to send funds. The quote expires in 15 minutes — a new one must be requested after expiry.
714
+ */
715
+ post: operations["postRampsOnramp"];
716
+ delete?: never;
717
+ options?: never;
718
+ head?: never;
719
+ patch?: never;
720
+ trace?: never;
721
+ };
722
+ "/ramps/offramp": {
723
+ parameters: {
724
+ query?: never;
725
+ header?: never;
726
+ path?: never;
727
+ cookie?: never;
728
+ };
729
+ get?: never;
730
+ put?: never;
731
+ /**
732
+ * Create offramp transaction
733
+ * @description Initiates a crypto-to-fiat offramp transaction using a previously obtained quoteId. Funds will be sent from the user's wallet to the provided bank account. The quote expires in 15 minutes.
734
+ */
735
+ post: operations["postRampsOfframp"];
736
+ delete?: never;
737
+ options?: never;
738
+ head?: never;
739
+ patch?: never;
740
+ trace?: never;
741
+ };
742
+ "/ramps/transaction/{txId}": {
743
+ parameters: {
744
+ query?: never;
745
+ header?: never;
746
+ path?: never;
747
+ cookie?: never;
748
+ };
749
+ /**
750
+ * Get ramp transaction status
751
+ * @description Returns the current status of an onramp or offramp transaction. Use this endpoint to poll for status updates. Only the authenticated user who created the transaction can access it.
752
+ */
753
+ get: operations["getRampsTransactionByTxId"];
754
+ put?: never;
755
+ post?: never;
756
+ delete?: never;
757
+ options?: never;
758
+ head?: never;
759
+ patch?: never;
760
+ trace?: never;
761
+ };
762
+ }
763
+ interface operations {
764
+ getHealth: {
765
+ parameters: {
766
+ query?: never;
767
+ header?: never;
768
+ path?: never;
769
+ cookie?: never;
770
+ };
771
+ requestBody?: never;
772
+ responses: {
773
+ /** @description Service is healthy */
774
+ 200: {
775
+ headers: {
776
+ [name: string]: unknown;
777
+ };
778
+ content: {
779
+ "application/json": {
780
+ /** @constant */
781
+ code: "SDK_API_HEALTH_OK";
782
+ /** @constant */
783
+ success: true;
784
+ content: {
785
+ /** @constant */
786
+ status: "ok";
787
+ version: string;
788
+ };
789
+ };
790
+ };
791
+ };
792
+ };
793
+ };
794
+ postAuthSession: {
795
+ parameters: {
796
+ query?: never;
797
+ header?: never;
798
+ path?: never;
799
+ cookie?: never;
800
+ };
801
+ requestBody?: never;
802
+ responses: {
803
+ /** @description Session created */
804
+ 201: {
805
+ headers: {
806
+ [name: string]: unknown;
807
+ };
808
+ content: {
809
+ "application/json": {
810
+ /** @constant */
811
+ code: "SDK_SESSION_CREATED";
812
+ /** @constant */
813
+ success: true;
814
+ content: {
815
+ clientSessionId: string;
816
+ };
817
+ };
818
+ };
819
+ };
820
+ /** @description Unauthorized */
821
+ 401: {
822
+ headers: {
823
+ [name: string]: unknown;
824
+ };
825
+ content: {
826
+ "application/json": {
827
+ /** @constant */
828
+ success: false;
829
+ error: string;
830
+ };
831
+ };
832
+ };
833
+ /** @description Forbidden */
834
+ 403: {
835
+ headers: {
836
+ [name: string]: unknown;
837
+ };
838
+ content: {
839
+ "application/json": {
840
+ /** @constant */
841
+ success: false;
842
+ error: string;
843
+ };
844
+ };
845
+ };
846
+ /** @description Not found */
847
+ 404: {
848
+ headers: {
849
+ [name: string]: unknown;
850
+ };
851
+ content: {
852
+ "application/json": {
853
+ /** @constant */
854
+ success: false;
855
+ error: string;
856
+ };
857
+ };
858
+ };
859
+ };
860
+ };
861
+ getAuthSessionStatusByClientSessionId: {
862
+ parameters: {
863
+ query?: never;
864
+ header?: never;
865
+ path: {
866
+ clientSessionId: string;
867
+ };
383
868
  cookie?: never;
384
869
  };
385
870
  requestBody?: never;
@@ -576,7 +1061,7 @@ interface operations {
576
1061
  path?: never;
577
1062
  cookie?: never;
578
1063
  };
579
- requestBody?: {
1064
+ requestBody: {
580
1065
  content: {
581
1066
  "application/json": {
582
1067
  clientSessionId: string;
@@ -665,7 +1150,7 @@ interface operations {
665
1150
  path?: never;
666
1151
  cookie?: never;
667
1152
  };
668
- requestBody?: {
1153
+ requestBody: {
669
1154
  content: {
670
1155
  "application/json": {
671
1156
  clientSessionId: string;
@@ -752,7 +1237,7 @@ interface operations {
752
1237
  path?: never;
753
1238
  cookie?: never;
754
1239
  };
755
- requestBody?: {
1240
+ requestBody: {
756
1241
  content: {
757
1242
  "application/json": {
758
1243
  clientSessionId: string;
@@ -840,7 +1325,7 @@ interface operations {
840
1325
  path?: never;
841
1326
  cookie?: never;
842
1327
  };
843
- requestBody?: {
1328
+ requestBody: {
844
1329
  content: {
845
1330
  "application/json": {
846
1331
  clientSessionId: string;
@@ -1080,12 +1565,26 @@ interface operations {
1080
1565
  path?: never;
1081
1566
  cookie?: never;
1082
1567
  };
1083
- requestBody?: {
1568
+ requestBody: {
1084
1569
  content: {
1085
1570
  "application/json": {
1086
1571
  /** @enum {string} */
1087
- network: "testnet" | "public";
1572
+ network: "testnet" | "mainnet";
1088
1573
  publicKey: string;
1574
+ options?: {
1575
+ timeoutSec?: number;
1576
+ memo?: {
1577
+ /** @constant */
1578
+ type: "text";
1579
+ value: string;
1580
+ } | {
1581
+ /** @constant */
1582
+ type: "id";
1583
+ value: string;
1584
+ };
1585
+ maxFeeStroops?: number;
1586
+ };
1587
+ } & ({
1089
1588
  /** @constant */
1090
1589
  operation: "payment";
1091
1590
  params: {
@@ -1099,43 +1598,196 @@ interface operations {
1099
1598
  type: "credit_alphanum4";
1100
1599
  code: string;
1101
1600
  issuer: string;
1601
+ } | {
1602
+ /** @constant */
1603
+ type: "credit_alphanum12";
1604
+ code: string;
1605
+ issuer: string;
1102
1606
  };
1103
1607
  };
1104
- options?: {
1105
- timeoutSec?: number;
1106
- memo?: {
1608
+ } | {
1609
+ /** @constant */
1610
+ operation: "change_trust";
1611
+ params: {
1612
+ asset: {
1107
1613
  /** @constant */
1108
- type: "text";
1109
- value: string;
1614
+ type: "credit_alphanum4";
1615
+ code: string;
1616
+ issuer: string;
1110
1617
  } | {
1111
1618
  /** @constant */
1112
- type: "id";
1113
- value: string;
1619
+ type: "credit_alphanum12";
1620
+ code: string;
1621
+ issuer: string;
1622
+ } | {
1623
+ /** @constant */
1624
+ type: "liquidity_pool_shares";
1625
+ assetA: {
1626
+ /** @constant */
1627
+ type: "native";
1628
+ } | {
1629
+ /** @constant */
1630
+ type: "credit_alphanum4";
1631
+ code: string;
1632
+ issuer: string;
1633
+ } | {
1634
+ /** @constant */
1635
+ type: "credit_alphanum12";
1636
+ code: string;
1637
+ issuer: string;
1638
+ };
1639
+ assetB: {
1640
+ /** @constant */
1641
+ type: "native";
1642
+ } | {
1643
+ /** @constant */
1644
+ type: "credit_alphanum4";
1645
+ code: string;
1646
+ issuer: string;
1647
+ } | {
1648
+ /** @constant */
1649
+ type: "credit_alphanum12";
1650
+ code: string;
1651
+ issuer: string;
1652
+ };
1114
1653
  };
1654
+ limit?: string;
1115
1655
  };
1116
- };
1117
- };
1118
- };
1119
- responses: {
1120
- /** @description Unsigned XDR and summary */
1121
- 200: {
1122
- headers: {
1123
- [name: string]: unknown;
1124
- };
1125
- content: {
1126
- "application/json": {
1127
- /** @constant */
1128
- code: "SDK_TX_BUILT";
1129
- /** @constant */
1130
- success: true;
1131
- content: {
1132
- unsignedXdr: string;
1133
- networkPassphrase: string;
1134
- estimatedFee: string;
1135
- summary: {
1136
- title: string;
1137
- lines: string[];
1138
- network: string;
1656
+ } | {
1657
+ /** @constant */
1658
+ operation: "path_payment_strict_send";
1659
+ params: {
1660
+ destination: string;
1661
+ sendAsset: {
1662
+ /** @constant */
1663
+ type: "native";
1664
+ } | {
1665
+ /** @constant */
1666
+ type: "credit_alphanum4";
1667
+ code: string;
1668
+ issuer: string;
1669
+ } | {
1670
+ /** @constant */
1671
+ type: "credit_alphanum12";
1672
+ code: string;
1673
+ issuer: string;
1674
+ };
1675
+ sendAmount: string;
1676
+ destAsset: {
1677
+ /** @constant */
1678
+ type: "native";
1679
+ } | {
1680
+ /** @constant */
1681
+ type: "credit_alphanum4";
1682
+ code: string;
1683
+ issuer: string;
1684
+ } | {
1685
+ /** @constant */
1686
+ type: "credit_alphanum12";
1687
+ code: string;
1688
+ issuer: string;
1689
+ };
1690
+ destMin: string;
1691
+ /** @default [] */
1692
+ path?: ({
1693
+ /** @constant */
1694
+ type: "native";
1695
+ } | {
1696
+ /** @constant */
1697
+ type: "credit_alphanum4";
1698
+ code: string;
1699
+ issuer: string;
1700
+ } | {
1701
+ /** @constant */
1702
+ type: "credit_alphanum12";
1703
+ code: string;
1704
+ issuer: string;
1705
+ })[];
1706
+ };
1707
+ } | {
1708
+ /** @constant */
1709
+ operation: "create_account";
1710
+ params: {
1711
+ destination: string;
1712
+ startingBalance: string;
1713
+ };
1714
+ } | {
1715
+ /** @constant */
1716
+ operation: "invoke_contract";
1717
+ params: {
1718
+ contractId: string;
1719
+ method: string;
1720
+ /** @default [] */
1721
+ args?: ({
1722
+ /** @constant */
1723
+ type: "bool";
1724
+ value: boolean;
1725
+ } | {
1726
+ /** @constant */
1727
+ type: "i32";
1728
+ value: number;
1729
+ } | {
1730
+ /** @constant */
1731
+ type: "u32";
1732
+ value: number;
1733
+ } | {
1734
+ /** @enum {string} */
1735
+ type: "i64" | "u64" | "i128" | "u128" | "i256" | "u256";
1736
+ value: string;
1737
+ } | {
1738
+ /** @constant */
1739
+ type: "address";
1740
+ value: string;
1741
+ } | {
1742
+ /** @enum {string} */
1743
+ type: "string" | "symbol";
1744
+ value: string;
1745
+ } | {
1746
+ /** @constant */
1747
+ type: "bytes";
1748
+ /** @description Base64-encoded bytes */
1749
+ value: string;
1750
+ } | {
1751
+ /** @constant */
1752
+ type: "vec";
1753
+ /** @description Array of ScValArg items */
1754
+ value: unknown[];
1755
+ } | {
1756
+ /** @constant */
1757
+ type: "map";
1758
+ /** @description Array of {key, val} ScValArg pairs */
1759
+ value: {
1760
+ key: unknown;
1761
+ val: unknown;
1762
+ }[];
1763
+ } | {
1764
+ /** @constant */
1765
+ type: "void";
1766
+ })[];
1767
+ };
1768
+ });
1769
+ };
1770
+ };
1771
+ responses: {
1772
+ /** @description Unsigned XDR and summary */
1773
+ 200: {
1774
+ headers: {
1775
+ [name: string]: unknown;
1776
+ };
1777
+ content: {
1778
+ "application/json": {
1779
+ /** @constant */
1780
+ code: "SDK_TX_BUILT";
1781
+ /** @constant */
1782
+ success: true;
1783
+ content: {
1784
+ unsignedXdr: string;
1785
+ networkPassphrase: string;
1786
+ estimatedFee: string;
1787
+ summary: {
1788
+ title: string;
1789
+ lines: string[];
1790
+ network: string;
1139
1791
  fee: string;
1140
1792
  };
1141
1793
  };
@@ -1190,12 +1842,13 @@ interface operations {
1190
1842
  path?: never;
1191
1843
  cookie?: never;
1192
1844
  };
1193
- requestBody?: {
1845
+ requestBody: {
1194
1846
  content: {
1195
1847
  "application/json": {
1196
1848
  /** @enum {string} */
1197
- network: "testnet" | "public";
1198
- signedXdr: string;
1849
+ network: "testnet" | "mainnet";
1850
+ publicKey: string;
1851
+ unsignedXdr: string;
1199
1852
  };
1200
1853
  };
1201
1854
  };
@@ -1252,7 +1905,7 @@ interface operations {
1252
1905
  getTxStatus: {
1253
1906
  parameters: {
1254
1907
  query: {
1255
- network: "testnet" | "public";
1908
+ network: "testnet" | "mainnet";
1256
1909
  hash: string;
1257
1910
  };
1258
1911
  header?: never;
@@ -1311,263 +1964,772 @@ interface operations {
1311
1964
  };
1312
1965
  };
1313
1966
  };
1314
- }
1315
-
1316
- type PollarApiClient = ReturnType<typeof createApiClient>;
1317
- declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
1318
-
1319
- declare const StateStatus: {
1320
- readonly NONE: "NONE";
1321
- readonly LOADING: "LOADING";
1322
- readonly SUCCESS: "SUCCESS";
1323
- readonly ERROR: "ERROR";
1324
- };
1325
- type StateStatus = (typeof StateStatus)[keyof typeof StateStatus];
1326
- declare const PollarStateVar: {
1327
- readonly NETWORK: "network";
1328
- readonly AUTHENTICATION: "authentication";
1329
- readonly TRANSACTION: "transaction";
1330
- };
1331
- type PollarStateVar = (typeof PollarStateVar)[keyof typeof PollarStateVar];
1332
- declare const STATE_VAR_CODES: {
1333
- readonly authentication: {
1334
- readonly NONE: "NONE";
1335
- readonly LOGOUT: "LOGOUT";
1336
- readonly CREATE_SESSION_START: "CREATE_SESSION_START";
1337
- readonly CREATE_SESSION_ERROR: "CREATE_SESSION_ERROR";
1338
- readonly CREATE_SESSION_SUCCESS: "CREATE_SESSION_SUCCESS";
1339
- readonly EMAIL_AUTH_START: "EMAIL_AUTH_START";
1340
- readonly EMAIL_AUTH_START_ERROR: "EMAIL_AUTH_START_ERROR";
1341
- readonly EMAIL_AUTH_START_SUCCESS: "EMAIL_AUTH_START_SUCCESS";
1342
- readonly EMAIL_AUTH_CODE_ERROR: "EMAIL_AUTH_CODE_ERROR";
1343
- readonly EMAIL_AUTH_CODE_SUCCESS: "EMAIL_AUTH_CODE_SUCCESS";
1344
- readonly WALLET_AUTH_START: "WALLET_AUTH_START";
1345
- readonly WALLET_AUTH_FREIGHTER_NOT_INSTALLED: "WALLET_AUTH_FREIGHTER_NOT_INSTALLED";
1346
- readonly WALLET_AUTH_ALBEDO_NOT_INSTALLED: "WALLET_AUTH_ALBEDO_NOT_INSTALLED";
1347
- readonly WALLET_AUTH_CONNECTED: "WALLET_AUTH_CONNECTED";
1348
- readonly WALLET_AUTH_LOGIN_START: "WALLET_AUTH_LOGIN_START";
1349
- readonly WALLET_AUTH_LOGIN_START_SUCCESS: "WALLET_AUTH_LOGIN_START_SUCCESS";
1350
- readonly WALLET_AUTH_LOGIN_START_ERROR: "WALLET_AUTH_LOGIN_START_ERROR";
1351
- readonly WALLET_AUTH_ERROR: "WALLET_AUTH_ERROR";
1352
- readonly STREAM_POLL_START: "STREAM_POLL_START";
1353
- readonly STREAM_POLL_EVENT: "STREAM_POLL_EVENT";
1354
- readonly STREAM_POLL_READY: "STREAM_POLL_READY";
1355
- readonly FETCH_SESSION_START: "FETCH_SESSION_START";
1356
- readonly FETCH_SESSION_SUCCESS: "FETCH_SESSION_SUCCESS";
1357
- readonly FETCH_SESSION_ERROR: "FETCH_SESSION_ERROR";
1358
- readonly NO_RESTORED_SESSION: "NO_RESTORED_SESSION";
1359
- readonly RESTORED_SESSION_SUCCESS: "RESTORED_SESSION_SUCCESS";
1360
- readonly RESTORED_SESSION_ERROR: "RESTORED_SESSION_ERROR";
1361
- readonly SESSION_STORED: "SESSION_STORED";
1362
- readonly ERROR_ABORTED: "ABORTED";
1363
- readonly ERROR_UNKNOWN: "ERROR_UNKNOWN";
1364
- };
1365
- readonly walletAddress: {
1366
- readonly NONE: "NONE";
1367
- readonly REMOVED_ADDRESS: "REMOVED_ADDRESS";
1368
- readonly UPDATED_ADDRESS: "UPDATED_ADDRESS";
1369
- };
1370
- readonly transaction: {
1371
- readonly NONE: "NONE";
1372
- readonly BUILD_TRANSACTION_ERROR_NO_WALLET: "BUILD_TRANSACTION_ERROR_NO_WALLET";
1373
- readonly BUILD_TRANSACTION_START: "BUILD_TRANSACTION_START";
1374
- readonly BUILD_TRANSACTION_SUCCESS: "BUILD_TRANSACTION_SUCCESS";
1375
- readonly BUILD_TRANSACTION_ERROR: "BUILD_TRANSACTION_ERROR";
1376
- readonly SIGN_SEND_TRANSACTION_START: "SIGN_SEND_TRANSACTION_START";
1377
- readonly SIGN_SEND_TRANSACTION_SUCCESS: "SIGN_SEND_TRANSACTION_SUCCESS";
1378
- readonly SIGN_SEND_TRANSACTION_ERROR: "SIGN_SEND_TRANSACTION_ERROR";
1967
+ getTxHistory: {
1968
+ parameters: {
1969
+ query?: {
1970
+ network?: "testnet" | "mainnet";
1971
+ limit?: number;
1972
+ offset?: number;
1973
+ };
1974
+ header?: never;
1975
+ path?: never;
1976
+ cookie?: never;
1977
+ };
1978
+ requestBody?: never;
1979
+ responses: {
1980
+ /** @description Paginated list of transactions */
1981
+ 200: {
1982
+ headers: {
1983
+ [name: string]: unknown;
1984
+ };
1985
+ content: {
1986
+ "application/json": {
1987
+ /** @constant */
1988
+ code: "SDK_TX_HISTORY";
1989
+ /** @constant */
1990
+ success: true;
1991
+ content: {
1992
+ records: {
1993
+ id: string;
1994
+ hash: string;
1995
+ /** @enum {string} */
1996
+ network: "testnet" | "mainnet";
1997
+ /** @enum {string} */
1998
+ status: "PENDING" | "SUCCESS" | "FAILED";
1999
+ operation: string;
2000
+ feeXlm?: string;
2001
+ resultCode?: string;
2002
+ details: {
2003
+ [key: string]: unknown;
2004
+ };
2005
+ summary: string;
2006
+ createdAt: string;
2007
+ }[];
2008
+ total: number;
2009
+ limit: number;
2010
+ offset: number;
2011
+ };
2012
+ };
2013
+ };
2014
+ };
2015
+ /** @description Validation error */
2016
+ 400: {
2017
+ headers: {
2018
+ [name: string]: unknown;
2019
+ };
2020
+ content: {
2021
+ "application/json": {
2022
+ /** @constant */
2023
+ success: false;
2024
+ error: string;
2025
+ };
2026
+ };
2027
+ };
2028
+ /** @description Unauthorized */
2029
+ 401: {
2030
+ headers: {
2031
+ [name: string]: unknown;
2032
+ };
2033
+ content: {
2034
+ "application/json": {
2035
+ /** @constant */
2036
+ success: false;
2037
+ error: string;
2038
+ };
2039
+ };
2040
+ };
2041
+ };
1379
2042
  };
1380
- readonly network: {
1381
- readonly NONE: "NONE";
1382
- readonly NETWORK_UPDATED: "NETWORK_UPDATED";
2043
+ getWalletBalance: {
2044
+ parameters: {
2045
+ query: {
2046
+ network: "testnet" | "mainnet";
2047
+ publicKey: string;
2048
+ };
2049
+ header?: never;
2050
+ path?: never;
2051
+ cookie?: never;
2052
+ };
2053
+ requestBody?: never;
2054
+ responses: {
2055
+ /** @description Account balances */
2056
+ 200: {
2057
+ headers: {
2058
+ [name: string]: unknown;
2059
+ };
2060
+ content: {
2061
+ "application/json": {
2062
+ /** @constant */
2063
+ code: "SDK_WALLET_BALANCE";
2064
+ /** @constant */
2065
+ success: true;
2066
+ content: {
2067
+ publicKey: string;
2068
+ /** @enum {string} */
2069
+ network: "testnet" | "mainnet";
2070
+ exists: boolean;
2071
+ balances: {
2072
+ /** @enum {string} */
2073
+ type: "native" | "credit_alphanum4" | "credit_alphanum12";
2074
+ code: string;
2075
+ issuer?: string;
2076
+ balance: string;
2077
+ available: string;
2078
+ limit?: string;
2079
+ }[];
2080
+ };
2081
+ };
2082
+ };
2083
+ };
2084
+ /** @description Validation error */
2085
+ 400: {
2086
+ headers: {
2087
+ [name: string]: unknown;
2088
+ };
2089
+ content: {
2090
+ "application/json": {
2091
+ /** @constant */
2092
+ success: false;
2093
+ error: string;
2094
+ };
2095
+ };
2096
+ };
2097
+ /** @description Unauthorized */
2098
+ 401: {
2099
+ headers: {
2100
+ [name: string]: unknown;
2101
+ };
2102
+ content: {
2103
+ "application/json": {
2104
+ /** @constant */
2105
+ success: false;
2106
+ error: string;
2107
+ };
2108
+ };
2109
+ };
2110
+ };
1383
2111
  };
1384
- };
1385
-
1386
- declare enum WalletType {
1387
- FREIGHTER = "freighter",
1388
- ALBEDO = "albedo"
1389
- }
1390
- interface ConnectWalletResponse {
1391
- address: string;
1392
- publicKey: string;
1393
- }
1394
- interface SignTransactionOptions {
1395
- network?: string;
1396
- networkPassphrase?: string;
1397
- accountToSign?: string;
1398
- }
1399
- interface SignAuthEntryOptions {
1400
- accountToSign?: string;
1401
- }
1402
- interface SignTransactionResponse {
1403
- signedTxXdr: string;
1404
- }
1405
- interface SignAuthEntryResponse {
1406
- signedAuthEntry: string;
1407
- }
1408
- interface WalletAdapter {
1409
- type: WalletType;
1410
- isAvailable(): Promise<boolean>;
1411
- connect(): Promise<ConnectWalletResponse>;
1412
- disconnect(): Promise<void>;
1413
- getPublicKey(): Promise<string | null>;
1414
- signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
1415
- signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
1416
- }
1417
-
1418
- declare class FreighterAdapter implements WalletAdapter {
1419
- readonly type = WalletType.FREIGHTER;
1420
- isAvailable(): Promise<boolean>;
1421
- connect(): Promise<ConnectWalletResponse>;
1422
- disconnect(): Promise<void>;
1423
- getPublicKey(): Promise<string | null>;
1424
- getNetwork(): Promise<string>;
1425
- signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse>;
1426
- signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
1427
- }
1428
-
1429
- declare class AlbedoAdapter implements WalletAdapter {
1430
- readonly type = WalletType.ALBEDO;
1431
- isAvailable(): Promise<boolean>;
1432
- connect(): Promise<ConnectWalletResponse>;
1433
- disconnect(): Promise<void>;
1434
- getPublicKey(): Promise<string | null>;
1435
- getNetwork(): Promise<string>;
1436
- signTransaction(xdr: string, _options?: SignTransactionOptions): Promise<SignTransactionResponse>;
1437
- signAuthEntry(entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
1438
- }
1439
-
1440
- type PollarApplicationConfigResponse = paths['/auth/login']['post']['responses'][200]['content']['application/json'];
1441
- type PollarApplicationConfigContent = PollarApplicationConfigResponse['content'];
1442
- interface PollarClientConfig {
1443
- stellarNetwork?: StellarNetwork;
1444
- baseUrl?: string;
1445
- apiKey: string;
1446
- }
1447
- type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
1448
- type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
1449
- type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
1450
- type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
1451
- type PollarLoginOptions = {
1452
- provider: 'google';
1453
- } | {
1454
- provider: 'github';
1455
- } | {
1456
- provider: 'email';
1457
- email: string;
1458
- } | {
1459
- provider: 'wallet';
1460
- type: WalletType;
1461
- };
1462
- type NetworkCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK];
1463
- type StateNetworkCodes = NetworkCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK]];
1464
- type AuthenticationCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION];
1465
- type StateAuthenticationCodes = AuthenticationCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION]];
1466
- type TransactionCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION];
1467
- type StateTransactionCodes = TransactionCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION]];
1468
- type StateVarCodes = StateNetworkCodes | StateAuthenticationCodes | StateTransactionCodes;
1469
- interface PollarStateEntry {
1470
- var: PollarStateVar;
1471
- code: StateVarCodes;
1472
- status: StateStatus;
1473
- level: 'info' | 'warn' | 'error';
1474
- data?: unknown;
1475
- ts: number;
1476
- }
1477
- type PollarState = {
1478
- [key in PollarStateVar]: PollarStateEntry[];
1479
- };
1480
-
1481
- declare class PollarClient {
1482
- readonly apiKey: string;
1483
- readonly id: string;
1484
- readonly basePath: string;
1485
- private readonly _api;
1486
- private _session;
1487
- private _stateListeners;
1488
- private _state;
1489
- constructor(config: PollarClientConfig);
1490
- isAuthenticated(): boolean;
1491
- getState(): {
1492
- session: {
1493
- clientSessionId: string;
1494
- userId: string | null;
1495
- status: string;
1496
- token: {
1497
- accessToken: string;
1498
- refreshToken: string;
1499
- expiresAt: number;
1500
- };
1501
- user: {
1502
- id?: string;
1503
- ready: boolean;
1504
- };
1505
- wallet: {
1506
- publicKey: string | null;
1507
- existsOnStellar?: boolean;
1508
- createdAt?: number;
1509
- };
1510
- data: {
1511
- mail: string;
1512
- first_name: string;
1513
- last_name: string;
1514
- avatar: string;
1515
- providers: {
1516
- email: {
1517
- address: string;
1518
- } | null;
1519
- google: {
1520
- id: string;
1521
- } | null;
1522
- github: {
1523
- id: string;
1524
- } | null;
1525
- wallet: {
1526
- address: string;
1527
- } | null;
1528
- };
1529
- };
1530
- } | null;
2112
+ getKycStatus: {
2113
+ parameters: {
2114
+ query?: {
2115
+ providerId?: string;
2116
+ };
2117
+ header?: never;
2118
+ path?: never;
2119
+ cookie?: never;
2120
+ };
2121
+ requestBody?: never;
2122
+ responses: {
2123
+ /** @description KYC status for the authenticated user */
2124
+ 200: {
2125
+ headers: {
2126
+ [name: string]: unknown;
2127
+ };
2128
+ content: {
2129
+ "application/json": {
2130
+ /** @constant */
2131
+ code: "SDK_KYC_STATUS";
2132
+ /** @constant */
2133
+ success: true;
2134
+ content: {
2135
+ /** @enum {string} */
2136
+ status: "none" | "pending" | "approved" | "rejected";
2137
+ /** @enum {string} */
2138
+ level?: "basic" | "intermediate" | "enhanced";
2139
+ providerId: string;
2140
+ expiresAt?: string;
2141
+ };
2142
+ };
2143
+ };
2144
+ };
2145
+ /** @description Validation error */
2146
+ 400: {
2147
+ headers: {
2148
+ [name: string]: unknown;
2149
+ };
2150
+ content: {
2151
+ "application/json": {
2152
+ /** @constant */
2153
+ success: false;
2154
+ error: string;
2155
+ };
2156
+ };
2157
+ };
2158
+ /** @description Unauthorized */
2159
+ 401: {
2160
+ headers: {
2161
+ [name: string]: unknown;
2162
+ };
2163
+ content: {
2164
+ "application/json": {
2165
+ /** @constant */
2166
+ success: false;
2167
+ error: string;
2168
+ };
2169
+ };
2170
+ };
2171
+ /** @description Not found */
2172
+ 404: {
2173
+ headers: {
2174
+ [name: string]: unknown;
2175
+ };
2176
+ content: {
2177
+ "application/json": {
2178
+ /** @constant */
2179
+ success: false;
2180
+ error: string;
2181
+ };
2182
+ };
2183
+ };
2184
+ };
2185
+ };
2186
+ getKycProviders: {
2187
+ parameters: {
2188
+ query: {
2189
+ country: string;
2190
+ };
2191
+ header?: never;
2192
+ path?: never;
2193
+ cookie?: never;
2194
+ };
2195
+ requestBody?: never;
2196
+ responses: {
2197
+ /** @description List of KYC providers available for the country */
2198
+ 200: {
2199
+ headers: {
2200
+ [name: string]: unknown;
2201
+ };
2202
+ content: {
2203
+ "application/json": {
2204
+ /** @constant */
2205
+ code: "SDK_KYC_PROVIDERS";
2206
+ /** @constant */
2207
+ success: true;
2208
+ content: {
2209
+ providers: {
2210
+ id: string;
2211
+ name: string;
2212
+ /** @enum {string} */
2213
+ flow: "iframe" | "form" | "redirect";
2214
+ levels: ("basic" | "intermediate" | "enhanced")[];
2215
+ }[];
2216
+ };
2217
+ };
2218
+ };
2219
+ };
2220
+ /** @description Validation error */
2221
+ 400: {
2222
+ headers: {
2223
+ [name: string]: unknown;
2224
+ };
2225
+ content: {
2226
+ "application/json": {
2227
+ /** @constant */
2228
+ success: false;
2229
+ error: string;
2230
+ };
2231
+ };
2232
+ };
2233
+ /** @description Unauthorized */
2234
+ 401: {
2235
+ headers: {
2236
+ [name: string]: unknown;
2237
+ };
2238
+ content: {
2239
+ "application/json": {
2240
+ /** @constant */
2241
+ success: false;
2242
+ error: string;
2243
+ };
2244
+ };
2245
+ };
2246
+ };
2247
+ };
2248
+ postKycStart: {
2249
+ parameters: {
2250
+ query?: never;
2251
+ header?: never;
2252
+ path?: never;
2253
+ cookie?: never;
2254
+ };
2255
+ requestBody: {
2256
+ content: {
2257
+ "application/json": {
2258
+ providerId: string;
2259
+ /** @enum {string} */
2260
+ level: "basic" | "intermediate" | "enhanced";
2261
+ };
2262
+ };
2263
+ };
2264
+ responses: {
2265
+ /** @description KYC session created */
2266
+ 200: {
2267
+ headers: {
2268
+ [name: string]: unknown;
2269
+ };
2270
+ content: {
2271
+ "application/json": {
2272
+ /** @constant */
2273
+ code: "SDK_KYC_STARTED";
2274
+ /** @constant */
2275
+ success: true;
2276
+ content: {
2277
+ sessionId: string;
2278
+ kycUrl?: string;
2279
+ fields?: {
2280
+ name: string;
2281
+ type: string;
2282
+ required: boolean;
2283
+ }[];
2284
+ };
2285
+ };
2286
+ };
2287
+ };
2288
+ /** @description Validation error */
2289
+ 400: {
2290
+ headers: {
2291
+ [name: string]: unknown;
2292
+ };
2293
+ content: {
2294
+ "application/json": {
2295
+ /** @constant */
2296
+ success: false;
2297
+ error: string;
2298
+ };
2299
+ };
2300
+ };
2301
+ /** @description Unauthorized */
2302
+ 401: {
2303
+ headers: {
2304
+ [name: string]: unknown;
2305
+ };
2306
+ content: {
2307
+ "application/json": {
2308
+ /** @constant */
2309
+ success: false;
2310
+ error: string;
2311
+ };
2312
+ };
2313
+ };
2314
+ /** @description Provider not found or not enabled for this application */
2315
+ 404: {
2316
+ headers: {
2317
+ [name: string]: unknown;
2318
+ };
2319
+ content: {
2320
+ "application/json": {
2321
+ /** @constant */
2322
+ success: false;
2323
+ error: string;
2324
+ };
2325
+ };
2326
+ };
2327
+ };
2328
+ };
2329
+ getRampsQuote: {
2330
+ parameters: {
2331
+ query: {
2332
+ country: string;
2333
+ amount: number;
2334
+ currency: string;
2335
+ direction: "onramp" | "offramp";
2336
+ };
2337
+ header?: never;
2338
+ path?: never;
2339
+ cookie?: never;
2340
+ };
2341
+ requestBody?: never;
2342
+ responses: {
2343
+ /** @description List of available quotes sorted by recommendation. First item is the best option. */
2344
+ 200: {
2345
+ headers: {
2346
+ [name: string]: unknown;
2347
+ };
2348
+ content: {
2349
+ "application/json": {
2350
+ /** @constant */
2351
+ code: "SDK_RAMPS_QUOTES";
2352
+ /** @constant */
2353
+ success: true;
2354
+ content: {
2355
+ quotes: {
2356
+ quoteId: string;
2357
+ provider: string;
2358
+ fee: number;
2359
+ feeCurrency: string;
2360
+ rate: number;
2361
+ /** @enum {string} */
2362
+ rail: "SPEI" | "PIX" | "PSE" | "ACH";
2363
+ /** @enum {string} */
2364
+ protocol: "SEP-24" | "REST";
2365
+ estimatedTime: string;
2366
+ recommended: boolean;
2367
+ }[];
2368
+ };
2369
+ };
2370
+ };
2371
+ };
2372
+ /** @description Validation error */
2373
+ 400: {
2374
+ headers: {
2375
+ [name: string]: unknown;
2376
+ };
2377
+ content: {
2378
+ "application/json": {
2379
+ /** @constant */
2380
+ success: false;
2381
+ error: string;
2382
+ };
2383
+ };
2384
+ };
2385
+ /** @description Unauthorized */
2386
+ 401: {
2387
+ headers: {
2388
+ [name: string]: unknown;
2389
+ };
2390
+ content: {
2391
+ "application/json": {
2392
+ /** @constant */
2393
+ success: false;
2394
+ error: string;
2395
+ };
2396
+ };
2397
+ };
2398
+ };
1531
2399
  };
1532
- getApi(): PollarApiClient;
1533
- login(options: PollarLoginOptions): {
1534
- cancelLogin: () => void;
2400
+ postRampsOnramp: {
2401
+ parameters: {
2402
+ query?: never;
2403
+ header?: never;
2404
+ path?: never;
2405
+ cookie?: never;
2406
+ };
2407
+ requestBody: {
2408
+ content: {
2409
+ "application/json": {
2410
+ quoteId: string;
2411
+ amount: number;
2412
+ currency: string;
2413
+ country: string;
2414
+ walletAddress: string;
2415
+ };
2416
+ };
2417
+ };
2418
+ responses: {
2419
+ /** @description Onramp transaction created with payment instructions */
2420
+ 200: {
2421
+ headers: {
2422
+ [name: string]: unknown;
2423
+ };
2424
+ content: {
2425
+ "application/json": {
2426
+ /** @constant */
2427
+ code: "SDK_RAMPS_ONRAMP_CREATED";
2428
+ /** @constant */
2429
+ success: true;
2430
+ content: {
2431
+ txId: string;
2432
+ provider: string;
2433
+ /** @enum {string} */
2434
+ status: "pending" | "processing" | "completed" | "failed";
2435
+ paymentInstructions: {
2436
+ /** @enum {string} */
2437
+ type: "CLABE" | "PIX" | "PSE" | "ACH";
2438
+ value: string;
2439
+ amount: number;
2440
+ currency: string;
2441
+ expiresAt?: string;
2442
+ };
2443
+ };
2444
+ };
2445
+ };
2446
+ };
2447
+ /** @description Validation error or quote expired */
2448
+ 400: {
2449
+ headers: {
2450
+ [name: string]: unknown;
2451
+ };
2452
+ content: {
2453
+ "application/json": {
2454
+ /** @constant */
2455
+ success: false;
2456
+ error: string;
2457
+ };
2458
+ };
2459
+ };
2460
+ /** @description Unauthorized */
2461
+ 401: {
2462
+ headers: {
2463
+ [name: string]: unknown;
2464
+ };
2465
+ content: {
2466
+ "application/json": {
2467
+ /** @constant */
2468
+ success: false;
2469
+ error: string;
2470
+ };
2471
+ };
2472
+ };
2473
+ /** @description Quote not found */
2474
+ 404: {
2475
+ headers: {
2476
+ [name: string]: unknown;
2477
+ };
2478
+ content: {
2479
+ "application/json": {
2480
+ /** @constant */
2481
+ success: false;
2482
+ error: string;
2483
+ };
2484
+ };
2485
+ };
2486
+ };
2487
+ };
2488
+ postRampsOfframp: {
2489
+ parameters: {
2490
+ query?: never;
2491
+ header?: never;
2492
+ path?: never;
2493
+ cookie?: never;
2494
+ };
2495
+ requestBody: {
2496
+ content: {
2497
+ "application/json": {
2498
+ quoteId: string;
2499
+ amount: number;
2500
+ currency: string;
2501
+ country: string;
2502
+ walletAddress: string;
2503
+ bankDetails: {
2504
+ /** @enum {string} */
2505
+ type: "CLABE" | "PIX" | "PSE" | "ACH";
2506
+ value: string;
2507
+ };
2508
+ };
2509
+ };
2510
+ };
2511
+ responses: {
2512
+ /** @description Offramp transaction created */
2513
+ 200: {
2514
+ headers: {
2515
+ [name: string]: unknown;
2516
+ };
2517
+ content: {
2518
+ "application/json": {
2519
+ /** @constant */
2520
+ code: "SDK_RAMPS_OFFRAMP_CREATED";
2521
+ /** @constant */
2522
+ success: true;
2523
+ content: {
2524
+ txId: string;
2525
+ provider: string;
2526
+ /** @enum {string} */
2527
+ status: "pending" | "processing" | "completed" | "failed";
2528
+ };
2529
+ };
2530
+ };
2531
+ };
2532
+ /** @description Validation error or quote expired */
2533
+ 400: {
2534
+ headers: {
2535
+ [name: string]: unknown;
2536
+ };
2537
+ content: {
2538
+ "application/json": {
2539
+ /** @constant */
2540
+ success: false;
2541
+ error: string;
2542
+ };
2543
+ };
2544
+ };
2545
+ /** @description Unauthorized */
2546
+ 401: {
2547
+ headers: {
2548
+ [name: string]: unknown;
2549
+ };
2550
+ content: {
2551
+ "application/json": {
2552
+ /** @constant */
2553
+ success: false;
2554
+ error: string;
2555
+ };
2556
+ };
2557
+ };
2558
+ /** @description Quote not found */
2559
+ 404: {
2560
+ headers: {
2561
+ [name: string]: unknown;
2562
+ };
2563
+ content: {
2564
+ "application/json": {
2565
+ /** @constant */
2566
+ success: false;
2567
+ error: string;
2568
+ };
2569
+ };
2570
+ };
2571
+ };
2572
+ };
2573
+ getRampsTransactionByTxId: {
2574
+ parameters: {
2575
+ query?: never;
2576
+ header?: never;
2577
+ path: {
2578
+ /** @description Transaction ID returned by POST /ramps/onramp or POST /ramps/offramp */
2579
+ txId: string;
2580
+ };
2581
+ cookie?: never;
2582
+ };
2583
+ requestBody?: never;
2584
+ responses: {
2585
+ /** @description Transaction status and details */
2586
+ 200: {
2587
+ headers: {
2588
+ [name: string]: unknown;
2589
+ };
2590
+ content: {
2591
+ "application/json": {
2592
+ /** @constant */
2593
+ code: "SDK_RAMPS_TX_STATUS";
2594
+ /** @constant */
2595
+ success: true;
2596
+ content: {
2597
+ txId: string;
2598
+ provider: string;
2599
+ /** @enum {string} */
2600
+ status: "pending" | "processing" | "completed" | "failed";
2601
+ /** @enum {string} */
2602
+ direction: "onramp" | "offramp";
2603
+ amount: number;
2604
+ currency: string;
2605
+ updatedAt: string;
2606
+ };
2607
+ };
2608
+ };
2609
+ };
2610
+ /** @description Unauthorized */
2611
+ 401: {
2612
+ headers: {
2613
+ [name: string]: unknown;
2614
+ };
2615
+ content: {
2616
+ "application/json": {
2617
+ /** @constant */
2618
+ success: false;
2619
+ error: string;
2620
+ };
2621
+ };
2622
+ };
2623
+ /** @description Forbidden */
2624
+ 403: {
2625
+ headers: {
2626
+ [name: string]: unknown;
2627
+ };
2628
+ content: {
2629
+ "application/json": {
2630
+ /** @constant */
2631
+ success: false;
2632
+ error: string;
2633
+ };
2634
+ };
2635
+ };
2636
+ /** @description Not found */
2637
+ 404: {
2638
+ headers: {
2639
+ [name: string]: unknown;
2640
+ };
2641
+ content: {
2642
+ "application/json": {
2643
+ /** @constant */
2644
+ success: false;
2645
+ error: string;
2646
+ };
2647
+ };
2648
+ };
2649
+ };
1535
2650
  };
1536
- onStateChange(cb: (state: PollarStateEntry) => void): () => void;
1537
- verifyEmailCode(clientSessionId: string, code: string): Promise<void>;
1538
- getNetwork(): "testnet" | "public";
1539
- buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
1540
- submitTx(signedXdr: string): Promise<void>;
1541
- logout(): void;
1542
- private _readStore;
1543
- private _storeSession;
1544
- private _clearSession;
1545
- private _emitState;
1546
2651
  }
1547
2652
 
2653
+ type PollarApiClient = ReturnType<typeof createApiClient>;
2654
+ declare function createApiClient(baseUrl: string): openapi_fetch.Client<paths, `${string}/${string}`>;
2655
+
1548
2656
  declare function isValidSession(value: unknown): value is PollarApplicationConfigContent;
1549
2657
 
1550
- type StellarNetwork = 'mainnet' | 'testnet';
1551
- type StellarClientConfig = StellarNetwork | {
1552
- horizonUrl: string;
1553
- };
1554
- interface StellarBalance {
1555
- asset: string;
1556
- balance: string;
1557
- assetIssuer?: string;
1558
- }
1559
- type GetBalancesResult = {
1560
- success: true;
1561
- balances: StellarBalance[];
1562
- } | {
1563
- success: false;
1564
- errorCode: 'ACCOUNT_NOT_FOUND' | 'HORIZON_ERROR' | 'NETWORK_ERROR';
1565
- balances: [];
1566
- };
1567
- declare class StellarClient {
1568
- private readonly horizonUrl;
1569
- constructor(config: StellarClientConfig);
1570
- getBalances(publicKey: string): Promise<GetBalancesResult>;
1571
- }
2658
+ /**
2659
+ * GET /kyc/status
2660
+ * Returns the current user's KYC status for a given provider.
2661
+ * Requires a valid auth token in the API client.
2662
+ */
2663
+ declare function getKycStatus(api: PollarApiClient, providerId?: string): Promise<{
2664
+ status: KycStatus;
2665
+ level?: KycLevel | undefined;
2666
+ providerId: string;
2667
+ expiresAt?: string;
2668
+ }>;
2669
+ /**
2670
+ * GET /kyc/providers
2671
+ * Returns available KYC providers for a given country.
2672
+ */
2673
+ declare function getKycProviders(api: PollarApiClient, country: string): Promise<{
2674
+ providers: KycProvider[];
2675
+ }>;
2676
+ /**
2677
+ * POST /kyc/start
2678
+ * Starts a KYC session.
2679
+ * - flow=iframe/redirect: returns kycUrl to embed or redirect to
2680
+ * - flow=form: returns fields[] to render a custom form
2681
+ */
2682
+ declare function startKyc(api: PollarApiClient, body: KycStartBody): Promise<KycStartResponse>;
2683
+ /**
2684
+ * Orchestrates the full KYC resolution flow:
2685
+ * 1. Checks current status
2686
+ * 2. If already approved, returns early
2687
+ * 3. Otherwise starts KYC and returns the session (kycUrl or fields)
2688
+ */
2689
+ declare function resolveKyc(api: PollarApiClient, providerId: string, level?: KycLevel): Promise<{
2690
+ alreadyApproved: boolean;
2691
+ } & Partial<KycStartResponse>>;
2692
+ /**
2693
+ * Polls GET /kyc/status every intervalMs until status is 'approved' or 'rejected'.
2694
+ * Throws if timeoutMs is exceeded.
2695
+ */
2696
+ declare function pollKycStatus(api: PollarApiClient, providerId: string, { intervalMs, timeoutMs }?: {
2697
+ intervalMs?: number;
2698
+ timeoutMs?: number;
2699
+ }): Promise<KycStatus>;
2700
+
2701
+ /**
2702
+ * GET /ramps/quote
2703
+ * Returns available quotes for an onramp or offramp.
2704
+ * The backend ranks providers by country, amount, fee and availability.
2705
+ * The first quote in the array is the recommended one.
2706
+ */
2707
+ declare function getRampsQuote(api: PollarApiClient, query: RampsQuoteQuery): Promise<RampsQuoteResponse>;
2708
+ /**
2709
+ * POST /ramps/onramp
2710
+ * Creates an onramp transaction.
2711
+ * For custodial users: backend orchestrates the full SEP-24 flow and returns payment instructions.
2712
+ * For non-custodial: backend may return an unsigned XDR that the client must sign via a wallet adapter.
2713
+ */
2714
+ declare function createOnRamp(api: PollarApiClient, body: RampsOnrampBody): Promise<RampsOnrampResponse>;
2715
+ /**
2716
+ * POST /ramps/offramp
2717
+ * Creates an offramp transaction.
2718
+ * Backend initiates the bank transfer once the Stellar transaction is confirmed.
2719
+ */
2720
+ declare function createOffRamp(api: PollarApiClient, body: RampsOfframpBody): Promise<RampsOfframpResponse>;
2721
+ /**
2722
+ * GET /ramps/transaction/{txId}
2723
+ * Returns the current status of a ramp transaction.
2724
+ */
2725
+ declare function getRampTransaction(api: PollarApiClient, txId: string): Promise<RampsTransactionResponse>;
2726
+ /**
2727
+ * Polls GET /ramps/transaction/{txId} every intervalMs until status is 'completed' or 'failed'.
2728
+ * Throws if timeoutMs is exceeded.
2729
+ */
2730
+ declare function pollRampTransaction(api: PollarApiClient, txId: string, { intervalMs, timeoutMs }?: {
2731
+ intervalMs?: number;
2732
+ timeoutMs?: number;
2733
+ }): Promise<RampTxStatus>;
1572
2734
 
1573
- export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateAuthenticationCodes, type StateNetworkCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TxBuildBody, type TxBuildResponse, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
2735
+ export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, FreighterAdapter, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type NetworkState, type PaymentInstructions, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, type WalletBalanceContent, type WalletBalanceRecord, WalletType, createOffRamp, createOnRamp, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };