@coinlist-co/react 0.4.0 → 0.5.1
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/chunk-CRACFEJ4.js +17 -0
- package/dist/chunk-CRACFEJ4.js.map +1 -0
- package/dist/{chunk-NC45IO63.js → chunk-N3WBC2VS.js} +20 -325
- package/dist/chunk-N3WBC2VS.js.map +1 -0
- package/dist/chunk-V6WO67RO.js +311 -0
- package/dist/chunk-V6WO67RO.js.map +1 -0
- package/dist/client/index.cjs +1013 -220
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +526 -9
- package/dist/client/index.d.ts +526 -9
- package/dist/client/index.js +1464 -94
- package/dist/client/index.js.map +1 -1
- package/dist/{participation-DMMEDxON.d.cts → requirement-BEO42QOr.d.cts} +204 -2
- package/dist/{participation-E-bT-GXJ.d.ts → requirement-BEO42QOr.d.ts} +204 -2
- package/dist/server/index.cjs +50 -100
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +67 -24
- package/dist/server/index.d.ts +67 -24
- package/dist/server/index.js +54 -87
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +375 -0
- package/dist/shared/index.cjs.map +1 -0
- package/dist/shared/index.d.cts +35 -0
- package/dist/shared/index.d.ts +35 -0
- package/dist/{client/core → shared}/index.js +35 -16
- package/dist/shared/index.js.map +1 -0
- package/package.json +7 -22
- package/dist/RequirementItem-B-MvcxSr.d.cts +0 -37
- package/dist/RequirementItem-DcYot2uC.d.ts +0 -37
- package/dist/chunk-EHZ6PIGN.js +0 -414
- package/dist/chunk-EHZ6PIGN.js.map +0 -1
- package/dist/chunk-NC45IO63.js.map +0 -1
- package/dist/chunk-RIFATQB5.js +0 -257
- package/dist/chunk-RIFATQB5.js.map +0 -1
- package/dist/chunk-UGJUTRXC.js +0 -304
- package/dist/chunk-UGJUTRXC.js.map +0 -1
- package/dist/chunk-YJQMJFA7.js +0 -16
- package/dist/chunk-YJQMJFA7.js.map +0 -1
- package/dist/client/components/index.cjs +0 -1108
- package/dist/client/components/index.cjs.map +0 -1
- package/dist/client/components/index.d.cts +0 -139
- package/dist/client/components/index.d.ts +0 -139
- package/dist/client/components/index.js +0 -558
- package/dist/client/components/index.js.map +0 -1
- package/dist/client/core/index.cjs +0 -1047
- package/dist/client/core/index.cjs.map +0 -1
- package/dist/client/core/index.d.cts +0 -23
- package/dist/client/core/index.d.ts +0 -23
- package/dist/client/core/index.js.map +0 -1
- package/dist/client/hooks/index.cjs +0 -307
- package/dist/client/hooks/index.cjs.map +0 -1
- package/dist/client/hooks/index.d.cts +0 -126
- package/dist/client/hooks/index.d.ts +0 -126
- package/dist/client/hooks/index.js +0 -19
- package/dist/client/hooks/index.js.map +0 -1
- package/dist/coinlist-client-BSxpqylo.d.ts +0 -158
- package/dist/coinlist-client-Cah5c_aF.d.cts +0 -158
- package/dist/requirement-XWT0T_zO.d.cts +0 -205
- package/dist/requirement-XWT0T_zO.d.ts +0 -205
- package/dist/useCoinListRequirements-B5-ZPOMz.d.ts +0 -80
- package/dist/useCoinListRequirements-Cuc32Tqw.d.cts +0 -80
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
declare const __brand: unique symbol;
|
|
2
|
+
type Newtype<Base, Branding> = Base & {
|
|
3
|
+
readonly [__brand]: Branding;
|
|
4
|
+
};
|
|
2
5
|
|
|
3
6
|
type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
|
|
4
7
|
declare const AuthorizationCode: (value: string) => AuthorizationCode;
|
|
@@ -85,6 +88,171 @@ declare const OAuthSession: {
|
|
|
85
88
|
fromDto: (dto: OAuthSessionDto) => OAuthSession;
|
|
86
89
|
};
|
|
87
90
|
|
|
91
|
+
type OfferDto = {
|
|
92
|
+
id: string;
|
|
93
|
+
slug: string;
|
|
94
|
+
tagline: string | null | undefined;
|
|
95
|
+
banner_url: string | null | undefined;
|
|
96
|
+
logo_url: string | null | undefined;
|
|
97
|
+
starts_at: string;
|
|
98
|
+
ends_at: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
type OfferId = Newtype<string, 'OfferId'>;
|
|
102
|
+
declare const OfferId: (value: string) => OfferId;
|
|
103
|
+
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
104
|
+
declare const OfferSlug: (value: string) => OfferSlug;
|
|
105
|
+
type Offer = {
|
|
106
|
+
id: OfferId;
|
|
107
|
+
slug: OfferSlug;
|
|
108
|
+
tagline: string | null;
|
|
109
|
+
bannerUrl: string | null;
|
|
110
|
+
logoUrl: string | null;
|
|
111
|
+
startsAt: Date;
|
|
112
|
+
endsAt: Date;
|
|
113
|
+
};
|
|
114
|
+
declare const Offer: {
|
|
115
|
+
fromDto: (dto: OfferDto) => Offer;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type AssetDto = {
|
|
119
|
+
code: string;
|
|
120
|
+
fractional_digits: number;
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
type AssetId = Newtype<string, 'AssetId'>;
|
|
126
|
+
declare const AssetId: (value: string) => AssetId;
|
|
127
|
+
type AssetCode = Newtype<string, 'AssetCode'>;
|
|
128
|
+
declare const AssetCode: (value: string) => AssetCode;
|
|
129
|
+
type Asset = {
|
|
130
|
+
id: AssetId;
|
|
131
|
+
code: AssetCode;
|
|
132
|
+
name: string;
|
|
133
|
+
fractionalDigits: number;
|
|
134
|
+
};
|
|
135
|
+
declare const Asset: {
|
|
136
|
+
fromDto: (dto: AssetDto) => Asset;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
type OfferDetailDto = {
|
|
140
|
+
asset: AssetDto;
|
|
141
|
+
faqs: OfferDetailFaqDto[];
|
|
142
|
+
funding_assets: AssetDto[];
|
|
143
|
+
id: string;
|
|
144
|
+
links: OfferDetailLinkDto[];
|
|
145
|
+
milestones: OfferDetailMilestoneDto[];
|
|
146
|
+
name: string;
|
|
147
|
+
object: 'offer_details';
|
|
148
|
+
options: OfferDetailOptionDto[];
|
|
149
|
+
slug: string;
|
|
150
|
+
terms: OfferDetailTermDto[];
|
|
151
|
+
about: string | null | undefined;
|
|
152
|
+
banner_url: string | null | undefined;
|
|
153
|
+
category: string | null | undefined;
|
|
154
|
+
ends_at: string;
|
|
155
|
+
logo_url: string | null | undefined;
|
|
156
|
+
starts_at: string;
|
|
157
|
+
tagline: string | null | undefined;
|
|
158
|
+
};
|
|
159
|
+
type OfferDetailFaqDto = {
|
|
160
|
+
answer: string | null;
|
|
161
|
+
question: string | null;
|
|
162
|
+
};
|
|
163
|
+
type OfferDetailLinkDto = {
|
|
164
|
+
label: string | null;
|
|
165
|
+
url: string | null;
|
|
166
|
+
};
|
|
167
|
+
type OfferDetailMilestoneDto = {
|
|
168
|
+
name: string | null;
|
|
169
|
+
schedule: string | null;
|
|
170
|
+
status: 'completed' | 'active' | 'upcoming';
|
|
171
|
+
};
|
|
172
|
+
type OfferDetailOptionDto = {
|
|
173
|
+
bid_increment: number | null;
|
|
174
|
+
floor_price_usd: number | null;
|
|
175
|
+
id: string;
|
|
176
|
+
minimum_purchase_usd: number | null;
|
|
177
|
+
price_usd: string | null;
|
|
178
|
+
sale_agreement_url: string | null;
|
|
179
|
+
slug: string;
|
|
180
|
+
total_token_supply: number | null;
|
|
181
|
+
};
|
|
182
|
+
type OfferDetailTermDto = {
|
|
183
|
+
key: string | null;
|
|
184
|
+
value: string | null;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
type OfferOptionId = Newtype<string, 'OfferOptionId'>;
|
|
188
|
+
declare const OfferOptionId: (value: string) => OfferOptionId;
|
|
189
|
+
type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
|
|
190
|
+
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
191
|
+
type OfferDetail = {
|
|
192
|
+
id: OfferId;
|
|
193
|
+
slug: OfferSlug;
|
|
194
|
+
name: string;
|
|
195
|
+
asset: Asset;
|
|
196
|
+
fundingAssets: Asset[];
|
|
197
|
+
about: string | null;
|
|
198
|
+
tagline: string | null;
|
|
199
|
+
bannerUrl: string | null;
|
|
200
|
+
logoUrl: string | null;
|
|
201
|
+
category: string | null;
|
|
202
|
+
startsAt: Date;
|
|
203
|
+
endsAt: Date;
|
|
204
|
+
faqs: FaqItem[];
|
|
205
|
+
links: Link[];
|
|
206
|
+
milestones: Milestone[];
|
|
207
|
+
options: OfferOption[];
|
|
208
|
+
terms: TermItem[];
|
|
209
|
+
};
|
|
210
|
+
declare const OfferDetail: {
|
|
211
|
+
fromDto: (dto: OfferDetailDto) => OfferDetail;
|
|
212
|
+
};
|
|
213
|
+
type OfferOption = {
|
|
214
|
+
id: OfferOptionId;
|
|
215
|
+
slug: OfferOptionSlug;
|
|
216
|
+
bidIncrement: number | null;
|
|
217
|
+
floorPriceUsd: number | null;
|
|
218
|
+
minimumPurchaseUsd: number | null;
|
|
219
|
+
priceUsd: string | null;
|
|
220
|
+
saleAgreementUrl: string | null;
|
|
221
|
+
totalTokenSupply: number | null;
|
|
222
|
+
};
|
|
223
|
+
declare const OfferOption: {
|
|
224
|
+
fromDto: (dto: OfferDetailOptionDto) => OfferOption;
|
|
225
|
+
};
|
|
226
|
+
type FaqItem = {
|
|
227
|
+
question: string | null;
|
|
228
|
+
answer: string | null;
|
|
229
|
+
};
|
|
230
|
+
declare const FaqItem: {
|
|
231
|
+
fromDto: (dto: OfferDetailFaqDto) => FaqItem;
|
|
232
|
+
};
|
|
233
|
+
type Link = {
|
|
234
|
+
label: string | null;
|
|
235
|
+
url: string | null;
|
|
236
|
+
};
|
|
237
|
+
declare const Link: {
|
|
238
|
+
fromDto: (dto: OfferDetailLinkDto) => Link;
|
|
239
|
+
};
|
|
240
|
+
type TermItem = {
|
|
241
|
+
key: string | null;
|
|
242
|
+
value: string | null;
|
|
243
|
+
};
|
|
244
|
+
declare const TermItem: {
|
|
245
|
+
fromDto: (dto: OfferDetailTermDto) => TermItem;
|
|
246
|
+
};
|
|
247
|
+
type Milestone = {
|
|
248
|
+
name: string | null;
|
|
249
|
+
schedule: string | null;
|
|
250
|
+
status: 'completed' | 'active' | 'upcoming';
|
|
251
|
+
};
|
|
252
|
+
declare const Milestone: {
|
|
253
|
+
fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
|
|
254
|
+
};
|
|
255
|
+
|
|
88
256
|
type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
|
|
89
257
|
type ParticipationDto = {
|
|
90
258
|
object: 'participation';
|
|
@@ -182,4 +350,38 @@ declare const CreateParticipationParams: {
|
|
|
182
350
|
toDto: (params: CreateParticipationParams) => CreateParticipationDto;
|
|
183
351
|
};
|
|
184
352
|
|
|
185
|
-
|
|
353
|
+
type RequirementTypeDto = 'kyc_approved' | 'identity_verified' | 'proof_of_address' | 'source_of_funds' | 'external_wallet' | 'whitelisted_wallet' | 'jurisdiction' | 'accreditation';
|
|
354
|
+
type RequirementDto = {
|
|
355
|
+
object: 'requirement';
|
|
356
|
+
id: string;
|
|
357
|
+
type: RequirementTypeDto;
|
|
358
|
+
details: Record<string, unknown> | null;
|
|
359
|
+
};
|
|
360
|
+
type RequirementStatusValueDto = 'not_started' | 'in_progress' | 'action_needed' | 'completed' | 'rejected';
|
|
361
|
+
type RequirementStatusesDto = {
|
|
362
|
+
object: 'requirement_statuses';
|
|
363
|
+
offer_id: string;
|
|
364
|
+
statuses: Record<string, RequirementStatusValueDto>;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
type RequirementId = Newtype<string, 'RequirementId'>;
|
|
368
|
+
declare const RequirementId: (value: string) => RequirementId;
|
|
369
|
+
type RequirementType = RequirementTypeDto;
|
|
370
|
+
type RequirementStatusValue = RequirementStatusValueDto;
|
|
371
|
+
type Requirement = {
|
|
372
|
+
id: RequirementId;
|
|
373
|
+
type: RequirementType;
|
|
374
|
+
details: Record<string, unknown> | null;
|
|
375
|
+
};
|
|
376
|
+
declare const Requirement: {
|
|
377
|
+
fromDto: (dto: RequirementDto) => Requirement;
|
|
378
|
+
};
|
|
379
|
+
type RequirementStatusInfo = {
|
|
380
|
+
id: RequirementId;
|
|
381
|
+
status: RequirementStatusValue;
|
|
382
|
+
};
|
|
383
|
+
declare const RequirementStatusInfo: {
|
|
384
|
+
fromStatusesDto: (dto: RequirementStatusesDto) => RequirementStatusInfo[];
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export { AuthorizationCode as A, Blockchain as B, CodeVerifier as C, type ParticipationStatus as D, RedirectUri as E, FaqItem as F, RequirementId as G, fetchAllPages as H, Link as L, Milestone as M, type Newtype as N, type OAuthAccessToken as O, PaginationParams as P, Requirement as R, TermItem as T, WalletAddress as W, type Config as a, Offer as b, PaginatedResponse as c, OfferId as d, OfferDetail as e, Participation as f, ParticipationsPaginationParams as g, ParticipationId as h, CreateParticipationParams as i, OfferOptionId as j, RequirementStatusInfo as k, type RequirementType as l, type RequirementStatusValue as m, OAuthSession as n, ClientSecret as o, Asset as p, AssetCode as q, AssetId as r, ClientId as s, CodeChallenge as t, Cursor as u, OAuthRefreshToken as v, OfferOption as w, OfferOptionSlug as x, OfferSlug as y, type PaginatedResponseDto as z };
|
package/dist/server/index.cjs
CHANGED
|
@@ -20,41 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/server/index.ts
|
|
21
21
|
var server_exports = {};
|
|
22
22
|
__export(server_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ClientId: () => ClientId,
|
|
26
|
-
ClientSecret: () => ClientSecret,
|
|
27
|
-
CodeChallenge: () => CodeChallenge,
|
|
28
|
-
CodeVerifier: () => CodeVerifier,
|
|
29
|
-
CreateParticipationParams: () => CreateParticipationParams,
|
|
30
|
-
Cursor: () => Cursor,
|
|
31
|
-
FaqItem: () => FaqItem,
|
|
32
|
-
Link: () => Link,
|
|
33
|
-
Milestone: () => Milestone,
|
|
34
|
-
NotAuthenticatedError: () => NotAuthenticatedError,
|
|
35
|
-
NotImplementedError: () => NotImplementedError,
|
|
36
|
-
OAuthRefreshToken: () => OAuthRefreshToken,
|
|
37
|
-
OAuthSession: () => OAuthSession,
|
|
38
|
-
Offer: () => Offer,
|
|
39
|
-
OfferDetail: () => OfferDetail,
|
|
40
|
-
OfferId: () => OfferId,
|
|
41
|
-
OfferOption: () => OfferOption,
|
|
42
|
-
OfferOptionId: () => OfferOptionId,
|
|
43
|
-
OfferOptionSlug: () => OfferOptionSlug,
|
|
44
|
-
OfferSlug: () => OfferSlug,
|
|
45
|
-
PaginatedResponse: () => PaginatedResponse,
|
|
46
|
-
PaginationParams: () => PaginationParams,
|
|
47
|
-
Participation: () => Participation,
|
|
48
|
-
ParticipationId: () => ParticipationId,
|
|
49
|
-
ParticipationsPaginationParams: () => ParticipationsPaginationParams,
|
|
50
|
-
RedirectUri: () => RedirectUri,
|
|
51
|
-
Requirement: () => Requirement,
|
|
52
|
-
RequirementId: () => RequirementId,
|
|
53
|
-
RequirementStatusInfo: () => RequirementStatusInfo,
|
|
54
|
-
TermItem: () => TermItem,
|
|
55
|
-
WalletAddress: () => WalletAddress,
|
|
56
|
-
createCoinListServer: () => createCoinListServer,
|
|
57
|
-
fetchAllPages: () => fetchAllPages
|
|
23
|
+
WritableSessionStoreRequiredError: () => WritableSessionStoreRequiredError,
|
|
24
|
+
createCoinListServer: () => createCoinListServer
|
|
58
25
|
});
|
|
59
26
|
module.exports = __toCommonJS(server_exports);
|
|
60
27
|
|
|
@@ -201,7 +168,7 @@ var Request = {
|
|
|
201
168
|
concatAttributes
|
|
202
169
|
};
|
|
203
170
|
|
|
204
|
-
// src/shared/api/frontline/
|
|
171
|
+
// src/shared/api/frontline/config.ts
|
|
205
172
|
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
206
173
|
var HEADER_API_VERSION = "X-API-Version";
|
|
207
174
|
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
@@ -432,6 +399,14 @@ var Api = class {
|
|
|
432
399
|
}
|
|
433
400
|
};
|
|
434
401
|
|
|
402
|
+
// src/server/errors.ts
|
|
403
|
+
var WritableSessionStoreRequiredError = class extends Error {
|
|
404
|
+
constructor(message = "This operation requires a writable SessionStore. Provide a `setSession` implementation in your SessionStore to persist or clear OAuth sessions.") {
|
|
405
|
+
super(message);
|
|
406
|
+
this.name = "WritableSessionStoreRequiredError";
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
435
410
|
// src/shared/api/pagination.ts
|
|
436
411
|
var Cursor = (value) => value;
|
|
437
412
|
async function fetchAllPages(fetchPage, baseParams) {
|
|
@@ -581,7 +556,7 @@ var Milestone = {
|
|
|
581
556
|
};
|
|
582
557
|
|
|
583
558
|
// src/shared/api/frontline/offers.ts
|
|
584
|
-
async function
|
|
559
|
+
async function fetchOffers(api) {
|
|
585
560
|
return fetchAllPages((params) => fetchOffersPage(api, params));
|
|
586
561
|
}
|
|
587
562
|
async function fetchOffersPage(api, params) {
|
|
@@ -651,7 +626,7 @@ var CreateParticipationParams = {
|
|
|
651
626
|
};
|
|
652
627
|
|
|
653
628
|
// src/shared/api/frontline/participations.ts
|
|
654
|
-
async function
|
|
629
|
+
async function fetchParticipations(api, offerId) {
|
|
655
630
|
return fetchAllPages(
|
|
656
631
|
(params) => fetchParticipationsPage(api, params),
|
|
657
632
|
{ offerId }
|
|
@@ -724,12 +699,6 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
724
699
|
}
|
|
725
700
|
|
|
726
701
|
// src/shared/types/errors.ts
|
|
727
|
-
var NotImplementedError = class extends Error {
|
|
728
|
-
constructor(message = "Not implemented yet") {
|
|
729
|
-
super(message);
|
|
730
|
-
this.name = "NotImplementedError";
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
702
|
var NotAuthenticatedError = class extends Error {
|
|
734
703
|
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
735
704
|
super(message);
|
|
@@ -765,10 +734,19 @@ var CoinListServerImpl = class {
|
|
|
765
734
|
baseUrl: this.baseUrl,
|
|
766
735
|
xApiVersion: API_VERSION
|
|
767
736
|
},
|
|
768
|
-
|
|
737
|
+
// When refresh=true the renewal middleware has received a 401 and wants a
|
|
738
|
+
// fresh token. A read-only store cannot persist a new session, so return
|
|
739
|
+
// null immediately — this tells the middleware to skip the retry rather
|
|
740
|
+
// than re-sending with the same expired token and wasting a round-trip.
|
|
741
|
+
(refresh) => refresh && !this._config.sessionStore.setSession ? Promise.resolve(null) : this.accessToken()
|
|
769
742
|
);
|
|
770
743
|
}
|
|
771
744
|
async completeOAuth(code, codeVerifier) {
|
|
745
|
+
const sessionStore = this._config.sessionStore;
|
|
746
|
+
const setSession = sessionStore.setSession?.bind(sessionStore);
|
|
747
|
+
if (!setSession) {
|
|
748
|
+
throw new WritableSessionStoreRequiredError();
|
|
749
|
+
}
|
|
772
750
|
const sessionDto = await this.api.send({
|
|
773
751
|
method: "POST",
|
|
774
752
|
url: `/oauth/token`,
|
|
@@ -782,11 +760,12 @@ var CoinListServerImpl = class {
|
|
|
782
760
|
}
|
|
783
761
|
});
|
|
784
762
|
const session = OAuthSession.fromDto(sessionDto);
|
|
785
|
-
|
|
763
|
+
await setSession(session);
|
|
786
764
|
return session;
|
|
787
765
|
}
|
|
788
766
|
async accessToken() {
|
|
789
|
-
const
|
|
767
|
+
const sessionStore = this._config.sessionStore;
|
|
768
|
+
const session = await sessionStore.getSession();
|
|
790
769
|
if (session == null) return null;
|
|
791
770
|
const now = Date.now();
|
|
792
771
|
const expiresAt = session.accessToken.expiresAt.getTime();
|
|
@@ -794,9 +773,16 @@ var CoinListServerImpl = class {
|
|
|
794
773
|
if (expiresAt > now + bufferMs) {
|
|
795
774
|
return session.accessToken;
|
|
796
775
|
}
|
|
797
|
-
const
|
|
776
|
+
const setSession = sessionStore.setSession?.bind(sessionStore);
|
|
777
|
+
if (!setSession) {
|
|
778
|
+
return session.accessToken;
|
|
779
|
+
} else {
|
|
780
|
+
return this.refreshSession(session.refreshToken, setSession);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async refreshSession(refreshToken, setSession) {
|
|
798
784
|
if (!refreshToken) {
|
|
799
|
-
await
|
|
785
|
+
await setSession(null);
|
|
800
786
|
return null;
|
|
801
787
|
}
|
|
802
788
|
try {
|
|
@@ -811,15 +797,20 @@ var CoinListServerImpl = class {
|
|
|
811
797
|
}
|
|
812
798
|
});
|
|
813
799
|
const newSession = OAuthSession.fromDto(sessionDto);
|
|
814
|
-
await
|
|
800
|
+
await setSession(newSession);
|
|
815
801
|
return newSession.accessToken;
|
|
816
802
|
} catch {
|
|
817
|
-
await
|
|
803
|
+
await setSession(null);
|
|
818
804
|
return null;
|
|
819
805
|
}
|
|
820
806
|
}
|
|
821
807
|
async logout() {
|
|
822
|
-
const
|
|
808
|
+
const sessionStore = this._config.sessionStore;
|
|
809
|
+
const setSession = sessionStore.setSession?.bind(sessionStore);
|
|
810
|
+
if (!setSession) {
|
|
811
|
+
throw new WritableSessionStoreRequiredError();
|
|
812
|
+
}
|
|
813
|
+
const session = await sessionStore.getSession();
|
|
823
814
|
if (session != null) {
|
|
824
815
|
const tokenToRevoke = session.accessToken.value;
|
|
825
816
|
try {
|
|
@@ -841,7 +832,7 @@ var CoinListServerImpl = class {
|
|
|
841
832
|
throw err;
|
|
842
833
|
}
|
|
843
834
|
}
|
|
844
|
-
await
|
|
835
|
+
await setSession(null);
|
|
845
836
|
}
|
|
846
837
|
}
|
|
847
838
|
async ensureAuthenticated() {
|
|
@@ -850,9 +841,9 @@ var CoinListServerImpl = class {
|
|
|
850
841
|
throw new NotAuthenticatedError();
|
|
851
842
|
}
|
|
852
843
|
}
|
|
853
|
-
async
|
|
844
|
+
async fetchOffers() {
|
|
854
845
|
await this.ensureAuthenticated();
|
|
855
|
-
return
|
|
846
|
+
return fetchOffers(this.api);
|
|
856
847
|
}
|
|
857
848
|
async fetchOffersPage(params) {
|
|
858
849
|
await this.ensureAuthenticated();
|
|
@@ -862,9 +853,9 @@ var CoinListServerImpl = class {
|
|
|
862
853
|
await this.ensureAuthenticated();
|
|
863
854
|
return fetchOfferDetails(this.api, id);
|
|
864
855
|
}
|
|
865
|
-
async
|
|
856
|
+
async fetchParticipations(offerId) {
|
|
866
857
|
await this.ensureAuthenticated();
|
|
867
|
-
return
|
|
858
|
+
return fetchParticipations(this.api, offerId);
|
|
868
859
|
}
|
|
869
860
|
async fetchParticipationsPage(params) {
|
|
870
861
|
await this.ensureAuthenticated();
|
|
@@ -890,50 +881,9 @@ var CoinListServerImpl = class {
|
|
|
890
881
|
function createCoinListServer(config) {
|
|
891
882
|
return new CoinListServerImpl(config);
|
|
892
883
|
}
|
|
893
|
-
|
|
894
|
-
// src/shared/types/oauth.ts
|
|
895
|
-
var AuthorizationCode = (value) => value;
|
|
896
|
-
var CodeVerifier = (value) => value;
|
|
897
|
-
var CodeChallenge = (value) => value;
|
|
898
|
-
var RedirectUri = (value) => value;
|
|
899
|
-
var ClientId = (value) => value;
|
|
900
|
-
var ClientSecret = (value) => value;
|
|
901
884
|
// Annotate the CommonJS export names for ESM import in node:
|
|
902
885
|
0 && (module.exports = {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
ClientId,
|
|
906
|
-
ClientSecret,
|
|
907
|
-
CodeChallenge,
|
|
908
|
-
CodeVerifier,
|
|
909
|
-
CreateParticipationParams,
|
|
910
|
-
Cursor,
|
|
911
|
-
FaqItem,
|
|
912
|
-
Link,
|
|
913
|
-
Milestone,
|
|
914
|
-
NotAuthenticatedError,
|
|
915
|
-
NotImplementedError,
|
|
916
|
-
OAuthRefreshToken,
|
|
917
|
-
OAuthSession,
|
|
918
|
-
Offer,
|
|
919
|
-
OfferDetail,
|
|
920
|
-
OfferId,
|
|
921
|
-
OfferOption,
|
|
922
|
-
OfferOptionId,
|
|
923
|
-
OfferOptionSlug,
|
|
924
|
-
OfferSlug,
|
|
925
|
-
PaginatedResponse,
|
|
926
|
-
PaginationParams,
|
|
927
|
-
Participation,
|
|
928
|
-
ParticipationId,
|
|
929
|
-
ParticipationsPaginationParams,
|
|
930
|
-
RedirectUri,
|
|
931
|
-
Requirement,
|
|
932
|
-
RequirementId,
|
|
933
|
-
RequirementStatusInfo,
|
|
934
|
-
TermItem,
|
|
935
|
-
WalletAddress,
|
|
936
|
-
createCoinListServer,
|
|
937
|
-
fetchAllPages
|
|
886
|
+
WritableSessionStoreRequiredError,
|
|
887
|
+
createCoinListServer
|
|
938
888
|
});
|
|
939
889
|
//# sourceMappingURL=index.cjs.map
|