@coinlist-co/react 0.1.2 → 0.3.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.
- package/dist/RequirementItem-BpkJQep8.d.ts +37 -0
- package/dist/RequirementItem-BvwsFu9e.d.cts +37 -0
- package/dist/{chunk-WFA6X7E2.js → chunk-IADBIDY6.js} +3 -3
- package/dist/chunk-IDCROXPS.js +412 -0
- package/dist/chunk-IDCROXPS.js.map +1 -0
- package/dist/{chunk-6CG7JT7Q.js → chunk-P4DTIPEX.js} +144 -5
- package/dist/chunk-P4DTIPEX.js.map +1 -0
- package/dist/{chunk-DLEKT4T4.js → chunk-V5M7SA3C.js} +47 -4
- package/dist/chunk-V5M7SA3C.js.map +1 -0
- package/dist/client/components/index.cjs +467 -5
- package/dist/client/components/index.cjs.map +1 -1
- package/dist/client/components/index.d.cts +61 -11
- package/dist/client/components/index.d.ts +61 -11
- package/dist/client/components/index.js +268 -240
- package/dist/client/components/index.js.map +1 -1
- package/dist/client/core/index.cjs +146 -4
- package/dist/client/core/index.cjs.map +1 -1
- package/dist/client/core/index.d.cts +2 -2
- package/dist/client/core/index.d.ts +2 -2
- package/dist/client/core/index.js +13 -1
- package/dist/client/hooks/index.cjs +49 -6
- package/dist/client/hooks/index.cjs.map +1 -1
- package/dist/client/hooks/index.d.cts +6 -5
- package/dist/client/hooks/index.d.ts +6 -5
- package/dist/client/hooks/index.js +5 -3
- package/dist/client/index.cjs +244 -10
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +6 -4
- package/dist/client/index.d.ts +6 -4
- package/dist/client/index.js +30 -2
- package/dist/client/styles.css +1 -1
- package/dist/coinlist-client-B_dJkbwB.d.ts +283 -0
- package/dist/coinlist-client-DBKa6j3f.d.cts +283 -0
- package/dist/requirement-CxbdY8l4.d.cts +202 -0
- package/dist/requirement-fJsQ3f9_.d.ts +202 -0
- package/dist/{useCoinListOffers-DIdOb5hB.d.ts → useCoinListOffers-C5lBlzcC.d.ts} +1 -1
- package/dist/{useCoinListOffers-DvJxu6qj.d.cts → useCoinListOffers-CguwXaCX.d.cts} +1 -1
- package/dist/useCoinListRequirements-BECx1cIw.d.ts +31 -0
- package/dist/useCoinListRequirements-CX2gV9gJ.d.cts +31 -0
- package/dist/{useCompleteCoinListOAuth-6Z4DGuiH.d.cts → useCompleteCoinListOAuth-BRhAqD4_.d.cts} +1 -1
- package/dist/{useCompleteCoinListOAuth-C3G1Vsf8.d.ts → useCompleteCoinListOAuth-DEZpHjd6.d.ts} +1 -1
- package/package.json +4 -4
- package/dist/chunk-6CG7JT7Q.js.map +0 -1
- package/dist/chunk-DLEKT4T4.js.map +0 -1
- package/dist/coinlist-client-BiA8a2yU.d.ts +0 -272
- package/dist/coinlist-client-DXKFDGhP.d.cts +0 -272
- package/dist/offer-D6p_Ijme.d.cts +0 -30
- package/dist/offer-DnFEFJw9.d.ts +0 -30
- /package/dist/{chunk-WFA6X7E2.js.map → chunk-IADBIDY6.js.map} +0 -0
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-DgItaMKN.cjs';
|
|
2
|
-
import { N as Newtype } from './newtype-yKTvFdg_.cjs';
|
|
3
|
-
import { a as OfferId, b as OfferSlug, O as Offer } from './offer-D6p_Ijme.cjs';
|
|
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
|
-
interface ClientConfig extends Config {
|
|
188
|
-
/**
|
|
189
|
-
* The SDK user must provide this function. It is responsible for fetching a
|
|
190
|
-
* valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
|
|
191
|
-
* backend is in TypeScript, it is recommended to use
|
|
192
|
-
* {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
|
|
193
|
-
*/
|
|
194
|
-
getAccessToken: () => Promise<OAuthAccessToken | null>;
|
|
195
|
-
/**
|
|
196
|
-
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
197
|
-
* default is production.
|
|
198
|
-
*/
|
|
199
|
-
authorizationPageUrl?: string;
|
|
200
|
-
}
|
|
201
|
-
interface CoinListClient {
|
|
202
|
-
/**
|
|
203
|
-
* Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
|
|
204
|
-
* the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
|
|
205
|
-
* you typically do not need to call it yourself unless you are using the client
|
|
206
|
-
* outside of the provider.
|
|
207
|
-
*/
|
|
208
|
-
init(): Promise<AuthState>;
|
|
209
|
-
/**
|
|
210
|
-
* Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
|
|
211
|
-
* Returns **unknown** until {@link CoinListClient.init} has completed. It is
|
|
212
|
-
* recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
|
|
213
|
-
* the SDK has initialized, or to manually await {@link CoinListClient.init}
|
|
214
|
-
* before relying on this value.
|
|
215
|
-
*/
|
|
216
|
-
getAuthState(): AuthState;
|
|
217
|
-
/**
|
|
218
|
-
* Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
|
|
219
|
-
* stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
|
|
220
|
-
* on redirect), then redirects the user to the CoinList authorization page. After
|
|
221
|
-
* the user authorizes, they are sent back to your application's redirect URI; call
|
|
222
|
-
* {@link CoinListClient.completeOAuth} on that page to finish the flow.
|
|
223
|
-
*/
|
|
224
|
-
startOAuth(): Promise<void>;
|
|
225
|
-
/**
|
|
226
|
-
* Completes the OAuth flow on the FE with PKCE and state validation. Parses the
|
|
227
|
-
* redirect URL (state, code) and validates them against sessionStorage
|
|
228
|
-
* (state, code_verifier). The state check protects against CSRF (cross-site
|
|
229
|
-
* request forgery). Call this on the frontend page the user is redirected
|
|
230
|
-
* to after authorizing.
|
|
231
|
-
*
|
|
232
|
-
* On `ok`: Call your backend to exchange the short-lived `authorizationCode`
|
|
233
|
-
* (and the returned `codeVerifier`) for a long-lived session. If your backend
|
|
234
|
-
* is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
|
|
235
|
-
* `@/server/coinlist.server` (CoinListServer) to perform that exchange.
|
|
236
|
-
*
|
|
237
|
-
* 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.
|
|
238
|
-
*/
|
|
239
|
-
completeOAuth(): OauthClientResult;
|
|
240
|
-
/**
|
|
241
|
-
* Clears the in-memory access token. Note: you need to manually
|
|
242
|
-
* also logout on the backend via CoinListServer#logout to clear the session cookie.
|
|
243
|
-
*/
|
|
244
|
-
logout(): void;
|
|
245
|
-
/**
|
|
246
|
-
* Fetches all offers by iterating through every paginated response.
|
|
247
|
-
*
|
|
248
|
-
* This method must be called only when the user's {@link AuthState} is
|
|
249
|
-
* `'logged-in'`. If the user is not authenticated, it throws
|
|
250
|
-
* {@link NotAuthenticatedError}.
|
|
251
|
-
*/
|
|
252
|
-
fetchAllOffers(): Promise<Offer[]>;
|
|
253
|
-
/**
|
|
254
|
-
* Fetches a single page of offers.
|
|
255
|
-
*
|
|
256
|
-
* This method must be called only when the user's {@link AuthState} is
|
|
257
|
-
* `'logged-in'`. If the user is not authenticated, it throws
|
|
258
|
-
* {@link NotAuthenticatedError}.
|
|
259
|
-
*/
|
|
260
|
-
fetchOffersPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
|
|
261
|
-
/**
|
|
262
|
-
* Fetches details for a given offer by its id.
|
|
263
|
-
*
|
|
264
|
-
* This method must be called only when the user's {@link AuthState} is
|
|
265
|
-
* `'logged-in'`. If the user is not authenticated, it throws
|
|
266
|
-
* {@link NotAuthenticatedError}.
|
|
267
|
-
*/
|
|
268
|
-
fetchOfferDetails(id: OfferId): Promise<OfferDetail>;
|
|
269
|
-
}
|
|
270
|
-
declare function createCoinListClient(config: ClientConfig): CoinListClient;
|
|
271
|
-
|
|
272
|
-
export { type AuthState as A, type ClientConfig as C, FaqItem as F, Link as L, Milestone as M, type OauthClientErrorReason as O, PaginatedResponse as P, TermItem as T, type CoinListClient as a, Cursor as b, type OauthClientResult as c, OfferDetail as d, OfferOption as e, OfferOptionId as f, OfferOptionSlug as g, type PaginatedResponseDto as h, PaginationParams as i, createCoinListClient as j, fetchAllPages as k };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { N as Newtype } from './newtype-yKTvFdg_.cjs';
|
|
2
|
-
|
|
3
|
-
type OfferDto = {
|
|
4
|
-
id: string;
|
|
5
|
-
slug: string;
|
|
6
|
-
tagline: string | null | undefined;
|
|
7
|
-
banner_url: string | null | undefined;
|
|
8
|
-
logo_url: string | null | undefined;
|
|
9
|
-
starts_at: string;
|
|
10
|
-
ends_at: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type OfferId = Newtype<string, 'OfferId'>;
|
|
14
|
-
declare const OfferId: (value: string) => OfferId;
|
|
15
|
-
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
16
|
-
declare const OfferSlug: (value: string) => OfferSlug;
|
|
17
|
-
type Offer = {
|
|
18
|
-
id: OfferId;
|
|
19
|
-
slug: OfferSlug;
|
|
20
|
-
tagline: string | null;
|
|
21
|
-
bannerUrl: string | null;
|
|
22
|
-
logoUrl: string | null;
|
|
23
|
-
startsAt: Date;
|
|
24
|
-
endsAt: Date;
|
|
25
|
-
};
|
|
26
|
-
declare const Offer: {
|
|
27
|
-
fromDto: (dto: OfferDto) => Offer;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { Offer as O, OfferId as a, OfferSlug as b };
|
package/dist/offer-DnFEFJw9.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { N as Newtype } from './newtype-yKTvFdg_.js';
|
|
2
|
-
|
|
3
|
-
type OfferDto = {
|
|
4
|
-
id: string;
|
|
5
|
-
slug: string;
|
|
6
|
-
tagline: string | null | undefined;
|
|
7
|
-
banner_url: string | null | undefined;
|
|
8
|
-
logo_url: string | null | undefined;
|
|
9
|
-
starts_at: string;
|
|
10
|
-
ends_at: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type OfferId = Newtype<string, 'OfferId'>;
|
|
14
|
-
declare const OfferId: (value: string) => OfferId;
|
|
15
|
-
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
16
|
-
declare const OfferSlug: (value: string) => OfferSlug;
|
|
17
|
-
type Offer = {
|
|
18
|
-
id: OfferId;
|
|
19
|
-
slug: OfferSlug;
|
|
20
|
-
tagline: string | null;
|
|
21
|
-
bannerUrl: string | null;
|
|
22
|
-
logoUrl: string | null;
|
|
23
|
-
startsAt: Date;
|
|
24
|
-
endsAt: Date;
|
|
25
|
-
};
|
|
26
|
-
declare const Offer: {
|
|
27
|
-
fromDto: (dto: OfferDto) => Offer;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { Offer as O, OfferId as a, OfferSlug as b };
|
|
File without changes
|