@getpara/core-sdk 2.0.0-alpha.15 → 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
  }
@@ -1495,15 +1524,13 @@ const _ParaCore = class _ParaCore {
1495
1524
  });
1496
1525
  }
1497
1526
  /**
1498
- * Initiates a Farcaster login attempt and return the URI for the user to connect.
1527
+ * Initiates a Farcaster login attempt and returns the URL for the user to connect.
1499
1528
  * You can create a QR code with this URI that works with Farcaster's mobile app.
1500
1529
  * @return {string} the Farcaster connect URI
1501
1530
  */
1502
1531
  getFarcasterConnectUri() {
1503
- return __async(this, null, function* () {
1504
- const {
1505
- data: { connect_uri: connectUri }
1506
- } = yield this.ctx.client.initializeFarcasterLogin();
1532
+ return __async(this, arguments, function* ({ appScheme } = {}) {
1533
+ const { connect_uri: connectUri } = yield this.ctx.client.initializeFarcasterLogin({ appScheme });
1507
1534
  return connectUri;
1508
1535
  });
1509
1536
  }
@@ -1566,13 +1593,6 @@ const _ParaCore = class _ParaCore {
1566
1593
  return __async(this, null, function* () {
1567
1594
  var _j = _i, { method, deeplinkUrl } = _j, params = __objRest(_j, ["method", "deeplinkUrl"]);
1568
1595
  var _a;
1569
- if (deeplinkUrl) {
1570
- try {
1571
- new URL(deeplinkUrl);
1572
- } catch (e) {
1573
- throw new Error("Invalid deeplink URL");
1574
- }
1575
- }
1576
1596
  const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1577
1597
  return (0, import_utils2.constructUrl)({
1578
1598
  base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
@@ -2947,9 +2967,17 @@ prepareAuthState_fn = function(_0) {
2947
2967
  authState = serverAuthState;
2948
2968
  break;
2949
2969
  case "login":
2970
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2971
+ authState = serverAuthState;
2972
+ break;
2973
+ }
2950
2974
  authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
2951
2975
  break;
2952
2976
  case "signup":
2977
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2978
+ authState = serverAuthState;
2979
+ break;
2980
+ }
2953
2981
  authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
2954
2982
  break;
2955
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.13";
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
  }
@@ -1458,15 +1487,13 @@ const _ParaCore = class _ParaCore {
1458
1487
  });
1459
1488
  }
1460
1489
  /**
1461
- * Initiates a Farcaster login attempt and return the URI for the user to connect.
1490
+ * Initiates a Farcaster login attempt and returns the URL for the user to connect.
1462
1491
  * You can create a QR code with this URI that works with Farcaster's mobile app.
1463
1492
  * @return {string} the Farcaster connect URI
1464
1493
  */
1465
1494
  getFarcasterConnectUri() {
1466
- return __async(this, null, function* () {
1467
- const {
1468
- data: { connect_uri: connectUri }
1469
- } = yield this.ctx.client.initializeFarcasterLogin();
1495
+ return __async(this, arguments, function* ({ appScheme } = {}) {
1496
+ const { connect_uri: connectUri } = yield this.ctx.client.initializeFarcasterLogin({ appScheme });
1470
1497
  return connectUri;
1471
1498
  });
1472
1499
  }
@@ -1529,13 +1556,6 @@ const _ParaCore = class _ParaCore {
1529
1556
  return __async(this, null, function* () {
1530
1557
  var _j = _i, { method, deeplinkUrl } = _j, params = __objRest(_j, ["method", "deeplinkUrl"]);
1531
1558
  var _a;
1532
- if (deeplinkUrl) {
1533
- try {
1534
- new URL(deeplinkUrl);
1535
- } catch (e) {
1536
- throw new Error("Invalid deeplink URL");
1537
- }
1538
- }
1539
1559
  const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1540
1560
  return constructUrl({
1541
1561
  base: getBaseOAuthUrl(this.ctx.env),
@@ -2910,9 +2930,17 @@ prepareAuthState_fn = function(_0) {
2910
2930
  authState = serverAuthState;
2911
2931
  break;
2912
2932
  case "login":
2933
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2934
+ authState = serverAuthState;
2935
+ break;
2936
+ }
2913
2937
  authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
2914
2938
  break;
2915
2939
  case "signup":
2940
+ if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
2941
+ authState = serverAuthState;
2942
+ break;
2943
+ }
2916
2944
  authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
2917
2945
  break;
2918
2946
  }
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.13";
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.
@@ -397,11 +398,13 @@ export declare abstract class ParaCore implements CoreInterface {
397
398
  waitForSignup({ isCanceled, onCancel, onPoll, }: CoreMethodParams<'waitForSignup'>): CoreMethodResponse<'waitForSignup'>;
398
399
  waitForWalletCreation({ isCanceled, onCancel, }?: CoreMethodParams<'waitForWalletCreation'>): CoreMethodResponse<'waitForWalletCreation'>;
399
400
  /**
400
- * Initiates a Farcaster login attempt and return the URI for the user to connect.
401
+ * Initiates a Farcaster login attempt and returns the URL for the user to connect.
401
402
  * You can create a QR code with this URI that works with Farcaster's mobile app.
402
403
  * @return {string} the Farcaster connect URI
403
404
  */
404
- getFarcasterConnectUri(): CoreMethodResponse<'getFarcasterConnectUri'>;
405
+ getFarcasterConnectUri({ appScheme }?: {
406
+ appScheme?: string;
407
+ }): CoreMethodResponse<'getFarcasterConnectUri'>;
405
408
  /**
406
409
  * Awaits the response from a user's attempt to log in with Farcaster.
407
410
  * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
@@ -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.15",
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.15",
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": "f837a1584f2a0b5d61c9b7a91cd74a68c01d5161"
44
+ "gitHead": "5cb0f3dee5564995c465ead160ed817ba2ba37a7"
45
45
  }