@pollar/core 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +352 -46
- package/dist/index.d.ts +352 -46
- package/dist/index.js +61 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -14
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.d.mts +1 -1
- package/dist/index.rn.d.ts +1 -1
- package/dist/index.rn.js +61 -13
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +60 -14
- package/dist/index.rn.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.rn.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyManager, PublicEcJwk } from './index.mjs';
|
|
2
|
-
export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthState, BuildProofArgs, ConnectWalletResponse, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, NetworkState, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, SessionInfo, SignAuthEntryOptions, SignAuthEntryResponse, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignSendResponse, WalletAdapter, WalletAdapterResolver, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.mjs';
|
|
2
|
+
export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthState, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, NetworkState, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SignAuthEntryOptions, SignAuthEntryResponse, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignSendResponse, WalletAdapter, WalletAdapterResolver, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.mjs';
|
|
3
3
|
import { S as Storage } from './types-DqgJIJBl.mjs';
|
|
4
4
|
export { O as OnStorageDegrade, a as StorageDegradeReason } from './types-DqgJIJBl.mjs';
|
|
5
5
|
import 'openapi-fetch';
|
package/dist/index.rn.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyManager, PublicEcJwk } from './index.js';
|
|
2
|
-
export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthState, BuildProofArgs, ConnectWalletResponse, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, NetworkState, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, SessionInfo, SignAuthEntryOptions, SignAuthEntryResponse, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignSendResponse, WalletAdapter, WalletAdapterResolver, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.js';
|
|
2
|
+
export { AUTH_ERROR_CODES, AdapterFn, AlbedoAdapter, AuthErrorCode, AuthState, BuildProofArgs, ConnectWalletResponse, DistributionClaimBody, DistributionClaimContent, DistributionRule, DistributionRulesState, FreighterAdapter, KycFlow, KycLevel, KycProvider, KycStartBody, KycStartResponse, KycStatus, LocalStorageAdapterOptions, NetworkState, PaymentInstructions, PollarAdapter, PollarAdapters, PollarApiClient, PollarApplicationConfigContent, PollarApplicationConfigResponse, PollarClient, PollarClientConfig, PollarFlowError, PollarLoginOptions, PollarPersistedSession, PollarUserProfile, RampDirection, RampQuote, RampTxStatus, RampsOfframpBody, RampsOfframpResponse, RampsOnrampBody, RampsOnrampResponse, RampsQuoteQuery, RampsQuoteResponse, RampsTransactionResponse, RulePeriod, SessionInfo, SignAuthEntryOptions, SignAuthEntryResponse, SignTransactionOptions, SignTransactionResponse, StellarBalance, StellarClient, StellarClientConfig, StellarNetwork, TransactionState, TxBuildBody, TxBuildContent, TxBuildResponse, TxHistoryContent, TxHistoryParams, TxHistoryRecord, TxHistoryState, TxSignAndSendBody, TxSignSendResponse, WalletAdapter, WalletAdapterResolver, WalletBalanceContent, WalletBalanceRecord, WalletBalanceState, WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, pollarPaths, resolveKyc, startKyc } from './index.js';
|
|
3
3
|
import { S as Storage } from './types-DqgJIJBl.js';
|
|
4
4
|
export { O as OnStorageDegrade, a as StorageDegradeReason } from './types-DqgJIJBl.js';
|
|
5
5
|
import 'openapi-fetch';
|
package/dist/index.rn.js
CHANGED
|
@@ -569,7 +569,7 @@ function createClient(clientOptions) {
|
|
|
569
569
|
const {
|
|
570
570
|
baseUrl: localBaseUrl,
|
|
571
571
|
fetch: fetch2 = baseFetch,
|
|
572
|
-
Request = CustomRequest,
|
|
572
|
+
Request: Request2 = CustomRequest,
|
|
573
573
|
headers,
|
|
574
574
|
params = {},
|
|
575
575
|
parseAs = "json",
|
|
@@ -621,7 +621,7 @@ function createClient(clientOptions) {
|
|
|
621
621
|
};
|
|
622
622
|
let id;
|
|
623
623
|
let options;
|
|
624
|
-
let request = new
|
|
624
|
+
let request = new Request2(
|
|
625
625
|
createFinalURL(schemaPath, { baseUrl: finalBaseUrl, params, querySerializer, pathSerializer }),
|
|
626
626
|
requestInit
|
|
627
627
|
);
|
|
@@ -651,7 +651,7 @@ function createClient(clientOptions) {
|
|
|
651
651
|
id
|
|
652
652
|
});
|
|
653
653
|
if (result) {
|
|
654
|
-
if (result instanceof
|
|
654
|
+
if (result instanceof Request2) {
|
|
655
655
|
request = result;
|
|
656
656
|
} else if (result instanceof Response) {
|
|
657
657
|
response = result;
|
|
@@ -1023,6 +1023,22 @@ function createApiClient(baseUrl) {
|
|
|
1023
1023
|
return createClient({ baseUrl });
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
+
// src/api/endpoints/distribution.ts
|
|
1027
|
+
async function listDistributionRules(api) {
|
|
1028
|
+
const { data, error } = await api.GET("/distribution/rules");
|
|
1029
|
+
if (!data?.content || error) {
|
|
1030
|
+
throw new Error(error?.error ?? "Failed to list distribution rules");
|
|
1031
|
+
}
|
|
1032
|
+
return data.content.rules;
|
|
1033
|
+
}
|
|
1034
|
+
async function claimDistributionRule(api, body) {
|
|
1035
|
+
const { data, error } = await api.POST("/distribution/claim", { body });
|
|
1036
|
+
if (!data?.content || error) {
|
|
1037
|
+
throw new Error(error?.error ?? "Failed to claim distribution rule");
|
|
1038
|
+
}
|
|
1039
|
+
return data.content;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1026
1042
|
// src/api/endpoints/kyc.ts
|
|
1027
1043
|
async function getKycStatus(api, providerId) {
|
|
1028
1044
|
const { data, error } = await api.GET("/kyc/status", {
|
|
@@ -1869,7 +1885,6 @@ async function loginWallet(type, deps) {
|
|
|
1869
1885
|
|
|
1870
1886
|
// src/client/client.ts
|
|
1871
1887
|
var isBrowser = typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
1872
|
-
var RETRIED_HEADER = "X-Pollar-Retried";
|
|
1873
1888
|
function warnServerSide(method) {
|
|
1874
1889
|
console.warn(
|
|
1875
1890
|
`[PollarClient] ${method}() called server-side \u2014 browser APIs unavailable. Use PollarClient only in Client Components.`
|
|
@@ -1887,6 +1902,13 @@ var PollarClient = class {
|
|
|
1887
1902
|
this._profile = null;
|
|
1888
1903
|
/** Last `DPoP-Nonce` we saw from a server response. Carried into the next proof. */
|
|
1889
1904
|
this._dpopNonce = null;
|
|
1905
|
+
/**
|
|
1906
|
+
* Snapshot of each in-flight request's body, taken in `onRequest` before
|
|
1907
|
+
* `fetch()` consumes the stream. Needed because `Request.clone()` throws
|
|
1908
|
+
* once the body is disturbed, so the auto-retry path (DPoP nonce challenge
|
|
1909
|
+
* / 401 refresh) must rebuild the request from scratch instead of cloning.
|
|
1910
|
+
*/
|
|
1911
|
+
this._requestBodyCache = /* @__PURE__ */ new WeakMap();
|
|
1890
1912
|
/** Singleton in-flight refresh — concurrent 401s coalesce into one /auth/refresh call. */
|
|
1891
1913
|
this._refreshPromise = null;
|
|
1892
1914
|
this._storageEventHandler = null;
|
|
@@ -1971,6 +1993,13 @@ var PollarClient = class {
|
|
|
1971
1993
|
onRequest: async ({ request }) => {
|
|
1972
1994
|
request.headers.set("x-pollar-api-key", self.apiKey);
|
|
1973
1995
|
await self._initialized;
|
|
1996
|
+
if (request.body !== null) {
|
|
1997
|
+
try {
|
|
1998
|
+
self._requestBodyCache.set(request, await request.clone().arrayBuffer());
|
|
1999
|
+
} catch (err) {
|
|
2000
|
+
console.warn("[PollarClient] Could not snapshot request body for retry", err);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
1974
2003
|
const isRefresh = request.url.includes("/auth/refresh");
|
|
1975
2004
|
if (!isRefresh && self._refreshPromise) await self._refreshPromise;
|
|
1976
2005
|
if (isRefresh) {
|
|
@@ -1993,7 +2022,6 @@ var PollarClient = class {
|
|
|
1993
2022
|
const newNonce = response.headers.get("DPoP-Nonce");
|
|
1994
2023
|
if (newNonce) self._dpopNonce = newNonce;
|
|
1995
2024
|
if (response.status !== 401) return response;
|
|
1996
|
-
if (request.headers.get(RETRIED_HEADER)) return response;
|
|
1997
2025
|
if (request.url.includes("/auth/refresh")) return response;
|
|
1998
2026
|
const wwwAuth = response.headers.get("WWW-Authenticate") ?? "";
|
|
1999
2027
|
const isNonceChallenge = wwwAuth.includes("use_dpop_nonce");
|
|
@@ -2026,19 +2054,29 @@ var PollarClient = class {
|
|
|
2026
2054
|
}
|
|
2027
2055
|
}
|
|
2028
2056
|
async _retryRequest(originalRequest) {
|
|
2029
|
-
const
|
|
2030
|
-
clone.headers.set(RETRIED_HEADER, "1");
|
|
2057
|
+
const headers = new Headers(originalRequest.headers);
|
|
2031
2058
|
const accessToken = this._session?.token?.accessToken;
|
|
2032
2059
|
if (accessToken) {
|
|
2033
|
-
const proof = await this._buildProofForRequest(
|
|
2060
|
+
const proof = await this._buildProofForRequest(originalRequest, accessToken);
|
|
2034
2061
|
if (proof) {
|
|
2035
|
-
|
|
2036
|
-
|
|
2062
|
+
headers.set("Authorization", `DPoP ${accessToken}`);
|
|
2063
|
+
headers.set("DPoP", proof);
|
|
2037
2064
|
} else {
|
|
2038
|
-
|
|
2065
|
+
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
2039
2066
|
}
|
|
2040
2067
|
}
|
|
2041
|
-
|
|
2068
|
+
const cachedBody = this._requestBodyCache.get(originalRequest);
|
|
2069
|
+
const retried = new Request(originalRequest.url, {
|
|
2070
|
+
method: originalRequest.method,
|
|
2071
|
+
headers,
|
|
2072
|
+
body: cachedBody ?? null,
|
|
2073
|
+
credentials: originalRequest.credentials,
|
|
2074
|
+
mode: originalRequest.mode,
|
|
2075
|
+
redirect: originalRequest.redirect,
|
|
2076
|
+
referrer: originalRequest.referrer,
|
|
2077
|
+
integrity: originalRequest.integrity
|
|
2078
|
+
});
|
|
2079
|
+
return fetch(retried);
|
|
2042
2080
|
}
|
|
2043
2081
|
// ─── Refresh (race-safe singleton) ───────────────────────────────────────
|
|
2044
2082
|
/**
|
|
@@ -2363,7 +2401,8 @@ var PollarClient = class {
|
|
|
2363
2401
|
const details = error?.details;
|
|
2364
2402
|
this._setTransactionState({ step: "error", ...details && { details } });
|
|
2365
2403
|
}
|
|
2366
|
-
} catch {
|
|
2404
|
+
} catch (err) {
|
|
2405
|
+
console.error("[PollarClient] buildTx failed", err);
|
|
2367
2406
|
this._setTransactionState({ step: "error" });
|
|
2368
2407
|
}
|
|
2369
2408
|
}
|
|
@@ -2451,6 +2490,13 @@ var PollarClient = class {
|
|
|
2451
2490
|
pollRampTransaction(txId, opts) {
|
|
2452
2491
|
return pollRampTransaction(this._api, txId, opts);
|
|
2453
2492
|
}
|
|
2493
|
+
// ─── Distribution ─────────────────────────────────────────────────────────
|
|
2494
|
+
listDistributionRules() {
|
|
2495
|
+
return listDistributionRules(this._api);
|
|
2496
|
+
}
|
|
2497
|
+
claimDistributionRule(body) {
|
|
2498
|
+
return claimDistributionRule(this._api, body);
|
|
2499
|
+
}
|
|
2454
2500
|
_setTxHistoryState(next) {
|
|
2455
2501
|
this._txHistoryState = next;
|
|
2456
2502
|
for (const cb of this._txHistoryStateListeners) cb(next);
|
|
@@ -2606,6 +2652,7 @@ exports.WalletType = WalletType;
|
|
|
2606
2652
|
exports.WebCryptoKeyManager = WebCryptoKeyManager;
|
|
2607
2653
|
exports.buildProof = buildProof;
|
|
2608
2654
|
exports.canonicalEcJwk = canonicalEcJwk;
|
|
2655
|
+
exports.claimDistributionRule = claimDistributionRule;
|
|
2609
2656
|
exports.computeJwkThumbprint = computeJwkThumbprint;
|
|
2610
2657
|
exports.createLocalStorageAdapter = createLocalStorageAdapter;
|
|
2611
2658
|
exports.createMemoryAdapter = createMemoryAdapter;
|
|
@@ -2618,6 +2665,7 @@ exports.getKycStatus = getKycStatus;
|
|
|
2618
2665
|
exports.getRampTransaction = getRampTransaction;
|
|
2619
2666
|
exports.getRampsQuote = getRampsQuote;
|
|
2620
2667
|
exports.isValidSession = isValidSession;
|
|
2668
|
+
exports.listDistributionRules = listDistributionRules;
|
|
2621
2669
|
exports.normalizeHtu = normalizeHtu;
|
|
2622
2670
|
exports.pollKycStatus = pollKycStatus;
|
|
2623
2671
|
exports.pollRampTransaction = pollRampTransaction;
|