@coinlist-co/react 0.12.2-rc.e1f6c82 → 0.12.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 +79 -43
- package/dist/{chunk-GIE4UWB3.js → chunk-2FZAXGVH.js} +384 -618
- package/dist/chunk-2FZAXGVH.js.map +1 -0
- package/dist/{chunk-PIOQA6HW.js → chunk-EAPBF7T2.js} +88 -109
- package/dist/chunk-EAPBF7T2.js.map +1 -0
- package/dist/{chunk-MJ6YXZWH.js → chunk-IWQ6A52U.js} +4 -2
- package/dist/chunk-IWQ6A52U.js.map +1 -0
- package/dist/{chunk-EKLUJZ7T.js → chunk-OQ2ANYUF.js} +328 -21
- package/dist/chunk-OQ2ANYUF.js.map +1 -0
- package/dist/client/index.d.ts +1634 -1268
- package/dist/client/index.js +10261 -10050
- package/dist/client/index.js.map +1 -1
- package/dist/client-credentials-BwcmPcn-.d.ts +13 -0
- package/dist/server/index.d.ts +58 -106
- package/dist/server/index.js +208 -170
- package/dist/server/index.js.map +1 -1
- package/dist/{time-Bbqlt2x7.d.ts → time-ChSGmKZe.d.ts} +114 -66
- package/dist/{token-registry-snapshot-DttZXGvY.d.ts → token-registry-snapshot-DMubXr2c.d.ts} +19 -21
- package/dist/universal/index.d.ts +86 -73
- package/dist/universal/index.js +12 -8
- package/package.json +1 -1
- package/dist/chunk-EKLUJZ7T.js.map +0 -1
- package/dist/chunk-GIE4UWB3.js.map +0 -1
- package/dist/chunk-MJ6YXZWH.js.map +0 -1
- package/dist/chunk-PIOQA6HW.js.map +0 -1
|
@@ -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,10 +97,51 @@ interface ServerAuthNamespace {
|
|
|
137
97
|
logout(): Promise<void>;
|
|
138
98
|
}
|
|
139
99
|
|
|
100
|
+
declare class WritableSessionStoreRequiredError extends Error {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface SessionStore {
|
|
105
|
+
getSession(): Promise<OAuthSession | null>;
|
|
106
|
+
/**
|
|
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.
|
|
124
|
+
*/
|
|
125
|
+
setSession?(session: OAuthSession | null): Promise<void>;
|
|
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;
|
|
139
|
+
|
|
140
140
|
/**
|
|
141
141
|
* The server-side offers namespace: the same reads as the shared
|
|
142
142
|
* {@link OffersNamespace}, each additionally callable with an app-level token
|
|
143
|
-
* 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())`.
|
|
144
145
|
*
|
|
145
146
|
* When a user session exists it takes precedence and `clientCreds` acts as a
|
|
146
147
|
* fallback. Without either, the reads throw {@link NotAuthenticatedError}.
|
|
@@ -218,70 +219,25 @@ interface ServerConfig extends Config {
|
|
|
218
219
|
* {@link ServerAuthNamespace.getAccessToken}.
|
|
219
220
|
*/
|
|
220
221
|
interface CoinListServer {
|
|
221
|
-
/**
|
|
222
|
-
* OAuth session lifecycle: exchanging an authorization code, serving a valid
|
|
223
|
-
* access token to the browser, minting app-level tokens, and logging out —
|
|
224
|
-
* e.g. `coinlist.auth.getAccessToken()`.
|
|
225
|
-
*/
|
|
222
|
+
/** The OAuth session lifecycle on your backend - see {@link ServerAuthNamespace}. */
|
|
226
223
|
readonly auth: ServerAuthNamespace;
|
|
227
|
-
/**
|
|
228
|
-
* The offer catalogue — e.g. `coinlist.offers.list()`. Every read also
|
|
229
|
-
* accepts an app-level token from {@link ServerAuthNamespace.clientCredentials}
|
|
230
|
-
* so it can run without a user session.
|
|
231
|
-
*/
|
|
224
|
+
/** The offer catalogue, e.g. `coinlist.offers.list()` - see {@link ServerOffersNamespace}. */
|
|
232
225
|
readonly offers: ServerOffersNamespace;
|
|
233
|
-
/**
|
|
234
|
-
* Offer requirements and the operations that satisfy them — e.g.
|
|
235
|
-
* `coinlist.requirements.statuses(offerId)`. `forOffer` also accepts an
|
|
236
|
-
* app-level token; the rest is per-user data and needs a user session.
|
|
237
|
-
*/
|
|
226
|
+
/** What a user must satisfy to participate - see {@link ServerRequirementsNamespace}. */
|
|
238
227
|
readonly requirements: ServerRequirementsNamespace;
|
|
239
|
-
/**
|
|
240
|
-
* The user's external wallets: ownership proofs and offer-option bindings —
|
|
241
|
-
* e.g. `coinlist.wallets.list({ offerId, offerOptionId })`.
|
|
242
|
-
*/
|
|
228
|
+
/** Wallet ownership proofs and offer-option bindings - see {@link WalletsNamespace}. */
|
|
243
229
|
readonly wallets: WalletsNamespace;
|
|
244
|
-
/**
|
|
245
|
-
* Generic ERC-20 reads (token allowance and balance) — e.g.
|
|
246
|
-
* `coinlist.erc20.getBalance({ ... })`.
|
|
247
|
-
*/
|
|
230
|
+
/** Generic ERC-20 allowance and balance reads - see {@link Erc20Namespace}. */
|
|
248
231
|
readonly erc20: Erc20Namespace;
|
|
249
|
-
/**
|
|
250
|
-
* Token-sale operations: listing, reading, and recording participations —
|
|
251
|
-
* e.g. `coinlist.tokenSale.list()`. The on-chain `execute`
|
|
252
|
-
* flow is client-only and is not exposed here.
|
|
253
|
-
*/
|
|
232
|
+
/** Token-sale participations - see {@link CoinListTokenSaleNamespace}. */
|
|
254
233
|
readonly tokenSale: CoinListTokenSaleNamespace;
|
|
255
|
-
/**
|
|
256
|
-
* On-chain swap operations: quoting a swap, reading swap-contract state, and
|
|
257
|
-
* allow-listing a proven wallet — e.g.
|
|
258
|
-
* `coinlist.superstate.getOutputToken({ contractAddress, chain })`.
|
|
259
|
-
*/
|
|
234
|
+
/** Superstate swap reads and wallet allow-listing - see {@link SuperstateSwapNamespace}. */
|
|
260
235
|
readonly superstate: SuperstateSwapNamespace;
|
|
261
|
-
/**
|
|
262
|
-
* Ondo swap reads: trading status and quoting. Both are free to poll.
|
|
263
|
-
*
|
|
264
|
-
* No CoinList fee is applied to a quote; see {@link OndoNamespace}.
|
|
265
|
-
*
|
|
266
|
-
* This is Ondo's whole surface for now — the wallet-driven half arrives with
|
|
267
|
-
* ENG-1680 and will be client-only, since it needs a wallet to sign with.
|
|
268
|
-
*/
|
|
236
|
+
/** Ondo swap quotes and transaction builders - see {@link OndoNamespace}. */
|
|
269
237
|
readonly ondo: OndoNamespace;
|
|
270
|
-
/**
|
|
271
|
-
* Centrifuge vault reads: the vault-wide ordering gate, and each wallet's
|
|
272
|
-
* position. The status read is free to poll.
|
|
273
|
-
*/
|
|
238
|
+
/** Centrifuge vault reads and calldata builders - see {@link CentrifugeNamespace}. */
|
|
274
239
|
readonly centrifuge: CentrifugeNamespace;
|
|
275
|
-
/**
|
|
276
|
-
* Token display metadata (name, symbol, decimals, logos) from CoinList's
|
|
277
|
-
* public token registry, keyed by chain + contract address — e.g.
|
|
278
|
-
* `coinlist.tokens.get({ chain, address })` for an entry of
|
|
279
|
-
* `Offer.tokens`, or `coinlist.tokens.list()` for the whole
|
|
280
|
-
* catalogue in one request.
|
|
281
|
-
*
|
|
282
|
-
* Public and unauthenticated: unlike the other namespaces, its methods never
|
|
283
|
-
* require a session, so it also works with a read-only store.
|
|
284
|
-
*/
|
|
240
|
+
/** Public token display metadata - see {@link TokensNamespace}. */
|
|
285
241
|
readonly tokens: TokensNamespace;
|
|
286
242
|
}
|
|
287
243
|
declare function createCoinListServer(config: ServerConfig): CoinListServer;
|
|
@@ -345,8 +301,4 @@ declare function createCoinListServer(config: ServerConfig): CoinListServer;
|
|
|
345
301
|
*/
|
|
346
302
|
declare function pinoServerLogger(options: PinoLoggerOptions): Logger;
|
|
347
303
|
|
|
348
|
-
|
|
349
|
-
constructor(message?: string);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export { type CoinListServer, type CompleteOAuthParams, type ServerAuthNamespace, type ServerConfig, type ServerOffersNamespace, type ServerRequirementsNamespace, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|
|
304
|
+
export { type CoinListServer, type ServerAuthNamespace, type ServerConfig, type ServerOffersNamespace, type ServerRequirementsNamespace, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|