@pollar/core 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -5
- package/dist/adapters/expo-secure-store.d.mts +11 -1
- package/dist/adapters/expo-secure-store.d.ts +11 -1
- package/dist/adapters/expo-secure-store.js +11 -3
- package/dist/adapters/expo-secure-store.js.map +1 -1
- package/dist/adapters/expo-secure-store.mjs +11 -4
- package/dist/adapters/expo-secure-store.mjs.map +1 -1
- package/dist/adapters/react-native-appstate.d.mts +10 -0
- package/dist/adapters/react-native-appstate.d.ts +10 -0
- package/dist/adapters/react-native-appstate.js +38 -0
- package/dist/adapters/react-native-appstate.js.map +1 -0
- package/dist/adapters/react-native-appstate.mjs +36 -0
- package/dist/adapters/react-native-appstate.mjs.map +1 -0
- package/dist/index.d.mts +194 -39
- package/dist/index.d.ts +194 -39
- package/dist/index.js +174 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -60
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.d.mts +2 -1
- package/dist/index.rn.d.ts +2 -1
- package/dist/index.rn.js +177 -64
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +174 -61
- package/dist/index.rn.mjs.map +1 -1
- package/dist/types-84G_htcn.d.mts +38 -0
- package/dist/types-84G_htcn.d.ts +38 -0
- package/package.json +12 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { S as Storage, O as OnStorageDegrade } from './types-DqgJIJBl.mjs';
|
|
2
2
|
export { a as StorageDegradeReason } from './types-DqgJIJBl.mjs';
|
|
3
|
+
import { V as VisibilityProvider } from './types-84G_htcn.mjs';
|
|
3
4
|
import * as openapi_fetch from 'openapi-fetch';
|
|
4
5
|
|
|
5
6
|
type StellarNetwork = 'mainnet' | 'testnet';
|
|
@@ -75,43 +76,6 @@ interface KeyManager {
|
|
|
75
76
|
sign(payload: Uint8Array): Promise<Uint8Array>;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
/**
|
|
79
|
-
* Pluggable "is the user looking at this app right now?" signal.
|
|
80
|
-
*
|
|
81
|
-
* Used by the silent-refresh scheduler so token renewals are skipped while
|
|
82
|
-
* the tab is hidden / the app is backgrounded — both saves network and
|
|
83
|
-
* works around aggressive `setTimeout` throttling that web browsers and RN
|
|
84
|
-
* apply to non-foreground contexts.
|
|
85
|
-
*
|
|
86
|
-
* Default web implementation listens to `visibilitychange` plus
|
|
87
|
-
* `pageshow`/`pagehide` (covers BFCache on iOS) and `focus`/`blur` (covers
|
|
88
|
-
* the cases where `visibilitychange` lags). Default for non-browser
|
|
89
|
-
* environments is a noop that always reports "visible".
|
|
90
|
-
*
|
|
91
|
-
* TODO(@pollar/react-native): when the dedicated RN package ships, it will
|
|
92
|
-
* export an `AppState`-backed provider. Until then, RN consumers can wire
|
|
93
|
-
* one inline:
|
|
94
|
-
*
|
|
95
|
-
* import { AppState } from 'react-native';
|
|
96
|
-
* const rnVisibility = {
|
|
97
|
-
* isVisible: () => AppState.currentState === 'active',
|
|
98
|
-
* onChange: (cb) => {
|
|
99
|
-
* const sub = AppState.addEventListener('change', (s) => cb(s === 'active'));
|
|
100
|
-
* return () => sub.remove();
|
|
101
|
-
* },
|
|
102
|
-
* };
|
|
103
|
-
* new PollarClient({ apiKey, visibilityProvider: rnVisibility });
|
|
104
|
-
*/
|
|
105
|
-
interface VisibilityProvider {
|
|
106
|
-
isVisible(): boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Subscribe to visibility transitions. The callback receives the new
|
|
109
|
-
* visibility state (`true` = visible). Returns an unsubscribe function
|
|
110
|
-
* that must detach every listener registered by this call.
|
|
111
|
-
*/
|
|
112
|
-
onChange(cb: (visible: boolean) => void): () => void;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
79
|
declare enum WalletType {
|
|
116
80
|
FREIGHTER = "freighter",
|
|
117
81
|
ALBEDO = "albedo"
|
|
@@ -290,6 +254,47 @@ interface PollarClientConfig {
|
|
|
290
254
|
* `undefined` = refresh forever as long as the app is visible.
|
|
291
255
|
*/
|
|
292
256
|
maxIdleMs?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Strategy for opening the hosted OAuth URL during
|
|
259
|
+
* `login({ provider: 'google' | 'github' })`. Defaults to a browser popup
|
|
260
|
+
* on web. React Native consumers MUST provide one (typically wrapping
|
|
261
|
+
* `expo-web-browser`'s `openAuthSessionAsync`), since `window.open` does
|
|
262
|
+
* not exist there. The SDK still drives the rest of the flow by polling the
|
|
263
|
+
* auth-session status, so the opener only needs to surface the URL — it does
|
|
264
|
+
* NOT need to capture the redirect payload.
|
|
265
|
+
*/
|
|
266
|
+
openAuthUrl?: AuthUrlOpener;
|
|
267
|
+
/**
|
|
268
|
+
* Value sent to the backend as `redirect_uri` for hosted OAuth (where the
|
|
269
|
+
* provider returns the user afterwards). Defaults to `window.location.origin`
|
|
270
|
+
* on web. On React Native set this to your app's deep link / scheme — the
|
|
271
|
+
* same URL you pass to `WebBrowser.openAuthSessionAsync`.
|
|
272
|
+
*/
|
|
273
|
+
oauthRedirectUri?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Strategy for opening the hosted OAuth URL. The SDK mints the per-login auth
|
|
277
|
+
* session lazily inside `getUrl()` (call it once; the first call creates the
|
|
278
|
+
* `clientSessionId` and returns the full URL, or `null` if session creation
|
|
279
|
+
* failed). Open the resolved URL however the platform allows — a popup on web,
|
|
280
|
+
* `WebBrowser.openAuthSessionAsync(url, redirectUri)` on React Native — and
|
|
281
|
+
* resolve once the user-facing browser step is done or dismissed. You do NOT
|
|
282
|
+
* need to capture the redirect payload: the SDK polls the auth-session status
|
|
283
|
+
* until the backend marks it READY.
|
|
284
|
+
*/
|
|
285
|
+
type AuthUrlOpener = (ctx: AuthOpenContext) => void | Promise<void>;
|
|
286
|
+
interface AuthOpenContext {
|
|
287
|
+
provider: 'google' | 'github';
|
|
288
|
+
/**
|
|
289
|
+
* Mints the auth session (once) and returns the full hosted-OAuth URL, or
|
|
290
|
+
* `null` if session creation failed. On web, call it AFTER reserving the
|
|
291
|
+
* popup window so popup blockers (which only honor `window.open` inside the
|
|
292
|
+
* original user-gesture tick) don't swallow it.
|
|
293
|
+
*/
|
|
294
|
+
getUrl: () => Promise<string | null>;
|
|
295
|
+
/** The redirect target passed to the backend as `redirect_uri`. */
|
|
296
|
+
redirectUri: string;
|
|
297
|
+
signal: AbortSignal;
|
|
293
298
|
}
|
|
294
299
|
/**
|
|
295
300
|
* One row in the active-sessions list (returned by `PollarClient.listSessions()`).
|
|
@@ -436,6 +441,8 @@ type SubmitOutcome = {
|
|
|
436
441
|
};
|
|
437
442
|
declare const AUTH_ERROR_CODES: {
|
|
438
443
|
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
444
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
445
|
+
readonly SESSION_INVALID: "SESSION_INVALID";
|
|
439
446
|
readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
|
|
440
447
|
readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
|
|
441
448
|
readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
|
|
@@ -637,6 +644,10 @@ declare class PollarClient {
|
|
|
637
644
|
private readonly _walletAdapterResolver;
|
|
638
645
|
private readonly _walletResolverTimeoutMs;
|
|
639
646
|
private _loginController;
|
|
647
|
+
/** Platform strategy for opening the hosted-OAuth URL (popup on web; injected on RN). */
|
|
648
|
+
private readonly _openAuthUrl;
|
|
649
|
+
/** `redirect_uri` sent to the backend for hosted OAuth. */
|
|
650
|
+
private readonly _oauthRedirectUri;
|
|
640
651
|
constructor(config: PollarClientConfig);
|
|
641
652
|
/** Awaitable handle for the initial keypair + session restore. */
|
|
642
653
|
ready(): Promise<void>;
|
|
@@ -1123,6 +1134,26 @@ interface paths {
|
|
|
1123
1134
|
patch?: never;
|
|
1124
1135
|
trace?: never;
|
|
1125
1136
|
};
|
|
1137
|
+
"/auth/session/status/{clientSessionId}/poll": {
|
|
1138
|
+
parameters: {
|
|
1139
|
+
query?: never;
|
|
1140
|
+
header?: never;
|
|
1141
|
+
path?: never;
|
|
1142
|
+
cookie?: never;
|
|
1143
|
+
};
|
|
1144
|
+
/**
|
|
1145
|
+
* Poll client session status (non-streaming)
|
|
1146
|
+
* @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.
|
|
1147
|
+
*/
|
|
1148
|
+
get: operations["getAuthSessionStatusByClientSessionIdPoll"];
|
|
1149
|
+
put?: never;
|
|
1150
|
+
post?: never;
|
|
1151
|
+
delete?: never;
|
|
1152
|
+
options?: never;
|
|
1153
|
+
head?: never;
|
|
1154
|
+
patch?: never;
|
|
1155
|
+
trace?: never;
|
|
1156
|
+
};
|
|
1126
1157
|
"/auth/google": {
|
|
1127
1158
|
parameters: {
|
|
1128
1159
|
query?: never;
|
|
@@ -1442,7 +1473,7 @@ interface paths {
|
|
|
1442
1473
|
put?: never;
|
|
1443
1474
|
/**
|
|
1444
1475
|
* Submit a pre-signed XDR
|
|
1445
|
-
* @description Submit step of the split build/sign/submit flow. Accepts a signed XDR produced by /tx/sign or by an external
|
|
1476
|
+
* @description Submit step of the split build/sign/submit flow. Accepts a signed XDR produced by /tx/sign or signed client-side by an external wallet (Freighter/Albedo/SWK). Routing is custody-aware: EXTERNAL (user-controlled) wallets and adapter-signed wallets are broadcast directly via Soroban RPC, since wallet-service holds no record of them; custodial wallets go through wallet-service /v1/tx/submit so the submission is policy-validated and idempotency-tracked. The EXTERNAL signal is per-user, so apps mixing social login and wallet login submit each user correctly. All paths return the same PENDING | SUCCESS | FAILED outcome.
|
|
1446
1477
|
*/
|
|
1447
1478
|
post: operations["postTxSubmit"];
|
|
1448
1479
|
delete?: never;
|
|
@@ -1877,6 +1908,65 @@ interface operations {
|
|
|
1877
1908
|
};
|
|
1878
1909
|
};
|
|
1879
1910
|
};
|
|
1911
|
+
getAuthSessionStatusByClientSessionIdPoll: {
|
|
1912
|
+
parameters: {
|
|
1913
|
+
query?: never;
|
|
1914
|
+
header?: never;
|
|
1915
|
+
path: {
|
|
1916
|
+
clientSessionId: string;
|
|
1917
|
+
};
|
|
1918
|
+
cookie?: never;
|
|
1919
|
+
};
|
|
1920
|
+
requestBody?: never;
|
|
1921
|
+
responses: {
|
|
1922
|
+
/** @description Current session status */
|
|
1923
|
+
200: {
|
|
1924
|
+
headers: {
|
|
1925
|
+
[name: string]: unknown;
|
|
1926
|
+
};
|
|
1927
|
+
content: {
|
|
1928
|
+
"application/json": {
|
|
1929
|
+
/** @constant */
|
|
1930
|
+
code: "SDK_SESSION_STATUS";
|
|
1931
|
+
/** @constant */
|
|
1932
|
+
success: true;
|
|
1933
|
+
content: {
|
|
1934
|
+
status: string;
|
|
1935
|
+
user: {
|
|
1936
|
+
ready: boolean;
|
|
1937
|
+
};
|
|
1938
|
+
};
|
|
1939
|
+
};
|
|
1940
|
+
};
|
|
1941
|
+
};
|
|
1942
|
+
/** @description Not found */
|
|
1943
|
+
404: {
|
|
1944
|
+
headers: {
|
|
1945
|
+
[name: string]: unknown;
|
|
1946
|
+
};
|
|
1947
|
+
content: {
|
|
1948
|
+
"application/json": {
|
|
1949
|
+
/** @constant */
|
|
1950
|
+
success: false;
|
|
1951
|
+
code: string;
|
|
1952
|
+
};
|
|
1953
|
+
};
|
|
1954
|
+
};
|
|
1955
|
+
/** @description Gone (expired) */
|
|
1956
|
+
410: {
|
|
1957
|
+
headers: {
|
|
1958
|
+
[name: string]: unknown;
|
|
1959
|
+
};
|
|
1960
|
+
content: {
|
|
1961
|
+
"application/json": {
|
|
1962
|
+
/** @constant */
|
|
1963
|
+
success: false;
|
|
1964
|
+
code: string;
|
|
1965
|
+
};
|
|
1966
|
+
};
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
};
|
|
1880
1970
|
getAuthGoogle: {
|
|
1881
1971
|
parameters: {
|
|
1882
1972
|
query: {
|
|
@@ -2172,6 +2262,19 @@ interface operations {
|
|
|
2172
2262
|
};
|
|
2173
2263
|
};
|
|
2174
2264
|
};
|
|
2265
|
+
/** @description Gone (expired) */
|
|
2266
|
+
410: {
|
|
2267
|
+
headers: {
|
|
2268
|
+
[name: string]: unknown;
|
|
2269
|
+
};
|
|
2270
|
+
content: {
|
|
2271
|
+
"application/json": {
|
|
2272
|
+
/** @constant */
|
|
2273
|
+
success: false;
|
|
2274
|
+
code: string;
|
|
2275
|
+
};
|
|
2276
|
+
};
|
|
2277
|
+
};
|
|
2175
2278
|
};
|
|
2176
2279
|
};
|
|
2177
2280
|
postAuthEmailVerifyCode: {
|
|
@@ -2259,6 +2362,19 @@ interface operations {
|
|
|
2259
2362
|
};
|
|
2260
2363
|
};
|
|
2261
2364
|
};
|
|
2365
|
+
/** @description Gone (expired) */
|
|
2366
|
+
410: {
|
|
2367
|
+
headers: {
|
|
2368
|
+
[name: string]: unknown;
|
|
2369
|
+
};
|
|
2370
|
+
content: {
|
|
2371
|
+
"application/json": {
|
|
2372
|
+
/** @constant */
|
|
2373
|
+
success: false;
|
|
2374
|
+
code: string;
|
|
2375
|
+
};
|
|
2376
|
+
};
|
|
2377
|
+
};
|
|
2262
2378
|
};
|
|
2263
2379
|
};
|
|
2264
2380
|
postAuthWallet: {
|
|
@@ -2347,6 +2463,19 @@ interface operations {
|
|
|
2347
2463
|
};
|
|
2348
2464
|
};
|
|
2349
2465
|
};
|
|
2466
|
+
/** @description Gone (expired) */
|
|
2467
|
+
410: {
|
|
2468
|
+
headers: {
|
|
2469
|
+
[name: string]: unknown;
|
|
2470
|
+
};
|
|
2471
|
+
content: {
|
|
2472
|
+
"application/json": {
|
|
2473
|
+
/** @constant */
|
|
2474
|
+
success: false;
|
|
2475
|
+
code: string;
|
|
2476
|
+
};
|
|
2477
|
+
};
|
|
2478
|
+
};
|
|
2350
2479
|
};
|
|
2351
2480
|
};
|
|
2352
2481
|
postAuthLogin: {
|
|
@@ -2478,6 +2607,19 @@ interface operations {
|
|
|
2478
2607
|
};
|
|
2479
2608
|
};
|
|
2480
2609
|
};
|
|
2610
|
+
/** @description Gone (expired) */
|
|
2611
|
+
410: {
|
|
2612
|
+
headers: {
|
|
2613
|
+
[name: string]: unknown;
|
|
2614
|
+
};
|
|
2615
|
+
content: {
|
|
2616
|
+
"application/json": {
|
|
2617
|
+
/** @constant */
|
|
2618
|
+
success: false;
|
|
2619
|
+
code: string;
|
|
2620
|
+
};
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2481
2623
|
};
|
|
2482
2624
|
};
|
|
2483
2625
|
postAuthRefresh: {
|
|
@@ -2568,6 +2710,19 @@ interface operations {
|
|
|
2568
2710
|
};
|
|
2569
2711
|
};
|
|
2570
2712
|
};
|
|
2713
|
+
/** @description Gone (expired) */
|
|
2714
|
+
410: {
|
|
2715
|
+
headers: {
|
|
2716
|
+
[name: string]: unknown;
|
|
2717
|
+
};
|
|
2718
|
+
content: {
|
|
2719
|
+
"application/json": {
|
|
2720
|
+
/** @constant */
|
|
2721
|
+
success: false;
|
|
2722
|
+
code: string;
|
|
2723
|
+
};
|
|
2724
|
+
};
|
|
2725
|
+
};
|
|
2571
2726
|
};
|
|
2572
2727
|
};
|
|
2573
2728
|
postAuthLogout: {
|
|
@@ -4842,4 +4997,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
|
|
|
4842
4997
|
*/
|
|
4843
4998
|
declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
|
|
4844
4999
|
|
|
4845
|
-
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthState, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
|
5000
|
+
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, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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-84G_htcn.js';
|
|
3
4
|
import * as openapi_fetch from 'openapi-fetch';
|
|
4
5
|
|
|
5
6
|
type StellarNetwork = 'mainnet' | 'testnet';
|
|
@@ -75,43 +76,6 @@ interface KeyManager {
|
|
|
75
76
|
sign(payload: Uint8Array): Promise<Uint8Array>;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
/**
|
|
79
|
-
* Pluggable "is the user looking at this app right now?" signal.
|
|
80
|
-
*
|
|
81
|
-
* Used by the silent-refresh scheduler so token renewals are skipped while
|
|
82
|
-
* the tab is hidden / the app is backgrounded — both saves network and
|
|
83
|
-
* works around aggressive `setTimeout` throttling that web browsers and RN
|
|
84
|
-
* apply to non-foreground contexts.
|
|
85
|
-
*
|
|
86
|
-
* Default web implementation listens to `visibilitychange` plus
|
|
87
|
-
* `pageshow`/`pagehide` (covers BFCache on iOS) and `focus`/`blur` (covers
|
|
88
|
-
* the cases where `visibilitychange` lags). Default for non-browser
|
|
89
|
-
* environments is a noop that always reports "visible".
|
|
90
|
-
*
|
|
91
|
-
* TODO(@pollar/react-native): when the dedicated RN package ships, it will
|
|
92
|
-
* export an `AppState`-backed provider. Until then, RN consumers can wire
|
|
93
|
-
* one inline:
|
|
94
|
-
*
|
|
95
|
-
* import { AppState } from 'react-native';
|
|
96
|
-
* const rnVisibility = {
|
|
97
|
-
* isVisible: () => AppState.currentState === 'active',
|
|
98
|
-
* onChange: (cb) => {
|
|
99
|
-
* const sub = AppState.addEventListener('change', (s) => cb(s === 'active'));
|
|
100
|
-
* return () => sub.remove();
|
|
101
|
-
* },
|
|
102
|
-
* };
|
|
103
|
-
* new PollarClient({ apiKey, visibilityProvider: rnVisibility });
|
|
104
|
-
*/
|
|
105
|
-
interface VisibilityProvider {
|
|
106
|
-
isVisible(): boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Subscribe to visibility transitions. The callback receives the new
|
|
109
|
-
* visibility state (`true` = visible). Returns an unsubscribe function
|
|
110
|
-
* that must detach every listener registered by this call.
|
|
111
|
-
*/
|
|
112
|
-
onChange(cb: (visible: boolean) => void): () => void;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
79
|
declare enum WalletType {
|
|
116
80
|
FREIGHTER = "freighter",
|
|
117
81
|
ALBEDO = "albedo"
|
|
@@ -290,6 +254,47 @@ interface PollarClientConfig {
|
|
|
290
254
|
* `undefined` = refresh forever as long as the app is visible.
|
|
291
255
|
*/
|
|
292
256
|
maxIdleMs?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Strategy for opening the hosted OAuth URL during
|
|
259
|
+
* `login({ provider: 'google' | 'github' })`. Defaults to a browser popup
|
|
260
|
+
* on web. React Native consumers MUST provide one (typically wrapping
|
|
261
|
+
* `expo-web-browser`'s `openAuthSessionAsync`), since `window.open` does
|
|
262
|
+
* not exist there. The SDK still drives the rest of the flow by polling the
|
|
263
|
+
* auth-session status, so the opener only needs to surface the URL — it does
|
|
264
|
+
* NOT need to capture the redirect payload.
|
|
265
|
+
*/
|
|
266
|
+
openAuthUrl?: AuthUrlOpener;
|
|
267
|
+
/**
|
|
268
|
+
* Value sent to the backend as `redirect_uri` for hosted OAuth (where the
|
|
269
|
+
* provider returns the user afterwards). Defaults to `window.location.origin`
|
|
270
|
+
* on web. On React Native set this to your app's deep link / scheme — the
|
|
271
|
+
* same URL you pass to `WebBrowser.openAuthSessionAsync`.
|
|
272
|
+
*/
|
|
273
|
+
oauthRedirectUri?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Strategy for opening the hosted OAuth URL. The SDK mints the per-login auth
|
|
277
|
+
* session lazily inside `getUrl()` (call it once; the first call creates the
|
|
278
|
+
* `clientSessionId` and returns the full URL, or `null` if session creation
|
|
279
|
+
* failed). Open the resolved URL however the platform allows — a popup on web,
|
|
280
|
+
* `WebBrowser.openAuthSessionAsync(url, redirectUri)` on React Native — and
|
|
281
|
+
* resolve once the user-facing browser step is done or dismissed. You do NOT
|
|
282
|
+
* need to capture the redirect payload: the SDK polls the auth-session status
|
|
283
|
+
* until the backend marks it READY.
|
|
284
|
+
*/
|
|
285
|
+
type AuthUrlOpener = (ctx: AuthOpenContext) => void | Promise<void>;
|
|
286
|
+
interface AuthOpenContext {
|
|
287
|
+
provider: 'google' | 'github';
|
|
288
|
+
/**
|
|
289
|
+
* Mints the auth session (once) and returns the full hosted-OAuth URL, or
|
|
290
|
+
* `null` if session creation failed. On web, call it AFTER reserving the
|
|
291
|
+
* popup window so popup blockers (which only honor `window.open` inside the
|
|
292
|
+
* original user-gesture tick) don't swallow it.
|
|
293
|
+
*/
|
|
294
|
+
getUrl: () => Promise<string | null>;
|
|
295
|
+
/** The redirect target passed to the backend as `redirect_uri`. */
|
|
296
|
+
redirectUri: string;
|
|
297
|
+
signal: AbortSignal;
|
|
293
298
|
}
|
|
294
299
|
/**
|
|
295
300
|
* One row in the active-sessions list (returned by `PollarClient.listSessions()`).
|
|
@@ -436,6 +441,8 @@ type SubmitOutcome = {
|
|
|
436
441
|
};
|
|
437
442
|
declare const AUTH_ERROR_CODES: {
|
|
438
443
|
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
444
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
445
|
+
readonly SESSION_INVALID: "SESSION_INVALID";
|
|
439
446
|
readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
|
|
440
447
|
readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
|
|
441
448
|
readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
|
|
@@ -637,6 +644,10 @@ declare class PollarClient {
|
|
|
637
644
|
private readonly _walletAdapterResolver;
|
|
638
645
|
private readonly _walletResolverTimeoutMs;
|
|
639
646
|
private _loginController;
|
|
647
|
+
/** Platform strategy for opening the hosted-OAuth URL (popup on web; injected on RN). */
|
|
648
|
+
private readonly _openAuthUrl;
|
|
649
|
+
/** `redirect_uri` sent to the backend for hosted OAuth. */
|
|
650
|
+
private readonly _oauthRedirectUri;
|
|
640
651
|
constructor(config: PollarClientConfig);
|
|
641
652
|
/** Awaitable handle for the initial keypair + session restore. */
|
|
642
653
|
ready(): Promise<void>;
|
|
@@ -1123,6 +1134,26 @@ interface paths {
|
|
|
1123
1134
|
patch?: never;
|
|
1124
1135
|
trace?: never;
|
|
1125
1136
|
};
|
|
1137
|
+
"/auth/session/status/{clientSessionId}/poll": {
|
|
1138
|
+
parameters: {
|
|
1139
|
+
query?: never;
|
|
1140
|
+
header?: never;
|
|
1141
|
+
path?: never;
|
|
1142
|
+
cookie?: never;
|
|
1143
|
+
};
|
|
1144
|
+
/**
|
|
1145
|
+
* Poll client session status (non-streaming)
|
|
1146
|
+
* @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.
|
|
1147
|
+
*/
|
|
1148
|
+
get: operations["getAuthSessionStatusByClientSessionIdPoll"];
|
|
1149
|
+
put?: never;
|
|
1150
|
+
post?: never;
|
|
1151
|
+
delete?: never;
|
|
1152
|
+
options?: never;
|
|
1153
|
+
head?: never;
|
|
1154
|
+
patch?: never;
|
|
1155
|
+
trace?: never;
|
|
1156
|
+
};
|
|
1126
1157
|
"/auth/google": {
|
|
1127
1158
|
parameters: {
|
|
1128
1159
|
query?: never;
|
|
@@ -1442,7 +1473,7 @@ interface paths {
|
|
|
1442
1473
|
put?: never;
|
|
1443
1474
|
/**
|
|
1444
1475
|
* Submit a pre-signed XDR
|
|
1445
|
-
* @description Submit step of the split build/sign/submit flow. Accepts a signed XDR produced by /tx/sign or by an external
|
|
1476
|
+
* @description Submit step of the split build/sign/submit flow. Accepts a signed XDR produced by /tx/sign or signed client-side by an external wallet (Freighter/Albedo/SWK). Routing is custody-aware: EXTERNAL (user-controlled) wallets and adapter-signed wallets are broadcast directly via Soroban RPC, since wallet-service holds no record of them; custodial wallets go through wallet-service /v1/tx/submit so the submission is policy-validated and idempotency-tracked. The EXTERNAL signal is per-user, so apps mixing social login and wallet login submit each user correctly. All paths return the same PENDING | SUCCESS | FAILED outcome.
|
|
1446
1477
|
*/
|
|
1447
1478
|
post: operations["postTxSubmit"];
|
|
1448
1479
|
delete?: never;
|
|
@@ -1877,6 +1908,65 @@ interface operations {
|
|
|
1877
1908
|
};
|
|
1878
1909
|
};
|
|
1879
1910
|
};
|
|
1911
|
+
getAuthSessionStatusByClientSessionIdPoll: {
|
|
1912
|
+
parameters: {
|
|
1913
|
+
query?: never;
|
|
1914
|
+
header?: never;
|
|
1915
|
+
path: {
|
|
1916
|
+
clientSessionId: string;
|
|
1917
|
+
};
|
|
1918
|
+
cookie?: never;
|
|
1919
|
+
};
|
|
1920
|
+
requestBody?: never;
|
|
1921
|
+
responses: {
|
|
1922
|
+
/** @description Current session status */
|
|
1923
|
+
200: {
|
|
1924
|
+
headers: {
|
|
1925
|
+
[name: string]: unknown;
|
|
1926
|
+
};
|
|
1927
|
+
content: {
|
|
1928
|
+
"application/json": {
|
|
1929
|
+
/** @constant */
|
|
1930
|
+
code: "SDK_SESSION_STATUS";
|
|
1931
|
+
/** @constant */
|
|
1932
|
+
success: true;
|
|
1933
|
+
content: {
|
|
1934
|
+
status: string;
|
|
1935
|
+
user: {
|
|
1936
|
+
ready: boolean;
|
|
1937
|
+
};
|
|
1938
|
+
};
|
|
1939
|
+
};
|
|
1940
|
+
};
|
|
1941
|
+
};
|
|
1942
|
+
/** @description Not found */
|
|
1943
|
+
404: {
|
|
1944
|
+
headers: {
|
|
1945
|
+
[name: string]: unknown;
|
|
1946
|
+
};
|
|
1947
|
+
content: {
|
|
1948
|
+
"application/json": {
|
|
1949
|
+
/** @constant */
|
|
1950
|
+
success: false;
|
|
1951
|
+
code: string;
|
|
1952
|
+
};
|
|
1953
|
+
};
|
|
1954
|
+
};
|
|
1955
|
+
/** @description Gone (expired) */
|
|
1956
|
+
410: {
|
|
1957
|
+
headers: {
|
|
1958
|
+
[name: string]: unknown;
|
|
1959
|
+
};
|
|
1960
|
+
content: {
|
|
1961
|
+
"application/json": {
|
|
1962
|
+
/** @constant */
|
|
1963
|
+
success: false;
|
|
1964
|
+
code: string;
|
|
1965
|
+
};
|
|
1966
|
+
};
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
};
|
|
1880
1970
|
getAuthGoogle: {
|
|
1881
1971
|
parameters: {
|
|
1882
1972
|
query: {
|
|
@@ -2172,6 +2262,19 @@ interface operations {
|
|
|
2172
2262
|
};
|
|
2173
2263
|
};
|
|
2174
2264
|
};
|
|
2265
|
+
/** @description Gone (expired) */
|
|
2266
|
+
410: {
|
|
2267
|
+
headers: {
|
|
2268
|
+
[name: string]: unknown;
|
|
2269
|
+
};
|
|
2270
|
+
content: {
|
|
2271
|
+
"application/json": {
|
|
2272
|
+
/** @constant */
|
|
2273
|
+
success: false;
|
|
2274
|
+
code: string;
|
|
2275
|
+
};
|
|
2276
|
+
};
|
|
2277
|
+
};
|
|
2175
2278
|
};
|
|
2176
2279
|
};
|
|
2177
2280
|
postAuthEmailVerifyCode: {
|
|
@@ -2259,6 +2362,19 @@ interface operations {
|
|
|
2259
2362
|
};
|
|
2260
2363
|
};
|
|
2261
2364
|
};
|
|
2365
|
+
/** @description Gone (expired) */
|
|
2366
|
+
410: {
|
|
2367
|
+
headers: {
|
|
2368
|
+
[name: string]: unknown;
|
|
2369
|
+
};
|
|
2370
|
+
content: {
|
|
2371
|
+
"application/json": {
|
|
2372
|
+
/** @constant */
|
|
2373
|
+
success: false;
|
|
2374
|
+
code: string;
|
|
2375
|
+
};
|
|
2376
|
+
};
|
|
2377
|
+
};
|
|
2262
2378
|
};
|
|
2263
2379
|
};
|
|
2264
2380
|
postAuthWallet: {
|
|
@@ -2347,6 +2463,19 @@ interface operations {
|
|
|
2347
2463
|
};
|
|
2348
2464
|
};
|
|
2349
2465
|
};
|
|
2466
|
+
/** @description Gone (expired) */
|
|
2467
|
+
410: {
|
|
2468
|
+
headers: {
|
|
2469
|
+
[name: string]: unknown;
|
|
2470
|
+
};
|
|
2471
|
+
content: {
|
|
2472
|
+
"application/json": {
|
|
2473
|
+
/** @constant */
|
|
2474
|
+
success: false;
|
|
2475
|
+
code: string;
|
|
2476
|
+
};
|
|
2477
|
+
};
|
|
2478
|
+
};
|
|
2350
2479
|
};
|
|
2351
2480
|
};
|
|
2352
2481
|
postAuthLogin: {
|
|
@@ -2478,6 +2607,19 @@ interface operations {
|
|
|
2478
2607
|
};
|
|
2479
2608
|
};
|
|
2480
2609
|
};
|
|
2610
|
+
/** @description Gone (expired) */
|
|
2611
|
+
410: {
|
|
2612
|
+
headers: {
|
|
2613
|
+
[name: string]: unknown;
|
|
2614
|
+
};
|
|
2615
|
+
content: {
|
|
2616
|
+
"application/json": {
|
|
2617
|
+
/** @constant */
|
|
2618
|
+
success: false;
|
|
2619
|
+
code: string;
|
|
2620
|
+
};
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2481
2623
|
};
|
|
2482
2624
|
};
|
|
2483
2625
|
postAuthRefresh: {
|
|
@@ -2568,6 +2710,19 @@ interface operations {
|
|
|
2568
2710
|
};
|
|
2569
2711
|
};
|
|
2570
2712
|
};
|
|
2713
|
+
/** @description Gone (expired) */
|
|
2714
|
+
410: {
|
|
2715
|
+
headers: {
|
|
2716
|
+
[name: string]: unknown;
|
|
2717
|
+
};
|
|
2718
|
+
content: {
|
|
2719
|
+
"application/json": {
|
|
2720
|
+
/** @constant */
|
|
2721
|
+
success: false;
|
|
2722
|
+
code: string;
|
|
2723
|
+
};
|
|
2724
|
+
};
|
|
2725
|
+
};
|
|
2571
2726
|
};
|
|
2572
2727
|
};
|
|
2573
2728
|
postAuthLogout: {
|
|
@@ -4842,4 +4997,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
|
|
|
4842
4997
|
*/
|
|
4843
4998
|
declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
|
|
4844
4999
|
|
|
4845
|
-
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthState, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
|
5000
|
+
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, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type NetworkState, OnStorageDegrade, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|