@coinlist-co/react 0.12.2-rc.7b430dd → 0.12.2-rc.9fb6364
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/{chunk-MOE5S6CE.js → chunk-BNMF2HMW.js} +114 -4
- package/dist/chunk-BNMF2HMW.js.map +1 -0
- package/dist/{chunk-VH34YC3Q.js → chunk-KRA6EM2L.js} +2 -2
- package/dist/{chunk-DCW7NQXH.js → chunk-STAHYDLY.js} +52 -19
- package/dist/chunk-STAHYDLY.js.map +1 -0
- package/dist/client/index.cjs +322 -96
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +26 -10
- package/dist/client/index.d.ts +26 -10
- package/dist/client/index.js +225 -102
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +437 -76
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +47 -38
- package/dist/server/index.d.ts +47 -38
- package/dist/server/index.js +316 -61
- package/dist/server/index.js.map +1 -1
- package/dist/time-B5YOQxuh.d.ts +50 -0
- package/dist/time-BY3apBpc.d.cts +50 -0
- package/dist/{token-registry-snapshot-BNBNuDu1.d.ts → token-registry-snapshot-C1NxdBmF.d.ts} +1 -1
- package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-DyjrA32p.d.cts} +1 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.cts → tokens-namespace-BJfFeowE.d.cts} +53 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.ts → tokens-namespace-BJfFeowE.d.ts} +53 -1
- package/dist/universal/index.cjs +100 -3
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +23 -5
- package/dist/universal/index.d.ts +23 -5
- package/dist/universal/index.js +12 -2
- package/package.json +1 -1
- package/dist/chunk-DCW7NQXH.js.map +0 -1
- package/dist/chunk-MOE5S6CE.js.map +0 -1
- /package/dist/{chunk-VH34YC3Q.js.map → chunk-KRA6EM2L.js.map} +0 -0
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { A as AuthorizationCode, C as CodeVerifier, aq as OAuthSession, v as OAuthAccessToken, ar as ClientCredentialsOAuth,
|
|
1
|
+
import { A as AuthorizationCode, C as CodeVerifier, aq as OAuthSession, v as OAuthAccessToken, ar as ClientCredentialsOAuth, as as Sender, L as Logger, w as OffersNamespace, J as Offer, at as PaginationParams, au 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, u as Config, av as ClientSecret, _ as PinoLoggerOptions } from '../tokens-namespace-BJfFeowE.cjs';
|
|
2
|
+
import { S as Seconds } from '../time-BY3apBpc.cjs';
|
|
2
3
|
import 'viem';
|
|
3
4
|
|
|
4
5
|
interface SessionStore {
|
|
@@ -55,18 +56,36 @@ interface ServerAuthNamespace {
|
|
|
55
56
|
* Exchanges an authorization code from `CoinListClient#auth.completeOAuth`
|
|
56
57
|
* for an OAuth session and persists it via {@link SessionStore.setSession}.
|
|
57
58
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* The exchange is never retried automatically: an authorization code is
|
|
60
|
+
* single-use, so a retry of an attempt that reached the server would fail
|
|
61
|
+
* anyway, and could mask why the first one did.
|
|
62
|
+
*
|
|
63
|
+
* @throws {@link WritableSessionStoreRequiredError} if the session store
|
|
64
|
+
* does not provide `setSession`.
|
|
65
|
+
* @throws {@link HttpError} if CoinList refuses the exchange.
|
|
60
66
|
*/
|
|
61
67
|
completeOAuth(params: CompleteOAuthParams): Promise<OAuthSession>;
|
|
62
68
|
/**
|
|
63
69
|
* Returns a valid access token for the current session, refreshing it if it
|
|
64
70
|
* is expired or near expiry. This is what you serve to
|
|
65
|
-
* {@link ClientConfig.getAccessToken}
|
|
71
|
+
* {@link ClientConfig.getAccessToken}: answer `null` with "no session"
|
|
72
|
+
* (e.g. a 204) and a throw with a failure (e.g. a 503), never the other way
|
|
73
|
+
* round - the browser signs the user out on the first and not the second.
|
|
66
74
|
*
|
|
67
75
|
* **Writable store**: if the token is expired, the SDK exchanges the refresh
|
|
68
76
|
* token for a new session, persists it, and returns the fresh access token.
|
|
69
|
-
*
|
|
77
|
+
* Concurrent calls for the same session in this process share one exchange.
|
|
78
|
+
*
|
|
79
|
+
* A rejected refresh token (`400 invalid_grant`) is only a *suspicion* at
|
|
80
|
+
* first, because the backend answers "rotated a moment ago by a concurrent
|
|
81
|
+
* request" and "expired or revoked" identically: the SDK writes nothing,
|
|
82
|
+
* so it cannot overwrite the session the winning request just stored, and
|
|
83
|
+
* returns `null` - or the current access token, if that has not actually
|
|
84
|
+
* expired yet. Only a second rejection of the same refresh token, 5 to 60
|
|
85
|
+
* seconds later in this process, is the verdict: the session is cleared via
|
|
86
|
+
* {@link SessionStore.setSession} and {@link Config.onSessionExpired} is
|
|
87
|
+
* called. A browser confirming through your endpoint asks again after one
|
|
88
|
+
* second, so it signs out on its own verdict and not on this one.
|
|
70
89
|
*
|
|
71
90
|
* **Read-only store** (no `setSession`): refresh is skipped entirely. The
|
|
72
91
|
* stored token is returned as-is, even if it is expired — a non-null return
|
|
@@ -75,8 +94,14 @@ interface ServerAuthNamespace {
|
|
|
75
94
|
* store (e.g. in a Route Handler) when you need the SDK to renew the session
|
|
76
95
|
* automatically.
|
|
77
96
|
*
|
|
78
|
-
* @returns the access token, or `null` if there is no session or the
|
|
79
|
-
*
|
|
97
|
+
* @returns the access token, or `null` if there is no session, or the
|
|
98
|
+
* session was rejected (suspected or confirmed).
|
|
99
|
+
* @throws the underlying error - an {@link HttpError} for a 5xx or
|
|
100
|
+
* `invalid_client`, the `fetch` error for a network failure - when the SDK
|
|
101
|
+
* could not find out whether a session exists and the current access token
|
|
102
|
+
* has already expired. The session is left untouched. **Never treat this as
|
|
103
|
+
* logged out**: it means "try again", and during an outage treating it as
|
|
104
|
+
* logged out would sign out every user at once.
|
|
80
105
|
*/
|
|
81
106
|
getAccessToken(): Promise<OAuthAccessToken | null>;
|
|
82
107
|
/**
|
|
@@ -101,33 +126,6 @@ interface ServerAuthNamespace {
|
|
|
101
126
|
*/
|
|
102
127
|
logout(): Promise<void>;
|
|
103
128
|
}
|
|
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
129
|
|
|
132
130
|
/**
|
|
133
131
|
* What the server-only namespaces need, on top of what
|
|
@@ -193,8 +191,16 @@ declare class ServerRequirementsNamespaceImpl extends RequirementsNamespaceImpl
|
|
|
193
191
|
interface ServerConfig extends Config {
|
|
194
192
|
readonly clientSecret: ClientSecret;
|
|
195
193
|
readonly sessionStore: SessionStore;
|
|
196
|
-
/**
|
|
197
|
-
|
|
194
|
+
/**
|
|
195
|
+
* How many seconds before its expiry an access token is refreshed. Defaults
|
|
196
|
+
* to 60. Refreshing early moves the work to a single request while the
|
|
197
|
+
* current token still works, and a refresh that fails inside this window
|
|
198
|
+
* keeps serving the current token rather than failing the request.
|
|
199
|
+
*
|
|
200
|
+
* Build it with `Seconds.of(n)`, which throws a `ValidationError` unless
|
|
201
|
+
* `n` is a non-negative integer.
|
|
202
|
+
*/
|
|
203
|
+
readonly accessTokenExpiryBufferSeconds?: Seconds;
|
|
198
204
|
/**
|
|
199
205
|
* Whether SDK will throw an exception in cases it can be silent.
|
|
200
206
|
* For example, if token revokation on logout fails.
|
|
@@ -222,7 +228,10 @@ interface ServerConfig extends Config {
|
|
|
222
228
|
* Next.js Server Components.
|
|
223
229
|
*
|
|
224
230
|
* Unless a namespace says otherwise, its methods require a user session and
|
|
225
|
-
* throw {@link NotAuthenticatedError} when there is none.
|
|
231
|
+
* throw {@link NotAuthenticatedError} when there is none. When the SDK could
|
|
232
|
+
* not find out whether there is one - CoinList's token endpoint failing, or
|
|
233
|
+
* the network - they throw that underlying error instead: see
|
|
234
|
+
* {@link ServerAuthNamespace.getAccessToken}.
|
|
226
235
|
*/
|
|
227
236
|
interface CoinListServer {
|
|
228
237
|
/**
|
|
@@ -351,4 +360,4 @@ declare class WritableSessionStoreRequiredError extends Error {
|
|
|
351
360
|
constructor(message?: string);
|
|
352
361
|
}
|
|
353
362
|
|
|
354
|
-
export { type CoinListServer, type CompleteOAuthParams, type
|
|
363
|
+
export { type CoinListServer, type CompleteOAuthParams, type ServerAuthNamespace, type ServerConfig, type ServerNamespaceContext, type ServerOffersNamespace, ServerOffersNamespaceImpl, type ServerRequirementsNamespace, ServerRequirementsNamespaceImpl, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { A as AuthorizationCode, C as CodeVerifier, aq as OAuthSession, v as OAuthAccessToken, ar as ClientCredentialsOAuth,
|
|
1
|
+
import { A as AuthorizationCode, C as CodeVerifier, aq as OAuthSession, v as OAuthAccessToken, ar as ClientCredentialsOAuth, as as Sender, L as Logger, w as OffersNamespace, J as Offer, at as PaginationParams, au 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, u as Config, av as ClientSecret, _ as PinoLoggerOptions } from '../tokens-namespace-BJfFeowE.js';
|
|
2
|
+
import { S as Seconds } from '../time-B5YOQxuh.js';
|
|
2
3
|
import 'viem';
|
|
3
4
|
|
|
4
5
|
interface SessionStore {
|
|
@@ -55,18 +56,36 @@ interface ServerAuthNamespace {
|
|
|
55
56
|
* Exchanges an authorization code from `CoinListClient#auth.completeOAuth`
|
|
56
57
|
* for an OAuth session and persists it via {@link SessionStore.setSession}.
|
|
57
58
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* The exchange is never retried automatically: an authorization code is
|
|
60
|
+
* single-use, so a retry of an attempt that reached the server would fail
|
|
61
|
+
* anyway, and could mask why the first one did.
|
|
62
|
+
*
|
|
63
|
+
* @throws {@link WritableSessionStoreRequiredError} if the session store
|
|
64
|
+
* does not provide `setSession`.
|
|
65
|
+
* @throws {@link HttpError} if CoinList refuses the exchange.
|
|
60
66
|
*/
|
|
61
67
|
completeOAuth(params: CompleteOAuthParams): Promise<OAuthSession>;
|
|
62
68
|
/**
|
|
63
69
|
* Returns a valid access token for the current session, refreshing it if it
|
|
64
70
|
* is expired or near expiry. This is what you serve to
|
|
65
|
-
* {@link ClientConfig.getAccessToken}
|
|
71
|
+
* {@link ClientConfig.getAccessToken}: answer `null` with "no session"
|
|
72
|
+
* (e.g. a 204) and a throw with a failure (e.g. a 503), never the other way
|
|
73
|
+
* round - the browser signs the user out on the first and not the second.
|
|
66
74
|
*
|
|
67
75
|
* **Writable store**: if the token is expired, the SDK exchanges the refresh
|
|
68
76
|
* token for a new session, persists it, and returns the fresh access token.
|
|
69
|
-
*
|
|
77
|
+
* Concurrent calls for the same session in this process share one exchange.
|
|
78
|
+
*
|
|
79
|
+
* A rejected refresh token (`400 invalid_grant`) is only a *suspicion* at
|
|
80
|
+
* first, because the backend answers "rotated a moment ago by a concurrent
|
|
81
|
+
* request" and "expired or revoked" identically: the SDK writes nothing,
|
|
82
|
+
* so it cannot overwrite the session the winning request just stored, and
|
|
83
|
+
* returns `null` - or the current access token, if that has not actually
|
|
84
|
+
* expired yet. Only a second rejection of the same refresh token, 5 to 60
|
|
85
|
+
* seconds later in this process, is the verdict: the session is cleared via
|
|
86
|
+
* {@link SessionStore.setSession} and {@link Config.onSessionExpired} is
|
|
87
|
+
* called. A browser confirming through your endpoint asks again after one
|
|
88
|
+
* second, so it signs out on its own verdict and not on this one.
|
|
70
89
|
*
|
|
71
90
|
* **Read-only store** (no `setSession`): refresh is skipped entirely. The
|
|
72
91
|
* stored token is returned as-is, even if it is expired — a non-null return
|
|
@@ -75,8 +94,14 @@ interface ServerAuthNamespace {
|
|
|
75
94
|
* store (e.g. in a Route Handler) when you need the SDK to renew the session
|
|
76
95
|
* automatically.
|
|
77
96
|
*
|
|
78
|
-
* @returns the access token, or `null` if there is no session or the
|
|
79
|
-
*
|
|
97
|
+
* @returns the access token, or `null` if there is no session, or the
|
|
98
|
+
* session was rejected (suspected or confirmed).
|
|
99
|
+
* @throws the underlying error - an {@link HttpError} for a 5xx or
|
|
100
|
+
* `invalid_client`, the `fetch` error for a network failure - when the SDK
|
|
101
|
+
* could not find out whether a session exists and the current access token
|
|
102
|
+
* has already expired. The session is left untouched. **Never treat this as
|
|
103
|
+
* logged out**: it means "try again", and during an outage treating it as
|
|
104
|
+
* logged out would sign out every user at once.
|
|
80
105
|
*/
|
|
81
106
|
getAccessToken(): Promise<OAuthAccessToken | null>;
|
|
82
107
|
/**
|
|
@@ -101,33 +126,6 @@ interface ServerAuthNamespace {
|
|
|
101
126
|
*/
|
|
102
127
|
logout(): Promise<void>;
|
|
103
128
|
}
|
|
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
129
|
|
|
132
130
|
/**
|
|
133
131
|
* What the server-only namespaces need, on top of what
|
|
@@ -193,8 +191,16 @@ declare class ServerRequirementsNamespaceImpl extends RequirementsNamespaceImpl
|
|
|
193
191
|
interface ServerConfig extends Config {
|
|
194
192
|
readonly clientSecret: ClientSecret;
|
|
195
193
|
readonly sessionStore: SessionStore;
|
|
196
|
-
/**
|
|
197
|
-
|
|
194
|
+
/**
|
|
195
|
+
* How many seconds before its expiry an access token is refreshed. Defaults
|
|
196
|
+
* to 60. Refreshing early moves the work to a single request while the
|
|
197
|
+
* current token still works, and a refresh that fails inside this window
|
|
198
|
+
* keeps serving the current token rather than failing the request.
|
|
199
|
+
*
|
|
200
|
+
* Build it with `Seconds.of(n)`, which throws a `ValidationError` unless
|
|
201
|
+
* `n` is a non-negative integer.
|
|
202
|
+
*/
|
|
203
|
+
readonly accessTokenExpiryBufferSeconds?: Seconds;
|
|
198
204
|
/**
|
|
199
205
|
* Whether SDK will throw an exception in cases it can be silent.
|
|
200
206
|
* For example, if token revokation on logout fails.
|
|
@@ -222,7 +228,10 @@ interface ServerConfig extends Config {
|
|
|
222
228
|
* Next.js Server Components.
|
|
223
229
|
*
|
|
224
230
|
* Unless a namespace says otherwise, its methods require a user session and
|
|
225
|
-
* throw {@link NotAuthenticatedError} when there is none.
|
|
231
|
+
* throw {@link NotAuthenticatedError} when there is none. When the SDK could
|
|
232
|
+
* not find out whether there is one - CoinList's token endpoint failing, or
|
|
233
|
+
* the network - they throw that underlying error instead: see
|
|
234
|
+
* {@link ServerAuthNamespace.getAccessToken}.
|
|
226
235
|
*/
|
|
227
236
|
interface CoinListServer {
|
|
228
237
|
/**
|
|
@@ -351,4 +360,4 @@ declare class WritableSessionStoreRequiredError extends Error {
|
|
|
351
360
|
constructor(message?: string);
|
|
352
361
|
}
|
|
353
362
|
|
|
354
|
-
export { type CoinListServer, type CompleteOAuthParams, type
|
|
363
|
+
export { type CoinListServer, type CompleteOAuthParams, type ServerAuthNamespace, type ServerConfig, type ServerNamespaceContext, type ServerOffersNamespace, ServerOffersNamespaceImpl, type ServerRequirementsNamespace, ServerRequirementsNamespaceImpl, type SessionStore, WritableSessionStoreRequiredError, createCoinListServer, emptySessionStore, pinoServerLogger };
|