@getpara/core-sdk 2.0.0-alpha.16 → 2.0.0-alpha.18
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/cjs/ParaCore.js
CHANGED
|
@@ -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* ({
|
|
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
|
}
|
|
@@ -1626,7 +1655,6 @@ const _ParaCore = class _ParaCore {
|
|
|
1626
1655
|
}
|
|
1627
1656
|
onPoll == null ? void 0 : onPoll();
|
|
1628
1657
|
} catch (err) {
|
|
1629
|
-
console.error(err);
|
|
1630
1658
|
onPoll == null ? void 0 : onPoll();
|
|
1631
1659
|
}
|
|
1632
1660
|
}
|
|
@@ -2938,9 +2966,17 @@ prepareAuthState_fn = function(_0) {
|
|
|
2938
2966
|
authState = serverAuthState;
|
|
2939
2967
|
break;
|
|
2940
2968
|
case "login":
|
|
2969
|
+
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
2970
|
+
authState = serverAuthState;
|
|
2971
|
+
break;
|
|
2972
|
+
}
|
|
2941
2973
|
authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
|
|
2942
2974
|
break;
|
|
2943
2975
|
case "signup":
|
|
2976
|
+
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
2977
|
+
authState = serverAuthState;
|
|
2978
|
+
break;
|
|
2979
|
+
}
|
|
2944
2980
|
authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
|
|
2945
2981
|
break;
|
|
2946
2982
|
}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -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.
|
|
42
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.18";
|
|
43
43
|
const PREFIX = "@CAPSULE/";
|
|
44
44
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
45
45
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -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* ({
|
|
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
|
}
|
|
@@ -1589,7 +1618,6 @@ const _ParaCore = class _ParaCore {
|
|
|
1589
1618
|
}
|
|
1590
1619
|
onPoll == null ? void 0 : onPoll();
|
|
1591
1620
|
} catch (err) {
|
|
1592
|
-
console.error(err);
|
|
1593
1621
|
onPoll == null ? void 0 : onPoll();
|
|
1594
1622
|
}
|
|
1595
1623
|
}
|
|
@@ -2901,9 +2929,17 @@ prepareAuthState_fn = function(_0) {
|
|
|
2901
2929
|
authState = serverAuthState;
|
|
2902
2930
|
break;
|
|
2903
2931
|
case "login":
|
|
2932
|
+
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
2933
|
+
authState = serverAuthState;
|
|
2934
|
+
break;
|
|
2935
|
+
}
|
|
2904
2936
|
authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
|
|
2905
2937
|
break;
|
|
2906
2938
|
case "signup":
|
|
2939
|
+
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
2940
|
+
authState = serverAuthState;
|
|
2941
|
+
break;
|
|
2942
|
+
}
|
|
2907
2943
|
authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
|
|
2908
2944
|
break;
|
|
2909
2945
|
}
|
package/dist/esm/constants.js
CHANGED
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "2.0.0-alpha.18",
|
|
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.
|
|
13
|
+
"@getpara/user-management-client": "2.0.0-alpha.18",
|
|
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": "
|
|
44
|
+
"gitHead": "2333bc727fe61593821d448ee12facaee230c4b0"
|
|
45
45
|
}
|