@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
|
@@ -44,6 +44,7 @@ __export(core_exports, {
|
|
|
44
44
|
PaginationParams: () => PaginationParams,
|
|
45
45
|
Participation: () => Participation,
|
|
46
46
|
ParticipationId: () => ParticipationId,
|
|
47
|
+
ParticipationsPaginationParams: () => ParticipationsPaginationParams,
|
|
47
48
|
RedirectUri: () => RedirectUri,
|
|
48
49
|
TermItem: () => TermItem,
|
|
49
50
|
User: () => User,
|
|
@@ -55,6 +56,83 @@ __export(core_exports, {
|
|
|
55
56
|
});
|
|
56
57
|
module.exports = __toCommonJS(core_exports);
|
|
57
58
|
|
|
59
|
+
// src/shared/utils.ts
|
|
60
|
+
async function sha256(data) {
|
|
61
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
62
|
+
const buffer = bytes.buffer.slice(
|
|
63
|
+
bytes.byteOffset,
|
|
64
|
+
bytes.byteOffset + bytes.byteLength
|
|
65
|
+
);
|
|
66
|
+
return crypto.subtle.digest("SHA-256", buffer);
|
|
67
|
+
}
|
|
68
|
+
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
69
|
+
const bytes = new Uint8Array(buffer);
|
|
70
|
+
let binary = "";
|
|
71
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
72
|
+
binary += String.fromCharCode(bytes[i]);
|
|
73
|
+
}
|
|
74
|
+
let base64 = btoa(binary);
|
|
75
|
+
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
76
|
+
if (!padding) {
|
|
77
|
+
base64 = base64.replace(/=+$/, "");
|
|
78
|
+
}
|
|
79
|
+
return base64;
|
|
80
|
+
}
|
|
81
|
+
function generateSecureRandomBase64Url(byteLength) {
|
|
82
|
+
const bytes = new Uint8Array(byteLength);
|
|
83
|
+
crypto.getRandomValues(bytes);
|
|
84
|
+
const buffer = bytes.buffer;
|
|
85
|
+
return arrayBufferToBase64Url(buffer, false);
|
|
86
|
+
}
|
|
87
|
+
function getUUIDv4() {
|
|
88
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
89
|
+
return crypto.randomUUID();
|
|
90
|
+
}
|
|
91
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
92
|
+
const bytes = new Uint8Array(16);
|
|
93
|
+
crypto.getRandomValues(bytes);
|
|
94
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
95
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
96
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
97
|
+
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("")}`;
|
|
98
|
+
}
|
|
99
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
100
|
+
}
|
|
101
|
+
function notBlankStringOrNull(value) {
|
|
102
|
+
if (value?.trim()) {
|
|
103
|
+
return value;
|
|
104
|
+
} else {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/client/core/api/middleware/device-id.ts
|
|
110
|
+
var DEVICE_ID_KEY = "coinlist.device_id";
|
|
111
|
+
function getDeviceId() {
|
|
112
|
+
let deviceId = localStorage.getItem(DEVICE_ID_KEY);
|
|
113
|
+
if (!deviceId) {
|
|
114
|
+
deviceId = getUUIDv4();
|
|
115
|
+
localStorage.setItem(DEVICE_ID_KEY, deviceId);
|
|
116
|
+
}
|
|
117
|
+
return deviceId;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/shared/api/frontline/index.ts
|
|
121
|
+
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
122
|
+
var HEADER_API_VERSION = "X-API-Version";
|
|
123
|
+
var HEADER_USER_AGENT = "User-Agent";
|
|
124
|
+
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
125
|
+
var API_VERSION = "2025-10-17";
|
|
126
|
+
var COINLIST_BASE_URL = "https://coinlist.co";
|
|
127
|
+
var OAUTH_PAGE_PATH = "/oauth/authorize";
|
|
128
|
+
var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
|
|
129
|
+
var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
130
|
+
var VERIFY_IDENTITY_VERIFIED_PATH = "/verify-identity/identity_verified";
|
|
131
|
+
var VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH = "/verify-identity/proof_of_address";
|
|
132
|
+
var VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH = "/verify-identity/source_of_funds";
|
|
133
|
+
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
134
|
+
var WALLET_PATH = "/wallet";
|
|
135
|
+
|
|
58
136
|
// src/shared/api/http-attributes.ts
|
|
59
137
|
var empty = {};
|
|
60
138
|
var concat = (left, right) => ({
|
|
@@ -100,24 +178,28 @@ var Attributes = {
|
|
|
100
178
|
wasRenewAttempted
|
|
101
179
|
};
|
|
102
180
|
|
|
103
|
-
// src/client/core/api/middleware/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
181
|
+
// src/client/core/api/middleware/user-agent.ts
|
|
182
|
+
var userAgentMiddleware = async (request) => {
|
|
183
|
+
if (!Attributes.needUserAgent(request.attributes)) {
|
|
184
|
+
return request;
|
|
185
|
+
}
|
|
186
|
+
const userAgent2 = generateUserAgent();
|
|
187
|
+
return {
|
|
188
|
+
...request,
|
|
189
|
+
headers: {
|
|
190
|
+
...request.headers ?? {},
|
|
191
|
+
[HEADER_USER_AGENT]: userAgent2
|
|
112
192
|
}
|
|
113
|
-
return {
|
|
114
|
-
...request,
|
|
115
|
-
headers: {
|
|
116
|
-
...request.headers ?? {},
|
|
117
|
-
Authorization: `Bearer ${accessToken.value}`
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
193
|
};
|
|
194
|
+
};
|
|
195
|
+
function generateUserAgent() {
|
|
196
|
+
const appInfo = `CoinList/1.0`;
|
|
197
|
+
const deviceInfo = "Web Browser";
|
|
198
|
+
const devicePlatform = "DevicePlatform web";
|
|
199
|
+
const deviceAppId = "DeviceAppID co.coinlist.sdk";
|
|
200
|
+
const deviceId = getDeviceId();
|
|
201
|
+
const finalDeviceId = `DeviceID ${deviceId}`;
|
|
202
|
+
return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;
|
|
121
203
|
}
|
|
122
204
|
|
|
123
205
|
// src/shared/api/http.ts
|
|
@@ -218,124 +300,6 @@ var Request = {
|
|
|
218
300
|
concatAttributes
|
|
219
301
|
};
|
|
220
302
|
|
|
221
|
-
// src/client/core/api/middleware/session-renewal.ts
|
|
222
|
-
function renewSessionMiddleware(fetchAccessToken) {
|
|
223
|
-
return async ({ request, response, retry }) => {
|
|
224
|
-
if (response.status !== 401) {
|
|
225
|
-
return response;
|
|
226
|
-
}
|
|
227
|
-
if (!Attributes.isProtected(request.attributes)) {
|
|
228
|
-
return response;
|
|
229
|
-
}
|
|
230
|
-
if (Attributes.wasRenewAttempted(request.attributes)) {
|
|
231
|
-
return response;
|
|
232
|
-
}
|
|
233
|
-
const newToken = await fetchAccessToken(true);
|
|
234
|
-
if (newToken) {
|
|
235
|
-
const nextRequest = Request.concatAttributes(
|
|
236
|
-
request,
|
|
237
|
-
Attributes.renewAttempted(true)
|
|
238
|
-
);
|
|
239
|
-
return retry(nextRequest);
|
|
240
|
-
} else {
|
|
241
|
-
return response;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/shared/utils.ts
|
|
247
|
-
async function sha256(data) {
|
|
248
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
249
|
-
const buffer = bytes.buffer.slice(
|
|
250
|
-
bytes.byteOffset,
|
|
251
|
-
bytes.byteOffset + bytes.byteLength
|
|
252
|
-
);
|
|
253
|
-
return crypto.subtle.digest("SHA-256", buffer);
|
|
254
|
-
}
|
|
255
|
-
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
256
|
-
const bytes = new Uint8Array(buffer);
|
|
257
|
-
let binary = "";
|
|
258
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
259
|
-
binary += String.fromCharCode(bytes[i]);
|
|
260
|
-
}
|
|
261
|
-
let base64 = btoa(binary);
|
|
262
|
-
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
263
|
-
if (!padding) {
|
|
264
|
-
base64 = base64.replace(/=+$/, "");
|
|
265
|
-
}
|
|
266
|
-
return base64;
|
|
267
|
-
}
|
|
268
|
-
function generateSecureRandomBase64Url(byteLength) {
|
|
269
|
-
const bytes = new Uint8Array(byteLength);
|
|
270
|
-
crypto.getRandomValues(bytes);
|
|
271
|
-
const buffer = bytes.buffer;
|
|
272
|
-
return arrayBufferToBase64Url(buffer, false);
|
|
273
|
-
}
|
|
274
|
-
function getUUIDv4() {
|
|
275
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
276
|
-
return crypto.randomUUID();
|
|
277
|
-
}
|
|
278
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
279
|
-
const bytes = new Uint8Array(16);
|
|
280
|
-
crypto.getRandomValues(bytes);
|
|
281
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
282
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
283
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
284
|
-
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("")}`;
|
|
285
|
-
}
|
|
286
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
287
|
-
}
|
|
288
|
-
function notBlankStringOrNull(value) {
|
|
289
|
-
if (value?.trim()) {
|
|
290
|
-
return value;
|
|
291
|
-
} else {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// src/client/core/api/middleware/device-id.ts
|
|
297
|
-
var DEVICE_ID_KEY = "coinlist.device_id";
|
|
298
|
-
function getDeviceId() {
|
|
299
|
-
let deviceId = localStorage.getItem(DEVICE_ID_KEY);
|
|
300
|
-
if (!deviceId) {
|
|
301
|
-
deviceId = getUUIDv4();
|
|
302
|
-
localStorage.setItem(DEVICE_ID_KEY, deviceId);
|
|
303
|
-
}
|
|
304
|
-
return deviceId;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// src/shared/api/frontline.ts
|
|
308
|
-
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
309
|
-
var HEADER_API_VERSION = "X-API-Version";
|
|
310
|
-
var HEADER_USER_AGENT = "User-Agent";
|
|
311
|
-
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
312
|
-
var API_VERSION = "2025-10-17";
|
|
313
|
-
var COINLIST_OAUTH_PAGE_URL = "https://coinlist.co/oauth/authorize";
|
|
314
|
-
|
|
315
|
-
// src/client/core/api/middleware/user-agent.ts
|
|
316
|
-
var userAgentMiddleware = async (request) => {
|
|
317
|
-
if (!Attributes.needUserAgent(request.attributes)) {
|
|
318
|
-
return request;
|
|
319
|
-
}
|
|
320
|
-
const userAgent2 = generateUserAgent();
|
|
321
|
-
return {
|
|
322
|
-
...request,
|
|
323
|
-
headers: {
|
|
324
|
-
...request.headers ?? {},
|
|
325
|
-
[HEADER_USER_AGENT]: userAgent2
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
function generateUserAgent() {
|
|
330
|
-
const appInfo = `CoinList/1.0`;
|
|
331
|
-
const deviceInfo = "Web Browser";
|
|
332
|
-
const devicePlatform = "DevicePlatform web";
|
|
333
|
-
const deviceAppId = "DeviceAppID co.coinlist.sdk";
|
|
334
|
-
const deviceId = getDeviceId();
|
|
335
|
-
const finalDeviceId = `DeviceID ${deviceId}`;
|
|
336
|
-
return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
303
|
// src/shared/api/http-client.ts
|
|
340
304
|
var HttpClient = class {
|
|
341
305
|
constructor(config, middleware = {}) {
|
|
@@ -405,6 +369,26 @@ var HttpClient = class {
|
|
|
405
369
|
}
|
|
406
370
|
};
|
|
407
371
|
|
|
372
|
+
// src/shared/api/middleware/attach-session-middleware.ts
|
|
373
|
+
function attachSessionMiddleware(fetchAccessToken) {
|
|
374
|
+
return async (request) => {
|
|
375
|
+
if (!Attributes.isProtected(request.attributes)) {
|
|
376
|
+
return request;
|
|
377
|
+
}
|
|
378
|
+
const accessToken = await fetchAccessToken(false);
|
|
379
|
+
if (accessToken === null) {
|
|
380
|
+
return request;
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
...request,
|
|
384
|
+
headers: {
|
|
385
|
+
...request.headers ?? {},
|
|
386
|
+
Authorization: `Bearer ${accessToken.value}`
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
408
392
|
// src/shared/api/middleware/idempotency-key.ts
|
|
409
393
|
var idempotencyKeyMiddleware = async (request) => {
|
|
410
394
|
if (!Attributes.isIdempotent(request.attributes)) {
|
|
@@ -458,19 +442,42 @@ function defaultDelay(ms) {
|
|
|
458
442
|
}
|
|
459
443
|
var requestRetryMiddleware = createRequestRetryMiddleware();
|
|
460
444
|
|
|
461
|
-
// src/
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
445
|
+
// src/shared/api/middleware/session-renewal.ts
|
|
446
|
+
function renewSessionMiddleware(fetchAccessToken) {
|
|
447
|
+
return async ({ request, response, retry }) => {
|
|
448
|
+
if (response.status !== 401) {
|
|
449
|
+
return response;
|
|
450
|
+
}
|
|
451
|
+
if (!Attributes.isProtected(request.attributes)) {
|
|
452
|
+
return response;
|
|
453
|
+
}
|
|
454
|
+
if (Attributes.wasRenewAttempted(request.attributes)) {
|
|
455
|
+
return response;
|
|
456
|
+
}
|
|
457
|
+
const newToken = await fetchAccessToken(true);
|
|
458
|
+
if (newToken) {
|
|
459
|
+
const nextRequest = Request.concatAttributes(
|
|
460
|
+
request,
|
|
461
|
+
Attributes.renewAttempted(true)
|
|
462
|
+
);
|
|
463
|
+
return retry(nextRequest);
|
|
464
|
+
} else {
|
|
465
|
+
return response;
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// src/shared/api/authenticated-api-client.ts
|
|
471
|
+
var AuthenticatedApiClient = class {
|
|
472
|
+
constructor(config, fetchAccessToken, additionalBeforeRequest = []) {
|
|
473
|
+
this.httpClient = new HttpClient(config, {
|
|
467
474
|
beforeRequest: [
|
|
468
|
-
attachSessionMiddleware(
|
|
469
|
-
|
|
475
|
+
attachSessionMiddleware(fetchAccessToken),
|
|
476
|
+
...additionalBeforeRequest,
|
|
470
477
|
idempotencyKeyMiddleware
|
|
471
478
|
],
|
|
472
479
|
afterRequest: [
|
|
473
|
-
renewSessionMiddleware(
|
|
480
|
+
renewSessionMiddleware(fetchAccessToken),
|
|
474
481
|
requestRetryMiddleware
|
|
475
482
|
]
|
|
476
483
|
});
|
|
@@ -485,15 +492,29 @@ var ApiClient = class {
|
|
|
485
492
|
}
|
|
486
493
|
};
|
|
487
494
|
|
|
495
|
+
// src/client/core/api/api-client.ts
|
|
496
|
+
var ApiClient = class {
|
|
497
|
+
constructor(config, fetchAccessToken) {
|
|
498
|
+
this.client = new AuthenticatedApiClient(config, fetchAccessToken, [
|
|
499
|
+
userAgentMiddleware
|
|
500
|
+
]);
|
|
501
|
+
}
|
|
502
|
+
async send(request) {
|
|
503
|
+
return this.client.send(request);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
488
507
|
// src/shared/api/pagination.ts
|
|
489
508
|
var Cursor = (value) => value;
|
|
490
|
-
async function fetchAllPages(fetchPage) {
|
|
509
|
+
async function fetchAllPages(fetchPage, baseParams) {
|
|
491
510
|
const items = [];
|
|
492
511
|
let cursor = null;
|
|
493
512
|
do {
|
|
494
|
-
const
|
|
513
|
+
const params = {
|
|
514
|
+
...baseParams ?? {},
|
|
495
515
|
after: cursor ?? void 0
|
|
496
|
-
}
|
|
516
|
+
};
|
|
517
|
+
const page = await fetchPage(params);
|
|
497
518
|
items.push(...page.data);
|
|
498
519
|
cursor = page.startingAfter;
|
|
499
520
|
} while (cursor);
|
|
@@ -522,22 +543,6 @@ var PaginationParams = {
|
|
|
522
543
|
}
|
|
523
544
|
};
|
|
524
545
|
|
|
525
|
-
// src/shared/types/errors.ts
|
|
526
|
-
var NotAuthenticatedError = class extends Error {
|
|
527
|
-
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
528
|
-
super(message);
|
|
529
|
-
this.name = "NotAuthenticatedError";
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
// src/shared/types/oauth.ts
|
|
534
|
-
var AuthorizationCode = (value) => value;
|
|
535
|
-
var CodeVerifier = (value) => value;
|
|
536
|
-
var CodeChallenge = (value) => value;
|
|
537
|
-
var RedirectUri = (value) => value;
|
|
538
|
-
var ClientId = (value) => value;
|
|
539
|
-
var ClientSecret = (value) => value;
|
|
540
|
-
|
|
541
546
|
// src/shared/types/offer.ts
|
|
542
547
|
var OfferId = (value) => value;
|
|
543
548
|
var OfferSlug = (value) => value;
|
|
@@ -647,10 +652,44 @@ var Milestone = {
|
|
|
647
652
|
})
|
|
648
653
|
};
|
|
649
654
|
|
|
655
|
+
// src/shared/api/frontline/offers.ts
|
|
656
|
+
async function fetchAllOffers(api) {
|
|
657
|
+
return fetchAllPages((params) => fetchOffersPage(api, params));
|
|
658
|
+
}
|
|
659
|
+
async function fetchOffersPage(api, params) {
|
|
660
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
661
|
+
const pageDto = await api.send({
|
|
662
|
+
method: "GET",
|
|
663
|
+
url: "/v1/offers",
|
|
664
|
+
queryParams,
|
|
665
|
+
attributes: Attributes.protected()
|
|
666
|
+
});
|
|
667
|
+
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
668
|
+
}
|
|
669
|
+
async function fetchOfferDetails(api, id) {
|
|
670
|
+
const dto = await api.send({
|
|
671
|
+
method: "GET",
|
|
672
|
+
url: `/v1/offers/${id}`,
|
|
673
|
+
attributes: Attributes.protected()
|
|
674
|
+
});
|
|
675
|
+
return OfferDetail.fromDto(dto);
|
|
676
|
+
}
|
|
677
|
+
|
|
650
678
|
// src/shared/types/participation.ts
|
|
651
679
|
var ParticipationId = (value) => value;
|
|
652
680
|
var Blockchain = (value) => value;
|
|
653
681
|
var WalletAddress = (value) => value;
|
|
682
|
+
var ParticipationsPaginationParams = {
|
|
683
|
+
toQueryParams: (params) => {
|
|
684
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
685
|
+
if (params.offerId) {
|
|
686
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
687
|
+
queryParams["filters[0][op]"] = "==";
|
|
688
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
689
|
+
}
|
|
690
|
+
return queryParams;
|
|
691
|
+
}
|
|
692
|
+
};
|
|
654
693
|
var Participation = {
|
|
655
694
|
/** Maps API DTO shape into the SDK participation domain model. */
|
|
656
695
|
fromDto: (dto) => {
|
|
@@ -683,6 +722,95 @@ var CreateParticipationParams = {
|
|
|
683
722
|
})
|
|
684
723
|
};
|
|
685
724
|
|
|
725
|
+
// src/shared/api/frontline/participations.ts
|
|
726
|
+
async function fetchAllParticipations(api, offerId) {
|
|
727
|
+
return fetchAllPages(
|
|
728
|
+
(params) => fetchParticipationsPage(api, params),
|
|
729
|
+
{ offerId }
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
async function fetchParticipationsPage(api, params) {
|
|
733
|
+
const pageDto = await api.send({
|
|
734
|
+
method: "GET",
|
|
735
|
+
url: "/v1/participations",
|
|
736
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
737
|
+
attributes: Attributes.protected()
|
|
738
|
+
});
|
|
739
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
740
|
+
}
|
|
741
|
+
async function fetchParticipation(api, id) {
|
|
742
|
+
const dto = await api.send({
|
|
743
|
+
method: "GET",
|
|
744
|
+
url: `/v1/participations/${id}`,
|
|
745
|
+
attributes: Attributes.protected()
|
|
746
|
+
});
|
|
747
|
+
return Participation.fromDto(dto);
|
|
748
|
+
}
|
|
749
|
+
async function createParticipation(api, params) {
|
|
750
|
+
const dto = await api.send({
|
|
751
|
+
method: "POST",
|
|
752
|
+
url: "/v1/participations",
|
|
753
|
+
body: CreateParticipationParams.toDto(params),
|
|
754
|
+
attributes: Attributes.protected()
|
|
755
|
+
});
|
|
756
|
+
return Participation.fromDto(dto);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/shared/types/requirement.ts
|
|
760
|
+
var RequirementId = (value) => value;
|
|
761
|
+
var Requirement = {
|
|
762
|
+
fromDto: (dto) => ({
|
|
763
|
+
id: RequirementId(dto.id),
|
|
764
|
+
type: dto.type,
|
|
765
|
+
details: dto.details
|
|
766
|
+
})
|
|
767
|
+
};
|
|
768
|
+
var RequirementStatusInfo = {
|
|
769
|
+
fromStatusesDto: (dto) => Object.entries(dto.statuses).map(([id, status]) => ({
|
|
770
|
+
id: RequirementId(id),
|
|
771
|
+
status
|
|
772
|
+
}))
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// src/shared/api/frontline/requirements.ts
|
|
776
|
+
async function fetchOfferRequirements(api, offerId) {
|
|
777
|
+
const response = await api.send({
|
|
778
|
+
method: "GET",
|
|
779
|
+
url: `/v1/offers/${offerId}/requirements`,
|
|
780
|
+
attributes: Attributes.protected()
|
|
781
|
+
});
|
|
782
|
+
return Object.fromEntries(
|
|
783
|
+
Object.entries(response.options).map(([optionId, list]) => [
|
|
784
|
+
optionId,
|
|
785
|
+
list.data.map(Requirement.fromDto)
|
|
786
|
+
])
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
async function fetchRequirementStatuses(api, offerId) {
|
|
790
|
+
const response = await api.send({
|
|
791
|
+
method: "GET",
|
|
792
|
+
url: `/v1/offers/${offerId}/requirements/statuses`,
|
|
793
|
+
attributes: Attributes.protected()
|
|
794
|
+
});
|
|
795
|
+
return RequirementStatusInfo.fromStatusesDto(response);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/shared/types/errors.ts
|
|
799
|
+
var NotAuthenticatedError = class extends Error {
|
|
800
|
+
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
801
|
+
super(message);
|
|
802
|
+
this.name = "NotAuthenticatedError";
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
// src/shared/types/oauth.ts
|
|
807
|
+
var AuthorizationCode = (value) => value;
|
|
808
|
+
var CodeVerifier = (value) => value;
|
|
809
|
+
var CodeChallenge = (value) => value;
|
|
810
|
+
var RedirectUri = (value) => value;
|
|
811
|
+
var ClientId = (value) => value;
|
|
812
|
+
var ClientSecret = (value) => value;
|
|
813
|
+
|
|
686
814
|
// src/client/core/coinlist-client.ts
|
|
687
815
|
var OAUTH_STATE_KEY = "coinlist.oauth_state";
|
|
688
816
|
var OAUTH_CODE_VERIFIER_KEY = "coinlist.oauth_code_verifier";
|
|
@@ -735,8 +863,8 @@ var CoinListClientImpl = class {
|
|
|
735
863
|
code_challenge_method: "S256",
|
|
736
864
|
state
|
|
737
865
|
});
|
|
738
|
-
const
|
|
739
|
-
const url = `${
|
|
866
|
+
const baseUrl = this._config.coinlistBaseUrl ?? COINLIST_BASE_URL;
|
|
867
|
+
const url = `${baseUrl}${OAUTH_PAGE_PATH}?${params.toString()}`;
|
|
740
868
|
window.location.href = url;
|
|
741
869
|
}
|
|
742
870
|
completeOAuth() {
|
|
@@ -772,61 +900,76 @@ var CoinListClientImpl = class {
|
|
|
772
900
|
}
|
|
773
901
|
async fetchAllOffers() {
|
|
774
902
|
this.ensureAuthenticated();
|
|
775
|
-
return
|
|
903
|
+
return fetchAllOffers(this.api);
|
|
776
904
|
}
|
|
777
905
|
async fetchOffersPage(params) {
|
|
778
906
|
this.ensureAuthenticated();
|
|
779
|
-
|
|
780
|
-
method: "GET",
|
|
781
|
-
url: "/v1/offers",
|
|
782
|
-
queryParams: PaginationParams.toQueryParams(params),
|
|
783
|
-
attributes: Attributes.protected()
|
|
784
|
-
});
|
|
785
|
-
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
907
|
+
return fetchOffersPage(this.api, params);
|
|
786
908
|
}
|
|
787
909
|
async fetchOfferDetails(id) {
|
|
788
910
|
this.ensureAuthenticated();
|
|
789
|
-
|
|
790
|
-
method: "GET",
|
|
791
|
-
url: `/v1/offers/${id}`,
|
|
792
|
-
attributes: Attributes.protected()
|
|
793
|
-
});
|
|
794
|
-
return OfferDetail.fromDto(offerDetailDto);
|
|
911
|
+
return fetchOfferDetails(this.api, id);
|
|
795
912
|
}
|
|
796
|
-
async fetchAllParticipations() {
|
|
913
|
+
async fetchAllParticipations(offerId) {
|
|
797
914
|
this.ensureAuthenticated();
|
|
798
|
-
return
|
|
915
|
+
return fetchAllParticipations(this.api, offerId);
|
|
799
916
|
}
|
|
800
917
|
async fetchParticipationsPage(params) {
|
|
801
918
|
this.ensureAuthenticated();
|
|
802
|
-
|
|
803
|
-
{
|
|
804
|
-
method: "GET",
|
|
805
|
-
url: "/v1/participations",
|
|
806
|
-
queryParams: PaginationParams.toQueryParams(params),
|
|
807
|
-
attributes: Attributes.protected()
|
|
808
|
-
}
|
|
809
|
-
);
|
|
810
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
919
|
+
return fetchParticipationsPage(this.api, params);
|
|
811
920
|
}
|
|
812
921
|
async fetchParticipation(id) {
|
|
813
922
|
this.ensureAuthenticated();
|
|
814
|
-
|
|
815
|
-
method: "GET",
|
|
816
|
-
url: `/v1/participations/${id}`,
|
|
817
|
-
attributes: Attributes.protected()
|
|
818
|
-
});
|
|
819
|
-
return Participation.fromDto(participationDto);
|
|
923
|
+
return fetchParticipation(this.api, id);
|
|
820
924
|
}
|
|
821
925
|
async createParticipation(params) {
|
|
822
926
|
this.ensureAuthenticated();
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
927
|
+
return createParticipation(this.api, params);
|
|
928
|
+
}
|
|
929
|
+
async fetchOfferRequirements(offerId) {
|
|
930
|
+
this.ensureAuthenticated();
|
|
931
|
+
return fetchOfferRequirements(this.api, offerId);
|
|
932
|
+
}
|
|
933
|
+
async fetchRequirementStatuses(offerId) {
|
|
934
|
+
this.ensureAuthenticated();
|
|
935
|
+
return fetchRequirementStatuses(this.api, offerId);
|
|
936
|
+
}
|
|
937
|
+
handleRequirement(requirement) {
|
|
938
|
+
const baseUrl = this._config.coinlistBaseUrl ?? COINLIST_BASE_URL;
|
|
939
|
+
let path;
|
|
940
|
+
switch (requirement.type) {
|
|
941
|
+
case "kyc_approved":
|
|
942
|
+
path = VERIFY_IDENTITY_PATH;
|
|
943
|
+
break;
|
|
944
|
+
case "identity_verified":
|
|
945
|
+
path = VERIFY_IDENTITY_VERIFIED_PATH;
|
|
946
|
+
break;
|
|
947
|
+
case "proof_of_address":
|
|
948
|
+
path = VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH;
|
|
949
|
+
break;
|
|
950
|
+
case "source_of_funds":
|
|
951
|
+
path = VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH;
|
|
952
|
+
break;
|
|
953
|
+
case "accreditation":
|
|
954
|
+
path = VERIFY_IDENTITY_ACCREDITATION_PATH;
|
|
955
|
+
break;
|
|
956
|
+
case "external_wallet":
|
|
957
|
+
case "whitelisted_wallet":
|
|
958
|
+
path = WALLET_PATH;
|
|
959
|
+
break;
|
|
960
|
+
case "jurisdiction":
|
|
961
|
+
path = null;
|
|
962
|
+
break;
|
|
963
|
+
default: {
|
|
964
|
+
const _exhaustive = requirement.type;
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
if (path === null) return;
|
|
969
|
+
openInNewTab(new URL(path, baseUrl).toString());
|
|
970
|
+
}
|
|
971
|
+
contactSupport() {
|
|
972
|
+
openInNewTab(SUPPORT_NEW_TICKET_URL);
|
|
830
973
|
}
|
|
831
974
|
ensureAuthenticated() {
|
|
832
975
|
if (this.getAuthState() !== "logged-in") {
|
|
@@ -834,6 +977,9 @@ var CoinListClientImpl = class {
|
|
|
834
977
|
}
|
|
835
978
|
}
|
|
836
979
|
};
|
|
980
|
+
function openInNewTab(url) {
|
|
981
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
982
|
+
}
|
|
837
983
|
function createCoinListClient(config) {
|
|
838
984
|
return new CoinListClientImpl(config);
|
|
839
985
|
}
|
|
@@ -888,6 +1034,7 @@ var User = {
|
|
|
888
1034
|
PaginationParams,
|
|
889
1035
|
Participation,
|
|
890
1036
|
ParticipationId,
|
|
1037
|
+
ParticipationsPaginationParams,
|
|
891
1038
|
RedirectUri,
|
|
892
1039
|
TermItem,
|
|
893
1040
|
User,
|