@coinlist-co/react 0.5.1 → 0.9.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.
Files changed (40) hide show
  1. package/dist/{chunk-5E3P7AMH.js → chunk-AAER5LOL.js} +3 -1
  2. package/dist/chunk-AAER5LOL.js.map +1 -0
  3. package/dist/chunk-I5YTJ5SL.js +644 -0
  4. package/dist/chunk-I5YTJ5SL.js.map +1 -0
  5. package/dist/{chunk-N3WBC2VS.js → chunk-MKCOK3DF.js} +68 -57
  6. package/dist/chunk-MKCOK3DF.js.map +1 -0
  7. package/dist/chunk-Z2HAA2TI.js +768 -0
  8. package/dist/chunk-Z2HAA2TI.js.map +1 -0
  9. package/dist/client/index.cjs +3360 -556
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.d.cts +921 -18
  12. package/dist/client/index.d.ts +921 -18
  13. package/dist/client/index.js +2275 -392
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/collections-B84Vw55t.d.cts +28 -0
  16. package/dist/collections-BQbFJS3g.d.ts +28 -0
  17. package/dist/requirement-C2w45Q11.d.cts +969 -0
  18. package/dist/requirement-C2w45Q11.d.ts +969 -0
  19. package/dist/server/index.cjs +521 -37
  20. package/dist/server/index.cjs.map +1 -1
  21. package/dist/server/index.d.cts +116 -9
  22. package/dist/server/index.d.ts +116 -9
  23. package/dist/server/index.js +95 -28
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/shared/index.cjs +1264 -42
  26. package/dist/shared/index.cjs.map +1 -1
  27. package/dist/shared/index.d.cts +644 -3
  28. package/dist/shared/index.d.ts +644 -3
  29. package/dist/shared/index.js +220 -5
  30. package/dist/shared/index.js.map +1 -1
  31. package/package.json +33 -30
  32. package/dist/chunk-5E3P7AMH.js.map +0 -1
  33. package/dist/chunk-CRACFEJ4.js +0 -17
  34. package/dist/chunk-CRACFEJ4.js.map +0 -1
  35. package/dist/chunk-N3WBC2VS.js.map +0 -1
  36. package/dist/chunk-V6WO67RO.js +0 -311
  37. package/dist/chunk-V6WO67RO.js.map +0 -1
  38. package/dist/client/styles.css +0 -2
  39. package/dist/requirement-BEO42QOr.d.cts +0 -387
  40. package/dist/requirement-BEO42QOr.d.ts +0 -387
@@ -43,6 +43,9 @@ var userAgent = () => ({ userAgent: true });
43
43
  var idempotencyKey = () => ({
44
44
  idempotencyKey: true
45
45
  });
46
+ var clientCredentials = (credentials) => ({
47
+ clientCredentials: credentials
48
+ });
46
49
  var retryAttempt = (attempt) => ({
47
50
  retryAttempt: attempt
48
51
  });
@@ -54,6 +57,7 @@ var needUserAgent = (attrs) => attrs?.userAgent === true;
54
57
  var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
55
58
  var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
56
59
  var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
60
+ var getClientCredentials = (attrs) => attrs?.clientCredentials;
57
61
  var Attributes = {
58
62
  empty,
59
63
  concat,
@@ -67,7 +71,9 @@ var Attributes = {
67
71
  retryAttempt,
68
72
  getRetryAttempt,
69
73
  renewAttempted,
70
- wasRenewAttempted
74
+ wasRenewAttempted,
75
+ clientCredentials,
76
+ getClientCredentials
71
77
  };
72
78
 
73
79
  // src/shared/api/http.ts
@@ -249,7 +255,13 @@ function attachSessionMiddleware(fetchAccessToken) {
249
255
  if (!Attributes.isProtected(request.attributes)) {
250
256
  return request;
251
257
  }
252
- const accessToken = await fetchAccessToken(false);
258
+ let accessToken = await fetchAccessToken(false);
259
+ if (!accessToken) {
260
+ const clientCreds = Attributes.getClientCredentials(request.attributes);
261
+ if (clientCreds) {
262
+ accessToken = clientCreds;
263
+ }
264
+ }
253
265
  if (accessToken === null) {
254
266
  return request;
255
267
  }
@@ -407,6 +419,46 @@ var WritableSessionStoreRequiredError = class extends Error {
407
419
  }
408
420
  };
409
421
 
422
+ // src/shared/types/document-submission.ts
423
+ var DocumentSubmission = {
424
+ fromDto: (dto) => ({
425
+ status: dto.status,
426
+ formType: dto.form_type
427
+ })
428
+ };
429
+
430
+ // src/shared/api/frontline/documents.ts
431
+ async function submitDocument(api, documentType, fields) {
432
+ const dto = await api.send({
433
+ method: "POST",
434
+ url: `/v1/documents/${documentType}/submission`,
435
+ body: fields,
436
+ attributes: Attributes.protected()
437
+ });
438
+ return DocumentSubmission.fromDto(dto);
439
+ }
440
+
441
+ // src/shared/types/kyc.ts
442
+ var KycToken = {
443
+ fromDto: (dto) => ({
444
+ token: dto.token
445
+ })
446
+ };
447
+
448
+ // src/shared/api/frontline/kyc.ts
449
+ async function createKycToken(api, levelName, reset) {
450
+ const dto = await api.send({
451
+ method: "POST",
452
+ url: "/v1/kyc-token",
453
+ body: {
454
+ ...levelName === void 0 ? {} : { level_name: levelName },
455
+ ...reset === void 0 ? {} : { reset }
456
+ },
457
+ attributes: Attributes.protected()
458
+ });
459
+ return KycToken.fromDto(dto);
460
+ }
461
+
410
462
  // src/shared/api/pagination.ts
411
463
  var Cursor = (value) => value;
412
464
  async function fetchAllPages(fetchPage, baseParams) {
@@ -556,24 +608,30 @@ var Milestone = {
556
608
  };
557
609
 
558
610
  // src/shared/api/frontline/offers.ts
559
- async function fetchOffers(api) {
560
- return fetchAllPages((params) => fetchOffersPage(api, params));
611
+ async function fetchOffers(api, clientCreds) {
612
+ return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
561
613
  }
562
- async function fetchOffersPage(api, params) {
614
+ async function fetchOffersPage(api, params, clientCreds) {
563
615
  const queryParams = PaginationParams.toQueryParams(params);
564
616
  const pageDto = await api.send({
565
617
  method: "GET",
566
618
  url: "/v1/offers",
567
619
  queryParams,
568
- attributes: Attributes.protected()
620
+ attributes: Attributes.concat(
621
+ Attributes.protected(),
622
+ Attributes.clientCredentials(clientCreds)
623
+ )
569
624
  });
570
625
  return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
571
626
  }
572
- async function fetchOfferDetails(api, id) {
627
+ async function fetchOfferDetails(api, id, clientCreds) {
573
628
  const dto = await api.send({
574
629
  method: "GET",
575
630
  url: `/v1/offers/${id}`,
576
- attributes: Attributes.protected()
631
+ attributes: Attributes.concat(
632
+ Attributes.protected(),
633
+ Attributes.clientCredentials(clientCreds)
634
+ )
577
635
  });
578
636
  return OfferDetail.fromDto(dto);
579
637
  }
@@ -659,6 +717,44 @@ async function createParticipation(api, params) {
659
717
  return Participation.fromDto(dto);
660
718
  }
661
719
 
720
+ // src/shared/types/pii.ts
721
+ var Iso2CountryCode = (value) => value;
722
+ var PiiJurisdiction = {
723
+ fromDto: (dto) => ({
724
+ iso2: Iso2CountryCode(dto.iso_2),
725
+ name: dto.name
726
+ })
727
+ };
728
+ var PiiAddress = {
729
+ fromDto: (dto) => ({
730
+ street: dto.street,
731
+ city: dto.city,
732
+ state: dto.state,
733
+ postalCode: dto.postal_code,
734
+ country: dto.country
735
+ })
736
+ };
737
+ var Pii = {
738
+ fromDto: (dto) => ({
739
+ kind: dto.kind,
740
+ fullLegalName: dto.full_legal_name,
741
+ dateOfBirth: dto.date_of_birth,
742
+ jurisdiction: dto.jurisdiction ? PiiJurisdiction.fromDto(dto.jurisdiction) : null,
743
+ taxId: dto.tax_id,
744
+ permanentAddress: PiiAddress.fromDto(dto.permanent_address)
745
+ })
746
+ };
747
+
748
+ // src/shared/api/frontline/pii.ts
749
+ async function fetchPii(api) {
750
+ const dto = await api.send({
751
+ method: "GET",
752
+ url: "/v1/pii",
753
+ attributes: Attributes.protected()
754
+ });
755
+ return Pii.fromDto(dto);
756
+ }
757
+
662
758
  // src/shared/types/requirement.ts
663
759
  var RequirementId = (value) => value;
664
760
  var Requirement = {
@@ -669,18 +765,26 @@ var Requirement = {
669
765
  })
670
766
  };
671
767
  var RequirementStatusInfo = {
672
- fromStatusesDto: (dto) => Object.entries(dto.statuses).map(([id, status]) => ({
673
- id: RequirementId(id),
674
- status
675
- }))
768
+ fromStatusesDto: (dto) => Object.entries(dto.statuses).map(
769
+ ([id, value]) => typeof value === "string" ? { id: RequirementId(id), status: value, action: null } : {
770
+ id: RequirementId(id),
771
+ status: value.status,
772
+ action: value.action ?? null,
773
+ kycLevel: value.kyc_level,
774
+ kycReset: value.kyc_reset
775
+ }
776
+ )
676
777
  };
677
778
 
678
779
  // src/shared/api/frontline/requirements.ts
679
- async function fetchOfferRequirements(api, offerId) {
780
+ async function fetchOfferRequirements(api, offerId, clientCreds) {
680
781
  const response = await api.send({
681
782
  method: "GET",
682
783
  url: `/v1/offers/${offerId}/requirements`,
683
- attributes: Attributes.protected()
784
+ attributes: Attributes.concat(
785
+ Attributes.protected(),
786
+ Attributes.clientCredentials(clientCreds)
787
+ )
684
788
  });
685
789
  return Object.fromEntries(
686
790
  Object.entries(response.options).map(([optionId, list]) => [
@@ -698,6 +802,327 @@ async function fetchRequirementStatuses(api, offerId) {
698
802
  return RequirementStatusInfo.fromStatusesDto(response);
699
803
  }
700
804
 
805
+ // src/shared/types/blockchain/core.ts
806
+ var EvmWalletAddress = (value) => value;
807
+ var EvmContractAddress = (value) => value;
808
+ var HexEncodedTransactionData = (value) => value;
809
+ var AssetDecimals = (value) => value;
810
+ var MAX_UINT_256 = 2n ** 256n - 1n;
811
+ var assertUint256 = (value) => {
812
+ if (value < 0n || value > MAX_UINT_256) {
813
+ throw new Error(`Value out of uint256 bounds: ${value}`);
814
+ }
815
+ return value;
816
+ };
817
+ var BlockchainAmount = Object.assign(
818
+ (value) => value,
819
+ {
820
+ add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
821
+ sub: (a, b) => combineAmounts(a, b, (x, y) => x - y)
822
+ }
823
+ );
824
+ function combineAmounts(a, b, op) {
825
+ if (a.decimals !== b.decimals) {
826
+ throw new Error(
827
+ `Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
828
+ );
829
+ }
830
+ const raw = op(a.raw, b.raw);
831
+ if (raw < 0n || raw > MAX_UINT_256) {
832
+ throw new Error(`BlockchainAmount out of uint256 bounds: ${raw}`);
833
+ }
834
+ return BlockchainAmount({ raw, decimals: a.decimals });
835
+ }
836
+ var AssetSymbol = (value) => value;
837
+
838
+ // src/shared/types/offer-option-address.ts
839
+ var OfferOptionAddressId = (value) => value;
840
+ var OfferOptionAddress = {
841
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
842
+ fromDto: (dto) => ({
843
+ id: OfferOptionAddressId(dto.id),
844
+ offerOptionId: OfferOptionId(dto.offer_option_id),
845
+ address: EvmWalletAddress(dto.address),
846
+ protocol: dto.protocol,
847
+ createdAt: new Date(dto.created_at)
848
+ })
849
+ };
850
+ var ConnectExternalWalletParams = {
851
+ /** Maps connect-wallet params into the API DTO payload. */
852
+ toDto: (params) => ({
853
+ offer_option_id: params.offerOptionId,
854
+ wallet_address: params.walletAddress,
855
+ chain: params.chain,
856
+ signature: params.signature
857
+ })
858
+ };
859
+
860
+ // src/shared/types/wallet-ownership-challenge.ts
861
+ var WalletOwnershipChallenge = {
862
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
863
+ fromDto: (dto) => ({
864
+ message: dto.message,
865
+ expiresAt: new Date(dto.expires_at)
866
+ })
867
+ };
868
+ var CreateWalletOwnershipChallengeParams = {
869
+ /**
870
+ * Maps challenge-request params into the API DTO payload. The discriminated
871
+ * union guarantees SIWE fields are present exactly when `challengeType` is
872
+ * `siwe`, so the mapping narrows on the discriminant.
873
+ */
874
+ toDto: (params) => {
875
+ switch (params.challengeType) {
876
+ case "plain":
877
+ return {
878
+ wallet_address: params.walletAddress,
879
+ chain: params.chain,
880
+ challenge_type: "plain"
881
+ };
882
+ case "siwe":
883
+ return {
884
+ wallet_address: params.walletAddress,
885
+ chain: params.chain,
886
+ challenge_type: "siwe",
887
+ domain: params.domain,
888
+ uri: params.uri,
889
+ statement: params.statement
890
+ };
891
+ default: {
892
+ const _exhaustive = params;
893
+ return _exhaustive;
894
+ }
895
+ }
896
+ }
897
+ };
898
+
899
+ // src/shared/api/frontline/wallet-connect.ts
900
+ async function createWalletOwnershipChallenge(api, params) {
901
+ const dto = await api.send({
902
+ method: "POST",
903
+ url: "/v1/wallet-ownership",
904
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
905
+ attributes: Attributes.protected()
906
+ });
907
+ return WalletOwnershipChallenge.fromDto(dto);
908
+ }
909
+ async function connectExternalWallet(api, offerId, params) {
910
+ const dto = await api.send({
911
+ method: "POST",
912
+ url: `/v1/offers/${offerId}/addresses`,
913
+ body: ConnectExternalWalletParams.toDto(params),
914
+ attributes: Attributes.protected()
915
+ });
916
+ return OfferOptionAddress.fromDto(dto);
917
+ }
918
+ async function listOptionAddresses(api, offerId, offerOptionId) {
919
+ const { data } = await api.send({
920
+ method: "GET",
921
+ url: `/v1/offers/${offerId}/addresses`,
922
+ queryParams: { offer_option_id: offerOptionId },
923
+ attributes: Attributes.protected()
924
+ });
925
+ return data.map(OfferOptionAddress.fromDto);
926
+ }
927
+ async function removeOptionAddress(api, offerId, addressId) {
928
+ const dto = await api.send({
929
+ method: "DELETE",
930
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
931
+ attributes: Attributes.protected()
932
+ });
933
+ return OfferOptionAddress.fromDto(dto);
934
+ }
935
+
936
+ // src/shared/types/swap.ts
937
+ var SwapAuthorization = {
938
+ fromDto: (dto) => ({
939
+ authorized: dto.authorized
940
+ })
941
+ };
942
+ var SwapPreview = {
943
+ fromDto: (dto) => ({
944
+ inputAmount: assertUint256(BigInt(dto.pay_input_amount)),
945
+ fee: assertUint256(BigInt(dto.fee)),
946
+ outputAmount: assertUint256(BigInt(dto.receive_output_amount))
947
+ })
948
+ };
949
+ var SwapStatus = {
950
+ fromDto: (dto) => ({
951
+ stopped: assertUint256(BigInt(dto.stopped)),
952
+ swapLevel: assertUint256(BigInt(dto.swap_level))
953
+ })
954
+ };
955
+ var TokenAllowance = {
956
+ fromDto: (dto) => ({
957
+ allowance: assertUint256(BigInt(dto.allowance))
958
+ })
959
+ };
960
+ var TokenBalance = {
961
+ fromDto: (dto) => ({
962
+ balance: assertUint256(BigInt(dto.balance))
963
+ })
964
+ };
965
+ var AllowWalletResponse = {
966
+ fromDto: (dto) => {
967
+ switch (dto.action) {
968
+ case "broadcast_transaction":
969
+ return {
970
+ action: "broadcast_transaction",
971
+ to: EvmContractAddress(dto.to),
972
+ data: HexEncodedTransactionData(dto.data)
973
+ };
974
+ case "none":
975
+ return {
976
+ action: "none",
977
+ alreadyAllowed: dto.already_allowed
978
+ };
979
+ default: {
980
+ const _exhaustive = dto;
981
+ return _exhaustive;
982
+ }
983
+ }
984
+ }
985
+ };
986
+
987
+ // src/shared/api/frontline/swap.ts
988
+ async function getSwapAuthorization(api, params) {
989
+ const dto = await api.send({
990
+ method: "GET",
991
+ url: "/v1/wallet/authorized",
992
+ queryParams: {
993
+ chain: params.chain,
994
+ contract_address: params.contractAddress,
995
+ wallet_address: params.walletAddress
996
+ },
997
+ attributes: Attributes.protected()
998
+ });
999
+ return SwapAuthorization.fromDto(dto);
1000
+ }
1001
+ async function getSwapOutputToken(api, params) {
1002
+ const dto = await api.send({
1003
+ method: "GET",
1004
+ url: "/v1/swap/output-token",
1005
+ queryParams: {
1006
+ chain: params.chain,
1007
+ contract_address: params.contractAddress
1008
+ },
1009
+ attributes: Attributes.protected()
1010
+ });
1011
+ return toErc20Asset(dto);
1012
+ }
1013
+ async function getSwapPreview(api, params) {
1014
+ const dto = await api.send({
1015
+ method: "GET",
1016
+ url: "/v1/swap/preview",
1017
+ queryParams: {
1018
+ chain: params.chain,
1019
+ contract_address: params.contractAddress,
1020
+ input_token: params.inputToken,
1021
+ amount: params.amount.toString()
1022
+ },
1023
+ attributes: Attributes.protected()
1024
+ });
1025
+ return SwapPreview.fromDto(dto);
1026
+ }
1027
+ async function getSwapStatus(api, params) {
1028
+ const dto = await api.send({
1029
+ method: "GET",
1030
+ url: "/v1/swap/status",
1031
+ queryParams: {
1032
+ chain: params.chain,
1033
+ contract_address: params.contractAddress
1034
+ },
1035
+ attributes: Attributes.protected()
1036
+ });
1037
+ return SwapStatus.fromDto(dto);
1038
+ }
1039
+ async function getTokenAllowance(api, params) {
1040
+ const dto = await api.send({
1041
+ method: "GET",
1042
+ url: "/v1/token/allowance",
1043
+ queryParams: {
1044
+ chain: params.chain,
1045
+ token_address: params.tokenAddress,
1046
+ owner: params.owner,
1047
+ spender: params.spender
1048
+ },
1049
+ attributes: Attributes.protected()
1050
+ });
1051
+ return TokenAllowance.fromDto(dto);
1052
+ }
1053
+ async function getTokenBalance(api, params) {
1054
+ const dto = await api.send({
1055
+ method: "GET",
1056
+ url: "/v1/token/balance",
1057
+ queryParams: {
1058
+ chain: params.chain,
1059
+ token_address: params.tokenAddress,
1060
+ owner: params.owner
1061
+ },
1062
+ attributes: Attributes.protected()
1063
+ });
1064
+ return TokenBalance.fromDto(dto);
1065
+ }
1066
+ async function allowWallet(api, params) {
1067
+ const dto = await api.send({
1068
+ method: "POST",
1069
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1070
+ body: {
1071
+ wallet_address: params.walletAddress,
1072
+ chain: params.chain,
1073
+ signature: params.signature
1074
+ },
1075
+ attributes: Attributes.protected()
1076
+ });
1077
+ return AllowWalletResponse.fromDto(dto);
1078
+ }
1079
+ function toErc20Asset(dto) {
1080
+ return {
1081
+ name: dto.name,
1082
+ symbol: AssetSymbol(dto.symbol),
1083
+ decimals: AssetDecimals(dto.decimals)
1084
+ };
1085
+ }
1086
+
1087
+ // src/shared/core/swap-namespace.ts
1088
+ var SwapNamespaceImpl = class {
1089
+ constructor(ctx) {
1090
+ this.ctx = ctx;
1091
+ }
1092
+ async getAuthorization(params) {
1093
+ await this.ctx.ensureUserAuthenticated();
1094
+ return getSwapAuthorization(this.ctx.api, params);
1095
+ }
1096
+ async getPreview(params) {
1097
+ await this.ctx.ensureUserAuthenticated();
1098
+ return getSwapPreview(this.ctx.api, params);
1099
+ }
1100
+ async getStatus(params) {
1101
+ await this.ctx.ensureUserAuthenticated();
1102
+ return getSwapStatus(this.ctx.api, params);
1103
+ }
1104
+ async getTokenAllowance(params) {
1105
+ await this.ctx.ensureUserAuthenticated();
1106
+ return getTokenAllowance(this.ctx.api, params);
1107
+ }
1108
+ async getTokenBalance(params) {
1109
+ await this.ctx.ensureUserAuthenticated();
1110
+ return getTokenBalance(this.ctx.api, params);
1111
+ }
1112
+ async getOutputToken(params) {
1113
+ await this.ctx.ensureUserAuthenticated();
1114
+ return getSwapOutputToken(this.ctx.api, params);
1115
+ }
1116
+ async requestWalletOwnershipChallenge(params) {
1117
+ await this.ctx.ensureUserAuthenticated();
1118
+ return createWalletOwnershipChallenge(this.ctx.api, params);
1119
+ }
1120
+ async allowWallet(params) {
1121
+ await this.ctx.ensureUserAuthenticated();
1122
+ return allowWallet(this.ctx.api, params);
1123
+ }
1124
+ };
1125
+
701
1126
  // src/shared/types/errors.ts
702
1127
  var NotAuthenticatedError = class extends Error {
703
1128
  constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
@@ -707,6 +1132,7 @@ var NotAuthenticatedError = class extends Error {
707
1132
  };
708
1133
 
709
1134
  // src/shared/types/oauth-session.ts
1135
+ var ClientCredentialsOAuth = (value) => value;
710
1136
  var OAuthRefreshToken = (value) => value;
711
1137
  var OAuthSession = {
712
1138
  fromDto: (dto) => {
@@ -740,6 +1166,10 @@ var CoinListServerImpl = class {
740
1166
  // than re-sending with the same expired token and wasting a round-trip.
741
1167
  (refresh) => refresh && !this._config.sessionStore.setSession ? Promise.resolve(null) : this.accessToken()
742
1168
  );
1169
+ this.swap = new SwapNamespaceImpl({
1170
+ api: this.api,
1171
+ ensureUserAuthenticated: () => this.ensureUserAuthenticated()
1172
+ });
743
1173
  }
744
1174
  async completeOAuth(code, codeVerifier) {
745
1175
  const sessionStore = this._config.sessionStore;
@@ -763,6 +1193,19 @@ var CoinListServerImpl = class {
763
1193
  await setSession(session);
764
1194
  return session;
765
1195
  }
1196
+ async clientCredentialsOAuth() {
1197
+ const sessionDto = await this.api.send({
1198
+ method: "POST",
1199
+ url: `/oauth/token`,
1200
+ body: {
1201
+ grant_type: "client_credentials",
1202
+ client_id: this._config.clientId,
1203
+ client_secret: this._config.clientSecret
1204
+ }
1205
+ });
1206
+ const session = OAuthSession.fromDto(sessionDto);
1207
+ return ClientCredentialsOAuth(session.accessToken);
1208
+ }
766
1209
  async accessToken() {
767
1210
  const sessionStore = this._config.sessionStore;
768
1211
  const session = await sessionStore.getSession();
@@ -835,48 +1278,89 @@ var CoinListServerImpl = class {
835
1278
  await setSession(null);
836
1279
  }
837
1280
  }
838
- async ensureAuthenticated() {
839
- const token = await this.accessToken();
840
- if (token === null) {
841
- throw new NotAuthenticatedError();
842
- }
843
- }
844
- async fetchOffers() {
845
- await this.ensureAuthenticated();
846
- return fetchOffers(this.api);
1281
+ async fetchOffers(clientCreds) {
1282
+ await this.ensureAuthenticated(clientCreds);
1283
+ return fetchOffers(this.api, clientCreds);
847
1284
  }
848
- async fetchOffersPage(params) {
849
- await this.ensureAuthenticated();
850
- return fetchOffersPage(this.api, params);
1285
+ async fetchOffersPage(params, clientCreds) {
1286
+ await this.ensureAuthenticated(clientCreds);
1287
+ return fetchOffersPage(this.api, params, clientCreds);
851
1288
  }
852
- async fetchOfferDetails(id) {
853
- await this.ensureAuthenticated();
854
- return fetchOfferDetails(this.api, id);
1289
+ async fetchOfferDetails(id, clientCreds) {
1290
+ await this.ensureAuthenticated(clientCreds);
1291
+ return fetchOfferDetails(this.api, id, clientCreds);
855
1292
  }
856
1293
  async fetchParticipations(offerId) {
857
- await this.ensureAuthenticated();
1294
+ await this.ensureUserAuthenticated();
858
1295
  return fetchParticipations(this.api, offerId);
859
1296
  }
860
1297
  async fetchParticipationsPage(params) {
861
- await this.ensureAuthenticated();
1298
+ await this.ensureUserAuthenticated();
862
1299
  return fetchParticipationsPage(this.api, params);
863
1300
  }
864
1301
  async fetchParticipation(id) {
865
- await this.ensureAuthenticated();
1302
+ await this.ensureUserAuthenticated();
866
1303
  return fetchParticipation(this.api, id);
867
1304
  }
868
1305
  async createParticipation(params) {
869
- await this.ensureAuthenticated();
1306
+ await this.ensureUserAuthenticated();
870
1307
  return createParticipation(this.api, params);
871
1308
  }
872
- async fetchOfferRequirements(offerId) {
873
- await this.ensureAuthenticated();
874
- return fetchOfferRequirements(this.api, offerId);
1309
+ async createWalletOwnershipChallenge(params) {
1310
+ await this.ensureUserAuthenticated();
1311
+ return createWalletOwnershipChallenge(this.api, params);
1312
+ }
1313
+ async connectExternalWallet(offerId, params) {
1314
+ await this.ensureUserAuthenticated();
1315
+ return connectExternalWallet(this.api, offerId, params);
1316
+ }
1317
+ async listOptionAddresses(offerId, offerOptionId) {
1318
+ await this.ensureUserAuthenticated();
1319
+ return listOptionAddresses(
1320
+ this.api,
1321
+ offerId,
1322
+ offerOptionId
1323
+ );
1324
+ }
1325
+ async removeOptionAddress(offerId, addressId) {
1326
+ await this.ensureUserAuthenticated();
1327
+ return removeOptionAddress(this.api, offerId, addressId);
1328
+ }
1329
+ async fetchOfferRequirements(offerId, clientCreds) {
1330
+ await this.ensureAuthenticated(clientCreds);
1331
+ return fetchOfferRequirements(
1332
+ this.api,
1333
+ offerId,
1334
+ clientCreds
1335
+ );
875
1336
  }
876
1337
  async fetchRequirementStatuses(offerId) {
877
- await this.ensureAuthenticated();
1338
+ await this.ensureUserAuthenticated();
878
1339
  return fetchRequirementStatuses(this.api, offerId);
879
1340
  }
1341
+ async ensureAuthenticated(clientCreds) {
1342
+ if (!clientCreds) {
1343
+ await this.ensureUserAuthenticated();
1344
+ }
1345
+ }
1346
+ async ensureUserAuthenticated() {
1347
+ const token = await this.accessToken();
1348
+ if (token === null) {
1349
+ throw new NotAuthenticatedError();
1350
+ }
1351
+ }
1352
+ async fetchPii() {
1353
+ await this.ensureUserAuthenticated();
1354
+ return fetchPii(this.api);
1355
+ }
1356
+ async submitDocument(documentType, fields) {
1357
+ await this.ensureUserAuthenticated();
1358
+ return submitDocument(this.api, documentType, fields);
1359
+ }
1360
+ async createKycToken(levelName, reset) {
1361
+ await this.ensureUserAuthenticated();
1362
+ return createKycToken(this.api, levelName, reset);
1363
+ }
880
1364
  };
881
1365
  function createCoinListServer(config) {
882
1366
  return new CoinListServerImpl(config);