@coinlist-co/react 0.2.0 → 0.4.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 (67) hide show
  1. package/dist/RequirementItem-B-MvcxSr.d.cts +37 -0
  2. package/dist/RequirementItem-DcYot2uC.d.ts +37 -0
  3. package/dist/chunk-EHZ6PIGN.js +414 -0
  4. package/dist/chunk-EHZ6PIGN.js.map +1 -0
  5. package/dist/chunk-NC45IO63.js +777 -0
  6. package/dist/chunk-NC45IO63.js.map +1 -0
  7. package/dist/chunk-RIFATQB5.js +257 -0
  8. package/dist/chunk-RIFATQB5.js.map +1 -0
  9. package/dist/chunk-UGJUTRXC.js +304 -0
  10. package/dist/chunk-UGJUTRXC.js.map +1 -0
  11. package/dist/client/components/index.cjs +473 -10
  12. package/dist/client/components/index.cjs.map +1 -1
  13. package/dist/client/components/index.d.cts +80 -12
  14. package/dist/client/components/index.d.ts +80 -12
  15. package/dist/client/components/index.js +243 -243
  16. package/dist/client/components/index.js.map +1 -1
  17. package/dist/client/core/index.cjs +349 -202
  18. package/dist/client/core/index.cjs.map +1 -1
  19. package/dist/client/core/index.d.cts +4 -4
  20. package/dist/client/core/index.d.ts +4 -4
  21. package/dist/client/core/index.js +16 -14
  22. package/dist/client/hooks/index.cjs +133 -16
  23. package/dist/client/hooks/index.cjs.map +1 -1
  24. package/dist/client/hooks/index.d.cts +102 -8
  25. package/dist/client/hooks/index.d.ts +102 -8
  26. package/dist/client/hooks/index.js +11 -9
  27. package/dist/client/index.cjs +591 -210
  28. package/dist/client/index.cjs.map +1 -1
  29. package/dist/client/index.d.cts +7 -6
  30. package/dist/client/index.d.ts +7 -6
  31. package/dist/client/index.js +41 -17
  32. package/dist/client/styles.css +1 -1
  33. package/dist/coinlist-client-BSxpqylo.d.ts +158 -0
  34. package/dist/coinlist-client-Cah5c_aF.d.cts +158 -0
  35. package/dist/participation-DMMEDxON.d.cts +185 -0
  36. package/dist/participation-E-bT-GXJ.d.ts +185 -0
  37. package/dist/requirement-XWT0T_zO.d.cts +205 -0
  38. package/dist/requirement-XWT0T_zO.d.ts +205 -0
  39. package/dist/server/index.cjs +519 -14
  40. package/dist/server/index.cjs.map +1 -1
  41. package/dist/server/index.d.cts +73 -4
  42. package/dist/server/index.d.ts +73 -4
  43. package/dist/server/index.js +116 -20
  44. package/dist/server/index.js.map +1 -1
  45. package/dist/useCoinListRequirements-B5-ZPOMz.d.ts +80 -0
  46. package/dist/useCoinListRequirements-Cuc32Tqw.d.cts +80 -0
  47. package/package.json +4 -4
  48. package/dist/chunk-32GOUV3L.js +0 -118
  49. package/dist/chunk-32GOUV3L.js.map +0 -1
  50. package/dist/chunk-G3B4RLXP.js +0 -76
  51. package/dist/chunk-G3B4RLXP.js.map +0 -1
  52. package/dist/chunk-GRVV7NLV.js +0 -282
  53. package/dist/chunk-GRVV7NLV.js.map +0 -1
  54. package/dist/chunk-Z5RFQOMS.js +0 -560
  55. package/dist/chunk-Z5RFQOMS.js.map +0 -1
  56. package/dist/coinlist-client-20v7fJSW.d.ts +0 -394
  57. package/dist/coinlist-client-Ds86ycAg.d.cts +0 -394
  58. package/dist/newtype-yKTvFdg_.d.cts +0 -6
  59. package/dist/newtype-yKTvFdg_.d.ts +0 -6
  60. package/dist/oauth-session-DgItaMKN.d.cts +0 -56
  61. package/dist/oauth-session-DnKDI5ou.d.ts +0 -56
  62. package/dist/offer-D6p_Ijme.d.cts +0 -30
  63. package/dist/offer-DnFEFJw9.d.ts +0 -30
  64. package/dist/useCoinListOffers-DIdOb5hB.d.ts +0 -27
  65. package/dist/useCoinListOffers-DvJxu6qj.d.cts +0 -27
  66. package/dist/useCompleteCoinListOAuth-C359mp_k.d.cts +0 -55
  67. package/dist/useCompleteCoinListOAuth-wZX3o8r2.d.ts +0 -55
@@ -1,394 +0,0 @@
1
- import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-DnKDI5ou.js';
2
- import { N as Newtype } from './newtype-yKTvFdg_.js';
3
- import { a as OfferId, b as OfferSlug, O as Offer } from './offer-DnFEFJw9.js';
4
-
5
- type AuthState = 'unknown' | 'logged-in' | 'logged-out';
6
- /** Discriminated error reasons from {@link CoinListClient.completeOAuth}. */
7
- type OauthClientErrorReason = 'user_canceled' | 'missing_state' | 'invalid_state' | 'missing_code' | 'missing_code_verifier';
8
- type OauthClientResult = {
9
- type: 'ok';
10
- code: AuthorizationCode;
11
- codeVerifier: CodeVerifier;
12
- } | {
13
- type: 'error';
14
- reason: OauthClientErrorReason;
15
- };
16
-
17
- type QueryParamValue = string | number | boolean | null | undefined;
18
-
19
- type Cursor = Newtype<string, 'Cursor'>;
20
- declare const Cursor: (value: string) => Cursor;
21
- interface PaginatedResponseDto<T> {
22
- data: T[];
23
- starting_after?: string;
24
- starting_before?: string;
25
- }
26
- declare function fetchAllPages<A>(fetchPage: (params: PaginationParams) => Promise<PaginatedResponse<A>>): Promise<A[]>;
27
- interface PaginatedResponse<T> {
28
- data: T[];
29
- startingAfter: Cursor | null;
30
- startingBefore: Cursor | null;
31
- }
32
- declare const PaginatedResponse: {
33
- fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
34
- };
35
- /**
36
- * Cursor-based pagination input used when requesting paginated API resources.
37
- * Set `after` or `before` to navigate relative to a known cursor, and `limit`
38
- * to control the maximum number of returned items.
39
- */
40
- interface PaginationParams {
41
- before?: Cursor;
42
- after?: Cursor;
43
- limit?: number;
44
- }
45
- declare const PaginationParams: {
46
- toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
47
- };
48
-
49
- type AssetDto = {
50
- code: string;
51
- fractional_digits: number;
52
- id: string;
53
- name: string;
54
- };
55
-
56
- type AssetId = Newtype<string, 'AssetId'>;
57
- declare const AssetId: (value: string) => AssetId;
58
- type AssetCode = Newtype<string, 'AssetCode'>;
59
- declare const AssetCode: (value: string) => AssetCode;
60
- type Asset = {
61
- id: AssetId;
62
- code: AssetCode;
63
- name: string;
64
- fractionalDigits: number;
65
- };
66
- declare const Asset: {
67
- fromDto: (dto: AssetDto) => Asset;
68
- };
69
-
70
- type OfferDetailDto = {
71
- asset: AssetDto;
72
- faqs: OfferDetailFaqDto[];
73
- funding_assets: AssetDto[];
74
- id: string;
75
- links: OfferDetailLinkDto[];
76
- milestones: OfferDetailMilestoneDto[];
77
- name: string;
78
- object: 'offer_details';
79
- options: OfferDetailOptionDto[];
80
- slug: string;
81
- terms: OfferDetailTermDto[];
82
- about: string | null | undefined;
83
- banner_url: string | null | undefined;
84
- category: string | null | undefined;
85
- ends_at: string;
86
- logo_url: string | null | undefined;
87
- starts_at: string;
88
- tagline: string | null | undefined;
89
- };
90
- type OfferDetailFaqDto = {
91
- answer: string | null;
92
- question: string | null;
93
- };
94
- type OfferDetailLinkDto = {
95
- label: string | null;
96
- url: string | null;
97
- };
98
- type OfferDetailMilestoneDto = {
99
- name: string | null;
100
- schedule: string | null;
101
- status: 'completed' | 'active' | 'upcoming';
102
- };
103
- type OfferDetailOptionDto = {
104
- bid_increment: number | null;
105
- floor_price_usd: number | null;
106
- id: string;
107
- minimum_purchase_usd: number | null;
108
- price_usd: number | null;
109
- sale_agreement_url: string | null;
110
- slug: string;
111
- total_token_supply: number | null;
112
- };
113
- type OfferDetailTermDto = {
114
- key: string | null;
115
- value: string | null;
116
- };
117
-
118
- type OfferOptionId = Newtype<string, 'OfferOptionId'>;
119
- declare const OfferOptionId: (value: string) => OfferOptionId;
120
- type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
121
- declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
122
- type OfferDetail = {
123
- id: OfferId;
124
- slug: OfferSlug;
125
- name: string;
126
- asset: Asset;
127
- fundingAssets: Asset[];
128
- about: string | null;
129
- tagline: string | null;
130
- bannerUrl: string | null;
131
- logoUrl: string | null;
132
- category: string | null;
133
- startsAt: Date;
134
- endsAt: Date;
135
- faqs: FaqItem[];
136
- links: Link[];
137
- milestones: Milestone[];
138
- options: OfferOption[];
139
- terms: TermItem[];
140
- };
141
- declare const OfferDetail: {
142
- fromDto: (dto: OfferDetailDto) => OfferDetail;
143
- };
144
- type OfferOption = {
145
- id: OfferOptionId;
146
- slug: OfferOptionSlug;
147
- bidIncrement: number | null;
148
- floorPriceUsd: number | null;
149
- minimumPurchaseUsd: number | null;
150
- priceUsd: number | null;
151
- saleAgreementUrl: string | null;
152
- totalTokenSupply: number | null;
153
- };
154
- declare const OfferOption: {
155
- fromDto: (dto: OfferDetailOptionDto) => OfferOption;
156
- };
157
- type FaqItem = {
158
- question: string | null;
159
- answer: string | null;
160
- };
161
- declare const FaqItem: {
162
- fromDto: (dto: OfferDetailFaqDto) => FaqItem;
163
- };
164
- type Link = {
165
- label: string | null;
166
- url: string | null;
167
- };
168
- declare const Link: {
169
- fromDto: (dto: OfferDetailLinkDto) => Link;
170
- };
171
- type TermItem = {
172
- key: string | null;
173
- value: string | null;
174
- };
175
- declare const TermItem: {
176
- fromDto: (dto: OfferDetailTermDto) => TermItem;
177
- };
178
- type Milestone = {
179
- name: string | null;
180
- schedule: string | null;
181
- status: 'completed' | 'active' | 'upcoming';
182
- };
183
- declare const Milestone: {
184
- fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
185
- };
186
-
187
- type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
188
- type ParticipationDto = {
189
- object: 'participation';
190
- id: string;
191
- offer_id: string;
192
- offer_option_id: string;
193
- status: ParticipationStatusDto;
194
- amount: string;
195
- amount_string: string;
196
- asset: AssetDto;
197
- chain: string;
198
- inserted_at: string | null | undefined;
199
- updated_at: string | null | undefined;
200
- wallet_address: string | null | undefined;
201
- };
202
- type CreateParticipationDto = {
203
- offer_id: string;
204
- offer_option_id: string;
205
- chain: string;
206
- wallet_address: string;
207
- amount: string;
208
- asset_id: string;
209
- approval_transaction_hash: string | null | undefined;
210
- };
211
-
212
- /** Unique identifier for a participation. */
213
- type ParticipationId = Newtype<string, 'ParticipationId'>;
214
- /** Casts a string into a typed {@link ParticipationId}. */
215
- declare const ParticipationId: (value: string) => ParticipationId;
216
- /** Blockchain identifier for where a participation is funded. */
217
- type Blockchain = Newtype<string, 'Blockchain'>;
218
- /** Casts a string into a typed {@link Blockchain}. */
219
- declare const Blockchain: (value: string) => Blockchain;
220
- /** Wallet address used for a participation. */
221
- type WalletAddress = Newtype<string, 'WalletAddress'>;
222
- /** Casts a string into a typed {@link WalletAddress}. */
223
- declare const WalletAddress: (value: string) => WalletAddress;
224
- /** Possible participation lifecycle states returned by the API. */
225
- type ParticipationStatus = ParticipationStatusDto;
226
- /** Domain model for a participation returned by CoinList APIs. */
227
- type Participation = {
228
- /** Unique participation id. */
229
- id: ParticipationId;
230
- /** Parent offer id. */
231
- offerId: OfferId;
232
- /** Selected offer option id. */
233
- offerOptionId: OfferOptionId;
234
- /** Current processing status. */
235
- status: ParticipationStatus;
236
- /** Raw participation amount from API. */
237
- amount: string;
238
- /** Human-readable formatted amount from API. */
239
- displayAmount: string;
240
- /** Asset metadata for the participation amount. */
241
- asset: Asset;
242
- /** Funding chain identifier. */
243
- chain: Blockchain;
244
- /** Creation timestamp, if returned by API. */
245
- insertedAt: Date | null;
246
- /** Last update timestamp, if returned by API. */
247
- updatedAt: Date | null;
248
- /** Wallet used for participation, blank values normalized to null. */
249
- walletAddress: WalletAddress | null;
250
- };
251
- declare const Participation: {
252
- /** Maps API DTO shape into the SDK participation domain model. */
253
- fromDto: (dto: ParticipationDto) => Participation;
254
- };
255
- /** Parameters required to create a new participation. */
256
- type CreateParticipationParams = {
257
- /** Offer to participate in. */
258
- offerId: OfferId;
259
- /** Offer option selected for participation. */
260
- offerOptionId: OfferOptionId;
261
- /** Blockchain for funding. */
262
- chain: Blockchain;
263
- /** Wallet address that funds the participation. */
264
- walletAddress: WalletAddress;
265
- /** Raw amount to participate with. */
266
- amount: string;
267
- /** Funding asset id. */
268
- assetId: AssetId;
269
- /** Optional approval transaction hash, if applicable. */
270
- approvalTransactionHash?: string | null;
271
- };
272
- declare const CreateParticipationParams: {
273
- /** Maps participation creation params into API DTO payload. */
274
- toDto: (params: CreateParticipationParams) => CreateParticipationDto;
275
- };
276
-
277
- interface ClientConfig extends Config {
278
- /**
279
- * The SDK user must provide this function. It is responsible for fetching a
280
- * valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
281
- * backend is in TypeScript, it is recommended to use
282
- * {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
283
- */
284
- getAccessToken: () => Promise<OAuthAccessToken | null>;
285
- /**
286
- * Recommended to leave undefined. Used to change the CoinList environment;
287
- * default is production.
288
- */
289
- authorizationPageUrl?: string;
290
- }
291
- interface CoinListClient {
292
- /**
293
- * Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
294
- * the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
295
- * you typically do not need to call it yourself unless you are using the client
296
- * outside of the provider.
297
- */
298
- init(): Promise<AuthState>;
299
- /**
300
- * Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
301
- * Returns **unknown** until {@link CoinListClient.init} has completed. It is
302
- * recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
303
- * the SDK has initialized, or to manually await {@link CoinListClient.init}
304
- * before relying on this value.
305
- */
306
- getAuthState(): AuthState;
307
- /**
308
- * Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
309
- * stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
310
- * on redirect), then redirects the user to the CoinList authorization page. After
311
- * the user authorizes, they are sent back to your application's redirect URI; call
312
- * {@link CoinListClient.completeOAuth} on that page to finish the flow.
313
- */
314
- startOAuth(): Promise<void>;
315
- /**
316
- * Completes the OAuth flow on the FE with PKCE and state validation. Parses the
317
- * redirect URL (state, code) and validates them against sessionStorage
318
- * (state, code_verifier). The state check protects against CSRF (cross-site
319
- * request forgery). Call this on the frontend page the user is redirected
320
- * to after authorizing.
321
- *
322
- * On `ok`: Call your backend to exchange the short-lived `authorizationCode`
323
- * (and the returned `codeVerifier`) for a long-lived session. If your backend
324
- * is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
325
- * `@/server/coinlist.server` (CoinListServer) to perform that exchange.
326
- *
327
- * On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.
328
- */
329
- completeOAuth(): OauthClientResult;
330
- /**
331
- * Clears the in-memory access token. Note: you need to manually
332
- * also logout on the backend via CoinListServer#logout to clear the session cookie.
333
- */
334
- logout(): void;
335
- /**
336
- * Fetches all offers by iterating through every paginated response.
337
- *
338
- * This method must be called only when the user's {@link AuthState} is
339
- * `'logged-in'`. If the user is not authenticated, it throws
340
- * {@link NotAuthenticatedError}.
341
- */
342
- fetchAllOffers(): Promise<Offer[]>;
343
- /**
344
- * Fetches a single page of offers.
345
- *
346
- * This method must be called only when the user's {@link AuthState} is
347
- * `'logged-in'`. If the user is not authenticated, it throws
348
- * {@link NotAuthenticatedError}.
349
- */
350
- fetchOffersPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
351
- /**
352
- * Fetches details for a given offer by its id.
353
- *
354
- * This method must be called only when the user's {@link AuthState} is
355
- * `'logged-in'`. If the user is not authenticated, it throws
356
- * {@link NotAuthenticatedError}.
357
- */
358
- fetchOfferDetails(id: OfferId): Promise<OfferDetail>;
359
- /**
360
- * Fetches all participations by iterating through every paginated response.
361
- *
362
- * This method must be called only when the user's {@link AuthState} is
363
- * `'logged-in'`. If the user is not authenticated, it throws
364
- * {@link NotAuthenticatedError}.
365
- */
366
- fetchAllParticipations(): Promise<Participation[]>;
367
- /**
368
- * Fetches a single page of participations.
369
- *
370
- * This method must be called only when the user's {@link AuthState} is
371
- * `'logged-in'`. If the user is not authenticated, it throws
372
- * {@link NotAuthenticatedError}.
373
- */
374
- fetchParticipationsPage(params: PaginationParams): Promise<PaginatedResponse<Participation>>;
375
- /**
376
- * Fetches a participation by id.
377
- *
378
- * This method must be called only when the user's {@link AuthState} is
379
- * `'logged-in'`. If the user is not authenticated, it throws
380
- * {@link NotAuthenticatedError}.
381
- */
382
- fetchParticipation(id: ParticipationId): Promise<Participation>;
383
- /**
384
- * Creates a participation.
385
- *
386
- * This method must be called only when the user's {@link AuthState} is
387
- * `'logged-in'`. If the user is not authenticated, it throws
388
- * {@link NotAuthenticatedError}.
389
- */
390
- createParticipation(params: CreateParticipationParams): Promise<Participation>;
391
- }
392
- declare function createCoinListClient(config: ClientConfig): CoinListClient;
393
-
394
- export { type AuthState as A, Blockchain as B, type ClientConfig as C, FaqItem as F, Link as L, Milestone as M, type OauthClientErrorReason as O, PaginatedResponse as P, TermItem as T, WalletAddress as W, type CoinListClient as a, CreateParticipationParams as b, Cursor as c, type OauthClientResult as d, OfferDetail as e, OfferOption as f, OfferOptionId as g, OfferOptionSlug as h, type PaginatedResponseDto as i, PaginationParams as j, Participation as k, ParticipationId as l, type ParticipationStatus as m, createCoinListClient as n, fetchAllPages as o };