@getpara/user-management-client 2.0.0-alpha.7 → 2.0.0-alpha.71

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.
@@ -5,7 +5,7 @@ import {
5
5
  __spreadValues
6
6
  } from "./chunk-BBZEL7EG.js";
7
7
  import axios from "axios";
8
- import { extractWalletRef, fromAccountMetadata } from "./utils.js";
8
+ import { extractWalletRef, fromAccountMetadata, fromLinkedAccounts } from "./utils.js";
9
9
  import { SESSION_COOKIE_HEADER_NAME, VERSION_HEADER_NAME, PARTNER_ID_HEADER_NAME, API_KEY_HEADER_NAME } from "./consts.js";
10
10
  import { ParaApiError } from "./error.js";
11
11
  const handleResponseSuccess = (response) => {
@@ -53,11 +53,15 @@ class Client {
53
53
  const res = yield this.baseRequest.get("/users/exists", {
54
54
  params: __spreadValues({}, auth)
55
55
  });
56
- return res;
56
+ return res.data;
57
57
  });
58
- this.verifyTelegram = (authObject) => __async(this, null, function* () {
58
+ this.verifyTelegram = (_0) => __async(this, [_0], function* ({
59
+ authObject,
60
+ sessionLookupId
61
+ }) {
59
62
  return (yield this.baseRequest.post("/users/telegram/v2", {
60
- authObject
63
+ authObject,
64
+ sessionLookupId
61
65
  })).data;
62
66
  });
63
67
  this.verifyOAuth = () => __async(this, null, function* () {
@@ -66,16 +70,69 @@ class Client {
66
70
  });
67
71
  this.loginExternalWallet = (_0) => __async(this, [_0], function* ({
68
72
  externalWallet,
69
- shouldTrackUser
73
+ shouldTrackUser,
74
+ chainId,
75
+ uri
70
76
  }) {
71
77
  const res = yield this.baseRequest.post(`/users/external-wallets/login/v2`, {
72
78
  externalWallet,
73
- shouldTrackUser
79
+ shouldTrackUser,
80
+ chainId,
81
+ uri
74
82
  });
75
83
  return res.data;
76
84
  });
77
- this.verifyNewAccount = (userId, body) => __async(this, null, function* () {
78
- const res = yield this.baseRequest.post(`/users/${userId}/verify`, body);
85
+ this.verifyAccount = (userId, body) => __async(this, null, function* () {
86
+ const res = yield this.baseRequest.post(
87
+ `/users/${userId}/verify`,
88
+ body
89
+ );
90
+ return res.data;
91
+ });
92
+ // POST /users/send-login-code
93
+ this.sendLoginVerificationCode = (auth, isRecovery) => __async(this, null, function* () {
94
+ const res = yield this.baseRequest.post(`/users/send-login-code`, __spreadProps(__spreadValues({}, auth), { isRecovery }));
95
+ return res.data;
96
+ });
97
+ this.getLinkedAccounts = (_0) => __async(this, [_0], function* ({
98
+ userId,
99
+ withMetadata = false
100
+ }) {
101
+ const res = yield this.baseRequest.get(
102
+ `/users/${userId}/linked-accounts`,
103
+ ...withMetadata ? [
104
+ {
105
+ params: { withMetadata }
106
+ }
107
+ ] : []
108
+ );
109
+ return { accounts: fromLinkedAccounts(res.data.accounts) };
110
+ });
111
+ this.linkAccount = (_a) => __async(this, null, function* () {
112
+ var _b = _a, { userId } = _b, opts = __objRest(_b, ["userId"]);
113
+ const res = yield this.baseRequest.post(`/users/${userId}/linked-accounts`, opts);
114
+ return res.data;
115
+ });
116
+ this.verifyLink = (_c) => __async(this, null, function* () {
117
+ var _d = _c, {
118
+ linkedAccountId,
119
+ userId
120
+ } = _d, opts = __objRest(_d, [
121
+ "linkedAccountId",
122
+ "userId"
123
+ ]);
124
+ const res = yield this.baseRequest.post(
125
+ `/users/${userId}/linked-accounts/${linkedAccountId}/verify`,
126
+ opts
127
+ );
128
+ if ("isConflict" in res.data) {
129
+ return res.data;
130
+ }
131
+ const { accounts } = res.data;
132
+ return { accounts: fromLinkedAccounts(accounts) };
133
+ });
134
+ this.unlinkAccount = (_0) => __async(this, [_0], function* ({ linkedAccountId, userId }) {
135
+ const res = yield this.baseRequest.delete(`/users/${userId}/linked-accounts/${linkedAccountId}`);
79
136
  return res.data;
80
137
  });
81
138
  // POST /users/:userId/verify-email
@@ -94,7 +151,10 @@ class Client {
94
151
  return res;
95
152
  });
96
153
  this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
97
- const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify/v2`, body);
154
+ const res = yield this.baseRequest.post(
155
+ `/users/${userId}/external-wallets/verify/v2`,
156
+ body
157
+ );
98
158
  return res.data;
99
159
  });
100
160
  // POST /users/:userId/biometrics/key
@@ -140,11 +200,36 @@ class Client {
140
200
  const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
141
201
  return res.data;
142
202
  });
143
- // GET /session/origin
203
+ // POST /sessions/portal-verification
204
+ this.sessionAddPortalVerification = () => __async(this, null, function* () {
205
+ const res = yield this.baseRequest.post(`/sessions/portal-verification`);
206
+ return res.data;
207
+ });
208
+ // GET /sessions/:sessionLookupId/origin
144
209
  this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
145
210
  const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/origin`);
146
211
  return res.data;
147
212
  });
213
+ // GET /sessions/:sessionLookupId/login-method
214
+ this.sessionLoginMethod = (sessionLookupId) => __async(this, null, function* () {
215
+ const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/login-method`);
216
+ return res.data;
217
+ });
218
+ // GET /sessions/:sessionLookupId/auth-verified
219
+ this.sessionAuthVerified = (sessionLookupId) => __async(this, null, function* () {
220
+ const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/auth-verified`);
221
+ return res.data;
222
+ });
223
+ // GET /sessions/:sessionLookupId/auth
224
+ this.sessionAuth = (sessionLookupId) => __async(this, null, function* () {
225
+ const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/auth`);
226
+ return res.data;
227
+ });
228
+ // GET /sessions/:sessionLookupId/siwe-message
229
+ this.sessionSIWEMessage = (sessionLookupId) => __async(this, null, function* () {
230
+ const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/siwe-message`);
231
+ return res.data;
232
+ });
148
233
  // POST /biometrics/verify
149
234
  this.verifyWebChallenge = (partnerId, body) => __async(this, null, function* () {
150
235
  const res = yield this.baseRequest.post(`/biometrics/verify`, body, {
@@ -257,8 +342,8 @@ class Client {
257
342
  const res = yield this.baseRequest.post("/recovery", body);
258
343
  return res;
259
344
  });
260
- this.preSignMessage = (userId, walletId, message, scheme, cosmosSignDoc) => __async(this, null, function* () {
261
- const body = { message, scheme, cosmosSignDoc };
345
+ this.preSignMessage = (userId, walletId, message, scheme, cosmosSignDoc, protocolId) => __async(this, null, function* () {
346
+ const body = { message, scheme, cosmosSignDoc, protocolId };
262
347
  const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/messages/sign`, body);
263
348
  return res.data;
264
349
  });
@@ -297,9 +382,80 @@ class Client {
297
382
  });
298
383
  return res.data;
299
384
  });
385
+ this.issueJwt = (..._0) => __async(this, [..._0], function* ({ keyIndex = 0 } = {}) {
386
+ const res = yield this.baseRequest.post(`/auth/jwt`, { keyIndex });
387
+ return res.data;
388
+ });
389
+ this.getProfileBalance = (_0) => __async(this, [_0], function* ({
390
+ config,
391
+ wallets,
392
+ refetch
393
+ }) {
394
+ const res = yield this.baseRequest.post(`/assets/balances`, {
395
+ config,
396
+ wallets,
397
+ refetch
398
+ });
399
+ return res.data;
400
+ });
401
+ this.getAssetInfo = () => __async(this, null, function* () {
402
+ const res = yield this.baseRequest.get(`/assets`);
403
+ return res.data;
404
+ });
300
405
  this.trackError = (opts) => __async(this, null, function* () {
301
406
  yield this.baseRequest.post("/errors/sdk", opts);
302
407
  });
408
+ this.trackReactSdkAnalytics = (opts) => __async(this, null, function* () {
409
+ yield this.baseRequest.post("/partners/analytics/react-sdk", opts);
410
+ });
411
+ // ENCLAVE METHODS
412
+ /**
413
+ * Get the enclave's public key for encryption
414
+ */
415
+ this.getEnclavePublicKey = () => __async(this, null, function* () {
416
+ const res = yield this.baseRequest.get(
417
+ "/enclave/public-key"
418
+ );
419
+ return res.data;
420
+ });
421
+ /**
422
+ * Persist encrypted key shares to the enclave
423
+ * @param encryptedPayload JSON string containing the encrypted ECIES payload
424
+ */
425
+ this.persistEnclaveShares = (_0) => __async(this, [_0], function* ({
426
+ encryptedPayload,
427
+ hasNoShares
428
+ }) {
429
+ const body = { encryptedPayload, hasNoShares };
430
+ const res = yield this.baseRequest.post("/enclave/key-shares", body);
431
+ return res.data;
432
+ });
433
+ /**
434
+ * Retrieve encrypted key shares from the enclave
435
+ * @param encryptedPayload JSON string containing the encrypted ECIES query
436
+ */
437
+ this.retrieveEnclaveShares = (encryptedPayload) => __async(this, null, function* () {
438
+ const res = yield this.baseRequest.get(
439
+ `/enclave/key-shares?encryptedPayload=${encodeURIComponent(encryptedPayload)}`
440
+ );
441
+ return res.data;
442
+ });
443
+ this.issueEnclaveJwt = (encryptedPayload) => __async(this, null, function* () {
444
+ const res = yield this.baseRequest.post(`/enclave/jwt/issue`, { encryptedPayload });
445
+ return res.data;
446
+ });
447
+ this.refreshEnclaveJwt = (encryptedPayload) => __async(this, null, function* () {
448
+ const res = yield this.baseRequest.post(`/enclave/jwt/refresh`, { encryptedPayload });
449
+ return res.data;
450
+ });
451
+ this.getUserPreferences = (userId) => __async(this, null, function* () {
452
+ const res = yield this.baseRequest.get(`/users/${userId}/preferences`);
453
+ return res.data;
454
+ });
455
+ this.updateUserPreferences = (userId, preferences) => __async(this, null, function* () {
456
+ const res = yield this.baseRequest.patch(`/users/${userId}/preferences`, { preferences });
457
+ return res.data;
458
+ });
303
459
  const headers = __spreadValues(__spreadValues({}, apiKey && { [API_KEY_HEADER_NAME]: apiKey }), partnerId && { [PARTNER_ID_HEADER_NAME]: partnerId });
304
460
  const axiosConfig = {
305
461
  baseURL: userManagementHost,
@@ -418,17 +574,17 @@ class Client {
418
574
  });
419
575
  }
420
576
  // POST '/users/:userId/resend-verification-code
421
- resendVerificationCode(_a) {
577
+ resendVerificationCode(_e) {
422
578
  return __async(this, null, function* () {
423
- var _b = _a, { userId } = _b, rest = __objRest(_b, ["userId"]);
579
+ var _f = _e, { userId } = _f, rest = __objRest(_f, ["userId"]);
424
580
  const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
425
581
  return res;
426
582
  });
427
583
  }
428
584
  // POST '/users/:userId/resend-verification-code-by-phone
429
- resendVerificationCodeByPhone(_c) {
585
+ resendVerificationCodeByPhone(_g) {
430
586
  return __async(this, null, function* () {
431
- var _d = _c, { userId } = _d, rest = __objRest(_d, ["userId"]);
587
+ var _h = _g, { userId } = _h, rest = __objRest(_h, ["userId"]);
432
588
  const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest);
433
589
  return res;
434
590
  });
@@ -469,14 +625,14 @@ class Client {
469
625
  }
470
626
  // POST /auth/farcaster/init
471
627
  initializeFarcasterLogin() {
472
- return __async(this, null, function* () {
473
- const res = yield this.baseRequest.post(`/auth/farcaster/init`);
474
- return res;
628
+ return __async(this, arguments, function* ({ appScheme } = {}) {
629
+ const res = yield this.baseRequest.post(`/auth/farcaster/init`, { appScheme });
630
+ return res.data;
475
631
  });
476
632
  }
477
633
  getFarcasterAuthStatus() {
478
- return __async(this, null, function* () {
479
- const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`);
634
+ return __async(this, arguments, function* ({ sessionLookupId } = {}) {
635
+ const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`, { sessionLookupId });
480
636
  return res.data;
481
637
  });
482
638
  }
@@ -578,12 +734,12 @@ class Client {
578
734
  return res.data;
579
735
  });
580
736
  }
581
- createOnRampPurchase(_e) {
737
+ createOnRampPurchase(_i) {
582
738
  return __async(this, null, function* () {
583
- var _f = _e, {
739
+ var _j = _i, {
584
740
  userId,
585
741
  params
586
- } = _f, walletParams = __objRest(_f, [
742
+ } = _j, walletParams = __objRest(_j, [
587
743
  "userId",
588
744
  "params"
589
745
  ]);
@@ -593,13 +749,13 @@ class Client {
593
749
  return res.data;
594
750
  });
595
751
  }
596
- updateOnRampPurchase(_g) {
752
+ updateOnRampPurchase(_k) {
597
753
  return __async(this, null, function* () {
598
- var _h = _g, {
754
+ var _l = _k, {
599
755
  userId,
600
756
  purchaseId,
601
757
  updates
602
- } = _h, params = __objRest(_h, [
758
+ } = _l, params = __objRest(_l, [
603
759
  "userId",
604
760
  "purchaseId",
605
761
  "updates"
@@ -613,12 +769,12 @@ class Client {
613
769
  return res.data;
614
770
  });
615
771
  }
616
- getOnRampPurchase(_i) {
772
+ getOnRampPurchase(_m) {
617
773
  return __async(this, null, function* () {
618
- var _j = _i, {
774
+ var _n = _m, {
619
775
  userId,
620
776
  purchaseId
621
- } = _j, params = __objRest(_j, [
777
+ } = _n, params = __objRest(_n, [
622
778
  "userId",
623
779
  "purchaseId"
624
780
  ]);
@@ -692,12 +848,12 @@ class Client {
692
848
  return res.data;
693
849
  });
694
850
  }
695
- distributeParaShare(_k) {
851
+ distributeParaShare(_o) {
696
852
  return __async(this, null, function* () {
697
- var _l = _k, {
853
+ var _p = _o, {
698
854
  userId,
699
855
  walletId
700
- } = _l, rest = __objRest(_l, [
856
+ } = _p, rest = __objRest(_p, [
701
857
  "userId",
702
858
  "walletId"
703
859
  ]);
@@ -786,6 +942,17 @@ class Client {
786
942
  return res.data;
787
943
  });
788
944
  }
945
+ getSupportedAuthMethodsV2(auth) {
946
+ return __async(this, null, function* () {
947
+ const res = yield this.baseRequest.get(
948
+ "/users/supported-auth-methods/v2",
949
+ {
950
+ params: __spreadValues({}, auth)
951
+ }
952
+ );
953
+ return res.data;
954
+ });
955
+ }
789
956
  getPasswords(auth) {
790
957
  return __async(this, null, function* () {
791
958
  const res = yield this.baseRequest.get("/users/passwords", {
@@ -805,9 +972,9 @@ class Client {
805
972
  return res;
806
973
  });
807
974
  }
808
- getEncryptedWalletPrivateKey(passwordId) {
975
+ getEncryptedWalletPrivateKey(passwordId, sessionLookupId) {
809
976
  return __async(this, null, function* () {
810
- const query = new URLSearchParams({ passwordId }).toString();
977
+ const query = new URLSearchParams({ passwordId, sessionLookupId }).toString();
811
978
  const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`);
812
979
  return res;
813
980
  });
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./chunk-BBZEL7EG.js";
2
2
  export * from "./client.js";
3
- export * from "./types/index.js";
4
3
  export * from "./utils.js";
5
4
  export * from "./error.js";
5
+ export * from "@getpara/shared";
6
6
  import Client from "./client.js";
7
7
  var src_default = Client;
8
8
  export {
package/dist/esm/utils.js CHANGED
@@ -179,10 +179,21 @@ function fromAccountMetadata(obj) {
179
179
  {}
180
180
  );
181
181
  }
182
+ function fromLinkedAccounts({ primary, linked }) {
183
+ return {
184
+ primary: primary.map((account) => __spreadProps(__spreadValues({}, account), {
185
+ date: new Date(account.date)
186
+ })),
187
+ linked: linked.map((account) => __spreadProps(__spreadValues({}, account), {
188
+ date: new Date(account.date)
189
+ }))
190
+ };
191
+ }
182
192
  export {
183
193
  extractAuthInfo,
184
194
  extractWalletRef,
185
195
  fromAccountMetadata,
196
+ fromLinkedAccounts,
186
197
  isCustomId,
187
198
  isDiscord,
188
199
  isEmail,