@coinlist-co/react 0.6.0 → 0.10.0

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.
Files changed (39) hide show
  1. package/dist/{chunk-5C4TEVM7.js → chunk-7BJ2HAG7.js} +62 -92
  2. package/dist/chunk-7BJ2HAG7.js.map +1 -0
  3. package/dist/{chunk-5E3P7AMH.js → chunk-AAER5LOL.js} +3 -1
  4. package/dist/chunk-AAER5LOL.js.map +1 -0
  5. package/dist/chunk-GSSAB4K5.js +644 -0
  6. package/dist/chunk-GSSAB4K5.js.map +1 -0
  7. package/dist/chunk-TUZKKFNW.js +836 -0
  8. package/dist/chunk-TUZKKFNW.js.map +1 -0
  9. package/dist/client/index.cjs +3203 -412
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.d.cts +996 -41
  12. package/dist/client/index.d.ts +996 -41
  13. package/dist/client/index.js +2069 -208
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/collections-CJ24dOda.d.cts +28 -0
  16. package/dist/collections-ZYLKp8JB.d.ts +28 -0
  17. package/dist/requirement-CDi5NJI8.d.cts +1036 -0
  18. package/dist/requirement-CDi5NJI8.d.ts +1036 -0
  19. package/dist/server/index.cjs +588 -85
  20. package/dist/server/index.cjs.map +1 -1
  21. package/dist/server/index.d.cts +117 -17
  22. package/dist/server/index.d.ts +117 -17
  23. package/dist/server/index.js +92 -40
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/shared/index.cjs +1334 -91
  26. package/dist/shared/index.cjs.map +1 -1
  27. package/dist/shared/index.d.cts +624 -3
  28. package/dist/shared/index.d.ts +624 -3
  29. package/dist/shared/index.js +220 -5
  30. package/dist/shared/index.js.map +1 -1
  31. package/package.json +7 -3
  32. package/dist/chunk-5C4TEVM7.js.map +0 -1
  33. package/dist/chunk-5E3P7AMH.js.map +0 -1
  34. package/dist/chunk-7SB2GKEU.js +0 -311
  35. package/dist/chunk-7SB2GKEU.js.map +0 -1
  36. package/dist/chunk-UEJVCU2J.js +0 -43
  37. package/dist/chunk-UEJVCU2J.js.map +0 -1
  38. package/dist/requirement-Dk6nYN1c.d.cts +0 -389
  39. package/dist/requirement-Dk6nYN1c.d.ts +0 -389
@@ -1,4 +1,5 @@
1
- import { A as AuthorizationCode, C as CodeVerifier, n as OAuthSession, O as OAuthAccessToken, b as Offer, P as PaginationParams, c as PaginatedResponse, d as OfferId, e as OfferDetail, f as Participation, g as ParticipationsPaginationParams, h as ParticipationId, i as CreateParticipationParams, j as OfferOptionId, R as Requirement, k as RequirementStatusInfo, a as Config, o as ClientSecret } from '../requirement-Dk6nYN1c.cjs';
1
+ import { h as AuthorizationCode, i as CodeVerifier, I as OAuthSession, J as ClientCredentialsOAuth, k as OAuthAccessToken, l as Offer, m as PaginationParams, n as PaginatedResponse, O as OfferId, o as OfferDetail, p as CreateWalletOwnershipChallengeParams, W as WalletOwnershipChallenge, q as ConnectExternalWalletParams, r as OfferOptionAddress, g as OfferOptionId, s as OfferOptionAddressId, R as Requirement, t as RequirementStatusInfo, u as Pii, D as DocumentType, v as DocumentSubmission, c as CoinListErc20Namespace, f as CoinListTokenSaleNamespace, C as CoinListSwapNamespace, K as KycLevelName, w as KycToken, j as Config, L as ClientSecret } from '../requirement-CDi5NJI8.cjs';
2
+ import 'viem';
2
3
 
3
4
  interface SessionStore {
4
5
  getSession(): Promise<OAuthSession | null>;
@@ -60,6 +61,21 @@ interface CoinListServer {
60
61
  * not provide `setSession`.
61
62
  */
62
63
  completeOAuth(code: AuthorizationCode, codeVerifier: CodeVerifier): Promise<OAuthSession>;
64
+ /**
65
+ * Obtains an app-level access token via the OAuth 2.0 `client_credentials`
66
+ * grant (RFC 6749 §4.4). No user is involved: the token authenticates the
67
+ * partner application itself and only grants access to app-level resources
68
+ * such as offers and offer requirements.
69
+ *
70
+ * The token is **not** persisted to the {@link SessionStore} and has no
71
+ * refresh token. It expires at `expiresAt`; once expired, call this method
72
+ * again to obtain a fresh token — the SDK does not renew it automatically.
73
+ *
74
+ * Pass the result to {@link fetchOffers}, {@link fetchOffersPage},
75
+ * {@link fetchOfferDetails}, or {@link fetchOfferRequirements} to call them
76
+ * without a user session.
77
+ */
78
+ clientCredentialsOAuth(): Promise<ClientCredentialsOAuth>;
63
79
  /**
64
80
  * Returns a valid access token for the current session, refreshing it if
65
81
  * it is expired or near expiry.
@@ -89,57 +105,141 @@ interface CoinListServer {
89
105
  /**
90
106
  * Fetches all offers by iterating through every paginated response.
91
107
  *
92
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
108
+ * @param clientCreds optional app-level token from
109
+ * {@link clientCredentialsOAuth}. When provided, no user session is
110
+ * required; if a user session exists it takes precedence and `clientCreds`
111
+ * is used as a fallback.
112
+ *
113
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
114
+ * nor `clientCreds`.
93
115
  */
94
- fetchOffers(): Promise<Offer[]>;
116
+ fetchOffers(clientCreds?: ClientCredentialsOAuth): Promise<Offer[]>;
95
117
  /**
96
118
  * Fetches a single page of offers.
97
119
  *
98
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
120
+ * @param clientCreds optional app-level token from
121
+ * {@link clientCredentialsOAuth}. When provided, no user session is
122
+ * required; if a user session exists it takes precedence and `clientCreds`
123
+ * is used as a fallback.
124
+ *
125
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
126
+ * nor `clientCreds`.
99
127
  */
100
- fetchOffersPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
128
+ fetchOffersPage(params: PaginationParams, clientCreds?: ClientCredentialsOAuth): Promise<PaginatedResponse<Offer>>;
101
129
  /**
102
130
  * Fetches details for a given offer by its id.
103
131
  *
104
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
132
+ * @param clientCreds optional app-level token from
133
+ * {@link clientCredentialsOAuth}. When provided, no user session is
134
+ * required; if a user session exists it takes precedence and `clientCreds`
135
+ * is used as a fallback.
136
+ *
137
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
138
+ * nor `clientCreds`.
105
139
  */
106
- fetchOfferDetails(id: OfferId): Promise<OfferDetail>;
140
+ fetchOfferDetails(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
107
141
  /**
108
- * Fetches all participations by iterating through every paginated response.
142
+ * Creates a single-use wallet-ownership challenge for the given wallet and
143
+ * chain. The user signs the returned {@link WalletOwnershipChallenge.message}
144
+ * with their wallet, then passes the signature to
145
+ * {@link connectExternalWallet}.
109
146
  *
110
147
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
111
148
  */
112
- fetchParticipations(offerId?: OfferId): Promise<Participation[]>;
149
+ createWalletOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
113
150
  /**
114
- * Fetches a single page of participations, optionally filtered by offer.
151
+ * Connects a proven external wallet to an offer option, using a signature of
152
+ * a challenge from {@link createWalletOwnershipChallenge}.
115
153
  *
116
154
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
117
155
  */
118
- fetchParticipationsPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
156
+ connectExternalWallet(offerId: OfferId, params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
119
157
  /**
120
- * Fetches a participation by id.
158
+ * Lists the user's proven wallet bindings for a single offer option.
121
159
  *
122
160
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
123
161
  */
124
- fetchParticipation(id: ParticipationId): Promise<Participation>;
162
+ listOptionAddresses(offerId: OfferId, offerOptionId: OfferOptionId): Promise<OfferOptionAddress[]>;
125
163
  /**
126
- * Creates a participation.
164
+ * Removes one of the user's wallet bindings and returns the removed binding.
127
165
  *
128
166
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
129
167
  */
130
- createParticipation(params: CreateParticipationParams): Promise<Participation>;
168
+ removeOptionAddress(offerId: OfferId, addressId: OfferOptionAddressId): Promise<OfferOptionAddress>;
131
169
  /**
132
170
  * Fetches the requirements for all options of a given offer, grouped by option ID.
133
171
  *
134
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
172
+ * @param clientCreds optional app-level token from
173
+ * {@link clientCredentialsOAuth}. When provided, no user session is
174
+ * required; if a user session exists it takes precedence and `clientCreds`
175
+ * is used as a fallback.
176
+ *
177
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
178
+ * nor `clientCreds`.
135
179
  */
136
- fetchOfferRequirements(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
180
+ fetchOfferRequirements(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
137
181
  /**
138
182
  * Fetches the user's requirement statuses for a given offer.
139
183
  *
140
184
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
141
185
  */
142
186
  fetchRequirementStatuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
187
+ /**
188
+ * Fetches the user's PII (tax form pre-fill data) — full legal name, date
189
+ * of birth, jurisdiction, tax ID, and permanent address for an individual;
190
+ * or the equivalent entity fields for a company/trust, used to pre-fill a
191
+ * W-8BEN. Fields the entity hasn't provided are `null`.
192
+ *
193
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
194
+ */
195
+ fetchPii(): Promise<Pii>;
196
+ /**
197
+ * Starts (or resumes) a document signing submission for the given type
198
+ * (currently only `tax_certification`, e.g. W-8BEN/W-8BEN-E). `fields` are
199
+ * signing-form values keyed by the document's DocuSeal field names,
200
+ * forwarded verbatim to Passport to pre-fill the document.
201
+ *
202
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
203
+ */
204
+ submitDocument(documentType: DocumentType, fields: Record<string, string>): Promise<DocumentSubmission>;
205
+ /**
206
+ * Generic ERC-20 reads (token allowance and balance) — e.g.
207
+ * `coinlist.erc20.getTokenBalance({ ... })`.
208
+ *
209
+ * These methods require a user session and throw
210
+ * {@link NotAuthenticatedError} if the user is not authenticated.
211
+ */
212
+ readonly erc20: CoinListErc20Namespace;
213
+ /**
214
+ * Token-sale operations: listing, reading, and recording participations —
215
+ * e.g. `coinlist.tokenSale.fetchParticipations()`. The on-chain
216
+ * `executeTokenSale` flow is client-only and is not exposed here.
217
+ *
218
+ * These methods require a user session and throw
219
+ * {@link NotAuthenticatedError} if the user is not authenticated.
220
+ */
221
+ readonly tokenSale: CoinListTokenSaleNamespace;
222
+ /**
223
+ * On-chain swap operations: quoting a swap, reading swap-contract state, and
224
+ * proving/allow-listing wallet ownership — e.g.
225
+ * `coinlist.swap.getOutputToken({ contractAddress, chain })`.
226
+ *
227
+ * These methods require a user session and throw
228
+ * {@link NotAuthenticatedError} if the user is not authenticated.
229
+ */
230
+ readonly swap: CoinListSwapNamespace;
231
+ /**
232
+ * Creates a short-lived Sumsub WebSDK access token for the current user so
233
+ * an identity verification (KYC) flow can be started, e.g. to seed the
234
+ * client-side `IdentityVerification` component when server-rendering.
235
+ * `levelName` selects the Sumsub verification level; defaults to the
236
+ * backend's standard level. `reset` resets the Sumsub applicant first, so
237
+ * an already-approved level can be executed again (e.g. to update stale
238
+ * PII).
239
+ *
240
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
241
+ */
242
+ createKycToken(levelName?: KycLevelName, reset?: boolean): Promise<KycToken>;
143
243
  }
144
244
  declare function createCoinListServer(config: ServerConfig): CoinListServer;
145
245
 
@@ -1,4 +1,5 @@
1
- import { A as AuthorizationCode, C as CodeVerifier, n as OAuthSession, O as OAuthAccessToken, b as Offer, P as PaginationParams, c as PaginatedResponse, d as OfferId, e as OfferDetail, f as Participation, g as ParticipationsPaginationParams, h as ParticipationId, i as CreateParticipationParams, j as OfferOptionId, R as Requirement, k as RequirementStatusInfo, a as Config, o as ClientSecret } from '../requirement-Dk6nYN1c.js';
1
+ import { h as AuthorizationCode, i as CodeVerifier, I as OAuthSession, J as ClientCredentialsOAuth, k as OAuthAccessToken, l as Offer, m as PaginationParams, n as PaginatedResponse, O as OfferId, o as OfferDetail, p as CreateWalletOwnershipChallengeParams, W as WalletOwnershipChallenge, q as ConnectExternalWalletParams, r as OfferOptionAddress, g as OfferOptionId, s as OfferOptionAddressId, R as Requirement, t as RequirementStatusInfo, u as Pii, D as DocumentType, v as DocumentSubmission, c as CoinListErc20Namespace, f as CoinListTokenSaleNamespace, C as CoinListSwapNamespace, K as KycLevelName, w as KycToken, j as Config, L as ClientSecret } from '../requirement-CDi5NJI8.js';
2
+ import 'viem';
2
3
 
3
4
  interface SessionStore {
4
5
  getSession(): Promise<OAuthSession | null>;
@@ -60,6 +61,21 @@ interface CoinListServer {
60
61
  * not provide `setSession`.
61
62
  */
62
63
  completeOAuth(code: AuthorizationCode, codeVerifier: CodeVerifier): Promise<OAuthSession>;
64
+ /**
65
+ * Obtains an app-level access token via the OAuth 2.0 `client_credentials`
66
+ * grant (RFC 6749 §4.4). No user is involved: the token authenticates the
67
+ * partner application itself and only grants access to app-level resources
68
+ * such as offers and offer requirements.
69
+ *
70
+ * The token is **not** persisted to the {@link SessionStore} and has no
71
+ * refresh token. It expires at `expiresAt`; once expired, call this method
72
+ * again to obtain a fresh token — the SDK does not renew it automatically.
73
+ *
74
+ * Pass the result to {@link fetchOffers}, {@link fetchOffersPage},
75
+ * {@link fetchOfferDetails}, or {@link fetchOfferRequirements} to call them
76
+ * without a user session.
77
+ */
78
+ clientCredentialsOAuth(): Promise<ClientCredentialsOAuth>;
63
79
  /**
64
80
  * Returns a valid access token for the current session, refreshing it if
65
81
  * it is expired or near expiry.
@@ -89,57 +105,141 @@ interface CoinListServer {
89
105
  /**
90
106
  * Fetches all offers by iterating through every paginated response.
91
107
  *
92
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
108
+ * @param clientCreds optional app-level token from
109
+ * {@link clientCredentialsOAuth}. When provided, no user session is
110
+ * required; if a user session exists it takes precedence and `clientCreds`
111
+ * is used as a fallback.
112
+ *
113
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
114
+ * nor `clientCreds`.
93
115
  */
94
- fetchOffers(): Promise<Offer[]>;
116
+ fetchOffers(clientCreds?: ClientCredentialsOAuth): Promise<Offer[]>;
95
117
  /**
96
118
  * Fetches a single page of offers.
97
119
  *
98
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
120
+ * @param clientCreds optional app-level token from
121
+ * {@link clientCredentialsOAuth}. When provided, no user session is
122
+ * required; if a user session exists it takes precedence and `clientCreds`
123
+ * is used as a fallback.
124
+ *
125
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
126
+ * nor `clientCreds`.
99
127
  */
100
- fetchOffersPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
128
+ fetchOffersPage(params: PaginationParams, clientCreds?: ClientCredentialsOAuth): Promise<PaginatedResponse<Offer>>;
101
129
  /**
102
130
  * Fetches details for a given offer by its id.
103
131
  *
104
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
132
+ * @param clientCreds optional app-level token from
133
+ * {@link clientCredentialsOAuth}. When provided, no user session is
134
+ * required; if a user session exists it takes precedence and `clientCreds`
135
+ * is used as a fallback.
136
+ *
137
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
138
+ * nor `clientCreds`.
105
139
  */
106
- fetchOfferDetails(id: OfferId): Promise<OfferDetail>;
140
+ fetchOfferDetails(id: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<OfferDetail>;
107
141
  /**
108
- * Fetches all participations by iterating through every paginated response.
142
+ * Creates a single-use wallet-ownership challenge for the given wallet and
143
+ * chain. The user signs the returned {@link WalletOwnershipChallenge.message}
144
+ * with their wallet, then passes the signature to
145
+ * {@link connectExternalWallet}.
109
146
  *
110
147
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
111
148
  */
112
- fetchParticipations(offerId?: OfferId): Promise<Participation[]>;
149
+ createWalletOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
113
150
  /**
114
- * Fetches a single page of participations, optionally filtered by offer.
151
+ * Connects a proven external wallet to an offer option, using a signature of
152
+ * a challenge from {@link createWalletOwnershipChallenge}.
115
153
  *
116
154
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
117
155
  */
118
- fetchParticipationsPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
156
+ connectExternalWallet(offerId: OfferId, params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
119
157
  /**
120
- * Fetches a participation by id.
158
+ * Lists the user's proven wallet bindings for a single offer option.
121
159
  *
122
160
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
123
161
  */
124
- fetchParticipation(id: ParticipationId): Promise<Participation>;
162
+ listOptionAddresses(offerId: OfferId, offerOptionId: OfferOptionId): Promise<OfferOptionAddress[]>;
125
163
  /**
126
- * Creates a participation.
164
+ * Removes one of the user's wallet bindings and returns the removed binding.
127
165
  *
128
166
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
129
167
  */
130
- createParticipation(params: CreateParticipationParams): Promise<Participation>;
168
+ removeOptionAddress(offerId: OfferId, addressId: OfferOptionAddressId): Promise<OfferOptionAddress>;
131
169
  /**
132
170
  * Fetches the requirements for all options of a given offer, grouped by option ID.
133
171
  *
134
- * Throws {@link NotAuthenticatedError} if the user is not authenticated.
172
+ * @param clientCreds optional app-level token from
173
+ * {@link clientCredentialsOAuth}. When provided, no user session is
174
+ * required; if a user session exists it takes precedence and `clientCreds`
175
+ * is used as a fallback.
176
+ *
177
+ * Throws {@link NotAuthenticatedError} if there is neither a user session
178
+ * nor `clientCreds`.
135
179
  */
136
- fetchOfferRequirements(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
180
+ fetchOfferRequirements(offerId: OfferId, clientCreds?: ClientCredentialsOAuth): Promise<Record<OfferOptionId, Requirement[]>>;
137
181
  /**
138
182
  * Fetches the user's requirement statuses for a given offer.
139
183
  *
140
184
  * Throws {@link NotAuthenticatedError} if the user is not authenticated.
141
185
  */
142
186
  fetchRequirementStatuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
187
+ /**
188
+ * Fetches the user's PII (tax form pre-fill data) — full legal name, date
189
+ * of birth, jurisdiction, tax ID, and permanent address for an individual;
190
+ * or the equivalent entity fields for a company/trust, used to pre-fill a
191
+ * W-8BEN. Fields the entity hasn't provided are `null`.
192
+ *
193
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
194
+ */
195
+ fetchPii(): Promise<Pii>;
196
+ /**
197
+ * Starts (or resumes) a document signing submission for the given type
198
+ * (currently only `tax_certification`, e.g. W-8BEN/W-8BEN-E). `fields` are
199
+ * signing-form values keyed by the document's DocuSeal field names,
200
+ * forwarded verbatim to Passport to pre-fill the document.
201
+ *
202
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
203
+ */
204
+ submitDocument(documentType: DocumentType, fields: Record<string, string>): Promise<DocumentSubmission>;
205
+ /**
206
+ * Generic ERC-20 reads (token allowance and balance) — e.g.
207
+ * `coinlist.erc20.getTokenBalance({ ... })`.
208
+ *
209
+ * These methods require a user session and throw
210
+ * {@link NotAuthenticatedError} if the user is not authenticated.
211
+ */
212
+ readonly erc20: CoinListErc20Namespace;
213
+ /**
214
+ * Token-sale operations: listing, reading, and recording participations —
215
+ * e.g. `coinlist.tokenSale.fetchParticipations()`. The on-chain
216
+ * `executeTokenSale` flow is client-only and is not exposed here.
217
+ *
218
+ * These methods require a user session and throw
219
+ * {@link NotAuthenticatedError} if the user is not authenticated.
220
+ */
221
+ readonly tokenSale: CoinListTokenSaleNamespace;
222
+ /**
223
+ * On-chain swap operations: quoting a swap, reading swap-contract state, and
224
+ * proving/allow-listing wallet ownership — e.g.
225
+ * `coinlist.swap.getOutputToken({ contractAddress, chain })`.
226
+ *
227
+ * These methods require a user session and throw
228
+ * {@link NotAuthenticatedError} if the user is not authenticated.
229
+ */
230
+ readonly swap: CoinListSwapNamespace;
231
+ /**
232
+ * Creates a short-lived Sumsub WebSDK access token for the current user so
233
+ * an identity verification (KYC) flow can be started, e.g. to seed the
234
+ * client-side `IdentityVerification` component when server-rendering.
235
+ * `levelName` selects the Sumsub verification level; defaults to the
236
+ * backend's standard level. `reset` resets the Sumsub applicant first, so
237
+ * an already-approved level can be executed again (e.g. to update stale
238
+ * PII).
239
+ *
240
+ * Throws {@link NotAuthenticatedError} if the user is not authenticated.
241
+ */
242
+ createKycToken(levelName?: KycLevelName, reset?: boolean): Promise<KycToken>;
143
243
  }
144
244
  declare function createCoinListServer(config: ServerConfig): CoinListServer;
145
245
 
@@ -3,22 +3,29 @@ import {
3
3
  AuthenticatedApiClient,
4
4
  HttpError,
5
5
  PUBLIC_API_BASE_URL,
6
- createParticipation,
6
+ createKycToken,
7
7
  fetchOfferDetails,
8
8
  fetchOfferRequirements,
9
9
  fetchOffers,
10
10
  fetchOffersPage,
11
- fetchParticipation,
12
- fetchParticipations,
13
- fetchParticipationsPage,
14
- fetchRequirementStatuses
15
- } from "../chunk-5C4TEVM7.js";
11
+ fetchPii,
12
+ fetchRequirementStatuses,
13
+ submitDocument
14
+ } from "../chunk-7BJ2HAG7.js";
16
15
  import {
16
+ ClientCredentialsOAuth,
17
17
  OAuthSession
18
- } from "../chunk-5E3P7AMH.js";
18
+ } from "../chunk-AAER5LOL.js";
19
19
  import {
20
- NotAuthenticatedError
21
- } from "../chunk-7SB2GKEU.js";
20
+ Erc20NamespaceImpl,
21
+ NotAuthenticatedError,
22
+ SwapNamespaceImpl,
23
+ TokenSaleNamespaceImpl,
24
+ connectExternalWallet,
25
+ createWalletOwnershipChallenge,
26
+ listOptionAddresses,
27
+ removeOptionAddress
28
+ } from "../chunk-TUZKKFNW.js";
22
29
 
23
30
  // src/server/api/api.server.ts
24
31
  var Api = class {
@@ -57,6 +64,13 @@ var CoinListServerImpl = class {
57
64
  // than re-sending with the same expired token and wasting a round-trip.
58
65
  (refresh) => refresh && !this._config.sessionStore.setSession ? Promise.resolve(null) : this.accessToken()
59
66
  );
67
+ const ctx = {
68
+ api: this.api,
69
+ ensureUserAuthenticated: () => this.ensureUserAuthenticated()
70
+ };
71
+ this.erc20 = new Erc20NamespaceImpl(ctx);
72
+ this.tokenSale = new TokenSaleNamespaceImpl(ctx);
73
+ this.swap = new SwapNamespaceImpl(ctx);
60
74
  }
61
75
  async completeOAuth(code, codeVerifier) {
62
76
  const sessionStore = this._config.sessionStore;
@@ -80,6 +94,19 @@ var CoinListServerImpl = class {
80
94
  await setSession(session);
81
95
  return session;
82
96
  }
97
+ async clientCredentialsOAuth() {
98
+ const sessionDto = await this.api.send({
99
+ method: "POST",
100
+ url: `/oauth/token`,
101
+ body: {
102
+ grant_type: "client_credentials",
103
+ client_id: this._config.clientId,
104
+ client_secret: this._config.clientSecret
105
+ }
106
+ });
107
+ const session = OAuthSession.fromDto(sessionDto);
108
+ return ClientCredentialsOAuth(session.accessToken);
109
+ }
83
110
  async accessToken() {
84
111
  const sessionStore = this._config.sessionStore;
85
112
  const session = await sessionStore.getSession();
@@ -152,48 +179,73 @@ var CoinListServerImpl = class {
152
179
  await setSession(null);
153
180
  }
154
181
  }
155
- async ensureAuthenticated() {
156
- const token = await this.accessToken();
157
- if (token === null) {
158
- throw new NotAuthenticatedError();
159
- }
160
- }
161
- async fetchOffers() {
162
- await this.ensureAuthenticated();
163
- return fetchOffers(this.api);
182
+ async fetchOffers(clientCreds) {
183
+ await this.ensureAuthenticated(clientCreds);
184
+ return fetchOffers(this.api, clientCreds);
164
185
  }
165
- async fetchOffersPage(params) {
166
- await this.ensureAuthenticated();
167
- return fetchOffersPage(this.api, params);
186
+ async fetchOffersPage(params, clientCreds) {
187
+ await this.ensureAuthenticated(clientCreds);
188
+ return fetchOffersPage(this.api, params, clientCreds);
168
189
  }
169
- async fetchOfferDetails(id) {
170
- await this.ensureAuthenticated();
171
- return fetchOfferDetails(this.api, id);
190
+ async fetchOfferDetails(id, clientCreds) {
191
+ await this.ensureAuthenticated(clientCreds);
192
+ return fetchOfferDetails(this.api, id, clientCreds);
172
193
  }
173
- async fetchParticipations(offerId) {
174
- await this.ensureAuthenticated();
175
- return fetchParticipations(this.api, offerId);
194
+ async createWalletOwnershipChallenge(params) {
195
+ await this.ensureUserAuthenticated();
196
+ return createWalletOwnershipChallenge(this.api, params);
176
197
  }
177
- async fetchParticipationsPage(params) {
178
- await this.ensureAuthenticated();
179
- return fetchParticipationsPage(this.api, params);
198
+ async connectExternalWallet(offerId, params) {
199
+ await this.ensureUserAuthenticated();
200
+ return connectExternalWallet(this.api, offerId, params);
180
201
  }
181
- async fetchParticipation(id) {
182
- await this.ensureAuthenticated();
183
- return fetchParticipation(this.api, id);
202
+ async listOptionAddresses(offerId, offerOptionId) {
203
+ await this.ensureUserAuthenticated();
204
+ return listOptionAddresses(
205
+ this.api,
206
+ offerId,
207
+ offerOptionId
208
+ );
184
209
  }
185
- async createParticipation(params) {
186
- await this.ensureAuthenticated();
187
- return createParticipation(this.api, params);
210
+ async removeOptionAddress(offerId, addressId) {
211
+ await this.ensureUserAuthenticated();
212
+ return removeOptionAddress(this.api, offerId, addressId);
188
213
  }
189
- async fetchOfferRequirements(offerId) {
190
- await this.ensureAuthenticated();
191
- return fetchOfferRequirements(this.api, offerId);
214
+ async fetchOfferRequirements(offerId, clientCreds) {
215
+ await this.ensureAuthenticated(clientCreds);
216
+ return fetchOfferRequirements(
217
+ this.api,
218
+ offerId,
219
+ clientCreds
220
+ );
192
221
  }
193
222
  async fetchRequirementStatuses(offerId) {
194
- await this.ensureAuthenticated();
223
+ await this.ensureUserAuthenticated();
195
224
  return fetchRequirementStatuses(this.api, offerId);
196
225
  }
226
+ async ensureAuthenticated(clientCreds) {
227
+ if (!clientCreds) {
228
+ await this.ensureUserAuthenticated();
229
+ }
230
+ }
231
+ async ensureUserAuthenticated() {
232
+ const token = await this.accessToken();
233
+ if (token === null) {
234
+ throw new NotAuthenticatedError();
235
+ }
236
+ }
237
+ async fetchPii() {
238
+ await this.ensureUserAuthenticated();
239
+ return fetchPii(this.api);
240
+ }
241
+ async submitDocument(documentType, fields) {
242
+ await this.ensureUserAuthenticated();
243
+ return submitDocument(this.api, documentType, fields);
244
+ }
245
+ async createKycToken(levelName, reset) {
246
+ await this.ensureUserAuthenticated();
247
+ return createKycToken(this.api, levelName, reset);
248
+ }
197
249
  };
198
250
  function createCoinListServer(config) {
199
251
  return new CoinListServerImpl(config);