@coinlist-co/react 0.12.2-rc.8a0d02a → 0.12.2-rc.8a65e9d
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-C6GF7MDF.js → chunk-2FZAXGVH.js} +1011 -1184
- package/dist/chunk-2FZAXGVH.js.map +1 -0
- package/dist/{chunk-IZJ4JSSC.js → chunk-EAPBF7T2.js} +152 -234
- package/dist/chunk-EAPBF7T2.js.map +1 -0
- package/dist/chunk-IWQ6A52U.js +24 -0
- package/dist/chunk-IWQ6A52U.js.map +1 -0
- package/dist/{chunk-3WW5FLT7.js → chunk-OQ2ANYUF.js} +334 -27
- package/dist/chunk-OQ2ANYUF.js.map +1 -0
- package/dist/client/index.d.ts +3277 -5736
- package/dist/client/index.js +10835 -10729
- package/dist/client/index.js.map +1 -1
- package/dist/client-credentials-BwcmPcn-.d.ts +13 -0
- package/dist/server/index.d.ts +54 -132
- package/dist/server/index.js +211 -171
- package/dist/server/index.js.map +1 -1
- package/dist/{time-CVZpAkGY.d.cts → time-ChSGmKZe.d.ts} +2194 -3422
- package/dist/{token-registry-snapshot-BkwA8KmD.d.ts → token-registry-snapshot-DMubXr2c.d.ts} +22 -58
- package/dist/universal/index.d.ts +94 -1068
- package/dist/universal/index.js +25 -47
- package/package.json +18 -14
- package/dist/chunk-3WW5FLT7.js.map +0 -1
- package/dist/chunk-C6GF7MDF.js.map +0 -1
- package/dist/chunk-IZJ4JSSC.js.map +0 -1
- package/dist/client/index.cjs +0 -20460
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -8195
- package/dist/server/index.cjs +0 -4525
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -382
- package/dist/time-CVZpAkGY.d.ts +0 -3987
- package/dist/token-registry-snapshot-bR14QehS.d.cts +0 -245
- package/dist/universal/index.cjs +0 -4562
- package/dist/universal/index.cjs.map +0 -1
- package/dist/universal/index.d.cts +0 -1362
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { bp as Newtype, x as OAuthAccessToken } from './time-ChSGmKZe.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An app-level access token, minted by `CoinListServer#auth.clientCredentials()`
|
|
5
|
+
* through the OAuth client-credentials grant. It authenticates the partner
|
|
6
|
+
* application rather than a user, so it must never reach a browser:
|
|
7
|
+
* `app-tokens-are-server-only` keeps every tree but the server and the api
|
|
8
|
+
* layer from importing this module.
|
|
9
|
+
*/
|
|
10
|
+
type ClientCredentialsOAuth = Newtype<OAuthAccessToken, 'ClientCredentialsOAuth'>;
|
|
11
|
+
declare const ClientCredentialsOAuth: (value: OAuthAccessToken) => ClientCredentialsOAuth;
|
|
12
|
+
|
|
13
|
+
export { ClientCredentialsOAuth as C };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,51 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ClientCredentialsOAuth } from '../client-credentials-BwcmPcn-.js';
|
|
2
|
+
import { A as AuthorizationGrant, ah as OAuthSession, x as OAuthAccessToken, y as OffersNamespace, D as Offer, ai as PaginationParams, aj as PaginatedResponse, n as OfferId, G as OfferDetail, R as RequirementsNamespace, f as OfferOptionId, s as Requirement, v as WalletsNamespace, z as Erc20Namespace, g as CoinListTokenSaleNamespace, r as SuperstateSwapNamespace, k as OndoNamespace, d as CentrifugeNamespace, T as TokensNamespace, w as Config, ak as ClientSecret, K as Seconds, X as PinoLoggerOptions, Y as Logger } from '../time-ChSGmKZe.js';
|
|
2
3
|
import 'viem';
|
|
3
4
|
|
|
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
5
|
/**
|
|
47
6
|
* OAuth session lifecycle on your backend: exchanging authorization codes,
|
|
48
|
-
* keeping the access token fresh
|
|
7
|
+
* keeping the access token fresh and serving it to the browser, minting
|
|
8
|
+
* app-level tokens, and logging out - e.g. `coinlist.auth.getAccessToken()`.
|
|
49
9
|
*
|
|
50
10
|
* This namespace is server-only: every method needs the `clientSecret` and the
|
|
51
11
|
* {@link SessionStore}, neither of which may exist in a browser.
|
|
@@ -63,7 +23,7 @@ interface ServerAuthNamespace {
|
|
|
63
23
|
* does not provide `setSession`.
|
|
64
24
|
* @throws {@link HttpError} if CoinList refuses the exchange.
|
|
65
25
|
*/
|
|
66
|
-
completeOAuth(
|
|
26
|
+
completeOAuth(grant: AuthorizationGrant): Promise<OAuthSession>;
|
|
67
27
|
/**
|
|
68
28
|
* Returns a valid access token for the current session, refreshing it if it
|
|
69
29
|
* is expired or near expiry. This is what you serve to
|
|
@@ -137,27 +97,51 @@ interface ServerAuthNamespace {
|
|
|
137
97
|
logout(): Promise<void>;
|
|
138
98
|
}
|
|
139
99
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
readonly api: Sender;
|
|
147
|
-
/** As {@link UniversalNamespaceContext.logger}: the raw port, scoped per namespace. */
|
|
148
|
-
readonly logger: Logger | null;
|
|
100
|
+
declare class WritableSessionStoreRequiredError extends Error {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface SessionStore {
|
|
105
|
+
getSession(): Promise<OAuthSession | null>;
|
|
149
106
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
107
|
+
* Persists or clears the OAuth session.
|
|
108
|
+
*
|
|
109
|
+
* **Omit this method to create a read-only store.** When absent, the SDK
|
|
110
|
+
* skips token refresh entirely — no network call is made and no refresh
|
|
111
|
+
* token is consumed. This is the correct approach for contexts that can read
|
|
112
|
+
* the session but cannot write it back, such as Next.js Server Components.
|
|
113
|
+
*
|
|
114
|
+
* ⚠️ Do **not** implement this as a no-op (`async () => {}`). If the method
|
|
115
|
+
* is present, the SDK assumes writes succeed: it will fire a token refresh
|
|
116
|
+
* network call, consume the refresh token, then invoke `setSession` — which
|
|
117
|
+
* would silently discard the new session and leave the browser holding an
|
|
118
|
+
* invalidated refresh token. Simply **omit** `setSession` to prevent any
|
|
119
|
+
* refresh from being attempted.
|
|
120
|
+
*
|
|
121
|
+
* {@link ServerAuthNamespace.completeOAuth} and
|
|
122
|
+
* {@link ServerAuthNamespace.logout} always require a writable store and
|
|
123
|
+
* throw {@link WritableSessionStoreRequiredError} if `setSession` is absent.
|
|
153
124
|
*/
|
|
154
|
-
|
|
125
|
+
setSession?(session: OAuthSession | null): Promise<void>;
|
|
155
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The empty session store: holds no session, reads nothing, never writes.
|
|
129
|
+
*
|
|
130
|
+
* For server contexts that act without a user — the client-credentials grant
|
|
131
|
+
* (`auth.clientCredentials`) and the public token registry (`tokens`) read
|
|
132
|
+
* nothing from the store, so hosts building those paths need no store of
|
|
133
|
+
* their own.
|
|
134
|
+
*
|
|
135
|
+
* `setSession` is deliberately absent, not a no-op — see
|
|
136
|
+
* {@link SessionStore.setSession} for why a no-op is a bug.
|
|
137
|
+
*/
|
|
138
|
+
declare function emptySessionStore(): SessionStore;
|
|
156
139
|
|
|
157
140
|
/**
|
|
158
141
|
* The server-side offers namespace: the same reads as the shared
|
|
159
142
|
* {@link OffersNamespace}, each additionally callable with an app-level token
|
|
160
|
-
* from `ServerAuthNamespace.clientCredentials` instead of a user session
|
|
143
|
+
* from `ServerAuthNamespace.clientCredentials` instead of a user session -
|
|
144
|
+
* e.g. `coinlist.offers.list(await coinlist.auth.clientCredentials())`.
|
|
161
145
|
*
|
|
162
146
|
* When a user session exists it takes precedence and `clientCreds` acts as a
|
|
163
147
|
* fallback. Without either, the reads throw {@link NotAuthenticatedError}.
|
|
@@ -170,14 +154,6 @@ interface ServerOffersNamespace extends OffersNamespace {
|
|
|
170
154
|
/** @param clientCreds app-level token to read without a user session. */
|
|
171
155
|
get(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
|
|
172
156
|
}
|
|
173
|
-
declare class ServerOffersNamespaceImpl implements ServerOffersNamespace {
|
|
174
|
-
private readonly ctx;
|
|
175
|
-
private readonly log;
|
|
176
|
-
constructor(ctx: ServerNamespaceContext);
|
|
177
|
-
list(clientCreds?: ClientCredentialsOAuth): Promise<Offer[]>;
|
|
178
|
-
listPage(params: PaginationParams, clientCreds?: ClientCredentialsOAuth): Promise<PaginatedResponse<Offer>>;
|
|
179
|
-
get(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
|
|
180
|
-
}
|
|
181
157
|
|
|
182
158
|
/**
|
|
183
159
|
* The server-side requirements namespace: the same surface as the shared
|
|
@@ -192,11 +168,6 @@ interface ServerRequirementsNamespace extends RequirementsNamespace {
|
|
|
192
168
|
/** @param clientCreds app-level token to read without a user session. */
|
|
193
169
|
forOffer(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
194
170
|
}
|
|
195
|
-
declare class ServerRequirementsNamespaceImpl extends RequirementsNamespaceImpl implements ServerRequirementsNamespace {
|
|
196
|
-
private readonly serverCtx;
|
|
197
|
-
constructor(serverCtx: UniversalNamespaceContext & ServerNamespaceContext);
|
|
198
|
-
forOffer(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
199
|
-
}
|
|
200
171
|
|
|
201
172
|
interface ServerConfig extends Config {
|
|
202
173
|
readonly clientSecret: ClientSecret;
|
|
@@ -248,70 +219,25 @@ interface ServerConfig extends Config {
|
|
|
248
219
|
* {@link ServerAuthNamespace.getAccessToken}.
|
|
249
220
|
*/
|
|
250
221
|
interface CoinListServer {
|
|
251
|
-
/**
|
|
252
|
-
* OAuth session lifecycle: exchanging an authorization code, serving a valid
|
|
253
|
-
* access token to the browser, minting app-level tokens, and logging out —
|
|
254
|
-
* e.g. `coinlist.auth.getAccessToken()`.
|
|
255
|
-
*/
|
|
222
|
+
/** The OAuth session lifecycle on your backend - see {@link ServerAuthNamespace}. */
|
|
256
223
|
readonly auth: ServerAuthNamespace;
|
|
257
|
-
/**
|
|
258
|
-
* The offer catalogue — e.g. `coinlist.offers.list()`. Every read also
|
|
259
|
-
* accepts an app-level token from {@link ServerAuthNamespace.clientCredentials}
|
|
260
|
-
* so it can run without a user session.
|
|
261
|
-
*/
|
|
224
|
+
/** The offer catalogue, e.g. `coinlist.offers.list()` - see {@link ServerOffersNamespace}. */
|
|
262
225
|
readonly offers: ServerOffersNamespace;
|
|
263
|
-
/**
|
|
264
|
-
* Offer requirements and the operations that satisfy them — e.g.
|
|
265
|
-
* `coinlist.requirements.statuses(offerId)`. `forOffer` also accepts an
|
|
266
|
-
* app-level token; the rest is per-user data and needs a user session.
|
|
267
|
-
*/
|
|
226
|
+
/** What a user must satisfy to participate - see {@link ServerRequirementsNamespace}. */
|
|
268
227
|
readonly requirements: ServerRequirementsNamespace;
|
|
269
|
-
/**
|
|
270
|
-
* The user's external wallets: ownership proofs and offer-option bindings —
|
|
271
|
-
* e.g. `coinlist.wallets.list({ offerId, offerOptionId })`.
|
|
272
|
-
*/
|
|
228
|
+
/** Wallet ownership proofs and offer-option bindings - see {@link WalletsNamespace}. */
|
|
273
229
|
readonly wallets: WalletsNamespace;
|
|
274
|
-
/**
|
|
275
|
-
* Generic ERC-20 reads (token allowance and balance) — e.g.
|
|
276
|
-
* `coinlist.erc20.getBalance({ ... })`.
|
|
277
|
-
*/
|
|
230
|
+
/** Generic ERC-20 allowance and balance reads - see {@link Erc20Namespace}. */
|
|
278
231
|
readonly erc20: Erc20Namespace;
|
|
279
|
-
/**
|
|
280
|
-
* Token-sale operations: listing, reading, and recording participations —
|
|
281
|
-
* e.g. `coinlist.tokenSale.list()`. The on-chain `execute`
|
|
282
|
-
* flow is client-only and is not exposed here.
|
|
283
|
-
*/
|
|
232
|
+
/** Token-sale participations - see {@link CoinListTokenSaleNamespace}. */
|
|
284
233
|
readonly tokenSale: CoinListTokenSaleNamespace;
|
|
285
|
-
/**
|
|
286
|
-
* On-chain swap operations: quoting a swap, reading swap-contract state, and
|
|
287
|
-
* allow-listing a proven wallet — e.g.
|
|
288
|
-
* `coinlist.superstate.getOutputToken({ contractAddress, chain })`.
|
|
289
|
-
*/
|
|
234
|
+
/** Superstate swap reads and wallet allow-listing - see {@link SuperstateSwapNamespace}. */
|
|
290
235
|
readonly superstate: SuperstateSwapNamespace;
|
|
291
|
-
/**
|
|
292
|
-
* Ondo swap reads: trading status and quoting. Both are free to poll.
|
|
293
|
-
*
|
|
294
|
-
* No CoinList fee is applied to a quote; see {@link OndoNamespace}.
|
|
295
|
-
*
|
|
296
|
-
* This is Ondo's whole surface for now — the wallet-driven half arrives with
|
|
297
|
-
* ENG-1680 and will be client-only, since it needs a wallet to sign with.
|
|
298
|
-
*/
|
|
236
|
+
/** Ondo swap quotes and transaction builders - see {@link OndoNamespace}. */
|
|
299
237
|
readonly ondo: OndoNamespace;
|
|
300
|
-
/**
|
|
301
|
-
* Centrifuge vault reads: the vault-wide ordering gate, and each wallet's
|
|
302
|
-
* position. The status read is free to poll.
|
|
303
|
-
*/
|
|
238
|
+
/** Centrifuge vault reads and calldata builders - see {@link CentrifugeNamespace}. */
|
|
304
239
|
readonly centrifuge: CentrifugeNamespace;
|
|
305
|
-
/**
|
|
306
|
-
* Token display metadata (name, symbol, decimals, logos) from CoinList's
|
|
307
|
-
* public token registry, keyed by chain + contract address — e.g.
|
|
308
|
-
* `coinlist.tokens.get({ chain, address })` for an entry of
|
|
309
|
-
* `Offer.tokens`, or `coinlist.tokens.list()` for the whole
|
|
310
|
-
* catalogue in one request.
|
|
311
|
-
*
|
|
312
|
-
* Public and unauthenticated: unlike the other namespaces, its methods never
|
|
313
|
-
* require a session, so it also works with a read-only store.
|
|
314
|
-
*/
|
|
240
|
+
/** Public token display metadata - see {@link TokensNamespace}. */
|
|
315
241
|
readonly tokens: TokensNamespace;
|
|
316
242
|
}
|
|
317
243
|
declare function createCoinListServer(config: ServerConfig): CoinListServer;
|
|
@@ -375,8 +301,4 @@ declare function createCoinListServer(config: ServerConfig): CoinListServer;
|
|
|
375
301
|
*/
|
|
376
302
|
declare function pinoServerLogger(options: PinoLoggerOptions): Logger;
|
|
377
303
|
|
|
378
|
-
|
|
379
|
-
constructor(message?: string);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export { type CoinListServer, type CompleteOAuthParams, type ServerAuthNamespace, type ServerConfig, type ServerNamespaceContext, type ServerOffersNamespace, ServerOffersNamespaceImpl, type ServerRequirementsNamespace, ServerRequirementsNamespaceImpl, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|
|
304
|
+
export { type CoinListServer, type ServerAuthNamespace, type ServerConfig, type ServerOffersNamespace, type ServerRequirementsNamespace, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|