@coinlist-co/react 0.3.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-BvwsFu9e.d.cts → RequirementItem-B-MvcxSr.d.cts} +3 -3
- package/dist/{RequirementItem-BpkJQep8.d.ts → RequirementItem-DcYot2uC.d.ts} +3 -3
- package/dist/{chunk-IDCROXPS.js → chunk-EHZ6PIGN.js} +6 -4
- 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 +60 -59
- package/dist/client/components/index.cjs.map +1 -1
- package/dist/client/components/index.d.cts +40 -22
- package/dist/client/components/index.d.ts +40 -22
- package/dist/client/components/index.js +34 -62
- package/dist/client/components/index.js.map +1 -1
- package/dist/client/core/index.cjs +308 -222
- 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 +14 -14
- package/dist/client/hooks/index.cjs +87 -13
- package/dist/client/hooks/index.cjs.map +1 -1
- package/dist/client/hooks/index.d.cts +102 -9
- package/dist/client/hooks/index.d.ts +102 -9
- package/dist/client/hooks/index.js +9 -9
- package/dist/client/index.cjs +465 -237
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +7 -8
- package/dist/client/index.d.ts +7 -8
- package/dist/client/index.js +24 -18
- package/dist/{coinlist-client-B_dJkbwB.d.ts → coinlist-client-BSxpqylo.d.ts} +13 -138
- package/dist/{coinlist-client-DBKa6j3f.d.cts → coinlist-client-Cah5c_aF.d.cts} +13 -138
- package/dist/participation-DMMEDxON.d.cts +185 -0
- package/dist/participation-E-bT-GXJ.d.ts +185 -0
- package/dist/{requirement-CxbdY8l4.d.cts → requirement-XWT0T_zO.d.cts} +5 -2
- package/dist/{requirement-fJsQ3f9_.d.ts → requirement-XWT0T_zO.d.ts} +5 -2
- 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 +1 -1
- package/dist/chunk-GRVV7NLV.js +0 -282
- package/dist/chunk-GRVV7NLV.js.map +0 -1
- package/dist/chunk-IADBIDY6.js +0 -76
- package/dist/chunk-IADBIDY6.js.map +0 -1
- package/dist/chunk-IDCROXPS.js.map +0 -1
- package/dist/chunk-P4DTIPEX.js +0 -623
- package/dist/chunk-P4DTIPEX.js.map +0 -1
- package/dist/chunk-V5M7SA3C.js +0 -161
- package/dist/chunk-V5M7SA3C.js.map +0 -1
- 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/useCoinListOffers-C5lBlzcC.d.ts +0 -27
- package/dist/useCoinListOffers-CguwXaCX.d.cts +0 -27
- package/dist/useCoinListRequirements-BECx1cIw.d.ts +0 -31
- package/dist/useCoinListRequirements-CX2gV9gJ.d.cts +0 -31
- package/dist/useCompleteCoinListOAuth-BRhAqD4_.d.cts +0 -55
- package/dist/useCompleteCoinListOAuth-DEZpHjd6.d.ts +0 -55
|
@@ -56,6 +56,83 @@ __export(core_exports, {
|
|
|
56
56
|
});
|
|
57
57
|
module.exports = __toCommonJS(core_exports);
|
|
58
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
|
+
|
|
59
136
|
// src/shared/api/http-attributes.ts
|
|
60
137
|
var empty = {};
|
|
61
138
|
var concat = (left, right) => ({
|
|
@@ -101,24 +178,28 @@ var Attributes = {
|
|
|
101
178
|
wasRenewAttempted
|
|
102
179
|
};
|
|
103
180
|
|
|
104
|
-
// src/client/core/api/middleware/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
113
192
|
}
|
|
114
|
-
return {
|
|
115
|
-
...request,
|
|
116
|
-
headers: {
|
|
117
|
-
...request.headers ?? {},
|
|
118
|
-
Authorization: `Bearer ${accessToken.value}`
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
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})`;
|
|
122
203
|
}
|
|
123
204
|
|
|
124
205
|
// src/shared/api/http.ts
|
|
@@ -219,124 +300,6 @@ var Request = {
|
|
|
219
300
|
concatAttributes
|
|
220
301
|
};
|
|
221
302
|
|
|
222
|
-
// src/client/core/api/middleware/session-renewal.ts
|
|
223
|
-
function renewSessionMiddleware(fetchAccessToken) {
|
|
224
|
-
return async ({ request, response, retry }) => {
|
|
225
|
-
if (response.status !== 401) {
|
|
226
|
-
return response;
|
|
227
|
-
}
|
|
228
|
-
if (!Attributes.isProtected(request.attributes)) {
|
|
229
|
-
return response;
|
|
230
|
-
}
|
|
231
|
-
if (Attributes.wasRenewAttempted(request.attributes)) {
|
|
232
|
-
return response;
|
|
233
|
-
}
|
|
234
|
-
const newToken = await fetchAccessToken(true);
|
|
235
|
-
if (newToken) {
|
|
236
|
-
const nextRequest = Request.concatAttributes(
|
|
237
|
-
request,
|
|
238
|
-
Attributes.renewAttempted(true)
|
|
239
|
-
);
|
|
240
|
-
return retry(nextRequest);
|
|
241
|
-
} else {
|
|
242
|
-
return response;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// src/shared/utils.ts
|
|
248
|
-
async function sha256(data) {
|
|
249
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
250
|
-
const buffer = bytes.buffer.slice(
|
|
251
|
-
bytes.byteOffset,
|
|
252
|
-
bytes.byteOffset + bytes.byteLength
|
|
253
|
-
);
|
|
254
|
-
return crypto.subtle.digest("SHA-256", buffer);
|
|
255
|
-
}
|
|
256
|
-
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
257
|
-
const bytes = new Uint8Array(buffer);
|
|
258
|
-
let binary = "";
|
|
259
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
260
|
-
binary += String.fromCharCode(bytes[i]);
|
|
261
|
-
}
|
|
262
|
-
let base64 = btoa(binary);
|
|
263
|
-
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
264
|
-
if (!padding) {
|
|
265
|
-
base64 = base64.replace(/=+$/, "");
|
|
266
|
-
}
|
|
267
|
-
return base64;
|
|
268
|
-
}
|
|
269
|
-
function generateSecureRandomBase64Url(byteLength) {
|
|
270
|
-
const bytes = new Uint8Array(byteLength);
|
|
271
|
-
crypto.getRandomValues(bytes);
|
|
272
|
-
const buffer = bytes.buffer;
|
|
273
|
-
return arrayBufferToBase64Url(buffer, false);
|
|
274
|
-
}
|
|
275
|
-
function getUUIDv4() {
|
|
276
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
277
|
-
return crypto.randomUUID();
|
|
278
|
-
}
|
|
279
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
280
|
-
const bytes = new Uint8Array(16);
|
|
281
|
-
crypto.getRandomValues(bytes);
|
|
282
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
283
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
284
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
285
|
-
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("")}`;
|
|
286
|
-
}
|
|
287
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
288
|
-
}
|
|
289
|
-
function notBlankStringOrNull(value) {
|
|
290
|
-
if (value?.trim()) {
|
|
291
|
-
return value;
|
|
292
|
-
} else {
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// src/client/core/api/middleware/device-id.ts
|
|
298
|
-
var DEVICE_ID_KEY = "coinlist.device_id";
|
|
299
|
-
function getDeviceId() {
|
|
300
|
-
let deviceId = localStorage.getItem(DEVICE_ID_KEY);
|
|
301
|
-
if (!deviceId) {
|
|
302
|
-
deviceId = getUUIDv4();
|
|
303
|
-
localStorage.setItem(DEVICE_ID_KEY, deviceId);
|
|
304
|
-
}
|
|
305
|
-
return deviceId;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// src/shared/api/frontline.ts
|
|
309
|
-
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
310
|
-
var HEADER_API_VERSION = "X-API-Version";
|
|
311
|
-
var HEADER_USER_AGENT = "User-Agent";
|
|
312
|
-
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
313
|
-
var API_VERSION = "2025-10-17";
|
|
314
|
-
var COINLIST_OAUTH_PAGE_URL = "https://coinlist.co/oauth/authorize";
|
|
315
|
-
|
|
316
|
-
// src/client/core/api/middleware/user-agent.ts
|
|
317
|
-
var userAgentMiddleware = async (request) => {
|
|
318
|
-
if (!Attributes.needUserAgent(request.attributes)) {
|
|
319
|
-
return request;
|
|
320
|
-
}
|
|
321
|
-
const userAgent2 = generateUserAgent();
|
|
322
|
-
return {
|
|
323
|
-
...request,
|
|
324
|
-
headers: {
|
|
325
|
-
...request.headers ?? {},
|
|
326
|
-
[HEADER_USER_AGENT]: userAgent2
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
function generateUserAgent() {
|
|
331
|
-
const appInfo = `CoinList/1.0`;
|
|
332
|
-
const deviceInfo = "Web Browser";
|
|
333
|
-
const devicePlatform = "DevicePlatform web";
|
|
334
|
-
const deviceAppId = "DeviceAppID co.coinlist.sdk";
|
|
335
|
-
const deviceId = getDeviceId();
|
|
336
|
-
const finalDeviceId = `DeviceID ${deviceId}`;
|
|
337
|
-
return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
303
|
// src/shared/api/http-client.ts
|
|
341
304
|
var HttpClient = class {
|
|
342
305
|
constructor(config, middleware = {}) {
|
|
@@ -406,6 +369,26 @@ var HttpClient = class {
|
|
|
406
369
|
}
|
|
407
370
|
};
|
|
408
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
|
+
|
|
409
392
|
// src/shared/api/middleware/idempotency-key.ts
|
|
410
393
|
var idempotencyKeyMiddleware = async (request) => {
|
|
411
394
|
if (!Attributes.isIdempotent(request.attributes)) {
|
|
@@ -459,19 +442,42 @@ function defaultDelay(ms) {
|
|
|
459
442
|
}
|
|
460
443
|
var requestRetryMiddleware = createRequestRetryMiddleware();
|
|
461
444
|
|
|
462
|
-
// src/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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, {
|
|
468
474
|
beforeRequest: [
|
|
469
|
-
attachSessionMiddleware(
|
|
470
|
-
|
|
475
|
+
attachSessionMiddleware(fetchAccessToken),
|
|
476
|
+
...additionalBeforeRequest,
|
|
471
477
|
idempotencyKeyMiddleware
|
|
472
478
|
],
|
|
473
479
|
afterRequest: [
|
|
474
|
-
renewSessionMiddleware(
|
|
480
|
+
renewSessionMiddleware(fetchAccessToken),
|
|
475
481
|
requestRetryMiddleware
|
|
476
482
|
]
|
|
477
483
|
});
|
|
@@ -486,6 +492,18 @@ var ApiClient = class {
|
|
|
486
492
|
}
|
|
487
493
|
};
|
|
488
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
|
+
|
|
489
507
|
// src/shared/api/pagination.ts
|
|
490
508
|
var Cursor = (value) => value;
|
|
491
509
|
async function fetchAllPages(fetchPage, baseParams) {
|
|
@@ -525,22 +543,6 @@ var PaginationParams = {
|
|
|
525
543
|
}
|
|
526
544
|
};
|
|
527
545
|
|
|
528
|
-
// src/shared/types/errors.ts
|
|
529
|
-
var NotAuthenticatedError = class extends Error {
|
|
530
|
-
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
531
|
-
super(message);
|
|
532
|
-
this.name = "NotAuthenticatedError";
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
// src/shared/types/oauth.ts
|
|
537
|
-
var AuthorizationCode = (value) => value;
|
|
538
|
-
var CodeVerifier = (value) => value;
|
|
539
|
-
var CodeChallenge = (value) => value;
|
|
540
|
-
var RedirectUri = (value) => value;
|
|
541
|
-
var ClientId = (value) => value;
|
|
542
|
-
var ClientSecret = (value) => value;
|
|
543
|
-
|
|
544
546
|
// src/shared/types/offer.ts
|
|
545
547
|
var OfferId = (value) => value;
|
|
546
548
|
var OfferSlug = (value) => value;
|
|
@@ -650,6 +652,29 @@ var Milestone = {
|
|
|
650
652
|
})
|
|
651
653
|
};
|
|
652
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
|
+
|
|
653
678
|
// src/shared/types/participation.ts
|
|
654
679
|
var ParticipationId = (value) => value;
|
|
655
680
|
var Blockchain = (value) => value;
|
|
@@ -697,6 +722,40 @@ var CreateParticipationParams = {
|
|
|
697
722
|
})
|
|
698
723
|
};
|
|
699
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
|
+
|
|
700
759
|
// src/shared/types/requirement.ts
|
|
701
760
|
var RequirementId = (value) => value;
|
|
702
761
|
var Requirement = {
|
|
@@ -713,6 +772,45 @@ var RequirementStatusInfo = {
|
|
|
713
772
|
}))
|
|
714
773
|
};
|
|
715
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
|
+
|
|
716
814
|
// src/client/core/coinlist-client.ts
|
|
717
815
|
var OAUTH_STATE_KEY = "coinlist.oauth_state";
|
|
718
816
|
var OAUTH_CODE_VERIFIER_KEY = "coinlist.oauth_code_verifier";
|
|
@@ -765,8 +863,8 @@ var CoinListClientImpl = class {
|
|
|
765
863
|
code_challenge_method: "S256",
|
|
766
864
|
state
|
|
767
865
|
});
|
|
768
|
-
const
|
|
769
|
-
const url = `${
|
|
866
|
+
const baseUrl = this._config.coinlistBaseUrl ?? COINLIST_BASE_URL;
|
|
867
|
+
const url = `${baseUrl}${OAUTH_PAGE_PATH}?${params.toString()}`;
|
|
770
868
|
window.location.href = url;
|
|
771
869
|
}
|
|
772
870
|
completeOAuth() {
|
|
@@ -802,91 +900,76 @@ var CoinListClientImpl = class {
|
|
|
802
900
|
}
|
|
803
901
|
async fetchAllOffers() {
|
|
804
902
|
this.ensureAuthenticated();
|
|
805
|
-
return
|
|
903
|
+
return fetchAllOffers(this.api);
|
|
806
904
|
}
|
|
807
905
|
async fetchOffersPage(params) {
|
|
808
906
|
this.ensureAuthenticated();
|
|
809
|
-
|
|
810
|
-
if (this._config.sandbox) {
|
|
811
|
-
queryParams.sandbox = true;
|
|
812
|
-
}
|
|
813
|
-
const pageDto = await this.api.send({
|
|
814
|
-
method: "GET",
|
|
815
|
-
url: "/v1/offers",
|
|
816
|
-
queryParams,
|
|
817
|
-
attributes: Attributes.protected()
|
|
818
|
-
});
|
|
819
|
-
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
907
|
+
return fetchOffersPage(this.api, params);
|
|
820
908
|
}
|
|
821
909
|
async fetchOfferDetails(id) {
|
|
822
910
|
this.ensureAuthenticated();
|
|
823
|
-
|
|
824
|
-
method: "GET",
|
|
825
|
-
url: `/v1/offers/${id}`,
|
|
826
|
-
attributes: Attributes.protected()
|
|
827
|
-
});
|
|
828
|
-
return OfferDetail.fromDto(offerDetailDto);
|
|
911
|
+
return fetchOfferDetails(this.api, id);
|
|
829
912
|
}
|
|
830
913
|
async fetchAllParticipations(offerId) {
|
|
831
914
|
this.ensureAuthenticated();
|
|
832
|
-
return
|
|
833
|
-
this.fetchParticipationsPage.bind(this),
|
|
834
|
-
{ offerId }
|
|
835
|
-
);
|
|
915
|
+
return fetchAllParticipations(this.api, offerId);
|
|
836
916
|
}
|
|
837
917
|
async fetchParticipationsPage(params) {
|
|
838
918
|
this.ensureAuthenticated();
|
|
839
|
-
|
|
840
|
-
{
|
|
841
|
-
method: "GET",
|
|
842
|
-
url: "/v1/participations",
|
|
843
|
-
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
844
|
-
attributes: Attributes.protected()
|
|
845
|
-
}
|
|
846
|
-
);
|
|
847
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
919
|
+
return fetchParticipationsPage(this.api, params);
|
|
848
920
|
}
|
|
849
921
|
async fetchParticipation(id) {
|
|
850
922
|
this.ensureAuthenticated();
|
|
851
|
-
|
|
852
|
-
method: "GET",
|
|
853
|
-
url: `/v1/participations/${id}`,
|
|
854
|
-
attributes: Attributes.protected()
|
|
855
|
-
});
|
|
856
|
-
return Participation.fromDto(participationDto);
|
|
923
|
+
return fetchParticipation(this.api, id);
|
|
857
924
|
}
|
|
858
925
|
async createParticipation(params) {
|
|
859
926
|
this.ensureAuthenticated();
|
|
860
|
-
|
|
861
|
-
method: "POST",
|
|
862
|
-
url: "/v1/participations",
|
|
863
|
-
body: CreateParticipationParams.toDto(params),
|
|
864
|
-
attributes: Attributes.protected()
|
|
865
|
-
});
|
|
866
|
-
return Participation.fromDto(participationDto);
|
|
927
|
+
return createParticipation(this.api, params);
|
|
867
928
|
}
|
|
868
929
|
async fetchOfferRequirements(offerId) {
|
|
869
930
|
this.ensureAuthenticated();
|
|
870
|
-
|
|
871
|
-
method: "GET",
|
|
872
|
-
url: `/v1/offers/${offerId}/requirements`,
|
|
873
|
-
attributes: Attributes.protected()
|
|
874
|
-
});
|
|
875
|
-
return Object.fromEntries(
|
|
876
|
-
Object.entries(response.options).map(([optionId, list]) => [
|
|
877
|
-
optionId,
|
|
878
|
-
list.data.map(Requirement.fromDto)
|
|
879
|
-
])
|
|
880
|
-
);
|
|
931
|
+
return fetchOfferRequirements(this.api, offerId);
|
|
881
932
|
}
|
|
882
933
|
async fetchRequirementStatuses(offerId) {
|
|
883
934
|
this.ensureAuthenticated();
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
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);
|
|
890
973
|
}
|
|
891
974
|
ensureAuthenticated() {
|
|
892
975
|
if (this.getAuthState() !== "logged-in") {
|
|
@@ -894,6 +977,9 @@ var CoinListClientImpl = class {
|
|
|
894
977
|
}
|
|
895
978
|
}
|
|
896
979
|
};
|
|
980
|
+
function openInNewTab(url) {
|
|
981
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
982
|
+
}
|
|
897
983
|
function createCoinListClient(config) {
|
|
898
984
|
return new CoinListClientImpl(config);
|
|
899
985
|
}
|