@coinlist-co/react 0.12.1 → 0.12.2-rc.0ff2d03
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 +10 -0
- package/dist/chunk-MJ6YXZWH.js +22 -0
- package/dist/chunk-MJ6YXZWH.js.map +1 -0
- package/dist/{chunk-VH34YC3Q.js → chunk-PWGUKS4Q.js} +199 -186
- package/dist/chunk-PWGUKS4Q.js.map +1 -0
- package/dist/{chunk-DCW7NQXH.js → chunk-QTBEDN7C.js} +52 -19
- package/dist/chunk-QTBEDN7C.js.map +1 -0
- package/dist/{chunk-MOE5S6CE.js → chunk-SVPFFLIT.js} +1314 -796
- package/dist/chunk-SVPFFLIT.js.map +1 -0
- package/dist/client/index.d.ts +3332 -4554
- package/dist/client/index.js +7374 -4387
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.d.ts +69 -71
- package/dist/server/index.js +327 -67
- package/dist/server/index.js.map +1 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.cts → time-BDzqB806.d.ts} +1901 -2491
- package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-cvLsnMo_.d.ts} +74 -42
- package/dist/universal/index.d.ts +100 -1001
- package/dist/universal/index.js +52 -36
- package/package.json +18 -14
- package/dist/chunk-DCW7NQXH.js.map +0 -1
- package/dist/chunk-MOE5S6CE.js.map +0 -1
- package/dist/chunk-VH34YC3Q.js.map +0 -1
- package/dist/client/index.cjs +0 -16840
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -6592
- package/dist/server/index.cjs +0 -3878
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -354
- package/dist/token-registry-snapshot-BNBNuDu1.d.ts +0 -179
- package/dist/tokens-namespace-CIWBtgt2.d.ts +0 -3301
- package/dist/universal/index.cjs +0 -4028
- package/dist/universal/index.cjs.map +0 -1
- package/dist/universal/index.d.cts +0 -1276
package/dist/server/index.d.cts
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import { A as AuthorizationCode, C as CodeVerifier, aq as OAuthSession, v as OAuthAccessToken, ar as ClientCredentialsOAuth, u as Config, as as ClientSecret, at as Sender, L as Logger, w as OffersNamespace, J as Offer, au as PaginationParams, av as PaginatedResponse, O as OfferId, z as OfferDetail, R as RequirementsNamespace, d as OfferOptionId, s as Requirement, t as RequirementsNamespaceImpl, U as UniversalNamespaceContext, o as WalletsNamespace, E as Erc20Namespace, c as CoinListTokenSaleNamespace, S as SuperstateSwapNamespace, g as OndoNamespace, T as TokensNamespace, _ as PinoLoggerOptions } from '../tokens-namespace-CIWBtgt2.cjs';
|
|
2
|
-
import 'viem';
|
|
3
|
-
|
|
4
|
-
interface SessionStore {
|
|
5
|
-
getSession(): Promise<OAuthSession | null>;
|
|
6
|
-
/**
|
|
7
|
-
* Persists or clears the OAuth session.
|
|
8
|
-
*
|
|
9
|
-
* **Omit this method to create a read-only store.** When absent, the SDK
|
|
10
|
-
* skips token refresh entirely — no network call is made and no refresh
|
|
11
|
-
* token is consumed. This is the correct approach for contexts that can read
|
|
12
|
-
* the session but cannot write it back, such as Next.js Server Components.
|
|
13
|
-
*
|
|
14
|
-
* ⚠️ Do **not** implement this as a no-op (`async () => {}`). If the method
|
|
15
|
-
* is present, the SDK assumes writes succeed: it will fire a token refresh
|
|
16
|
-
* network call, consume the refresh token, then invoke `setSession` — which
|
|
17
|
-
* would silently discard the new session and leave the browser holding an
|
|
18
|
-
* invalidated refresh token. Simply **omit** `setSession` to prevent any
|
|
19
|
-
* refresh from being attempted.
|
|
20
|
-
*
|
|
21
|
-
* {@link ServerAuthNamespace.completeOAuth} and
|
|
22
|
-
* {@link ServerAuthNamespace.logout} always require a writable store and
|
|
23
|
-
* throw {@link WritableSessionStoreRequiredError} if `setSession` is absent.
|
|
24
|
-
*/
|
|
25
|
-
setSession?(session: OAuthSession | null): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The empty session store: holds no session, reads nothing, never writes.
|
|
29
|
-
*
|
|
30
|
-
* For server contexts that act without a user — the client-credentials grant
|
|
31
|
-
* (`auth.clientCredentials`) and the public token registry (`tokens`) read
|
|
32
|
-
* nothing from the store, so hosts building those paths need no store of
|
|
33
|
-
* their own.
|
|
34
|
-
*
|
|
35
|
-
* `setSession` is deliberately absent, not a no-op — see
|
|
36
|
-
* {@link SessionStore.setSession} for why a no-op is a bug.
|
|
37
|
-
*/
|
|
38
|
-
declare function emptySessionStore(): SessionStore;
|
|
39
|
-
/** The PKCE pair `CoinListClient#auth.completeOAuth` hands to the backend. */
|
|
40
|
-
interface CompleteOAuthParams {
|
|
41
|
-
/** The short-lived authorization code parsed out of the redirect URL. */
|
|
42
|
-
code: AuthorizationCode;
|
|
43
|
-
/** The `code_verifier` the browser generated when starting the flow. */
|
|
44
|
-
codeVerifier: CodeVerifier;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* OAuth session lifecycle on your backend: exchanging authorization codes,
|
|
48
|
-
* keeping the access token fresh, minting app-level tokens, and logging out.
|
|
49
|
-
*
|
|
50
|
-
* This namespace is server-only: every method needs the `clientSecret` and the
|
|
51
|
-
* {@link SessionStore}, neither of which may exist in a browser.
|
|
52
|
-
*/
|
|
53
|
-
interface ServerAuthNamespace {
|
|
54
|
-
/**
|
|
55
|
-
* Exchanges an authorization code from `CoinListClient#auth.completeOAuth`
|
|
56
|
-
* for an OAuth session and persists it via {@link SessionStore.setSession}.
|
|
57
|
-
*
|
|
58
|
-
* Throws {@link WritableSessionStoreRequiredError} if the session store does
|
|
59
|
-
* not provide `setSession`.
|
|
60
|
-
*/
|
|
61
|
-
completeOAuth(params: CompleteOAuthParams): Promise<OAuthSession>;
|
|
62
|
-
/**
|
|
63
|
-
* Returns a valid access token for the current session, refreshing it if it
|
|
64
|
-
* is expired or near expiry. This is what you serve to
|
|
65
|
-
* {@link ClientConfig.getAccessToken}.
|
|
66
|
-
*
|
|
67
|
-
* **Writable store**: if the token is expired, the SDK exchanges the refresh
|
|
68
|
-
* token for a new session, persists it, and returns the fresh access token.
|
|
69
|
-
* Returns `null` if there is no session or the refresh fails.
|
|
70
|
-
*
|
|
71
|
-
* **Read-only store** (no `setSession`): refresh is skipped entirely. The
|
|
72
|
-
* stored token is returned as-is, even if it is expired — a non-null return
|
|
73
|
-
* value does **not** guarantee the token is accepted by the API. Before
|
|
74
|
-
* making API calls, check `token.expiresAt > new Date()`. Use a writable
|
|
75
|
-
* store (e.g. in a Route Handler) when you need the SDK to renew the session
|
|
76
|
-
* automatically.
|
|
77
|
-
*
|
|
78
|
-
* @returns the access token, or `null` if there is no session or the session
|
|
79
|
-
* could not be refreshed.
|
|
80
|
-
*/
|
|
81
|
-
getAccessToken(): Promise<OAuthAccessToken | null>;
|
|
82
|
-
/**
|
|
83
|
-
* Obtains an app-level access token via the OAuth 2.0 `client_credentials`
|
|
84
|
-
* grant (RFC 6749 §4.4). No user is involved: the token authenticates the
|
|
85
|
-
* partner application itself and only grants access to app-level resources
|
|
86
|
-
* such as offers and offer requirements.
|
|
87
|
-
*
|
|
88
|
-
* The token is **not** persisted to the {@link SessionStore} and has no
|
|
89
|
-
* refresh token. It expires at `expiresAt`; once expired, call this method
|
|
90
|
-
* again to obtain a fresh token — the SDK does not renew it automatically.
|
|
91
|
-
*
|
|
92
|
-
* Pass the result to `ServerOffersNamespace` or
|
|
93
|
-
* `ServerRequirementsNamespace.forOffer` to read without a user session.
|
|
94
|
-
*/
|
|
95
|
-
clientCredentials(): Promise<ClientCredentialsOAuth>;
|
|
96
|
-
/**
|
|
97
|
-
* Revokes the current token via `POST /oauth/revoke` and clears the session.
|
|
98
|
-
*
|
|
99
|
-
* Throws {@link WritableSessionStoreRequiredError} if the session store does
|
|
100
|
-
* not provide `setSession`.
|
|
101
|
-
*/
|
|
102
|
-
logout(): Promise<void>;
|
|
103
|
-
}
|
|
104
|
-
/** What {@link ServerAuthNamespaceImpl} needs out of `ServerConfig`. */
|
|
105
|
-
type ServerAuthConfig = Config & {
|
|
106
|
-
readonly clientSecret: ClientSecret;
|
|
107
|
-
readonly sessionStore: SessionStore;
|
|
108
|
-
/** Seconds before expiry at which a token counts as expired for refresh. */
|
|
109
|
-
readonly accessTokenExpiryBufferSeconds: number;
|
|
110
|
-
/** Whether to rethrow errors the SDK could otherwise swallow (e.g. revoke). */
|
|
111
|
-
readonly strict: boolean;
|
|
112
|
-
};
|
|
113
|
-
declare class ServerAuthNamespaceImpl implements ServerAuthNamespace {
|
|
114
|
-
private readonly api;
|
|
115
|
-
private readonly config;
|
|
116
|
-
private readonly log;
|
|
117
|
-
constructor(api: Sender, config: ServerAuthConfig);
|
|
118
|
-
completeOAuth(params: CompleteOAuthParams): Promise<OAuthSession>;
|
|
119
|
-
getAccessToken(): Promise<OAuthAccessToken | null>;
|
|
120
|
-
private readAccessToken;
|
|
121
|
-
private refreshSession;
|
|
122
|
-
clientCredentials(): Promise<ClientCredentialsOAuth>;
|
|
123
|
-
logout(): Promise<void>;
|
|
124
|
-
private revokeAndClear;
|
|
125
|
-
/**
|
|
126
|
-
* Returns the store's `setSession`, or throws — the guard every
|
|
127
|
-
* session-writing operation shares.
|
|
128
|
-
*/
|
|
129
|
-
private writableSessionStore;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* What the server-only namespaces need, on top of what
|
|
134
|
-
* {@link UniversalNamespaceContext} provides: authentication that a caller can
|
|
135
|
-
* satisfy with an app-level token instead of a user session.
|
|
136
|
-
*/
|
|
137
|
-
interface ServerNamespaceContext {
|
|
138
|
-
readonly api: Sender;
|
|
139
|
-
/** As {@link UniversalNamespaceContext.logger}: the raw port, scoped per namespace. */
|
|
140
|
-
readonly logger: Logger | null;
|
|
141
|
-
/**
|
|
142
|
-
* Requires a user session, unless `clientCreds` is supplied — an app-level
|
|
143
|
-
* token authenticates the request on its own. Throws
|
|
144
|
-
* {@link NotAuthenticatedError} when neither is present.
|
|
145
|
-
*/
|
|
146
|
-
ensureAuthenticated(clientCreds?: ClientCredentialsOAuth): Promise<void>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The server-side offers namespace: the same reads as the shared
|
|
151
|
-
* {@link OffersNamespace}, each additionally callable with an app-level token
|
|
152
|
-
* from `ServerAuthNamespace.clientCredentials` instead of a user session.
|
|
153
|
-
*
|
|
154
|
-
* When a user session exists it takes precedence and `clientCreds` acts as a
|
|
155
|
-
* fallback. Without either, the reads throw {@link NotAuthenticatedError}.
|
|
156
|
-
*/
|
|
157
|
-
interface ServerOffersNamespace extends OffersNamespace {
|
|
158
|
-
/** @param clientCreds app-level token to read without a user session. */
|
|
159
|
-
list(clientCreds?: ClientCredentialsOAuth): Promise<Offer[]>;
|
|
160
|
-
/** @param clientCreds app-level token to read without a user session. */
|
|
161
|
-
listPage(params: PaginationParams, clientCreds?: ClientCredentialsOAuth): Promise<PaginatedResponse<Offer>>;
|
|
162
|
-
/** @param clientCreds app-level token to read without a user session. */
|
|
163
|
-
get(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
|
|
164
|
-
}
|
|
165
|
-
declare class ServerOffersNamespaceImpl implements ServerOffersNamespace {
|
|
166
|
-
private readonly ctx;
|
|
167
|
-
private readonly log;
|
|
168
|
-
constructor(ctx: ServerNamespaceContext);
|
|
169
|
-
list(clientCreds?: ClientCredentialsOAuth): Promise<Offer[]>;
|
|
170
|
-
listPage(params: PaginationParams, clientCreds?: ClientCredentialsOAuth): Promise<PaginatedResponse<Offer>>;
|
|
171
|
-
get(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The server-side requirements namespace: the same surface as the shared
|
|
176
|
-
* {@link RequirementsNamespace}, except {@link forOffer} — the offer's
|
|
177
|
-
* requirement definitions are app-level data, so it is additionally callable
|
|
178
|
-
* with a token from `ServerAuthNamespace.clientCredentials`.
|
|
179
|
-
*
|
|
180
|
-
* Everything else is per-user data and needs a user session. `handle` is
|
|
181
|
-
* client-only: there is no browser tab to open on a server.
|
|
182
|
-
*/
|
|
183
|
-
interface ServerRequirementsNamespace extends RequirementsNamespace {
|
|
184
|
-
/** @param clientCreds app-level token to read without a user session. */
|
|
185
|
-
forOffer(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
186
|
-
}
|
|
187
|
-
declare class ServerRequirementsNamespaceImpl extends RequirementsNamespaceImpl implements ServerRequirementsNamespace {
|
|
188
|
-
private readonly serverCtx;
|
|
189
|
-
constructor(serverCtx: UniversalNamespaceContext & ServerNamespaceContext);
|
|
190
|
-
forOffer(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
interface ServerConfig extends Config {
|
|
194
|
-
readonly clientSecret: ClientSecret;
|
|
195
|
-
readonly sessionStore: SessionStore;
|
|
196
|
-
/** Buffer in seconds before expiry to consider token expired for refresh. */
|
|
197
|
-
readonly accessTokenExpiryBufferSeconds?: number;
|
|
198
|
-
/**
|
|
199
|
-
* Whether SDK will throw an exception in cases it can be silent.
|
|
200
|
-
* For example, if token revokation on logout fails.
|
|
201
|
-
*/
|
|
202
|
-
readonly strict?: boolean;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Server-side CoinList SDK client.
|
|
206
|
-
*
|
|
207
|
-
* Functionality is grouped into namespaces — `coinlist.auth.getAccessToken()`,
|
|
208
|
-
* `coinlist.offers.list()`, `coinlist.requirements.statuses(offerId)`.
|
|
209
|
-
*
|
|
210
|
-
* Operates in one of two modes depending on whether {@link SessionStore}
|
|
211
|
-
* includes a `setSession` implementation:
|
|
212
|
-
*
|
|
213
|
-
* - **Writable store** (`setSession` provided) — full functionality: token
|
|
214
|
-
* refresh, `auth.completeOAuth`, and `auth.logout` all work normally.
|
|
215
|
-
*
|
|
216
|
-
* - **Read-only store** (no `setSession`) — token refresh is skipped entirely,
|
|
217
|
-
* meaning no network call is made and no refresh token is consumed.
|
|
218
|
-
* `auth.completeOAuth` and `auth.logout` throw
|
|
219
|
-
* {@link WritableSessionStoreRequiredError}. `auth.getAccessToken` may
|
|
220
|
-
* return an expired token (see its docs). Use this mode in execution
|
|
221
|
-
* contexts that can read the session but cannot write it back, such as
|
|
222
|
-
* Next.js Server Components.
|
|
223
|
-
*
|
|
224
|
-
* Unless a namespace says otherwise, its methods require a user session and
|
|
225
|
-
* throw {@link NotAuthenticatedError} when there is none.
|
|
226
|
-
*/
|
|
227
|
-
interface CoinListServer {
|
|
228
|
-
/**
|
|
229
|
-
* OAuth session lifecycle: exchanging an authorization code, serving a valid
|
|
230
|
-
* access token to the browser, minting app-level tokens, and logging out —
|
|
231
|
-
* e.g. `coinlist.auth.getAccessToken()`.
|
|
232
|
-
*/
|
|
233
|
-
readonly auth: ServerAuthNamespace;
|
|
234
|
-
/**
|
|
235
|
-
* The offer catalogue — e.g. `coinlist.offers.list()`. Every read also
|
|
236
|
-
* accepts an app-level token from {@link ServerAuthNamespace.clientCredentials}
|
|
237
|
-
* so it can run without a user session.
|
|
238
|
-
*/
|
|
239
|
-
readonly offers: ServerOffersNamespace;
|
|
240
|
-
/**
|
|
241
|
-
* Offer requirements and the operations that satisfy them — e.g.
|
|
242
|
-
* `coinlist.requirements.statuses(offerId)`. `forOffer` also accepts an
|
|
243
|
-
* app-level token; the rest is per-user data and needs a user session.
|
|
244
|
-
*/
|
|
245
|
-
readonly requirements: ServerRequirementsNamespace;
|
|
246
|
-
/**
|
|
247
|
-
* The user's external wallets: ownership proofs and offer-option bindings —
|
|
248
|
-
* e.g. `coinlist.wallets.list({ offerId, offerOptionId })`.
|
|
249
|
-
*/
|
|
250
|
-
readonly wallets: WalletsNamespace;
|
|
251
|
-
/**
|
|
252
|
-
* Generic ERC-20 reads (token allowance and balance) — e.g.
|
|
253
|
-
* `coinlist.erc20.getBalance({ ... })`.
|
|
254
|
-
*/
|
|
255
|
-
readonly erc20: Erc20Namespace;
|
|
256
|
-
/**
|
|
257
|
-
* Token-sale operations: listing, reading, and recording participations —
|
|
258
|
-
* e.g. `coinlist.tokenSale.list()`. The on-chain `execute`
|
|
259
|
-
* flow is client-only and is not exposed here.
|
|
260
|
-
*/
|
|
261
|
-
readonly tokenSale: CoinListTokenSaleNamespace;
|
|
262
|
-
/**
|
|
263
|
-
* On-chain swap operations: quoting a swap, reading swap-contract state, and
|
|
264
|
-
* allow-listing a proven wallet — e.g.
|
|
265
|
-
* `coinlist.superstate.getOutputToken({ contractAddress, chain })`.
|
|
266
|
-
*/
|
|
267
|
-
readonly superstate: SuperstateSwapNamespace;
|
|
268
|
-
/**
|
|
269
|
-
* Ondo swap reads: trading status and quoting. Both are free to poll.
|
|
270
|
-
*
|
|
271
|
-
* No CoinList fee is applied to a quote; see {@link OndoNamespace}.
|
|
272
|
-
*
|
|
273
|
-
* This is Ondo's whole surface for now — the wallet-driven half arrives with
|
|
274
|
-
* ENG-1680 and will be client-only, since it needs a wallet to sign with.
|
|
275
|
-
*/
|
|
276
|
-
readonly ondo: OndoNamespace;
|
|
277
|
-
/**
|
|
278
|
-
* Token display metadata (name, symbol, decimals, logos) from CoinList's
|
|
279
|
-
* public token registry, keyed by chain + contract address — e.g.
|
|
280
|
-
* `coinlist.tokens.get({ chain, address })` for an entry of
|
|
281
|
-
* `Offer.tokens`, or `coinlist.tokens.list()` for the whole
|
|
282
|
-
* catalogue in one request.
|
|
283
|
-
*
|
|
284
|
-
* Public and unauthenticated: unlike the other namespaces, its methods never
|
|
285
|
-
* require a session, so it also works with a read-only store.
|
|
286
|
-
*/
|
|
287
|
-
readonly tokens: TokensNamespace;
|
|
288
|
-
}
|
|
289
|
-
declare function createCoinListServer(config: ServerConfig): CoinListServer;
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* A {@link Logger} that writes newline-delimited JSON to stdout through pino.
|
|
293
|
-
*
|
|
294
|
-
* ```ts
|
|
295
|
-
* createCoinListServer({
|
|
296
|
-
* ...config,
|
|
297
|
-
* logger: pinoServerLogger({ isDev: false, level: 'info' }),
|
|
298
|
-
* });
|
|
299
|
-
* ```
|
|
300
|
-
*
|
|
301
|
-
* The Node counterpart of {@link pinoClientLogger}, for a route handler, a BFF
|
|
302
|
-
* or SSR. One line per record, which is what every log aggregator ingests
|
|
303
|
-
* without configuration.
|
|
304
|
-
*
|
|
305
|
-
* ## What it deliberately does not do
|
|
306
|
-
*
|
|
307
|
-
* **No transport, and no `pino-pretty`.** A pino transport runs on a worker
|
|
308
|
-
* thread through `thread-stream`, which every bundler has to be told about
|
|
309
|
-
* (`serverExternalPackages` in Next) and which edge runtimes cannot run at
|
|
310
|
-
* all. Pretty-printing is a pipe the host owns rather than a dependency the
|
|
311
|
-
* SDK takes on their behalf:
|
|
312
|
-
*
|
|
313
|
-
* ```sh
|
|
314
|
-
* node server.js | npx pino-pretty
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* **No environment-dependent formatting.** `isDev` decides which levels are
|
|
318
|
-
* legal and nothing else, so a development record and a production record are
|
|
319
|
-
* the same shape - what you debug is what you ship.
|
|
320
|
-
*
|
|
321
|
-
* If you already run pino, or want transports, redaction or `destination`,
|
|
322
|
-
* implement {@link Logger} yourself: it is four methods over an event, and
|
|
323
|
-
* `@opentelemetry/instrumentation-pino` patches the pino module rather than an
|
|
324
|
-
* instance, so trace correlation reaches this logger either way.
|
|
325
|
-
*
|
|
326
|
-
* ## Production
|
|
327
|
-
*
|
|
328
|
-
* **Not advised in production**, the same as everywhere else this seam is
|
|
329
|
-
* documented: the SDK's default answer is to leave {@link Config.logger}
|
|
330
|
-
* undefined outside development, staging and incident reproduction. A backend
|
|
331
|
-
* is the least bad place to disregard that - the records go to your process
|
|
332
|
-
* and your sink rather than to a page the end user can read - but it is still
|
|
333
|
-
* a disregard, and the retention and access questions become yours.
|
|
334
|
-
*
|
|
335
|
-
* If you run one, `isDev: false` restricts you to `'error'`, `'warn'` and
|
|
336
|
-
* `'info'` - `{ isDev: false, level: 'debug' }` does not compile, see
|
|
337
|
-
* {@link PinoLoggerOptions}. Those levels are redacted by construction, which
|
|
338
|
-
* is a mechanism the SDK holds itself to; whether that clears your bar is a
|
|
339
|
-
* judgement the SDK is not in a position to make for you.
|
|
340
|
-
*
|
|
341
|
-
* Holds no module-level state: every call builds its own pino instance, and
|
|
342
|
-
* the level is fixed at construction, so two loggers never interfere. Fixed is
|
|
343
|
-
* this implementation's choice, not the seam's - the SDK re-reads
|
|
344
|
-
* {@link Logger.level} before every log call - so if you want a level you can
|
|
345
|
-
* change at runtime, implement {@link Logger} over your own pino instance
|
|
346
|
-
* rather than calling this.
|
|
347
|
-
*/
|
|
348
|
-
declare function pinoServerLogger(options: PinoLoggerOptions): Logger;
|
|
349
|
-
|
|
350
|
-
declare class WritableSessionStoreRequiredError extends Error {
|
|
351
|
-
constructor(message?: string);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export { type CoinListServer, type CompleteOAuthParams, type ServerAuthConfig, type ServerAuthNamespace, ServerAuthNamespaceImpl, type ServerConfig, type ServerNamespaceContext, type ServerOffersNamespace, ServerOffersNamespaceImpl, type ServerRequirementsNamespace, ServerRequirementsNamespaceImpl, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype, D as TokenMetadata, aH as Chain, b as EvmContractAddress, bf as OfferToken } from './tokens-namespace-CIWBtgt2.js';
|
|
2
|
-
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
|
-
|
|
4
|
-
type PKCEParams = {
|
|
5
|
-
clientId: ClientId;
|
|
6
|
-
responseType: 'code';
|
|
7
|
-
redirectUri: RedirectUri;
|
|
8
|
-
codeChallenge: CodeChallenge;
|
|
9
|
-
codeChallengeMethod: 'S256';
|
|
10
|
-
state: PKCEState;
|
|
11
|
-
codeVerifier: CodeVerifier;
|
|
12
|
-
};
|
|
13
|
-
type PKCEConfig = {
|
|
14
|
-
clientId: ClientId;
|
|
15
|
-
redirectUri: RedirectUri;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Generates PKCE parameters for an OAuth2 authorization code flow.
|
|
19
|
-
* Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use
|
|
20
|
-
* in server-side code and Next.js middleware.
|
|
21
|
-
*/
|
|
22
|
-
declare function generatePKCEParams(config: PKCEConfig): Promise<PKCEParams>;
|
|
23
|
-
|
|
24
|
-
type WriteContractParams = {
|
|
25
|
-
abi: Abi;
|
|
26
|
-
address: `0x${string}`;
|
|
27
|
-
functionName: string;
|
|
28
|
-
args?: readonly unknown[];
|
|
29
|
-
value?: bigint;
|
|
30
|
-
chain: EthereumChain;
|
|
31
|
-
};
|
|
32
|
-
type BroadcastTxParams = Tx & {
|
|
33
|
-
chain: EthereumChain;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The signing-only wallet capability: address + `signMessage`. This is all the
|
|
37
|
-
* external-wallet ownership proof needs (see `useConnectWallet`), so hosts can
|
|
38
|
-
* satisfy that flow without implementing on-chain capabilities. The richer
|
|
39
|
-
* {@link EvmWallet} extends this for swap flows.
|
|
40
|
-
*
|
|
41
|
-
* SDK users implement this against their own wallet stack (e.g. viem, wagmi,
|
|
42
|
-
* Privy). `signMessage` throws on failure and the SDK classifies it.
|
|
43
|
-
*/
|
|
44
|
-
interface EvmSigner {
|
|
45
|
-
readonly address: EvmWalletAddress;
|
|
46
|
-
signMessage(message: string): Promise<Hex>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The full on-chain wallet the SDK needs to run the swap flows: an
|
|
50
|
-
* {@link EvmSigner} plus contract writes, raw-tx broadcast, and confirmation.
|
|
51
|
-
* SDK users implement this against their own wallet stack (e.g. viem, wagmi,
|
|
52
|
-
* Privy).
|
|
53
|
-
*
|
|
54
|
-
* Methods throw on failure. The SDK catches and classifies the thrown error
|
|
55
|
-
* (viem's `UserRejectedRequestError`, `InsufficientFundsError`, timeouts, …)
|
|
56
|
-
* into a typed {@link WalletError}, so implementers can simply let their wallet
|
|
57
|
-
* library's errors propagate.
|
|
58
|
-
*/
|
|
59
|
-
interface EvmWallet extends EvmSigner {
|
|
60
|
-
writeContract(params: WriteContractParams): Promise<Hash>;
|
|
61
|
-
broadcastRawTx(params: BroadcastTxParams): Promise<Hash>;
|
|
62
|
-
awaitTx(hash: Hash, chain: EthereumChain): Promise<TransactionReceipt>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The host-provided wallet the ownership flow signs with: the signing-only
|
|
66
|
-
* {@link EvmSigner} plus the {@link EthereumChain} the signature is proven on.
|
|
67
|
-
* `chain` rides on the wallet (not the offer) because the binding is
|
|
68
|
-
* chain-agnostic: it only records which EVM chain signed.
|
|
69
|
-
*/
|
|
70
|
-
type ConnectWallet = EvmSigner & {
|
|
71
|
-
readonly chain: EthereumChain;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* A read-only quote for a swap as domain amounts: how much goes in, the
|
|
76
|
-
* protocol fee, and how much would come out. Derived from the raw
|
|
77
|
-
* {@link SwapPreview} the swap contract returns.
|
|
78
|
-
*/
|
|
79
|
-
type SwapQuote = {
|
|
80
|
-
inputTokenAmount: BlockchainAmount;
|
|
81
|
-
fee: BlockchainAmount;
|
|
82
|
-
outputTokenAmount: BlockchainAmount;
|
|
83
|
-
};
|
|
84
|
-
declare const SwapQuote: {
|
|
85
|
-
/**
|
|
86
|
-
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
87
|
-
* input and fee are denominated in the input token; the output in the output
|
|
88
|
-
* token.
|
|
89
|
-
*/
|
|
90
|
-
fromPreview: (preview: SwapPreview, inputDecimals: AssetDecimals, outputDecimals: AssetDecimals) => SwapQuote;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;
|
|
94
|
-
declare const FormattedAmountUi: (value: string) => FormattedAmountUi;
|
|
95
|
-
type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;
|
|
96
|
-
declare const FormattedPercentUi: (value: string) => FormattedPercentUi;
|
|
97
|
-
type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;
|
|
98
|
-
declare const TxExplorerUrl: (value: string) => TxExplorerUrl;
|
|
99
|
-
/**
|
|
100
|
-
* A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a
|
|
101
|
-
* `0x${string}` base but drops the runtime `0x` narrowing.
|
|
102
|
-
*/
|
|
103
|
-
type ShortenedWalletAddress = Newtype<`0x${string}`, 'ShortenedWalletAddress'>;
|
|
104
|
-
declare const ShortenedWalletAddress: (value: string) => ShortenedWalletAddress;
|
|
105
|
-
type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;
|
|
106
|
-
declare const FormattedAmountAssetUi: (value: string) => FormattedAmountAssetUi;
|
|
107
|
-
type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;
|
|
108
|
-
declare const AssetIconUrl: (value: string) => AssetIconUrl;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* An array guaranteed to hold at least one element. Use it where an empty list
|
|
112
|
-
* would be a bug (e.g. the set of assets a swap always offers).
|
|
113
|
-
*/
|
|
114
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* A token as a lookup names it. `Chain` rather than `EthereumChain` because
|
|
118
|
-
* `OfferToken.chain` is the wider type; a Solana entry simply never matches,
|
|
119
|
-
* since the snapshot models EVM chains only.
|
|
120
|
-
*/
|
|
121
|
-
type TokenKey = {
|
|
122
|
-
chain: Chain;
|
|
123
|
-
address: EvmContractAddress;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* One `coinlist.tokens.list()` answer, indexed for the lookups a catalogue
|
|
127
|
-
* makes: by the `(chain, address)` pairs `Offer.tokens` carries.
|
|
128
|
-
*
|
|
129
|
-
* The registry is fetched whole - a few hundred tokens across every chain in
|
|
130
|
-
* one request - and then asked one question per offer. Building the index
|
|
131
|
-
* once is what keeps that a map lookup per card rather than a scan of the
|
|
132
|
-
* snapshot per card. The same rule frontline-web and every other host wrote
|
|
133
|
-
* for themselves, kept here so that none of them has to.
|
|
134
|
-
*/
|
|
135
|
-
type TokenRegistrySnapshot = {
|
|
136
|
-
/** Every token the snapshot lists, in registry order. */
|
|
137
|
-
readonly tokens: readonly TokenMetadata[];
|
|
138
|
-
/** `chain:address` (address lowercased) to its metadata. */
|
|
139
|
-
readonly byKey: ReadonlyMap<string, TokenMetadata>;
|
|
140
|
-
};
|
|
141
|
-
declare const TokenRegistrySnapshot: {
|
|
142
|
-
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
143
|
-
fromTokens: (tokens: readonly TokenMetadata[]) => TokenRegistrySnapshot;
|
|
144
|
-
/**
|
|
145
|
-
* The registry's entry for one token, or `null` when it lists none. The
|
|
146
|
-
* registry is curated, so `null` is an ordinary answer rather than an
|
|
147
|
-
* error, and callers fall back to their own display defaults.
|
|
148
|
-
*/
|
|
149
|
-
get: (snapshot: TokenRegistrySnapshot, token: TokenKey) => TokenMetadata | null;
|
|
150
|
-
/**
|
|
151
|
-
* The registry's entry for the token an offer is *about*, or `null` when
|
|
152
|
-
* it lists none of them.
|
|
153
|
-
*
|
|
154
|
-
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
155
|
-
* distributes or a swap hands over, never the funding token the user pays
|
|
156
|
-
* with. An offer deployed on several chains carries one such token per
|
|
157
|
-
* chain, and the first the registry knows wins - they are the same asset,
|
|
158
|
-
* so any listed one answers for the offer.
|
|
159
|
-
*/
|
|
160
|
-
forOffer: (snapshot: TokenRegistrySnapshot, offer: {
|
|
161
|
-
tokens: readonly OfferToken[];
|
|
162
|
-
}) => TokenMetadata | null;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* The tokens an offer is *about*, most specific first: every `swap` entry,
|
|
166
|
-
* then every `distribution` entry. `funding` entries name what a swap is paid
|
|
167
|
-
* with (USDC, USDT) and never the asset on offer, so they are left out.
|
|
168
|
-
*
|
|
169
|
-
* `swap` outranks `distribution` because a swap product names the asset it
|
|
170
|
-
* hands over precisely, while a sale's distribution entry names the same
|
|
171
|
-
* token for a sale product and is accepted as the fallback. The checkout's
|
|
172
|
-
* per-chain lookup and the catalogue's any-chain lookup both read this
|
|
173
|
-
* ordering, which is why it is stated once, here.
|
|
174
|
-
*/
|
|
175
|
-
declare function offerDisplayTokens(offer: {
|
|
176
|
-
tokens: readonly OfferToken[];
|
|
177
|
-
}): OfferToken[];
|
|
178
|
-
|
|
179
|
-
export { AssetIconUrl as A, type BroadcastTxParams as B, type ConnectWallet as C, type EvmWallet as E, FormattedAmountAssetUi as F, type NonEmptyArray as N, type PKCEConfig as P, SwapQuote as S, TxExplorerUrl as T, type WriteContractParams as W, ShortenedWalletAddress as a, FormattedPercentUi as b, TokenRegistrySnapshot as c, type EvmSigner as d, FormattedAmountUi as e, type PKCEParams as f, generatePKCEParams as g, offerDisplayTokens as o };
|