@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.
- package/dist/RequirementItem-B-MvcxSr.d.cts +37 -0
- package/dist/RequirementItem-DcYot2uC.d.ts +37 -0
- package/dist/chunk-EHZ6PIGN.js +414 -0
- package/dist/chunk-EHZ6PIGN.js.map +1 -0
- package/dist/chunk-NC45IO63.js +777 -0
- package/dist/chunk-NC45IO63.js.map +1 -0
- package/dist/chunk-RIFATQB5.js +257 -0
- package/dist/chunk-RIFATQB5.js.map +1 -0
- package/dist/chunk-UGJUTRXC.js +304 -0
- package/dist/chunk-UGJUTRXC.js.map +1 -0
- package/dist/client/components/index.cjs +473 -10
- package/dist/client/components/index.cjs.map +1 -1
- package/dist/client/components/index.d.cts +80 -12
- package/dist/client/components/index.d.ts +80 -12
- package/dist/client/components/index.js +243 -243
- package/dist/client/components/index.js.map +1 -1
- package/dist/client/core/index.cjs +349 -202
- package/dist/client/core/index.cjs.map +1 -1
- package/dist/client/core/index.d.cts +4 -4
- package/dist/client/core/index.d.ts +4 -4
- package/dist/client/core/index.js +16 -14
- package/dist/client/hooks/index.cjs +133 -16
- package/dist/client/hooks/index.cjs.map +1 -1
- package/dist/client/hooks/index.d.cts +102 -8
- package/dist/client/hooks/index.d.ts +102 -8
- package/dist/client/hooks/index.js +11 -9
- package/dist/client/index.cjs +591 -210
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +7 -6
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.js +41 -17
- package/dist/client/styles.css +1 -1
- package/dist/coinlist-client-BSxpqylo.d.ts +158 -0
- package/dist/coinlist-client-Cah5c_aF.d.cts +158 -0
- package/dist/participation-DMMEDxON.d.cts +185 -0
- package/dist/participation-E-bT-GXJ.d.ts +185 -0
- package/dist/requirement-XWT0T_zO.d.cts +205 -0
- package/dist/requirement-XWT0T_zO.d.ts +205 -0
- package/dist/server/index.cjs +519 -14
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +73 -4
- package/dist/server/index.d.ts +73 -4
- package/dist/server/index.js +116 -20
- package/dist/server/index.js.map +1 -1
- package/dist/useCoinListRequirements-B5-ZPOMz.d.ts +80 -0
- package/dist/useCoinListRequirements-Cuc32Tqw.d.cts +80 -0
- package/package.json +4 -4
- package/dist/chunk-32GOUV3L.js +0 -118
- package/dist/chunk-32GOUV3L.js.map +0 -1
- package/dist/chunk-G3B4RLXP.js +0 -76
- package/dist/chunk-G3B4RLXP.js.map +0 -1
- package/dist/chunk-GRVV7NLV.js +0 -282
- package/dist/chunk-GRVV7NLV.js.map +0 -1
- package/dist/chunk-Z5RFQOMS.js +0 -560
- package/dist/chunk-Z5RFQOMS.js.map +0 -1
- package/dist/coinlist-client-20v7fJSW.d.ts +0 -394
- package/dist/coinlist-client-Ds86ycAg.d.cts +0 -394
- package/dist/newtype-yKTvFdg_.d.cts +0 -6
- package/dist/newtype-yKTvFdg_.d.ts +0 -6
- package/dist/oauth-session-DgItaMKN.d.cts +0 -56
- package/dist/oauth-session-DnKDI5ou.d.ts +0 -56
- package/dist/offer-D6p_Ijme.d.cts +0 -30
- package/dist/offer-DnFEFJw9.d.ts +0 -30
- package/dist/useCoinListOffers-DIdOb5hB.d.ts +0 -27
- package/dist/useCoinListOffers-DvJxu6qj.d.cts +0 -27
- package/dist/useCompleteCoinListOAuth-C359mp_k.d.cts +0 -55
- package/dist/useCompleteCoinListOAuth-wZX3o8r2.d.ts +0 -55
package/dist/chunk-Z5RFQOMS.js
DELETED
|
@@ -1,560 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
API_VERSION,
|
|
3
|
-
Attributes,
|
|
4
|
-
AuthorizationCode,
|
|
5
|
-
COINLIST_OAUTH_PAGE_URL,
|
|
6
|
-
CodeVerifier,
|
|
7
|
-
HEADER_IDEMPOTENCY_KEY,
|
|
8
|
-
HEADER_USER_AGENT,
|
|
9
|
-
HttpClient,
|
|
10
|
-
HttpError,
|
|
11
|
-
PUBLIC_API_BASE_URL,
|
|
12
|
-
Request,
|
|
13
|
-
requestRetryMiddleware
|
|
14
|
-
} from "./chunk-GRVV7NLV.js";
|
|
15
|
-
|
|
16
|
-
// src/shared/api/pagination.ts
|
|
17
|
-
var Cursor = (value) => value;
|
|
18
|
-
async function fetchAllPages(fetchPage) {
|
|
19
|
-
const items = [];
|
|
20
|
-
let cursor = null;
|
|
21
|
-
do {
|
|
22
|
-
const page = await fetchPage({
|
|
23
|
-
after: cursor ?? void 0
|
|
24
|
-
});
|
|
25
|
-
items.push(...page.data);
|
|
26
|
-
cursor = page.startingAfter;
|
|
27
|
-
} while (cursor);
|
|
28
|
-
return items;
|
|
29
|
-
}
|
|
30
|
-
var PaginatedResponse = {
|
|
31
|
-
fromDto: (dto, itemMapper) => ({
|
|
32
|
-
data: dto.data.map(itemMapper),
|
|
33
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
34
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
var PaginationParams = {
|
|
38
|
-
toQueryParams: (params) => {
|
|
39
|
-
const queryParams = {};
|
|
40
|
-
if (params.after) {
|
|
41
|
-
queryParams.starting_after = params.after;
|
|
42
|
-
}
|
|
43
|
-
if (params.before) {
|
|
44
|
-
queryParams.starting_before = params.before;
|
|
45
|
-
}
|
|
46
|
-
if (params.limit) {
|
|
47
|
-
queryParams.limit = params.limit;
|
|
48
|
-
}
|
|
49
|
-
return queryParams;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/shared/utils.ts
|
|
54
|
-
async function sha256(data) {
|
|
55
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
56
|
-
const buffer = bytes.buffer.slice(
|
|
57
|
-
bytes.byteOffset,
|
|
58
|
-
bytes.byteOffset + bytes.byteLength
|
|
59
|
-
);
|
|
60
|
-
return crypto.subtle.digest("SHA-256", buffer);
|
|
61
|
-
}
|
|
62
|
-
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
63
|
-
const bytes = new Uint8Array(buffer);
|
|
64
|
-
let binary = "";
|
|
65
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
66
|
-
binary += String.fromCharCode(bytes[i]);
|
|
67
|
-
}
|
|
68
|
-
let base64 = btoa(binary);
|
|
69
|
-
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
70
|
-
if (!padding) {
|
|
71
|
-
base64 = base64.replace(/=+$/, "");
|
|
72
|
-
}
|
|
73
|
-
return base64;
|
|
74
|
-
}
|
|
75
|
-
function generateSecureRandomBase64Url(byteLength) {
|
|
76
|
-
const bytes = new Uint8Array(byteLength);
|
|
77
|
-
crypto.getRandomValues(bytes);
|
|
78
|
-
const buffer = bytes.buffer;
|
|
79
|
-
return arrayBufferToBase64Url(buffer, false);
|
|
80
|
-
}
|
|
81
|
-
function getUUIDv4() {
|
|
82
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
83
|
-
return crypto.randomUUID();
|
|
84
|
-
}
|
|
85
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
86
|
-
const bytes = new Uint8Array(16);
|
|
87
|
-
crypto.getRandomValues(bytes);
|
|
88
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
89
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
90
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
91
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
|
|
92
|
-
}
|
|
93
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
94
|
-
}
|
|
95
|
-
function notBlankStringOrNull(value) {
|
|
96
|
-
if (value?.trim()) {
|
|
97
|
-
return value;
|
|
98
|
-
} else {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/shared/types/offer.ts
|
|
104
|
-
var OfferId = (value) => value;
|
|
105
|
-
var OfferSlug = (value) => value;
|
|
106
|
-
var Offer = {
|
|
107
|
-
fromDto: (dto) => ({
|
|
108
|
-
id: OfferId(dto.id),
|
|
109
|
-
slug: OfferSlug(dto.slug),
|
|
110
|
-
tagline: notBlankStringOrNull(dto.tagline),
|
|
111
|
-
bannerUrl: notBlankStringOrNull(dto.banner_url),
|
|
112
|
-
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
113
|
-
startsAt: new Date(dto.starts_at),
|
|
114
|
-
endsAt: new Date(dto.ends_at)
|
|
115
|
-
})
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/shared/types/asset.ts
|
|
119
|
-
var AssetId = (value) => value;
|
|
120
|
-
var AssetCode = (value) => value;
|
|
121
|
-
var Asset = {
|
|
122
|
-
fromDto: (dto) => ({
|
|
123
|
-
id: AssetId(dto.id),
|
|
124
|
-
code: AssetCode(dto.code),
|
|
125
|
-
name: dto.name,
|
|
126
|
-
fractionalDigits: dto.fractional_digits
|
|
127
|
-
})
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/shared/types/offer-detail.ts
|
|
131
|
-
var OfferOptionId = (value) => value;
|
|
132
|
-
var OfferOptionSlug = (value) => value;
|
|
133
|
-
var OfferDetail = {
|
|
134
|
-
fromDto: (dto) => {
|
|
135
|
-
if (!Array.isArray(dto.funding_assets)) {
|
|
136
|
-
throw new Error(`funding_assets must be an array`);
|
|
137
|
-
}
|
|
138
|
-
if (!Array.isArray(dto.options)) {
|
|
139
|
-
throw new Error(`options must be an array`);
|
|
140
|
-
}
|
|
141
|
-
if (!Array.isArray(dto.terms)) {
|
|
142
|
-
throw new Error(`terms must be an array`);
|
|
143
|
-
}
|
|
144
|
-
if (!Array.isArray(dto.links)) {
|
|
145
|
-
throw new Error(`links must be an array`);
|
|
146
|
-
}
|
|
147
|
-
if (!Array.isArray(dto.faqs)) {
|
|
148
|
-
throw new Error(`faqs must be an array`);
|
|
149
|
-
}
|
|
150
|
-
if (!Array.isArray(dto.milestones)) {
|
|
151
|
-
throw new Error(`milestones must be an array`);
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
id: OfferId(dto.id),
|
|
155
|
-
slug: OfferSlug(dto.slug),
|
|
156
|
-
name: dto.name,
|
|
157
|
-
asset: Asset.fromDto(dto.asset),
|
|
158
|
-
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
159
|
-
about: notBlankStringOrNull(dto.about),
|
|
160
|
-
tagline: notBlankStringOrNull(dto.tagline),
|
|
161
|
-
bannerUrl: notBlankStringOrNull(dto.banner_url),
|
|
162
|
-
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
163
|
-
category: notBlankStringOrNull(dto.category),
|
|
164
|
-
startsAt: new Date(dto.starts_at),
|
|
165
|
-
endsAt: new Date(dto.ends_at),
|
|
166
|
-
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
167
|
-
links: dto.links.map(Link.fromDto),
|
|
168
|
-
milestones: dto.milestones.map(Milestone.fromDto),
|
|
169
|
-
options: dto.options.map(OfferOption.fromDto),
|
|
170
|
-
terms: dto.terms.map(TermItem.fromDto)
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
var OfferOption = {
|
|
175
|
-
fromDto: (dto) => ({
|
|
176
|
-
id: OfferOptionId(dto.id),
|
|
177
|
-
slug: OfferOptionSlug(dto.slug),
|
|
178
|
-
bidIncrement: dto.bid_increment,
|
|
179
|
-
floorPriceUsd: dto.floor_price_usd,
|
|
180
|
-
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
181
|
-
priceUsd: dto.price_usd,
|
|
182
|
-
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
183
|
-
totalTokenSupply: dto.total_token_supply
|
|
184
|
-
})
|
|
185
|
-
};
|
|
186
|
-
var FaqItem = {
|
|
187
|
-
fromDto: (dto) => ({
|
|
188
|
-
question: notBlankStringOrNull(dto.question),
|
|
189
|
-
answer: notBlankStringOrNull(dto.answer)
|
|
190
|
-
})
|
|
191
|
-
};
|
|
192
|
-
var Link = {
|
|
193
|
-
fromDto: (dto) => ({
|
|
194
|
-
label: notBlankStringOrNull(dto.label),
|
|
195
|
-
url: notBlankStringOrNull(dto.url)
|
|
196
|
-
})
|
|
197
|
-
};
|
|
198
|
-
var TermItem = {
|
|
199
|
-
fromDto: (dto) => ({
|
|
200
|
-
key: notBlankStringOrNull(dto.key),
|
|
201
|
-
value: notBlankStringOrNull(dto.value)
|
|
202
|
-
})
|
|
203
|
-
};
|
|
204
|
-
var Milestone = {
|
|
205
|
-
fromDto: (dto) => ({
|
|
206
|
-
name: notBlankStringOrNull(dto.name),
|
|
207
|
-
schedule: notBlankStringOrNull(dto.schedule),
|
|
208
|
-
status: dto.status
|
|
209
|
-
})
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// src/shared/types/participation.ts
|
|
213
|
-
var ParticipationId = (value) => value;
|
|
214
|
-
var Blockchain = (value) => value;
|
|
215
|
-
var WalletAddress = (value) => value;
|
|
216
|
-
var Participation = {
|
|
217
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
218
|
-
fromDto: (dto) => {
|
|
219
|
-
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
220
|
-
return {
|
|
221
|
-
id: ParticipationId(dto.id),
|
|
222
|
-
offerId: OfferId(dto.offer_id),
|
|
223
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
224
|
-
status: dto.status,
|
|
225
|
-
amount: dto.amount,
|
|
226
|
-
displayAmount: dto.amount_string,
|
|
227
|
-
asset: Asset.fromDto(dto.asset),
|
|
228
|
-
chain: Blockchain(dto.chain),
|
|
229
|
-
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
230
|
-
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
231
|
-
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
var CreateParticipationParams = {
|
|
236
|
-
/** Maps participation creation params into API DTO payload. */
|
|
237
|
-
toDto: (params) => ({
|
|
238
|
-
offer_id: params.offerId,
|
|
239
|
-
offer_option_id: params.offerOptionId,
|
|
240
|
-
chain: params.chain,
|
|
241
|
-
wallet_address: params.walletAddress,
|
|
242
|
-
amount: params.amount,
|
|
243
|
-
asset_id: params.assetId,
|
|
244
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
245
|
-
})
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// src/client/core/api/middleware/attach-session-middleware.ts
|
|
249
|
-
function attachSessionMiddleware(fetchAccessToken) {
|
|
250
|
-
return async (request) => {
|
|
251
|
-
if (!Attributes.isProtected(request.attributes)) {
|
|
252
|
-
return request;
|
|
253
|
-
}
|
|
254
|
-
const accessToken = await fetchAccessToken(false);
|
|
255
|
-
if (accessToken === null) {
|
|
256
|
-
return request;
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
...request,
|
|
260
|
-
headers: {
|
|
261
|
-
...request.headers ?? {},
|
|
262
|
-
Authorization: `Bearer ${accessToken.value}`
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// src/client/core/api/middleware/session-renewal.ts
|
|
269
|
-
function renewSessionMiddleware(fetchAccessToken) {
|
|
270
|
-
return async ({ request, response, retry }) => {
|
|
271
|
-
if (response.status !== 401) {
|
|
272
|
-
return response;
|
|
273
|
-
}
|
|
274
|
-
if (!Attributes.isProtected(request.attributes)) {
|
|
275
|
-
return response;
|
|
276
|
-
}
|
|
277
|
-
if (Attributes.wasRenewAttempted(request.attributes)) {
|
|
278
|
-
return response;
|
|
279
|
-
}
|
|
280
|
-
const newToken = await fetchAccessToken(true);
|
|
281
|
-
if (newToken) {
|
|
282
|
-
const nextRequest = Request.concatAttributes(
|
|
283
|
-
request,
|
|
284
|
-
Attributes.renewAttempted(true)
|
|
285
|
-
);
|
|
286
|
-
return retry(nextRequest);
|
|
287
|
-
} else {
|
|
288
|
-
return response;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// src/client/core/api/middleware/device-id.ts
|
|
294
|
-
var DEVICE_ID_KEY = "coinlist.device_id";
|
|
295
|
-
function getDeviceId() {
|
|
296
|
-
let deviceId = localStorage.getItem(DEVICE_ID_KEY);
|
|
297
|
-
if (!deviceId) {
|
|
298
|
-
deviceId = getUUIDv4();
|
|
299
|
-
localStorage.setItem(DEVICE_ID_KEY, deviceId);
|
|
300
|
-
}
|
|
301
|
-
return deviceId;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// src/client/core/api/middleware/user-agent.ts
|
|
305
|
-
var userAgentMiddleware = async (request) => {
|
|
306
|
-
if (!Attributes.needUserAgent(request.attributes)) {
|
|
307
|
-
return request;
|
|
308
|
-
}
|
|
309
|
-
const userAgent = generateUserAgent();
|
|
310
|
-
return {
|
|
311
|
-
...request,
|
|
312
|
-
headers: {
|
|
313
|
-
...request.headers ?? {},
|
|
314
|
-
[HEADER_USER_AGENT]: userAgent
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
function generateUserAgent() {
|
|
319
|
-
const appInfo = `CoinList/1.0`;
|
|
320
|
-
const deviceInfo = "Web Browser";
|
|
321
|
-
const devicePlatform = "DevicePlatform web";
|
|
322
|
-
const deviceAppId = "DeviceAppID co.coinlist.sdk";
|
|
323
|
-
const deviceId = getDeviceId();
|
|
324
|
-
const finalDeviceId = `DeviceID ${deviceId}`;
|
|
325
|
-
return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/shared/api/middleware/idempotency-key.ts
|
|
329
|
-
var idempotencyKeyMiddleware = async (request) => {
|
|
330
|
-
if (!Attributes.isIdempotent(request.attributes)) {
|
|
331
|
-
return request;
|
|
332
|
-
}
|
|
333
|
-
const existingHeaders = request.headers ?? {};
|
|
334
|
-
if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {
|
|
335
|
-
return request;
|
|
336
|
-
}
|
|
337
|
-
return {
|
|
338
|
-
...request,
|
|
339
|
-
headers: {
|
|
340
|
-
...existingHeaders,
|
|
341
|
-
[HEADER_IDEMPOTENCY_KEY]: getUUIDv4()
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
// src/client/core/api/api-client.ts
|
|
347
|
-
var ApiClient = class {
|
|
348
|
-
constructor(config, fetchAccessToken) {
|
|
349
|
-
this.config = config;
|
|
350
|
-
this.fetchAccessToken = fetchAccessToken;
|
|
351
|
-
this.httpClient = new HttpClient(this.config, {
|
|
352
|
-
beforeRequest: [
|
|
353
|
-
attachSessionMiddleware(this.fetchAccessToken),
|
|
354
|
-
userAgentMiddleware,
|
|
355
|
-
idempotencyKeyMiddleware
|
|
356
|
-
],
|
|
357
|
-
afterRequest: [
|
|
358
|
-
renewSessionMiddleware(this.fetchAccessToken),
|
|
359
|
-
requestRetryMiddleware
|
|
360
|
-
]
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
async send(request) {
|
|
364
|
-
const response = await this.httpClient.send(request);
|
|
365
|
-
if (response.status >= 200 && response.status < 300) {
|
|
366
|
-
return response.body;
|
|
367
|
-
} else {
|
|
368
|
-
throw new HttpError(response);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// src/shared/types/errors.ts
|
|
374
|
-
var NotAuthenticatedError = class extends Error {
|
|
375
|
-
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
376
|
-
super(message);
|
|
377
|
-
this.name = "NotAuthenticatedError";
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// src/client/core/coinlist-client.ts
|
|
382
|
-
var OAUTH_STATE_KEY = "coinlist.oauth_state";
|
|
383
|
-
var OAUTH_CODE_VERIFIER_KEY = "coinlist.oauth_code_verifier";
|
|
384
|
-
var CoinListClientImpl = class {
|
|
385
|
-
constructor(_config) {
|
|
386
|
-
this._config = _config;
|
|
387
|
-
/** Cached access token: undefined = loading, null = no token, AccessToken = logged in */
|
|
388
|
-
this._accessToken = void 0;
|
|
389
|
-
this.api = new ApiClient(
|
|
390
|
-
{
|
|
391
|
-
baseUrl: _config.baseUrl || PUBLIC_API_BASE_URL,
|
|
392
|
-
xApiVersion: API_VERSION
|
|
393
|
-
},
|
|
394
|
-
this.fetchAccessToken.bind(this)
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
async init() {
|
|
398
|
-
await this.fetchAccessToken(true);
|
|
399
|
-
return this.getAuthState();
|
|
400
|
-
}
|
|
401
|
-
async fetchAccessToken(refresh) {
|
|
402
|
-
if (!refresh && this._accessToken !== void 0) return this._accessToken;
|
|
403
|
-
try {
|
|
404
|
-
const accessToken = await this._config.getAccessToken();
|
|
405
|
-
this._accessToken = accessToken;
|
|
406
|
-
return accessToken;
|
|
407
|
-
} catch (_) {
|
|
408
|
-
this._accessToken = null;
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
getAuthState() {
|
|
413
|
-
if (this._accessToken === void 0) {
|
|
414
|
-
return "unknown";
|
|
415
|
-
}
|
|
416
|
-
return this._accessToken !== null ? "logged-in" : "logged-out";
|
|
417
|
-
}
|
|
418
|
-
async startOAuth() {
|
|
419
|
-
const state = generateSecureRandomBase64Url(32);
|
|
420
|
-
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
421
|
-
const codeChallengeRaw = await sha256(codeVerifier);
|
|
422
|
-
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
423
|
-
sessionStorage.setItem(OAUTH_STATE_KEY, state);
|
|
424
|
-
sessionStorage.setItem(OAUTH_CODE_VERIFIER_KEY, codeVerifier);
|
|
425
|
-
const params = new URLSearchParams({
|
|
426
|
-
client_id: this._config.clientId,
|
|
427
|
-
response_type: "code",
|
|
428
|
-
redirect_uri: this._config.redirectUri,
|
|
429
|
-
code_challenge: codeChallenge,
|
|
430
|
-
code_challenge_method: "S256",
|
|
431
|
-
state
|
|
432
|
-
});
|
|
433
|
-
const oauthPageUrl = this._config.authorizationPageUrl ?? COINLIST_OAUTH_PAGE_URL;
|
|
434
|
-
const url = `${oauthPageUrl}?${params.toString()}`;
|
|
435
|
-
window.location.href = url;
|
|
436
|
-
}
|
|
437
|
-
completeOAuth() {
|
|
438
|
-
const params = new URLSearchParams(window.location.search);
|
|
439
|
-
const coinlistError = params.get("error");
|
|
440
|
-
if (coinlistError) {
|
|
441
|
-
return { type: "error", reason: "user_canceled" };
|
|
442
|
-
}
|
|
443
|
-
const stateParam = params.get("state");
|
|
444
|
-
if (!stateParam) {
|
|
445
|
-
return { type: "error", reason: "missing_state" };
|
|
446
|
-
}
|
|
447
|
-
const storedState = sessionStorage.getItem(OAUTH_STATE_KEY);
|
|
448
|
-
if (storedState === null || storedState !== stateParam) {
|
|
449
|
-
return { type: "error", reason: "invalid_state" };
|
|
450
|
-
}
|
|
451
|
-
const codeParam = params.get("code");
|
|
452
|
-
if (!codeParam) {
|
|
453
|
-
return { type: "error", reason: "missing_code" };
|
|
454
|
-
}
|
|
455
|
-
const codeVerifierValue = sessionStorage.getItem(OAUTH_CODE_VERIFIER_KEY);
|
|
456
|
-
if (!codeVerifierValue) {
|
|
457
|
-
return { type: "error", reason: "missing_code_verifier" };
|
|
458
|
-
}
|
|
459
|
-
return {
|
|
460
|
-
type: "ok",
|
|
461
|
-
code: AuthorizationCode(codeParam),
|
|
462
|
-
codeVerifier: CodeVerifier(codeVerifierValue)
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
logout() {
|
|
466
|
-
this._accessToken = null;
|
|
467
|
-
}
|
|
468
|
-
async fetchAllOffers() {
|
|
469
|
-
this.ensureAuthenticated();
|
|
470
|
-
return await fetchAllPages(this.fetchOffersPage.bind(this));
|
|
471
|
-
}
|
|
472
|
-
async fetchOffersPage(params) {
|
|
473
|
-
this.ensureAuthenticated();
|
|
474
|
-
const pageDto = await this.api.send({
|
|
475
|
-
method: "GET",
|
|
476
|
-
url: "/v1/offers",
|
|
477
|
-
queryParams: PaginationParams.toQueryParams(params),
|
|
478
|
-
attributes: Attributes.protected()
|
|
479
|
-
});
|
|
480
|
-
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
481
|
-
}
|
|
482
|
-
async fetchOfferDetails(id) {
|
|
483
|
-
this.ensureAuthenticated();
|
|
484
|
-
const offerDetailDto = await this.api.send({
|
|
485
|
-
method: "GET",
|
|
486
|
-
url: `/v1/offers/${id}`,
|
|
487
|
-
attributes: Attributes.protected()
|
|
488
|
-
});
|
|
489
|
-
return OfferDetail.fromDto(offerDetailDto);
|
|
490
|
-
}
|
|
491
|
-
async fetchAllParticipations() {
|
|
492
|
-
this.ensureAuthenticated();
|
|
493
|
-
return await fetchAllPages(this.fetchParticipationsPage.bind(this));
|
|
494
|
-
}
|
|
495
|
-
async fetchParticipationsPage(params) {
|
|
496
|
-
this.ensureAuthenticated();
|
|
497
|
-
const pageDto = await this.api.send(
|
|
498
|
-
{
|
|
499
|
-
method: "GET",
|
|
500
|
-
url: "/v1/participations",
|
|
501
|
-
queryParams: PaginationParams.toQueryParams(params),
|
|
502
|
-
attributes: Attributes.protected()
|
|
503
|
-
}
|
|
504
|
-
);
|
|
505
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
506
|
-
}
|
|
507
|
-
async fetchParticipation(id) {
|
|
508
|
-
this.ensureAuthenticated();
|
|
509
|
-
const participationDto = await this.api.send({
|
|
510
|
-
method: "GET",
|
|
511
|
-
url: `/v1/participations/${id}`,
|
|
512
|
-
attributes: Attributes.protected()
|
|
513
|
-
});
|
|
514
|
-
return Participation.fromDto(participationDto);
|
|
515
|
-
}
|
|
516
|
-
async createParticipation(params) {
|
|
517
|
-
this.ensureAuthenticated();
|
|
518
|
-
const participationDto = await this.api.send({
|
|
519
|
-
method: "POST",
|
|
520
|
-
url: "/v1/participations",
|
|
521
|
-
body: CreateParticipationParams.toDto(params),
|
|
522
|
-
attributes: Attributes.protected()
|
|
523
|
-
});
|
|
524
|
-
return Participation.fromDto(participationDto);
|
|
525
|
-
}
|
|
526
|
-
ensureAuthenticated() {
|
|
527
|
-
if (this.getAuthState() !== "logged-in") {
|
|
528
|
-
throw new NotAuthenticatedError();
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
function createCoinListClient(config) {
|
|
533
|
-
return new CoinListClientImpl(config);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
export {
|
|
537
|
-
Cursor,
|
|
538
|
-
fetchAllPages,
|
|
539
|
-
PaginatedResponse,
|
|
540
|
-
PaginationParams,
|
|
541
|
-
NotAuthenticatedError,
|
|
542
|
-
OfferId,
|
|
543
|
-
OfferSlug,
|
|
544
|
-
Offer,
|
|
545
|
-
OfferOptionId,
|
|
546
|
-
OfferOptionSlug,
|
|
547
|
-
OfferDetail,
|
|
548
|
-
OfferOption,
|
|
549
|
-
FaqItem,
|
|
550
|
-
Link,
|
|
551
|
-
TermItem,
|
|
552
|
-
Milestone,
|
|
553
|
-
ParticipationId,
|
|
554
|
-
Blockchain,
|
|
555
|
-
WalletAddress,
|
|
556
|
-
Participation,
|
|
557
|
-
CreateParticipationParams,
|
|
558
|
-
createCoinListClient
|
|
559
|
-
};
|
|
560
|
-
//# sourceMappingURL=chunk-Z5RFQOMS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/api/pagination.ts","../src/shared/utils.ts","../src/shared/types/offer.ts","../src/shared/types/asset.ts","../src/shared/types/offer-detail.ts","../src/shared/types/participation.ts","../src/client/core/api/middleware/attach-session-middleware.ts","../src/client/core/api/middleware/session-renewal.ts","../src/client/core/api/middleware/device-id.ts","../src/client/core/api/middleware/user-agent.ts","../src/shared/api/middleware/idempotency-key.ts","../src/client/core/api/api-client.ts","../src/shared/types/errors.ts","../src/client/core/coinlist-client.ts"],"sourcesContent":["import type { QueryParamValue } from '@/shared/api/http';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type Cursor = Newtype<string, 'Cursor'>;\nexport const Cursor = (value: string) => value as Cursor;\n\n/**\n * Cursor-based pagination input used when requesting paginated API resources.\n * Set `after` or `before` to navigate relative to a known cursor, and `limit`\n * to control the maximum number of returned items.\n */\nexport interface PaginationParams {\n before?: Cursor;\n after?: Cursor;\n limit?: number;\n}\n\nexport interface PaginatedResponseDto<T> {\n data: T[];\n starting_after?: string;\n starting_before?: string;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n startingAfter: Cursor | null;\n startingBefore: Cursor | null;\n}\n\nexport async function fetchAllPages<A>(\n fetchPage: (params: PaginationParams) => Promise<PaginatedResponse<A>>\n): Promise<A[]> {\n const items: A[] = [];\n let cursor: Cursor | null = null;\n\n do {\n const page = await fetchPage({\n after: cursor ?? undefined,\n });\n items.push(...page.data);\n cursor = page.startingAfter;\n } while (cursor);\n\n return items;\n}\n\nexport const PaginatedResponse = {\n fromDto: <A, B>(\n dto: PaginatedResponseDto<A>,\n itemMapper: (item: A) => B\n ): PaginatedResponse<B> => ({\n data: dto.data.map(itemMapper),\n startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,\n startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null,\n }),\n};\n\nexport const PaginationParams = {\n toQueryParams: (\n params: PaginationParams\n ): Record<string, QueryParamValue> => {\n const queryParams: Record<string, QueryParamValue> = {};\n if (params.after) {\n queryParams.starting_after = params.after;\n }\n if (params.before) {\n queryParams.starting_before = params.before;\n }\n if (params.limit) {\n queryParams.limit = params.limit;\n }\n return queryParams;\n },\n};\n","/**\n * Computes SHA-256 digest of the input (UTF-8 string or raw bytes).\n * Uses the Web Crypto API.\n */\nexport async function sha256(data: string | Uint8Array): Promise<ArrayBuffer> {\n const bytes =\n typeof data === 'string' ? new TextEncoder().encode(data) : data;\n const buffer = bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n ) as ArrayBuffer;\n return crypto.subtle.digest('SHA-256', buffer);\n}\n\n/**\n * Converts an ArrayBuffer to Base64-URL encoding (RFC 4648).\n * @param padding - If false, omits trailing '=' padding (e.g. for PKCE).\n */\nexport function arrayBufferToBase64Url(\n buffer: ArrayBuffer,\n padding: boolean = true\n): string {\n const bytes = new Uint8Array(buffer);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n let base64 = btoa(binary);\n base64 = base64.replace(/\\+/g, '-').replace(/\\//g, '_');\n if (!padding) {\n base64 = base64.replace(/=+$/, '');\n }\n return base64;\n}\n\n/**\n * Securely generates random bytes and returns them as Base64-URL (no padding).\n * Suitable for PKCE code_verifier and OAuth state.\n * @param byteLength - Number of random bytes (e.g. 32 for PKCE).\n */\nexport function generateSecureRandomBase64Url(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n crypto.getRandomValues(bytes);\n const buffer = bytes.buffer;\n return arrayBufferToBase64Url(buffer, false);\n}\n\n/**\n * Generate a UUID v4 using the standard Web Crypto API (crypto.randomUUID).\n * Falls back to RFC 4122–compliant generation via crypto.getRandomValues in old browsers.\n */\nexport function getUUIDv4(): string {\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.randomUUID === 'function'\n ) {\n return crypto.randomUUID();\n }\n\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.getRandomValues === 'function'\n ) {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0'));\n return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10, 16).join('')}`;\n }\n\n return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;\n}\n\nexport function notBlankStringOrNull(value?: string | null): string | null {\n if (value?.trim()) {\n return value;\n } else {\n return null;\n }\n}\n","import type { OfferDto } from '@/shared/types/dto/offer';\nimport type { Newtype } from '@/shared/types/newtype';\nimport { notBlankStringOrNull } from '@/shared/utils';\n\nexport type OfferId = Newtype<string, 'OfferId'>;\nexport const OfferId = (value: string) => value as OfferId;\n\nexport type OfferSlug = Newtype<string, 'OfferSlug'>;\nexport const OfferSlug = (value: string) => value as OfferSlug;\n\nexport type Offer = {\n id: OfferId;\n slug: OfferSlug;\n tagline: string | null;\n bannerUrl: string | null;\n logoUrl: string | null;\n startsAt: Date;\n endsAt: Date;\n};\n\nexport const Offer = {\n fromDto: (dto: OfferDto): Offer => ({\n id: OfferId(dto.id),\n slug: OfferSlug(dto.slug),\n tagline: notBlankStringOrNull(dto.tagline),\n bannerUrl: notBlankStringOrNull(dto.banner_url),\n logoUrl: notBlankStringOrNull(dto.logo_url),\n startsAt: new Date(dto.starts_at),\n endsAt: new Date(dto.ends_at),\n }),\n};\n","import type { AssetDto } from '@/shared/types/dto/asset';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type AssetId = Newtype<string, 'AssetId'>;\nexport const AssetId = (value: string) => value as AssetId;\n\nexport type AssetCode = Newtype<string, 'AssetCode'>;\nexport const AssetCode = (value: string) => value as AssetCode;\n\nexport type Asset = {\n id: AssetId;\n code: AssetCode;\n name: string;\n fractionalDigits: number;\n};\n\nexport const Asset = {\n fromDto: (dto: AssetDto): Asset => ({\n id: AssetId(dto.id),\n code: AssetCode(dto.code),\n name: dto.name,\n fractionalDigits: dto.fractional_digits,\n }),\n};\n","import { Asset } from '@/shared/types/asset';\nimport type {\n OfferDetailDto,\n OfferDetailFaqDto,\n OfferDetailLinkDto,\n OfferDetailMilestoneDto,\n OfferDetailOptionDto,\n OfferDetailTermDto,\n} from '@/shared/types/dto/offer-detail';\nimport type { Newtype } from '@/shared/types/newtype';\nimport { OfferId, OfferSlug } from '@/shared/types/offer';\nimport { notBlankStringOrNull } from '@/shared/utils';\n\nexport type OfferDetail = {\n id: OfferId;\n slug: OfferSlug;\n name: string;\n\n asset: Asset;\n fundingAssets: Asset[];\n\n about: string | null;\n tagline: string | null;\n bannerUrl: string | null;\n logoUrl: string | null;\n category: string | null;\n\n startsAt: Date;\n endsAt: Date;\n\n faqs: FaqItem[];\n links: Link[];\n milestones: Milestone[];\n options: OfferOption[];\n terms: TermItem[];\n};\n\nexport type OfferOptionId = Newtype<string, 'OfferOptionId'>;\nexport const OfferOptionId = (value: string) => value as OfferOptionId;\n\nexport type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;\nexport const OfferOptionSlug = (value: string) => value as OfferOptionSlug;\n\nexport type OfferOption = {\n id: OfferOptionId;\n slug: OfferOptionSlug;\n bidIncrement: number | null;\n floorPriceUsd: number | null;\n minimumPurchaseUsd: number | null;\n priceUsd: number | null;\n saleAgreementUrl: string | null;\n totalTokenSupply: number | null;\n};\n\nexport type FaqItem = {\n question: string | null;\n answer: string | null;\n};\n\nexport type TermItem = {\n key: string | null;\n value: string | null;\n};\n\nexport type Milestone = {\n name: string | null;\n schedule: string | null;\n status: 'completed' | 'active' | 'upcoming';\n};\n\nexport type Link = {\n label: string | null;\n url: string | null;\n};\n\nexport const OfferDetail = {\n fromDto: (dto: OfferDetailDto): OfferDetail => {\n if (!Array.isArray(dto.funding_assets)) {\n throw new Error(`funding_assets must be an array`);\n }\n\n if (!Array.isArray(dto.options)) {\n throw new Error(`options must be an array`);\n }\n\n if (!Array.isArray(dto.terms)) {\n throw new Error(`terms must be an array`);\n }\n\n if (!Array.isArray(dto.links)) {\n throw new Error(`links must be an array`);\n }\n\n if (!Array.isArray(dto.faqs)) {\n throw new Error(`faqs must be an array`);\n }\n\n if (!Array.isArray(dto.milestones)) {\n throw new Error(`milestones must be an array`);\n }\n\n return {\n id: OfferId(dto.id),\n slug: OfferSlug(dto.slug),\n name: dto.name,\n\n asset: Asset.fromDto(dto.asset),\n fundingAssets: dto.funding_assets.map(Asset.fromDto),\n\n about: notBlankStringOrNull(dto.about),\n tagline: notBlankStringOrNull(dto.tagline),\n bannerUrl: notBlankStringOrNull(dto.banner_url),\n logoUrl: notBlankStringOrNull(dto.logo_url),\n category: notBlankStringOrNull(dto.category),\n\n startsAt: new Date(dto.starts_at),\n endsAt: new Date(dto.ends_at),\n\n faqs: dto.faqs.map(FaqItem.fromDto),\n links: dto.links.map(Link.fromDto),\n milestones: dto.milestones.map(Milestone.fromDto),\n options: dto.options.map(OfferOption.fromDto),\n terms: dto.terms.map(TermItem.fromDto),\n };\n },\n};\n\nexport const OfferOption = {\n fromDto: (dto: OfferDetailOptionDto): OfferOption => ({\n id: OfferOptionId(dto.id),\n slug: OfferOptionSlug(dto.slug),\n bidIncrement: dto.bid_increment,\n floorPriceUsd: dto.floor_price_usd,\n minimumPurchaseUsd: dto.minimum_purchase_usd,\n priceUsd: dto.price_usd,\n saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),\n totalTokenSupply: dto.total_token_supply,\n }),\n};\n\nexport const FaqItem = {\n fromDto: (dto: OfferDetailFaqDto): FaqItem => ({\n question: notBlankStringOrNull(dto.question),\n answer: notBlankStringOrNull(dto.answer),\n }),\n};\n\nexport const Link = {\n fromDto: (dto: OfferDetailLinkDto): Link => ({\n label: notBlankStringOrNull(dto.label),\n url: notBlankStringOrNull(dto.url),\n }),\n};\n\nexport const TermItem = {\n fromDto: (dto: OfferDetailTermDto): TermItem => ({\n key: notBlankStringOrNull(dto.key),\n value: notBlankStringOrNull(dto.value),\n }),\n};\n\nexport const Milestone = {\n fromDto: (dto: OfferDetailMilestoneDto): Milestone => ({\n name: notBlankStringOrNull(dto.name),\n schedule: notBlankStringOrNull(dto.schedule),\n status: dto.status,\n }),\n};\n","import { Asset, type AssetId } from '@/shared/types/asset';\nimport type {\n CreateParticipationDto,\n ParticipationDto,\n ParticipationStatusDto,\n} from '@/shared/types/dto/participation';\nimport type { Newtype } from '@/shared/types/newtype';\nimport { OfferId, type OfferId as OfferIdType } from '@/shared/types/offer';\nimport {\n OfferOptionId,\n type OfferOptionId as OfferOptionIdType,\n} from '@/shared/types/offer-detail';\nimport { notBlankStringOrNull } from '@/shared/utils';\n\n/** Unique identifier for a participation. */\nexport type ParticipationId = Newtype<string, 'ParticipationId'>;\n/** Casts a string into a typed {@link ParticipationId}. */\nexport const ParticipationId = (value: string) => value as ParticipationId;\n\n/** Blockchain identifier for where a participation is funded. */\nexport type Blockchain = Newtype<string, 'Blockchain'>;\n/** Casts a string into a typed {@link Blockchain}. */\nexport const Blockchain = (value: string) => value as Blockchain;\n\n/** Wallet address used for a participation. */\nexport type WalletAddress = Newtype<string, 'WalletAddress'>;\n/** Casts a string into a typed {@link WalletAddress}. */\nexport const WalletAddress = (value: string) => value as WalletAddress;\n\n/** Possible participation lifecycle states returned by the API. */\nexport type ParticipationStatus = ParticipationStatusDto;\n\n/** Domain model for a participation returned by CoinList APIs. */\nexport type Participation = {\n /** Unique participation id. */\n id: ParticipationId;\n /** Parent offer id. */\n offerId: OfferIdType;\n /** Selected offer option id. */\n offerOptionId: OfferOptionIdType;\n /** Current processing status. */\n status: ParticipationStatus;\n /** Raw participation amount from API. */\n amount: string;\n /** Human-readable formatted amount from API. */\n displayAmount: string;\n /** Asset metadata for the participation amount. */\n asset: Asset;\n /** Funding chain identifier. */\n chain: Blockchain;\n /** Creation timestamp, if returned by API. */\n insertedAt: Date | null;\n /** Last update timestamp, if returned by API. */\n updatedAt: Date | null;\n /** Wallet used for participation, blank values normalized to null. */\n walletAddress: WalletAddress | null;\n};\n\n/** Parameters required to create a new participation. */\nexport type CreateParticipationParams = {\n /** Offer to participate in. */\n offerId: OfferIdType;\n /** Offer option selected for participation. */\n offerOptionId: OfferOptionIdType;\n /** Blockchain for funding. */\n chain: Blockchain;\n /** Wallet address that funds the participation. */\n walletAddress: WalletAddress;\n /** Raw amount to participate with. */\n amount: string;\n /** Funding asset id. */\n assetId: AssetId;\n /** Optional approval transaction hash, if applicable. */\n approvalTransactionHash?: string | null;\n};\n\nexport const Participation = {\n /** Maps API DTO shape into the SDK participation domain model. */\n fromDto: (dto: ParticipationDto): Participation => {\n const walletAddress = notBlankStringOrNull(dto.wallet_address);\n return {\n id: ParticipationId(dto.id),\n offerId: OfferId(dto.offer_id),\n offerOptionId: OfferOptionId(dto.offer_option_id),\n status: dto.status,\n amount: dto.amount,\n displayAmount: dto.amount_string,\n asset: Asset.fromDto(dto.asset),\n chain: Blockchain(dto.chain),\n insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,\n updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,\n walletAddress: walletAddress ? WalletAddress(walletAddress) : null,\n };\n },\n};\n\nexport const CreateParticipationParams = {\n /** Maps participation creation params into API DTO payload. */\n toDto: (params: CreateParticipationParams): CreateParticipationDto => ({\n offer_id: params.offerId,\n offer_option_id: params.offerOptionId,\n chain: params.chain,\n wallet_address: params.walletAddress,\n amount: params.amount,\n asset_id: params.assetId,\n approval_transaction_hash: params.approvalTransactionHash,\n }),\n};\n","import type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function attachSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): BeforeRequestMiddleware {\n return async (request: HttpRequest): Promise<HttpRequest> => {\n if (!Attributes.isProtected(request.attributes)) {\n return request;\n }\n\n const accessToken = await fetchAccessToken(false);\n if (accessToken === null) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n Authorization: `Bearer ${accessToken.value}`,\n },\n };\n };\n}\n","import { Request } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function renewSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): AfterRequestMiddleware {\n return async ({ request, response, retry }) => {\n if (response.status !== 401) {\n return response;\n }\n if (!Attributes.isProtected(request.attributes)) {\n return response;\n }\n if (Attributes.wasRenewAttempted(request.attributes)) {\n return response;\n }\n\n const newToken = await fetchAccessToken(true);\n if (newToken) {\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.renewAttempted(true)\n );\n return retry(nextRequest);\n } else {\n return response;\n }\n };\n}\n","'use client';\n\nimport { getUUIDv4 } from '@/shared/utils';\n\nconst DEVICE_ID_KEY = 'coinlist.device_id';\n\n/**\n * Get or create a device ID stored in localStorage.\n * Uses a crypto UUID that persists across sessions.\n */\nexport function getDeviceId(): string {\n let deviceId = localStorage.getItem(DEVICE_ID_KEY);\n\n if (!deviceId) {\n deviceId = getUUIDv4();\n localStorage.setItem(DEVICE_ID_KEY, deviceId);\n }\n\n return deviceId;\n}\n\n/**\n * Clear the stored device ID (useful for testing or logout).\n */\nexport function clearDeviceId(): void {\n localStorage.removeItem(DEVICE_ID_KEY);\n}\n","'use client';\n\nimport { getDeviceId } from '@/client/core/api/middleware/device-id';\nimport { HEADER_USER_AGENT } from '@/shared/api/frontline';\nimport type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\n\nexport const userAgentMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.needUserAgent(request.attributes)) {\n return request;\n }\n\n const userAgent = generateUserAgent();\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n [HEADER_USER_AGENT]: userAgent,\n },\n };\n};\n\n// Generate User-Agent in the required format for Frontline API\n// Format: <app-info> (<device-info>; DevicePlatform <device-platform>; DeviceAppID <device-app-id>; DeviceID <device-id>)\nfunction generateUserAgent(): string {\n const appInfo = `CoinList/1.0`;\n const deviceInfo = 'Web Browser';\n const devicePlatform = 'DevicePlatform web'; // Must be 'web' for validation\n\n const deviceAppId = 'DeviceAppID co.coinlist.sdk'; // SDK app ID\n\n const deviceId = getDeviceId();\n const finalDeviceId = `DeviceID ${deviceId}`;\n\n return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;\n}\n","import { HEADER_IDEMPOTENCY_KEY } from '@/shared/api/frontline';\nimport type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport { getUUIDv4 } from '@/shared/utils';\n\nexport const idempotencyKeyMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.isIdempotent(request.attributes)) {\n return request;\n }\n\n const existingHeaders = request.headers ?? {};\n if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...existingHeaders,\n [HEADER_IDEMPOTENCY_KEY]: getUUIDv4(),\n },\n };\n};\n","'use client';\n\nimport { attachSessionMiddleware } from '@/client/core/api/middleware/attach-session-middleware';\nimport { renewSessionMiddleware } from '@/client/core/api/middleware/session-renewal';\nimport { userAgentMiddleware } from '@/client/core/api/middleware/user-agent';\nimport {\n type HttpClientConfig,\n HttpError,\n type HttpRequest,\n} from '@/shared/api/http';\nimport { HttpClient } from '@/shared/api/http-client';\nimport { idempotencyKeyMiddleware } from '@/shared/api/middleware/idempotency-key';\nimport { requestRetryMiddleware } from '@/shared/api/middleware/request-retry';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport class ApiClient {\n private readonly httpClient: HttpClient;\n\n constructor(\n readonly config: HttpClientConfig,\n readonly fetchAccessToken: (\n refresh: boolean\n ) => Promise<OAuthAccessToken | null>\n ) {\n this.httpClient = new HttpClient(this.config, {\n beforeRequest: [\n attachSessionMiddleware(this.fetchAccessToken),\n userAgentMiddleware,\n idempotencyKeyMiddleware,\n ],\n afterRequest: [\n renewSessionMiddleware(this.fetchAccessToken),\n requestRetryMiddleware,\n ],\n });\n }\n\n async send<TResponse>(request: HttpRequest): Promise<TResponse> {\n const response = await this.httpClient.send<TResponse>(request);\n if (response.status >= 200 && response.status < 300) {\n return response.body as TResponse;\n } else {\n throw new HttpError(response);\n }\n }\n}\n","/**\n * Error thrown when a feature or code path is not yet implemented.\n */\nexport class NotImplementedError extends Error {\n constructor(message = 'Not implemented yet') {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * Error thrown when accessing a feature that requires authentication\n * without being authenticated.\n */\nexport class NotAuthenticatedError extends Error {\n constructor(\n message = 'The user is not authenticated. Go through the OAuth flow first!'\n ) {\n super(message);\n this.name = 'NotAuthenticatedError';\n }\n}\n","'use client';\n\nimport { ApiClient } from '@/client/core/api/api-client';\nimport type {\n AuthState,\n OauthClientResult,\n} from '@/client/core/types/client-types';\nimport {\n API_VERSION,\n COINLIST_OAUTH_PAGE_URL,\n PUBLIC_API_BASE_URL,\n} from '@/shared/api/frontline';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport {\n fetchAllPages,\n PaginatedResponse,\n type PaginatedResponseDto,\n PaginationParams,\n} from '@/shared/api/pagination';\nimport type { Config } from '@/shared/types/config';\nimport type { OfferDto } from '@/shared/types/dto/offer';\nimport type { OfferDetailDto } from '@/shared/types/dto/offer-detail';\nimport type { ParticipationDto } from '@/shared/types/dto/participation';\nimport { NotAuthenticatedError } from '@/shared/types/errors';\nimport { AuthorizationCode, CodeVerifier } from '@/shared/types/oauth';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\nimport { Offer, type OfferId } from '@/shared/types/offer';\nimport { OfferDetail } from '@/shared/types/offer-detail';\nimport {\n CreateParticipationParams,\n Participation,\n type ParticipationId,\n} from '@/shared/types/participation';\nimport {\n arrayBufferToBase64Url,\n generateSecureRandomBase64Url,\n sha256,\n} from '@/shared/utils';\n\n/** Session storage keys for OAuth PKCE (used by startOauth and completeOauth). */\nexport const OAUTH_STATE_KEY = 'coinlist.oauth_state';\nexport const OAUTH_CODE_VERIFIER_KEY = 'coinlist.oauth_code_verifier';\n\nexport interface ClientConfig extends Config {\n /**\n * The SDK user must provide this function. It is responsible for fetching a\n * valid {@link OAuthAccessToken}, or **null** for logged-out users. If your\n * backend is in TypeScript, it is recommended to use\n * {@link CoinListServer#accessToken} from `@/server/coinlist.server`.\n */\n getAccessToken: () => Promise<OAuthAccessToken | null>;\n /**\n * Recommended to leave undefined. Used to change the CoinList environment;\n * default is production.\n */\n authorizationPageUrl?: string;\n}\n\nexport interface CoinListClient {\n /**\n * Calls the provided {@link ClientConfig.getAccessToken} lambda to determine\n * the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};\n * you typically do not need to call it yourself unless you are using the client\n * outside of the provider.\n */\n init(): Promise<AuthState>;\n /**\n * Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.\n * Returns **unknown** until {@link CoinListClient.init} has completed. It is\n * recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when\n * the SDK has initialized, or to manually await {@link CoinListClient.init}\n * before relying on this value.\n */\n getAuthState(): AuthState;\n /**\n * Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,\n * stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}\n * on redirect), then redirects the user to the CoinList authorization page. After\n * the user authorizes, they are sent back to your application's redirect URI; call\n * {@link CoinListClient.completeOAuth} on that page to finish the flow.\n */\n startOAuth(): Promise<void>;\n /**\n * Completes the OAuth flow on the FE with PKCE and state validation. Parses the\n * redirect URL (state, code) and validates them against sessionStorage\n * (state, code_verifier). The state check protects against CSRF (cross-site\n * request forgery). Call this on the frontend page the user is redirected\n * to after authorizing.\n *\n * On `ok`: Call your backend to exchange the short-lived `authorizationCode`\n * (and the returned `codeVerifier`) for a long-lived session. If your backend\n * is in TypeScript, you can use {@link CoinListServer#completeOAuth} from\n * `@/server/coinlist.server` (CoinListServer) to perform that exchange.\n *\n * 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.\n */\n completeOAuth(): OauthClientResult;\n /**\n * Clears the in-memory access token. Note: you need to manually\n * also logout on the backend via CoinListServer#logout to clear the session cookie.\n */\n logout(): void;\n\n /**\n * Fetches all offers by iterating through every paginated response.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchAllOffers(): Promise<Offer[]>;\n /**\n * Fetches a single page of offers.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchOffersPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;\n /**\n * Fetches details for a given offer by its id.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchOfferDetails(id: OfferId): Promise<OfferDetail>;\n /**\n * Fetches all participations by iterating through every paginated response.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchAllParticipations(): Promise<Participation[]>;\n /**\n * Fetches a single page of participations.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchParticipationsPage(\n params: PaginationParams\n ): Promise<PaginatedResponse<Participation>>;\n /**\n * Fetches a participation by id.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n fetchParticipation(id: ParticipationId): Promise<Participation>;\n /**\n * Creates a participation.\n *\n * This method must be called only when the user's {@link AuthState} is\n * `'logged-in'`. If the user is not authenticated, it throws\n * {@link NotAuthenticatedError}.\n */\n createParticipation(\n params: CreateParticipationParams\n ): Promise<Participation>;\n}\n\nclass CoinListClientImpl implements CoinListClient {\n /** Cached access token: undefined = loading, null = no token, AccessToken = logged in */\n private _accessToken: OAuthAccessToken | null | undefined = undefined;\n private readonly api: ApiClient;\n\n constructor(readonly _config: ClientConfig) {\n this.api = new ApiClient(\n {\n baseUrl: _config.baseUrl || PUBLIC_API_BASE_URL,\n xApiVersion: API_VERSION,\n },\n this.fetchAccessToken.bind(this)\n );\n }\n\n async init(): Promise<AuthState> {\n await this.fetchAccessToken(true);\n return this.getAuthState();\n }\n\n async fetchAccessToken(refresh: boolean): Promise<OAuthAccessToken | null> {\n if (!refresh && this._accessToken !== undefined) return this._accessToken;\n\n try {\n const accessToken = await this._config.getAccessToken();\n this._accessToken = accessToken;\n return accessToken;\n } catch (_) {\n this._accessToken = null;\n return null;\n }\n }\n\n getAuthState(): AuthState {\n if (this._accessToken === undefined) {\n return 'unknown';\n }\n return this._accessToken !== null ? 'logged-in' : 'logged-out';\n }\n\n async startOAuth(): Promise<void> {\n const state = generateSecureRandomBase64Url(32);\n const codeVerifier = generateSecureRandomBase64Url(32);\n\n const codeChallengeRaw = await sha256(codeVerifier);\n const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);\n\n sessionStorage.setItem(OAUTH_STATE_KEY, state);\n sessionStorage.setItem(OAUTH_CODE_VERIFIER_KEY, codeVerifier);\n\n const params = new URLSearchParams({\n client_id: this._config.clientId,\n response_type: 'code',\n redirect_uri: this._config.redirectUri,\n code_challenge: codeChallenge,\n code_challenge_method: 'S256',\n state,\n });\n const oauthPageUrl =\n this._config.authorizationPageUrl ?? COINLIST_OAUTH_PAGE_URL;\n const url = `${oauthPageUrl}?${params.toString()}`;\n window.location.href = url;\n }\n\n completeOAuth(): OauthClientResult {\n const params = new URLSearchParams(window.location.search);\n\n const coinlistError = params.get('error');\n if (coinlistError) {\n return { type: 'error', reason: 'user_canceled' };\n }\n\n const stateParam = params.get('state');\n if (!stateParam) {\n return { type: 'error', reason: 'missing_state' };\n }\n const storedState = sessionStorage.getItem(OAUTH_STATE_KEY);\n if (storedState === null || storedState !== stateParam) {\n return { type: 'error', reason: 'invalid_state' };\n }\n\n const codeParam = params.get('code');\n if (!codeParam) {\n return { type: 'error', reason: 'missing_code' };\n }\n\n const codeVerifierValue = sessionStorage.getItem(OAUTH_CODE_VERIFIER_KEY);\n if (!codeVerifierValue) {\n return { type: 'error', reason: 'missing_code_verifier' };\n }\n\n return {\n type: 'ok',\n code: AuthorizationCode(codeParam),\n codeVerifier: CodeVerifier(codeVerifierValue),\n };\n }\n\n logout(): void {\n this._accessToken = null;\n }\n\n async fetchAllOffers(): Promise<Offer[]> {\n this.ensureAuthenticated();\n return await fetchAllPages(this.fetchOffersPage.bind(this));\n }\n\n async fetchOffersPage(\n params: PaginationParams\n ): Promise<PaginatedResponse<Offer>> {\n this.ensureAuthenticated();\n const pageDto = await this.api.send<PaginatedResponseDto<OfferDto>>({\n method: 'GET',\n url: '/v1/offers',\n queryParams: PaginationParams.toQueryParams(params),\n attributes: Attributes.protected(),\n });\n return PaginatedResponse.fromDto(pageDto, Offer.fromDto);\n }\n\n async fetchOfferDetails(id: OfferId): Promise<OfferDetail> {\n this.ensureAuthenticated();\n const offerDetailDto = await this.api.send<OfferDetailDto>({\n method: 'GET',\n url: `/v1/offers/${id}`,\n attributes: Attributes.protected(),\n });\n return OfferDetail.fromDto(offerDetailDto);\n }\n\n async fetchAllParticipations(): Promise<Participation[]> {\n this.ensureAuthenticated();\n return await fetchAllPages(this.fetchParticipationsPage.bind(this));\n }\n\n async fetchParticipationsPage(\n params: PaginationParams\n ): Promise<PaginatedResponse<Participation>> {\n this.ensureAuthenticated();\n const pageDto = await this.api.send<PaginatedResponseDto<ParticipationDto>>(\n {\n method: 'GET',\n url: '/v1/participations',\n queryParams: PaginationParams.toQueryParams(params),\n attributes: Attributes.protected(),\n }\n );\n return PaginatedResponse.fromDto(pageDto, Participation.fromDto);\n }\n\n async fetchParticipation(id: ParticipationId): Promise<Participation> {\n this.ensureAuthenticated();\n const participationDto = await this.api.send<ParticipationDto>({\n method: 'GET',\n url: `/v1/participations/${id}`,\n attributes: Attributes.protected(),\n });\n return Participation.fromDto(participationDto);\n }\n\n async createParticipation(\n params: CreateParticipationParams\n ): Promise<Participation> {\n this.ensureAuthenticated();\n const participationDto = await this.api.send<ParticipationDto>({\n method: 'POST',\n url: '/v1/participations',\n body: CreateParticipationParams.toDto(params),\n attributes: Attributes.protected(),\n });\n return Participation.fromDto(participationDto);\n }\n\n private ensureAuthenticated() {\n if (this.getAuthState() !== 'logged-in') {\n throw new NotAuthenticatedError();\n }\n }\n}\n\nexport function createCoinListClient(config: ClientConfig): CoinListClient {\n return new CoinListClientImpl(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIO,IAAM,SAAS,CAAC,UAAkB;AAyBzC,eAAsB,cACpB,WACc;AACd,QAAM,QAAa,CAAC;AACpB,MAAI,SAAwB;AAE5B,KAAG;AACD,UAAM,OAAO,MAAM,UAAU;AAAA,MAC3B,OAAO,UAAU;AAAA,IACnB,CAAC;AACD,UAAM,KAAK,GAAG,KAAK,IAAI;AACvB,aAAS,KAAK;AAAA,EAChB,SAAS;AAET,SAAO;AACT;AAEO,IAAM,oBAAoB;AAAA,EAC/B,SAAS,CACP,KACA,gBAC0B;AAAA,IAC1B,MAAM,IAAI,KAAK,IAAI,UAAU;AAAA,IAC7B,eAAe,IAAI,iBAAiB,OAAO,IAAI,cAAc,IAAI;AAAA,IACjE,gBAAgB,IAAI,kBAAkB,OAAO,IAAI,eAAe,IAAI;AAAA,EACtE;AACF;AAEO,IAAM,mBAAmB;AAAA,EAC9B,eAAe,CACb,WACoC;AACpC,UAAM,cAA+C,CAAC;AACtD,QAAI,OAAO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