@getpara/core-sdk 2.0.0-alpha.16 → 2.0.0-alpha.17

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.
@@ -417,6 +417,8 @@ const _ParaCore = class _ParaCore {
417
417
  get externalWalletConnectionType() {
418
418
  if (this.isExternalWalletAuth) {
419
419
  return "AUTHENTICATED";
420
+ } else if (this.isExternalWalletWithVerification) {
421
+ return "VERIFICATION";
420
422
  } else if (!!Object.keys(this.externalWallets).length) {
421
423
  return "CONNECTION_ONLY";
422
424
  }
@@ -442,6 +444,10 @@ const _ParaCore = class _ParaCore {
442
444
  var _a, _b, _c;
443
445
  return (0, import_user_management_client.isExternalWallet)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) && !!((_c = (_b = __privateGet(this, _authInfo)) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.withFullParaAuth);
444
446
  }
447
+ get isExternalWalletWithVerification() {
448
+ var _a, _b, _c;
449
+ return (0, import_user_management_client.isExternalWallet)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) && !!((_c = (_b = __privateGet(this, _authInfo)) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.withVerification);
450
+ }
445
451
  get partnerId() {
446
452
  var _a;
447
453
  return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
@@ -905,7 +911,15 @@ const _ParaCore = class _ParaCore {
905
911
  * @param externalType - Type of external wallet to set.
906
912
  */
907
913
  setExternalWallet(_0) {
908
- return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
914
+ return __async(this, arguments, function* ({
915
+ address,
916
+ type,
917
+ provider,
918
+ addressBech32,
919
+ withFullParaAuth,
920
+ isConnectionOnly,
921
+ withVerification
922
+ }) {
909
923
  this.externalWallets = {
910
924
  [address]: {
911
925
  id: address,
@@ -914,7 +928,9 @@ const _ParaCore = class _ParaCore {
914
928
  name: provider,
915
929
  isExternal: true,
916
930
  isExternalWithParaAuth: withFullParaAuth,
917
- signer: ""
931
+ signer: "",
932
+ isExternalConnectionOnly: isConnectionOnly,
933
+ isExternalWithVerification: withVerification
918
934
  }
919
935
  };
920
936
  this.setExternalWallets(this.externalWallets);
@@ -1260,7 +1276,7 @@ const _ParaCore = class _ParaCore {
1260
1276
  } = _b, urlOptions = __objRest(_b, [
1261
1277
  "externalWallet"
1262
1278
  ]);
1263
- if (this.externalWalletConnectionOnly) {
1279
+ if (this.externalWalletConnectionOnly || externalWallet.isConnectionOnly) {
1264
1280
  externalWallet.withFullParaAuth = false;
1265
1281
  yield this.setExternalWallet(externalWallet);
1266
1282
  return Promise.resolve({
@@ -1269,6 +1285,9 @@ const _ParaCore = class _ParaCore {
1269
1285
  }
1270
1286
  this.requireApiKey();
1271
1287
  const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
1288
+ if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
1289
+ yield this.touchSession(true);
1290
+ }
1272
1291
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1273
1292
  });
1274
1293
  }
@@ -1374,7 +1393,14 @@ const _ParaCore = class _ParaCore {
1374
1393
  if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
1375
1394
  return true;
1376
1395
  }
1377
- const { isAuthenticated } = yield this.touchSession();
1396
+ const { isAuthenticated, verifiedExternalWalletAddresses } = yield this.touchSession();
1397
+ if (this.externalWalletConnectionType === "VERIFICATION") {
1398
+ if (!verifiedExternalWalletAddresses) {
1399
+ return false;
1400
+ }
1401
+ const externalAddresses = Object.values(this.externalWallets).map((w) => w.id);
1402
+ return externalAddresses.every((address) => verifiedExternalWalletAddresses.includes(address));
1403
+ }
1378
1404
  return !!isAuthenticated;
1379
1405
  });
1380
1406
  }
@@ -1391,6 +1417,9 @@ const _ParaCore = class _ParaCore {
1391
1417
  return true;
1392
1418
  }
1393
1419
  const isSessionActive = yield this.isSessionActive();
1420
+ if (this.externalWalletConnectionType === "VERIFICATION") {
1421
+ return isSessionActive;
1422
+ }
1394
1423
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1395
1424
  });
1396
1425
  }
@@ -2938,9 +2967,17 @@ prepareAuthState_fn = function(_0) {
2938
2967
  authState = serverAuthState;
2939
2968
  break;
2940
2969
  case "login":
2970
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2971
+ authState = serverAuthState;
2972
+ break;
2973
+ }
2941
2974
  authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
2942
2975
  break;
2943
2976
  case "signup":
2977
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2978
+ authState = serverAuthState;
2979
+ break;
2980
+ }
2944
2981
  authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
2945
2982
  break;
2946
2983
  }
@@ -39,7 +39,7 @@ __export(constants_exports, {
39
39
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
40
40
  });
41
41
  module.exports = __toCommonJS(constants_exports);
42
- const PARA_CORE_VERSION = "2.0.0-alpha.16";
42
+ const PARA_CORE_VERSION = "2.0.0-alpha.17";
43
43
  const PREFIX = "@CAPSULE/";
44
44
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
45
45
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -380,6 +380,8 @@ const _ParaCore = class _ParaCore {
380
380
  get externalWalletConnectionType() {
381
381
  if (this.isExternalWalletAuth) {
382
382
  return "AUTHENTICATED";
383
+ } else if (this.isExternalWalletWithVerification) {
384
+ return "VERIFICATION";
383
385
  } else if (!!Object.keys(this.externalWallets).length) {
384
386
  return "CONNECTION_ONLY";
385
387
  }
@@ -405,6 +407,10 @@ const _ParaCore = class _ParaCore {
405
407
  var _a, _b, _c;
406
408
  return isExternalWallet((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) && !!((_c = (_b = __privateGet(this, _authInfo)) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.withFullParaAuth);
407
409
  }
410
+ get isExternalWalletWithVerification() {
411
+ var _a, _b, _c;
412
+ return isExternalWallet((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) && !!((_c = (_b = __privateGet(this, _authInfo)) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.withVerification);
413
+ }
408
414
  get partnerId() {
409
415
  var _a;
410
416
  return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
@@ -868,7 +874,15 @@ const _ParaCore = class _ParaCore {
868
874
  * @param externalType - Type of external wallet to set.
869
875
  */
870
876
  setExternalWallet(_0) {
871
- return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
877
+ return __async(this, arguments, function* ({
878
+ address,
879
+ type,
880
+ provider,
881
+ addressBech32,
882
+ withFullParaAuth,
883
+ isConnectionOnly,
884
+ withVerification
885
+ }) {
872
886
  this.externalWallets = {
873
887
  [address]: {
874
888
  id: address,
@@ -877,7 +891,9 @@ const _ParaCore = class _ParaCore {
877
891
  name: provider,
878
892
  isExternal: true,
879
893
  isExternalWithParaAuth: withFullParaAuth,
880
- signer: ""
894
+ signer: "",
895
+ isExternalConnectionOnly: isConnectionOnly,
896
+ isExternalWithVerification: withVerification
881
897
  }
882
898
  };
883
899
  this.setExternalWallets(this.externalWallets);
@@ -1223,7 +1239,7 @@ const _ParaCore = class _ParaCore {
1223
1239
  } = _b, urlOptions = __objRest(_b, [
1224
1240
  "externalWallet"
1225
1241
  ]);
1226
- if (this.externalWalletConnectionOnly) {
1242
+ if (this.externalWalletConnectionOnly || externalWallet.isConnectionOnly) {
1227
1243
  externalWallet.withFullParaAuth = false;
1228
1244
  yield this.setExternalWallet(externalWallet);
1229
1245
  return Promise.resolve({
@@ -1232,6 +1248,9 @@ const _ParaCore = class _ParaCore {
1232
1248
  }
1233
1249
  this.requireApiKey();
1234
1250
  const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
1251
+ if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
1252
+ yield this.touchSession(true);
1253
+ }
1235
1254
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1236
1255
  });
1237
1256
  }
@@ -1337,7 +1356,14 @@ const _ParaCore = class _ParaCore {
1337
1356
  if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
1338
1357
  return true;
1339
1358
  }
1340
- const { isAuthenticated } = yield this.touchSession();
1359
+ const { isAuthenticated, verifiedExternalWalletAddresses } = yield this.touchSession();
1360
+ if (this.externalWalletConnectionType === "VERIFICATION") {
1361
+ if (!verifiedExternalWalletAddresses) {
1362
+ return false;
1363
+ }
1364
+ const externalAddresses = Object.values(this.externalWallets).map((w) => w.id);
1365
+ return externalAddresses.every((address) => verifiedExternalWalletAddresses.includes(address));
1366
+ }
1341
1367
  return !!isAuthenticated;
1342
1368
  });
1343
1369
  }
@@ -1354,6 +1380,9 @@ const _ParaCore = class _ParaCore {
1354
1380
  return true;
1355
1381
  }
1356
1382
  const isSessionActive = yield this.isSessionActive();
1383
+ if (this.externalWalletConnectionType === "VERIFICATION") {
1384
+ return isSessionActive;
1385
+ }
1357
1386
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1358
1387
  });
1359
1388
  }
@@ -2901,9 +2930,17 @@ prepareAuthState_fn = function(_0) {
2901
2930
  authState = serverAuthState;
2902
2931
  break;
2903
2932
  case "login":
2933
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2934
+ authState = serverAuthState;
2935
+ break;
2936
+ }
2904
2937
  authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
2905
2938
  break;
2906
2939
  case "signup":
2940
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2941
+ authState = serverAuthState;
2942
+ break;
2943
+ }
2907
2944
  authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
2908
2945
  break;
2909
2946
  }
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.16";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.17";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
5
5
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -25,6 +25,7 @@ export declare abstract class ParaCore implements CoreInterface {
25
25
  get isFarcaster(): boolean;
26
26
  get isTelegram(): boolean;
27
27
  get isExternalWalletAuth(): boolean;
28
+ get isExternalWalletWithVerification(): boolean;
28
29
  get partnerId(): string | undefined;
29
30
  /**
30
31
  * The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
@@ -232,7 +233,7 @@ export declare abstract class ParaCore implements CoreInterface {
232
233
  * @param externalAddress - External wallet address to set.
233
234
  * @param externalType - Type of external wallet to set.
234
235
  */
235
- setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth }: ExternalWalletInfo): Promise<void>;
236
+ setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth, isConnectionOnly, withVerification, }: ExternalWalletInfo): Promise<void>;
236
237
  /**
237
238
  * Sets the user id associated with the `ParaCore` instance.
238
239
  * @param userId - User id to set.
@@ -20,6 +20,8 @@ export interface Wallet {
20
20
  lastUsedPartnerId?: string;
21
21
  isExternal?: boolean;
22
22
  isExternalWithParaAuth?: boolean;
23
+ isExternalWithVerification?: boolean;
24
+ isExternalConnectionOnly?: boolean;
23
25
  ensName?: string | null;
24
26
  ensAvatar?: string | null;
25
27
  }
@@ -39,4 +41,4 @@ export interface DeniedSignatureResWithUrl extends DeniedSignatureRes {
39
41
  }
40
42
  export type SignatureRes = SuccessfulSignatureRes | DeniedSignatureRes;
41
43
  export type FullSignatureRes = SuccessfulSignatureRes | DeniedSignatureResWithUrl;
42
- export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED';
44
+ export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED' | 'VERIFICATION';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.16",
3
+ "version": "2.0.0-alpha.17",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@celo/utils": "^8.0.2",
11
11
  "@cosmjs/encoding": "^0.32.4",
12
12
  "@ethereumjs/util": "^9.1.0",
13
- "@getpara/user-management-client": "2.0.0-alpha.16",
13
+ "@getpara/user-management-client": "2.0.0-alpha.17",
14
14
  "@noble/hashes": "^1.5.0",
15
15
  "base64url": "^3.0.1",
16
16
  "libphonenumber-js": "1.11.2",
@@ -41,5 +41,5 @@
41
41
  "require": "./dist/cjs/index.js"
42
42
  }
43
43
  },
44
- "gitHead": "84eb1a14fa8918c449ae4b163fe173d34688cdcd"
44
+ "gitHead": "5cb0f3dee5564995c465ead160ed817ba2ba37a7"
45
45
  }